Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
renamed
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchouwenburg committed Jun 18, 2017
1 parent 637e93d commit 3360937
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 87 deletions.
10 changes: 6 additions & 4 deletions core.pro
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,10 @@ SOURCES += core/kernel.cpp \
core/ilwisobjects/operation/modeller/junctionNode.cpp \
core/ilwisobjects/operation/modeller/conditionNode.cpp \
core/ilwisobjects/operation/modeller/operationnode.cpp \
core/ilwisobjects/operation/modeller/loopnode.cpp \
core/ilwisobjects/operation/modeller/executionnode.cpp \
core/ilwisobjects/table/combinationmatrix.cpp
core/ilwisobjects/table/combinationmatrix.cpp \
core/ilwisobjects/operation/modeller/rangenode.cpp \
core/ilwisobjects/operation/modeller/rangejunctionnode.cpp

HEADERS += core/kernel.h\
core/kernel_global.h \
Expand Down Expand Up @@ -980,9 +981,10 @@ HEADERS += core/kernel.h\
core/ilwisobjects/operation/modeller/conditionNode.h \
core/ilwisobjects/operation/modeller/junctionNode.h \
core/ilwisobjects/operation/modeller/operationnode.h \
core/ilwisobjects/operation/modeller/loopnode.h \
core/ilwisobjects/operation/modeller/executionnode.h \
core/ilwisobjects/table/combinationmatrix.h
core/ilwisobjects/table/combinationmatrix.h \
core/ilwisobjects/operation/modeller/rangenode.h \
core/ilwisobjects/operation/modeller/rangejunctionnode.h

