use of org.jbpm.workflow.core.NodeContainer in project jbpm by kiegroup.
the class IntermediateCatchEventHandler 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();
// 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 EventNode
handleSignalNode(node, element, uri, localName, parser);
break;
} else if ("messageEventDefinition".equals(nodeName)) {
// reuse already created EventNode
handleMessageNode(node, element, uri, localName, parser);
break;
} else if ("timerEventDefinition".equals(nodeName)) {
// create new timerNode
TimerNode timerNode = new TimerNode();
timerNode.setId(node.getId());
timerNode.setName(node.getName());
timerNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
node = timerNode;
handleTimerNode(node, element, uri, localName, parser);
break;
} else if ("conditionalEventDefinition".equals(nodeName)) {
// create new stateNode
StateNode stateNode = new StateNode();
stateNode.setId(node.getId());
stateNode.setName(node.getName());
stateNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
node = stateNode;
handleStateNode(node, element, uri, localName, parser);
break;
} else if ("linkEventDefinition".equals(nodeName)) {
CatchLinkNode linkNode = new CatchLinkNode();
linkNode.setId(node.getId());
node = linkNode;
handleLinkNode(element, node, xmlNode, parser);
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 IntermediateThrowEventHandler method handleLinkNode.
protected void handleLinkNode(Element element, Node node, org.w3c.dom.Node xmlLinkNode, ExtensibleXmlParser parser) {
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();
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
IntermediateLink aLink = new IntermediateLink();
aLink.setName(name);
aLink.setUniqueId(id);
while (null != xmlNode) {
String nodeName = xmlNode.getNodeName();
if (LINK_TARGET.equals(nodeName)) {
String target = xmlNode.getTextContent();
node.setMetaData(LINK_TARGET, target);
}
if (LINK_SOURCE.equals(nodeName)) {
String source = xmlNode.getTextContent();
ArrayList<String> sources = (ArrayList<String>) node.getMetaData().get(LINK_SOURCE);
// if there is no list, create one
if (null == sources) {
sources = new ArrayList<String>();
}
// to connect nodes.
aLink.addSource(source);
// to do the xml dump
sources.add(source);
node.setMetaData(LINK_SOURCE, sources);
}
xmlNode = xmlNode.getNextSibling();
}
aLink.configureThrow();
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 AbstractNodeHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
final Node node = createNode(attrs);
String id = attrs.getValue("id");
node.setMetaData("UniqueId", id);
final String name = attrs.getValue("name");
node.setName(name);
if ("true".equalsIgnoreCase(System.getProperty("jbpm.v5.id.strategy"))) {
try {
// remove starting _
id = id.substring(1);
// remove ids of parent nodes
id = id.substring(id.lastIndexOf("-") + 1);
node.setId(Integer.parseInt(id));
} catch (NumberFormatException e) {
// id is not in the expected format, generating a new one
long newId = 0;
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
for (org.kie.api.definition.process.Node n : nodeContainer.getNodes()) {
if (n.getId() > newId) {
newId = n.getId();
}
}
((org.jbpm.workflow.core.Node) node).setId(++newId);
}
} else {
AtomicInteger idGen = (AtomicInteger) parser.getMetaData().get("idGen");
node.setId(idGen.getAndIncrement());
}
return node;
}
use of org.jbpm.workflow.core.NodeContainer in project jbpm by kiegroup.
the class AbstractNodeHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
final Node node = createNode();
final String id = attrs.getValue("id");
node.setId(new Long(id));
final String name = attrs.getValue("name");
node.setName(name);
nodeContainer.addNode(node);
return node;
}
use of org.jbpm.workflow.core.NodeContainer in project jbpm by kiegroup.
the class ConnectionHandler method start.
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
parser.startElementBuilder(localName, attrs);
String fromId = attrs.getValue("from");
emptyAttributeCheck(localName, "from", fromId, parser);
String toId = attrs.getValue("to");
emptyAttributeCheck(localName, "to", toId, parser);
String bendpoints = attrs.getValue("bendpoints");
String fromType = attrs.getValue("fromType");
if (fromType == null || fromType.trim().length() == 0) {
fromType = NodeImpl.CONNECTION_DEFAULT_TYPE;
}
String toType = attrs.getValue("toType");
if (toType == null || toType.trim().length() == 0) {
toType = NodeImpl.CONNECTION_DEFAULT_TYPE;
}
NodeContainer nodeContainer = (NodeContainer) parser.getParent();
Node fromNode = nodeContainer.getNode(new Long(fromId));
Node toNode = nodeContainer.getNode(new Long(toId));
if (fromNode == null) {
throw new SAXParseException("Node '" + fromId + "'cannot be found", parser.getLocator());
}
if (toNode == null) {
throw new SAXParseException("Node '" + toId + "' cannot be found", parser.getLocator());
}
ConnectionImpl connection = new ConnectionImpl(fromNode, fromType, toNode, toType);
connection.setMetaData("bendpoints", bendpoints);
return connection;
}
Aggregations