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);
    }
  }
Esempio n. 2
0
 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
   handleNode(node, element, uri, localName, parser);
   org.w3c.dom.Node xmlNode = element.getFirstChild();
   while (xmlNode != null) {
     String nodeName = xmlNode.getNodeName();
     if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
       // create new timerNode
       ForEachNode forEachNode = new ForEachNode();
       forEachNode.setId(node.getId());
       forEachNode.setMetaData("UniqueId", node.getMetaData().get("UniqueId"));
       node.setMetaData("UniqueId", null);
       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 = forEachNode;
       handleForEachNode(node, element, uri, localName, parser);
       break;
     }
     xmlNode = xmlNode.getNextSibling();
   }
   NodeContainer nodeContainer = (NodeContainer) parser.getParent();
   nodeContainer.addNode(node);
   return node;
 }
Esempio n. 3
0
 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
   boolean found = false;
   org.w3c.dom.Node xmlNode = element.getFirstChild();
   while (xmlNode != null) {
     String nodeName = xmlNode.getNodeName();
     if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
       // create new timerNode
       ForEachNode forEachNode = new ForEachNode();
       forEachNode.setId(node.getId());
       forEachNode.setName(node.getName());
       for (org.kie.api.definition.process.Node subNode :
           ((CompositeContextNode) node).getNodes()) {
         forEachNode.addNode(subNode);
       }
       forEachNode.setMetaData("UniqueId", ((CompositeContextNode) node).getMetaData("UniqueId"));
       forEachNode.setMetaData(
           ProcessHandler.CONNECTIONS,
           ((CompositeContextNode) node).getMetaData(ProcessHandler.CONNECTIONS));
       VariableScope v =
           (VariableScope)
               ((CompositeContextNode) node).getDefaultContext(VariableScope.VARIABLE_SCOPE);
       ((VariableScope)
               ((CompositeContextNode) forEachNode.internalGetNode(2))
                   .getDefaultContext(VariableScope.VARIABLE_SCOPE))
           .setVariables(v.getVariables());
       node = forEachNode;
       handleForEachNode(node, element, uri, localName, parser);
       found = true;
       break;
     }
     xmlNode = xmlNode.getNextSibling();
   }
   if (!found) {
     handleCompositeContextNode(node, element, uri, localName, parser);
   }
   NodeContainer nodeContainer = (NodeContainer) parser.getParent();
   nodeContainer.addNode(node);
   return node;
 }
 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);
   return node;
 }
Esempio n. 5
0
  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);
    ActionNode actionNode = (ActionNode) node;
    node.setMetaData("NodeType", "ScriptTask");
    DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
    if (action == null) {
      action = new DroolsConsequenceAction();
      actionNode.setAction(action);
    }
    String language = element.getAttribute("scriptFormat");
    if (XmlBPMNProcessDumper.JAVA_LANGUAGE.equals(language)) {
      action.setDialect(JavaDialect.ID);
    } else if (XmlBPMNProcessDumper.JAVASCRIPT_LANGUAGE.equals(language)) {
      action.setDialect("JavaScript");
    }
    action.setConsequence("");
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
      if (xmlNode instanceof Element && "script".equals(xmlNode.getNodeName())) {
        action.setConsequence(xmlNode.getTextContent());
      }
      xmlNode = xmlNode.getNextSibling();
    }

    String compensation = element.getAttribute("isForCompensation");
    if (compensation != null) {
      boolean isForCompensation = Boolean.parseBoolean(compensation);
      if (isForCompensation) {
        actionNode.setMetaData("isForCompensation", isForCompensation);
      }
    }
  }