OTHER_FILES += \
core/resources/referencesystems.csv \
Expand Down
2 changes: 1 addition & 1 deletion core/catalog/catalogconnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "workflownode.h"
#include "conditionNode.h"
#include "junctionNode.h"
#include "loopnode.h"
#include "rangenode.h"
#include "executionnode.h"
#include "workflowimplementation.h"
#include "workflow.h"
Expand Down
1 change: 1 addition & 0 deletions core/ilwisobjects/operation/modeller/conditionNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ typedef std::shared_ptr<WorkFlowNode> SPWorkFlowNode;
class KERNELSHARED_EXPORT WorkFlowCondition : public WorkFlowNode
{
public:
enum ConditionParts{cpTEST=0, cpTRUECASE=1, cpFALSECASE=2};
struct Test{
LogicalOperator _pre= loNONE;
SPWorkFlowNode _operation;
Expand Down
49 changes: 30 additions & 19 deletions core/ilwisobjects/operation/modeller/executionnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ bool ExecutionNode::execute(ExecutionContext *ctx, SymbolTable &symTable, Workfl
bool ok;
switch(_node->type()) {
case WorkFlowNode::ntCONDITION:
ok = executeCondition(ctx, symTable, workflowImpl, mapping);break;
ok = executeTest(ctx, symTable, workflowImpl, mapping);break;
case WorkFlowNode::ntJUNCTION:
ok = executeJunction(ctx, symTable, workflowImpl, mapping); break;
case WorkFlowNode::ntOPERATION:
ok = executeOperation(ctx, symTable, workflowImpl, mapping); break;
case WorkFlowNode::ntLOOP:
ok = executeLoop(ctx, symTable, workflowImpl, mapping); break;
case WorkFlowNode::ntRANGE:
ok = executeRange(ctx, symTable, workflowImpl, mapping); break;
case WorkFlowNode::ntRANGEJUNCTION:
ok = executeRangeJunction(ctx, symTable, workflowImpl, mapping); break;
default:
return false;
}
Expand All @@ -69,6 +71,7 @@ bool ExecutionNode::executeOperation(ExecutionContext *ctx, SymbolTable &symTabl
//auto iter = ctx->_additionalInfo.find("testoperation");
SymbolTable symTable2(symTable);
int inputCount = _node->inputCount();
// for all input parameters
for(int i=0; i < inputCount; ++i){
if ( workflowImpl->stopExecution())
return false;
Expand All @@ -86,17 +89,13 @@ bool ExecutionNode::executeOperation(ExecutionContext *ctx, SymbolTable &symTabl
}else{
return false;
}
// // if this is a workflow it has used a number of parameters that were in the list of input parameters; they are used and
// // are not considered anymore for matching input values and node execution
// if ( parameter.inputLink()->isWorkflow()){
// mapping.advanceOffset(parameter.inputLink()->inputCount());
// }
}
}
}
if ( workflowImpl->stopExecution())
return false;

// all input parameters should have a value now so we can start building the expression for this operation
SPOperationNode opNode = std::static_pointer_cast<OperationNode>(_node);
IOperationMetaData metadata = opNode->operation();
QString expr = metadata->name() + "(";
Expand Down Expand Up @@ -146,19 +145,22 @@ bool ExecutionNode::executeOperation(ExecutionContext *ctx, SymbolTable &symTabl
return ok;
}

bool ExecutionNode::executeCondition(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation* workflowImpl, WorkflowIdMapping& mapping)
bool ExecutionNode::executeTest(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation* workflowImpl, WorkflowIdMapping& mapping)
{

bool testRestult = true;
SPCondition condition = std::static_pointer_cast<WorkFlowCondition>(_node);
// for all tests
for(int i=0; i < condition->testCount(); ++i){
const WorkFlowCondition::Test& test = condition->test(i);
SymbolTable symTableLocal(symTable);
ExecutionContext ctx;
ctx._additionalInfo["testoperation"] = true;
// execute test
ExecutionNode& exNode = workflowImpl->executionNode(test._operation,mapping);
if (!exNode.execute(&ctx,symTableLocal,workflowImpl, mapping))
return false;
// combine result test with previous tests
if ( ctx._results.size() == 1){
Symbol sym = symTableLocal.getSymbol(ctx._results[0]);
if ( sym._type == itBOOL){
Expand All @@ -182,27 +184,32 @@ bool ExecutionNode::executeCondition(ExecutionContext *ctx, SymbolTable &symTabl

bool ExecutionNode::executeJunction(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation* workflowImpl, WorkflowIdMapping& mapping)
{
WorkFlowParameter& condParm = _node->inputRef(0);
// get the parameter that represents the test in the condition. It's value determines which path the junction takes (true, false)
WorkFlowParameter& testParameter = _node->inputRef(WorkFlowCondition::cpTEST);
// if the value of the condition (basically the test value
// is not set we are going to execute the tests of the condition
// the result of the tests is the "value" of the condition node (true or false)
// of course this isnt the result of the operations inside the condition; those have their own logic
if (!parameterValue(0).isValid()){
ExecutionContext ctxLocal;
if (!parameterValue(WorkFlowCondition::cpTEST).isValid()){
= ExecutionContext ctxLocal;
SymbolTable symTableLocal(symTable);
ExecutionNode& exNode = workflowImpl->executionNode(condParm.inputLink(),mapping);
if (exNode.execute(&ctxLocal, symTableLocal,workflowImpl, mapping)){
// the value of the parameter comes from the test node, so we follow the inputlink and than execute the test
// after execution we know the result of the test
ExecutionNode& tests = workflowImpl->executionNode(testParameter.inputLink(),mapping);
if (tests.execute(&ctxLocal, symTableLocal,workflowImpl, mapping)){
// collect the result from the test; the result will be used to determine which branch of the flow is taken
QString outputName = ctxLocal._results[0];
QVariant val = symTableLocal.getValue(outputName);
condParm.value("", symTableLocal.getSymbol(outputName)._type);
_parameterValues[0] = val;
_parameterValues[WorkFlowCondition::cpTEST] = val;
}
}
ExecutionContext ctxLocal;
SymbolTable symTableLocal(symTable);
ExecutionNode& exNode = parameterValue(0).toString() == "true" ?
workflowImpl->executionNode(_node->inputRef(1).inputLink(),mapping) :
workflowImpl->executionNode(_node->inputRef(2).inputLink(),mapping);
// determine which link we follow for the flow
ExecutionNode& exNode = parameterValue(WorkFlowCondition::cpTEST) == "true" ?
workflowImpl->executionNode(_node->inputRef(WorkFlowCondition::cpTRUECASE).inputLink(),mapping) :
workflowImpl->executionNode(_node->inputRef(WorkFlowCondition::cpFALSECASE).inputLink(),mapping);

exNode.execute(ctx, symTableLocal,workflowImpl, mapping);
symTable.copyFrom(ctx, symTableLocal);
Expand Down Expand Up @@ -249,7 +256,11 @@ int ExecutionNode::parameterCount() const
return _parameterValues.size();
}

bool ExecutionNode::executeLoop(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation* workflowImpl, WorkflowIdMapping& mapping)
bool ExecutionNode::executeRangeJunction(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation* workflowImpl, WorkflowIdMapping& mapping){
return executeJunction(ctx,symTable, workflowImpl, mapping) ;
}

bool ExecutionNode::executeRange(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation* workflowImpl, WorkflowIdMapping& mapping)
{
while( next()){
if(!executeContent(ctx,symTable, workflowImpl, mapping))
Expand Down
5 changes: 3 additions & 2 deletions core/ilwisobjects/operation/modeller/executionnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ class ExecutionNode
SPWorkFlowNode _node;

bool executeOperation(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation *workflowImpl, Ilwis::WorkflowIdMapping &mapping);
bool executeCondition(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation* workflowImpl, WorkflowIdMapping &mapping);
bool executeTest(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation* workflowImpl, WorkflowIdMapping &mapping);
bool executeJunction(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation* workflowImpl, WorkflowIdMapping &mapping);
bool executeContent(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation *workflowImpl, WorkflowIdMapping &mapping);
bool executeLoop(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation *workflowImpl, WorkflowIdMapping &mapping);
bool executeRange(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation *workflowImpl, WorkflowIdMapping &mapping);
bool next();

void unloadInputs(const std::vector<QString>& objects);
bool executeRangeJunction(ExecutionContext *ctx, SymbolTable &symTable, WorkflowImplementation *workflowImpl, WorkflowIdMapping &mapping);
};
}

Expand Down
44 changes: 22 additions & 22 deletions core/ilwisobjects/operation/modeller/junctionNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,50 @@

using namespace Ilwis;

Junction::Junction() : WorkFlowNode("")
JunctionNode::JunctionNode() : WorkFlowNode("")
{
_inputParameters1.resize(3);

}

Junction::Junction(quint64 nodeid) : WorkFlowNode("")
JunctionNode::JunctionNode(quint64 nodeid) : WorkFlowNode("")
{
nodeId(nodeid);
_inputParameters1.push_back(WorkFlowParameter(0,id(),"condition"));
_inputParameters1.push_back(WorkFlowParameter(1,id(),"trueLink"));
_inputParameters1.push_back(WorkFlowParameter(2,id(),"falseLink"));
_inputParameters1.push_back(WorkFlowParameter(WorkFlowCondition::cpTEST,id(),"condition"));
_inputParameters1.push_back(WorkFlowParameter(WorkFlowCondition::cpTRUECASE,id(),"trueLink"));
_inputParameters1.push_back(WorkFlowParameter(WorkFlowCondition::cpFALSECASE,id(),"falseLink"));
}

WorkFlowNode::NodeTypes Junction::type() const
WorkFlowNode::NodeTypes JunctionNode::type() const
{
return WorkFlowNode::ntJUNCTION ;
}

void Junction::link2condition(SPWorkFlowNode conditionnode)
void JunctionNode::link2condition(SPWorkFlowNode conditionnode)
{
WorkFlowParameter parm(0,id(),sUNDEF);
WorkFlowParameter parm(WorkFlowCondition::cpTEST,id(),sUNDEF);
parm.inputLink(conditionnode, iUNDEF);
_inputParameters1[0] = parm;
_inputParameters1[WorkFlowCondition::cpTEST] = parm;
if ( conditionnode)
name(QString("junction_%1_%2").arg(conditionnode->id()).arg(id()));
else
name(QString("junction_%1").arg(id()));
}

void Junction::nodeId(quint64 id)
void JunctionNode::nodeId(quint64 id)
{
WorkFlowNode::nodeId(id);
name(QString("junction_%1").arg(id));
}

bool Junction::isValid(const Workflow *workflow, WorkFlowNode::ValidityCheck) const
bool JunctionNode::isValid(const Workflow *workflow, WorkFlowNode::ValidityCheck) const
{
WorkFlowParameter parm1 = input(1);
WorkFlowParameter parm2 = input(2);
WorkFlowParameter trueParm = input(WorkFlowCondition::cpTRUECASE);
WorkFlowParameter falseParm = input(WorkFlowCondition::cpFALSECASE);

bool ok = parm1.inputLink() && parm2.inputLink();
bool ok = trueParm.inputLink() && falseParm.inputLink();
if ( ok){
ok = parm1.valueType() == parm2.valueType();
ok = trueParm.valueType() == falseParm.valueType();
if ( ok){
// we now try to find the junction as input in one of the nodes of the graph, else the junction is not correctly linked and thus invalid(incomplete)
const std::vector<SPWorkFlowNode>& nodes = workflow->graph();
Expand All @@ -79,21 +79,21 @@ bool Junction::isValid(const Workflow *workflow, WorkFlowNode::ValidityCheck) co

}

void Junction::link2trueCase(SPWorkFlowNode trueNode, int parmIndex)
void JunctionNode::link2trueCase(SPWorkFlowNode trueNode, int parmIndex)
{
WorkFlowParameter parm(1,id(),sUNDEF);
WorkFlowParameter parm(WorkFlowCondition::cpTRUECASE,id(),sUNDEF);
parm.inputLink(trueNode, parmIndex);
_inputParameters1[1] = parm;
_inputParameters1[WorkFlowCondition::cpTRUECASE] = parm;
}

void Junction::link2falseCase(SPWorkFlowNode falseNode, int parmIndex)
void JunctionNode::link2falseCase(SPWorkFlowNode falseNode, int parmIndex)
{
WorkFlowParameter parm(2,id(),sUNDEF);
WorkFlowParameter parm(WorkFlowCondition::cpFALSECASE,id(),sUNDEF);
parm.inputLink(falseNode, parmIndex);
_inputParameters1[2] = parm;
_inputParameters1[WorkFlowCondition::cpFALSECASE] = parm;
}

int Junction::inputCount() const
int JunctionNode::inputCount() const
{
return 1; // though there are three parameters in the junction, there is only one that is not optional and that is the link to the condition (actually thet tests)
}
10 changes: 5 additions & 5 deletions core/ilwisobjects/operation/modeller/junctionNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace Ilwis {

class KERNELSHARED_EXPORT Junction : public WorkFlowNode
class KERNELSHARED_EXPORT JunctionNode : public WorkFlowNode
{
public:
Junction();
Junction(quint64 nodeid);
public:Workfl
JunctionNode();
JunctionNode(quint64 nodeid);
Ilwis::WorkFlowNode::NodeTypes type() const;
int inputCount() const;
void link2trueCase(SPWorkFlowNode trueNode, int parmIndex);
Expand All @@ -21,7 +21,7 @@ class KERNELSHARED_EXPORT Junction : public WorkFlowNode
private:
};

typedef std::shared_ptr<Junction> SPJunction;
typedef std::shared_ptr<JunctionNode> SPJunctionNode;
}

#endif // JUNCTION_H
8 changes: 8 additions & 0 deletions core/ilwisobjects/operation/modeller/rangejunctionnode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "rangejunctionnode.h"

using namespace Ilwis;

RangeJunctionNode::RangeJunctionNode()
{

}
12 changes: 12 additions & 0 deletions core/ilwisobjects/operation/modeller/rangejunctionnode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef RANGEJUNCTIONNODE_H
#define RANGEJUNCTIONNODE_H

namespace Ilwis {
class RangeJunctionNode : public JunctionNode
{
public:
RangeJunctionNode();
};
}

#endif // RANGEJUNCTIONNODE_H
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@
#include "mastercatalog.h"
#include "operationhelper.h"
#include "conditionNode.h"
#include "loopnode.h"
#include "rangenode.h"

using namespace Ilwis;

LoopNode::LoopNode() : WorkFlowNode("")
RangeNode::RangeNode() : WorkFlowNode("")
{

}

Ilwis::WorkFlowNode::NodeTypes Ilwis::LoopNode::type() const
Ilwis::WorkFlowNode::NodeTypes Ilwis::RangeNode::type() const
{
return WorkFlowNode::ntLOOP;
return WorkFlowNode::ntRANGE;
}

bool LoopNode::isValid(const Ilwis::Workflow *workflow, WorkFlowNode::ValidityCheck check) const
bool RangeNode::isValid(const Ilwis::Workflow *workflow, WorkFlowNode::ValidityCheck check) const
{
return true;
}

void LoopNode::nodeId(quint64 id)
void RangeNode::nodeId(quint64 id)
{
WorkFlowNode::nodeId(id);
name(QString("loop_%1").arg(id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

namespace Ilwis {

class KERNELSHARED_EXPORT LoopNode : public WorkFlowNode
class KERNELSHARED_EXPORT RangeNode : public WorkFlowNode
{
public:
LoopNode();
RangeNode();

Ilwis::WorkFlowNode::NodeTypes type() const;
bool isValid(const Ilwis::Workflow *workflow, WorkFlowNode::ValidityCheck check) const;
Expand All @@ -19,7 +19,7 @@ class KERNELSHARED_EXPORT LoopNode : public WorkFlowNode

};

typedef std::shared_ptr<LoopNode> SPLoopNode;
typedef std::shared_ptr<RangeNode> SPLRangeNode;
}

#endif // LOOPNODE_H
Loading

0 comments on commit 3360937

Please sign in to comment.