use of org.jbpm.workflow.core.node.ForEachNode in project jbpm by kiegroup.
the class ForEachNodeHandler method handleNode.
protected void handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
ForEachNode forEachNode = (ForEachNode) node;
final String variableName = element.getAttribute("variableName");
if (variableName != null && variableName.length() != 0) {
forEachNode.setVariable(variableName, new ObjectDataType());
}
final String collectionExpression = element.getAttribute("collectionExpression");
if (collectionExpression != null && collectionExpression.length() != 0) {
forEachNode.setCollectionExpression(collectionExpression);
}
final String waitForCompletion = element.getAttribute("waitForCompletion");
if ("false".equals(waitForCompletion)) {
forEachNode.setWaitForCompletion(false);
}
}
use of org.jbpm.workflow.core.node.ForEachNode in project jbpm by kiegroup.
the class SubProcessHandler method handleForEachNode.
@SuppressWarnings("unchecked")
protected void handleForEachNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser, boolean isAsync) throws SAXException {
super.handleNode(node, element, uri, localName, parser);
ForEachNode forEachNode = (ForEachNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("ioSpecification".equals(nodeName)) {
readIoSpecification(xmlNode, dataInputs, dataOutputs);
} else if ("dataInputAssociation".equals(nodeName)) {
readDataInputAssociation(xmlNode, inputAssociation);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, outputAssociation);
} else if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
readMultiInstanceLoopCharacteristics(xmlNode, forEachNode, parser);
}
xmlNode = xmlNode.getNextSibling();
}
handleScript(forEachNode, element, "onEntry");
handleScript(forEachNode, element, "onExit");
List<SequenceFlow> connections = (List<SequenceFlow>) forEachNode.getMetaData(ProcessHandler.CONNECTIONS);
ProcessHandler.linkConnections(forEachNode, connections);
ProcessHandler.linkBoundaryEvents(forEachNode);
// This must be done *after* linkConnections(process, connections)
// because it adds hidden connections for compensations
List<Association> associations = (List<Association>) forEachNode.getMetaData(ProcessHandler.ASSOCIATIONS);
ProcessHandler.linkAssociations((Definitions) forEachNode.getMetaData("Definitions"), forEachNode, associations);
applyAsync(node, isAsync);
}
use of org.jbpm.workflow.core.node.ForEachNode in project jbpm by kiegroup.
the class CallActivityHandler method end.
@SuppressWarnings("unchecked")
@Override
public Object end(String uri, String localName, ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Node node = (Node) parser.getCurrent();
handleNode(node, element, uri, localName, parser);
org.w3c.dom.Node xmlNode = element.getFirstChild();
int uniqueIdGen = 1;
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
// create new timerNode
ForEachNode forEachNode = new ForEachNode();
forEachNode.setId(node.getId());
String uniqueId = (String) node.getMetaData().get("UniqueId");
forEachNode.setMetaData("UniqueId", uniqueId);
node.setMetaData("UniqueId", uniqueId + ":" + uniqueIdGen++);
node.setMetaData("hidden", true);
forEachNode.addNode(node);
forEachNode.linkIncomingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE, node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE);
forEachNode.linkOutgoingConnections(node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE, NodeImpl.CONNECTION_DEFAULT_TYPE);
Node orignalNode = node;
node = forEachNode;
handleForEachNode(node, element, uri, localName, parser);
// remove output collection data output of for each to avoid problems when running in variable strict mode
if (orignalNode instanceof SubProcessNode) {
((SubProcessNode) orignalNode).adjustOutMapping(forEachNode.getOutputCollectionExpression());
}
Map<String, String> dataInputs = (Map<String, String>) orignalNode.getMetaData().remove("DataInputs");
Map<String, String> dataOutputs = (Map<String, String>) orignalNode.getMetaData().remove("DataOutputs");
orignalNode.setMetaData("MICollectionOutput", dataOutputs.get(((ForEachNode) node).getMetaData("MICollectionOutput")));
orignalNode.setMetaData("MICollectionInput", dataInputs.get(((ForEachNode) node).getMetaData("MICollectionInput")));
break;
}
xmlNode = xmlNode.getNextSibling();
}
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
nodeContainer.addNode(node);
((ProcessBuildData) parser.getData()).addNode(node);
return node;
}
use of org.jbpm.workflow.core.node.ForEachNode in project jbpm by kiegroup.
the class CallActivityHandler method handleForEachNode.
protected void handleForEachNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
ForEachNode forEachNode = (ForEachNode) node;
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("dataInputAssociation".equals(nodeName)) {
readDataInputAssociation(xmlNode, inputAssociation);
} else if ("dataOutputAssociation".equals(nodeName)) {
readDataOutputAssociation(xmlNode, outputAssociation);
} else if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
readMultiInstanceLoopCharacteristics(xmlNode, forEachNode, parser);
}
xmlNode = xmlNode.getNextSibling();
}
}
use of org.jbpm.workflow.core.node.ForEachNode in project jbpm by kiegroup.
the class ForEachNodeHandler method writeNode.
public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
ForEachNode forEachNode = (ForEachNode) node;
writeNode("subProcess", forEachNode, xmlDump, metaDataType);
xmlDump.append(" >" + EOL);
writeExtensionElements(node, xmlDump);
// ioSpecification and dataInputAssociation
xmlDump.append(" <ioSpecification>" + EOL);
String parameterName = forEachNode.getVariableName();
if (parameterName != null) {
xmlDump.append(" <dataInput id=\"" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_input\" name=\"MultiInstanceInput\" />" + EOL);
}
xmlDump.append(" <inputSet/>" + EOL + " <outputSet/>" + EOL + " </ioSpecification>" + EOL);
String collectionExpression = forEachNode.getCollectionExpression();
if (collectionExpression != null) {
xmlDump.append(" <dataInputAssociation>" + EOL + " <sourceRef>" + XmlDumper.replaceIllegalChars(collectionExpression) + "</sourceRef>" + EOL + " <targetRef>" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_input</targetRef>" + EOL + " </dataInputAssociation>" + EOL);
}
// multiInstanceLoopCharacteristics
xmlDump.append(" <multiInstanceLoopCharacteristics>" + EOL + " <loopDataInputRef>" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_input</loopDataInputRef>" + EOL);
if (parameterName != null) {
xmlDump.append(" <inputDataItem id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(parameterName) + "\" itemSubjectRef=\"" + XmlBPMNProcessDumper.getUniqueNodeId(forEachNode) + "_multiInstanceItemType\"/>" + EOL);
}
xmlDump.append(" </multiInstanceLoopCharacteristics>" + EOL);
// nodes
List<Node> subNodes = getSubNodes(forEachNode);
XmlBPMNProcessDumper.INSTANCE.visitNodes(subNodes, xmlDump, metaDataType);
// connections
visitConnectionsAndAssociations(forEachNode, xmlDump, metaDataType);
endNode("subProcess", xmlDump);
}
Aggregations