use of io.automatiko.engine.api.definition.process.NodeContainer in project automatiko-engine by automatiko-io.
the class BPMNPlaneHandler method processNodeInfo.
private boolean processNodeInfo(NodeInfo nodeInfo, Node[] nodes) {
if (nodeInfo == null || nodeInfo.getNodeRef() == null) {
return false;
}
for (Node node : nodes) {
String id = (String) node.getMetaData().get("UniqueId");
if (nodeInfo.getNodeRef().equals(id)) {
((io.automatiko.engine.workflow.process.core.Node) node).setMetaData("x", nodeInfo.getX());
((io.automatiko.engine.workflow.process.core.Node) node).setMetaData("y", nodeInfo.getY());
((io.automatiko.engine.workflow.process.core.Node) node).setMetaData("width", nodeInfo.getWidth());
((io.automatiko.engine.workflow.process.core.Node) node).setMetaData("height", nodeInfo.getHeight());
return true;
}
if (node instanceof NodeContainer) {
boolean found = processNodeInfo(nodeInfo, ((NodeContainer) node).getNodes());
if (found) {
return true;
}
}
}
return false;
}
use of io.automatiko.engine.api.definition.process.NodeContainer in project automatiko-engine by automatiko-io.
the class CompensationEventListener method createNodeInstanceContainers.
private Stack<NodeInstance> createNodeInstanceContainers(Node toCompensateNode, boolean generalCompensation) {
Stack<NodeContainer> nestedNodes = new Stack<NodeContainer>();
Stack<NodeInstance> generatedInstances = new Stack<NodeInstance>();
NodeContainer parentContainer = toCompensateNode.getParentContainer();
while (!(parentContainer instanceof ExecutableProcess)) {
nestedNodes.add(parentContainer);
parentContainer = ((Node) parentContainer).getParentContainer();
}
NodeInstanceContainer parentInstance;
if (nestedNodes.isEmpty()) {
// nestedNodes is empty
parentInstance = (NodeInstanceContainer) getProcessInstance();
} else {
parentInstance = (NodeInstanceContainer) ((WorkflowProcessInstanceImpl) getProcessInstance()).getNodeInstance((Node) nestedNodes.pop());
generatedInstances.add((NodeInstance) parentInstance);
}
NodeInstanceContainer childInstance;
while (!nestedNodes.isEmpty()) {
// generate
childInstance = (NodeInstanceContainer) parentInstance.getNodeInstance((Node) nestedNodes.pop());
assert childInstance instanceof CompositeNodeInstance : "A node with child nodes should end up creating a CompositeNodeInstance type.";
// track and modify
generatedInstances.add((NodeInstance) childInstance);
// loop
parentInstance = childInstance;
}
if (generalCompensation) {
childInstance = (NodeInstanceContainer) parentInstance.getNodeInstance(toCompensateNode);
generatedInstances.add((NodeInstance) childInstance);
}
return generatedInstances;
}
Aggregations