use of org.jbpm.workflow.core.NodeContainer in project jbpm by kiegroup.
the class SequenceFlowHandler method start.
@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
final String id = attrs.getValue("id");
final String sourceRef = attrs.getValue("sourceRef");
final String targetRef = attrs.getValue("targetRef");
final String bendpoints = attrs.getValue("g:bendpoints");
final String name = attrs.getValue("name");
final String priority = attrs.getValue("http://www.jboss.org/drools", "priority");
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
List<SequenceFlow> connections = null;
if (nodeContainer instanceof RuleFlowProcess) {
RuleFlowProcess process = (RuleFlowProcess) nodeContainer;
connections = (List<SequenceFlow>) process.getMetaData(ProcessHandler.CONNECTIONS);
if (connections == null) {
connections = new ArrayList<SequenceFlow>();
process.setMetaData(ProcessHandler.CONNECTIONS, connections);
}
} else if (nodeContainer instanceof CompositeNode) {
CompositeNode compositeNode = (CompositeNode) nodeContainer;
connections = (List<SequenceFlow>) compositeNode.getMetaData(ProcessHandler.CONNECTIONS);
if (connections == null) {
connections = new ArrayList<SequenceFlow>();
compositeNode.setMetaData(ProcessHandler.CONNECTIONS, connections);
}
}
SequenceFlow connection = new SequenceFlow(id, sourceRef, targetRef);
connection.setBendpoints(bendpoints);
connection.setName(name);
if (priority != null) {
connection.setPriority(Integer.parseInt(priority));
}
connections.add(connection);
return connection;
}
use of org.jbpm.workflow.core.NodeContainer in project jbpm by kiegroup.
the class BoundaryEventHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
Node node = (Node) parser.getCurrent();
String attachedTo = element.getAttribute("attachedToRef");
Attr cancelActivityAttr = element.getAttributeNode("cancelActivity");
boolean cancelActivity = Boolean.parseBoolean(cancelActivityAttr.getValue());
// determine type of event definition, so the correct type of node can be generated
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("escalationEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleEscalationNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
break;
} else if ("errorEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleErrorNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
break;
} else if ("timerEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleTimerNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
break;
} else if ("compensateEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleCompensationNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
break;
} else if ("signalEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleSignalNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
break;
} else if ("conditionalEventDefinition".equals(nodeName)) {
handleConditionNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
break;
} else if ("messageEventDefinition".equals(nodeName)) {
handleMessageNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
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.NodeContainer 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.NodeContainer in project jbpm by kiegroup.
the class IntermediateCatchEventHandler method handleLinkNode.
protected void handleLinkNode(Element element, Node node, org.w3c.dom.Node xmlLinkNode, ExtensibleXmlParser parser) {
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
node.setName(element.getAttribute("name"));
NamedNodeMap linkAttr = xmlLinkNode.getAttributes();
String name = linkAttr.getNamedItem("name").getNodeValue();
String id = element.getAttribute("id");
node.setMetaData("UniqueId", id);
node.setMetaData(LINK_NAME, name);
org.w3c.dom.Node xmlNode = xmlLinkNode.getFirstChild();
IntermediateLink aLink = new IntermediateLink();
aLink.setName(name);
aLink.setUniqueId(id);
while (null != xmlNode) {
String nodeName = xmlNode.getNodeName();
if ("target".equals(nodeName)) {
String target = xmlNode.getTextContent();
node.setMetaData("target", target);
aLink.setTarget(target);
}
if ("source".equals(nodeName)) {
String source = xmlNode.getTextContent();
node.setMetaData("source", source);
aLink.addSource(source);
}
xmlNode = xmlNode.getNextSibling();
}
if (nodeContainer instanceof RuleFlowProcess) {
RuleFlowProcess process = (RuleFlowProcess) nodeContainer;
List<IntermediateLink> links = (List<IntermediateLink>) process.getMetaData().get(ProcessHandler.LINKS);
if (null == links) {
links = new ArrayList<IntermediateLink>();
}
links.add(aLink);
process.setMetaData(ProcessHandler.LINKS, links);
} else if (nodeContainer instanceof CompositeNode) {
CompositeNode subprocess = (CompositeNode) nodeContainer;
List<IntermediateLink> links = (List<IntermediateLink>) subprocess.getMetaData().get(ProcessHandler.LINKS);
if (null == links) {
links = new ArrayList<IntermediateLink>();
}
links.add(aLink);
subprocess.setMetaData(ProcessHandler.LINKS, links);
}
}
use of org.jbpm.workflow.core.NodeContainer in project jbpm by kiegroup.
the class IntermediateThrowEventHandler method end.
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
final Element element = parser.endElementBuilder();
ActionNode node = (ActionNode) parser.getCurrent();
// determine type of event definition, so the correct type of node
// can be generated
org.w3c.dom.Node xmlNode = element.getFirstChild();
while (xmlNode != null) {
String nodeName = xmlNode.getNodeName();
if ("signalEventDefinition".equals(nodeName)) {
// reuse already created ActionNode
handleSignalNode(node, element, uri, localName, parser);
break;
} else if ("messageEventDefinition".equals(nodeName)) {
// reuse already created ActionNode
handleMessageNode(node, element, uri, localName, parser);
break;
} else if ("escalationEventDefinition".equals(nodeName)) {
// reuse already created ActionNode
handleEscalationNode(node, element, uri, localName, parser);
break;
} else if ("compensateEventDefinition".equals(nodeName)) {
// reuse already created ActionNode
handleThrowCompensationEventNode(node, element, uri, localName, parser);
break;
} else if ("linkEventDefinition".equals(nodeName)) {
ThrowLinkNode linkNode = new ThrowLinkNode();
linkNode.setId(node.getId());
handleLinkNode(element, linkNode, xmlNode, parser);
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
nodeContainer.addNode(linkNode);
((ProcessBuildData) parser.getData()).addNode(node);
// we break the while and stop the execution of this method.
return linkNode;
}
xmlNode = xmlNode.getNextSibling();
}
// none event definition
if (node.getAction() == null) {
node.setAction(new DroolsConsequenceAction("mvel", ""));
node.setMetaData("NodeType", "IntermediateThrowEvent-None");
}
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
nodeContainer.addNode(node);
return node;
}
Aggregations