.getJcrComponentRegistry()
.getRegistry()
.saveWorkflowExecutionStatus(this.topic,
ExecutionStatus.STARTED);
} catch (RegistryException e) {
throw new XBayaException(e);
}
}
ArrayList<Node> inputNodes = this.getInputNodesDynamically();
Object[] values = new Object[inputNodes.size()];
String[] keywords = new String[inputNodes.size()];
for (int i = 0; i < inputNodes.size(); ++i) {
Node node = inputNodes.get(i);
node.getGUI().setBodyColor(NodeState.FINISHED.color);
if (this.mode == GUI_MODE) {
this.engine.getGUI().getGraphCanvas().repaint();
}
keywords[i] = ((InputNode) node).getName();
values[i] = ((InputNode) node).getDefaultValue();
}
this.notifier.workflowStarted(values, keywords);
while (this.getWorkflow().getExecutionState() != XBayaExecutionState.STOPPED) {
if (getRemainNodesDynamically() == 0) {
if (this.mode == GUI_MODE) {
this.notifyPause();
} else {
this.getWorkflow().setExecutionState(
XBayaExecutionState.STOPPED);
}
}
// ok we have paused sleep
while (this.getWorkflow().getExecutionState() == XBayaExecutionState.PAUSED) {
try {
Thread.sleep(400);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
// get task list and execute them
ArrayList<Node> readyNodes = this.getReadyNodesDynamically();
for (Node node : readyNodes) {
if (node.isBreak()) {
this.notifyPause();
break;
}
if (this.getWorkflow().getExecutionState() == XBayaExecutionState.PAUSED
|| this.getWorkflow().getExecutionState() == XBayaExecutionState.STOPPED) {
break;
// stop executing and sleep in the outer loop cause we
// want
// recalculate the execution stack
}
boolean nodeOutputLoadedFromProvenance = false;
if (this.actOnProvenance) {
nodeOutputLoadedFromProvenance = readProvenance(node);
} else {
writeProvenanceLater(node);
}
if (!nodeOutputLoadedFromProvenance) {
executeDynamically(node);
}
if (this.getWorkflow().getExecutionState() == XBayaExecutionState.STEP) {
this.getWorkflow().setExecutionState(
XBayaExecutionState.PAUSED);
break;
}
}
// TODO commented this for foreach, fix this.
sendOutputsDynamically();
// Dry run sleep a lil bit to release load
if (readyNodes.size() == 0) {
// when there are no ready nodes and no running nodes
// and there are failed nodes then workflow is stuck because
// of failure
// so we should pause the execution
if (InterpreterUtil.getRunningNodeCountDynamically(this.graph) == 0
&& InterpreterUtil.getFailedNodeCountDynamically(this.graph) != 0) {
this.getWorkflow().setExecutionState(
XBayaExecutionState.PAUSED);
}
try {
Thread.sleep(400);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
if (InterpreterUtil.getFailedNodeCountDynamically(this.graph) == 0) {
if (actOnProvenance) {
try {
try {
this.configuration
.getJcrComponentRegistry()
.getRegistry()
.saveWorkflowExecutionStatus(this.topic,
ExecutionStatus.FINISHED);
} catch (Exception e) {
throw new XBayaException(e);
}
} catch (Exception e) {
throw new XBayaException(e);
}
// System.out.println(this.configuration.getJcrComponentRegistry().getRegistry().getWorkflowStatus(this.topic));
}
} else {
if (actOnProvenance) {
try {
this.configuration
.getJcrComponentRegistry()
.getRegistry()
.saveWorkflowExecutionStatus(this.topic,
ExecutionStatus.FAILED);
} catch (RegistryException e) {
throw new XBayaException(e);
}
}
}
this.notifier.workflowTerminated();
if (this.mode == GUI_MODE) {