Package org.jbpm.workflow.core.node

Examples of org.jbpm.workflow.core.node.CompositeNode


                        final String localName,
                        final Attributes attrs,
                        final ExtensibleXmlParser parser) throws SAXException {
        parser.startElementBuilder( localName,
                                    attrs );
        CompositeNode compositeNode = (CompositeNode) parser.getParent();
        final String type = attrs.getValue("type");
        emptyAttributeCheck(localName, "type", type, parser);
        final String nodeId = attrs.getValue("nodeId");
        emptyAttributeCheck(localName, "nodeId", nodeId, parser);
        final String nodeInType = attrs.getValue("nodeInType");
        emptyAttributeCheck(localName, "nodeInType", nodeInType, parser);
        compositeNode.linkIncomingConnections(type, new Long(nodeId), nodeInType);
        return null;
    }   
View Full Code Here


                        final String localName,
                        final Attributes attrs,
                        final ExtensibleXmlParser parser) throws SAXException {
        parser.startElementBuilder( localName,
                                    attrs );
        CompositeNode compositeNode = (CompositeNode) parser.getParent();
        final String type = attrs.getValue("type");
        emptyAttributeCheck(localName, "type", type, parser);
        final String nodeId = attrs.getValue("nodeId");
        emptyAttributeCheck(localName, "nodeId", nodeId, parser);
        final String nodeOutType = attrs.getValue("nodeOutType");
        emptyAttributeCheck(localName, "nodeOutType", nodeOutType, parser);
        compositeNode.linkOutgoingConnections(new Long(nodeId), nodeOutType, type);
        return null;
    }   
View Full Code Here

      return "composite";
    }

    public void writeNode(Node node, StringBuilder xmlDump, boolean includeMeta) {
      super.writeNode(getNodeName(), node, xmlDump, includeMeta);
        CompositeNode compositeNode = (CompositeNode) node;
        writeAttributes(compositeNode, xmlDump, includeMeta);
        xmlDump.append(">" + EOL);
        if (includeMeta) {
          writeMetaData(compositeNode, xmlDump);
        }
      for (String eventType: compositeNode.getActionTypes()) {
          writeActions(eventType, compositeNode.getActions(eventType), xmlDump);
        }
        writeTimers(compositeNode.getTimers(), xmlDump);
        if (compositeNode instanceof CompositeContextNode) {
          VariableScope variableScope = (VariableScope)
        ((CompositeContextNode) compositeNode).getDefaultContext(VariableScope.VARIABLE_SCOPE);
          if (variableScope != null) {
            List<Variable> variables = variableScope.getVariables();
View Full Code Here

        }
        int parentOffsetX = 0;
        int parentOffsetY = 0;
        NodeContainer nodeContainer = node.getNodeContainer();
        while (nodeContainer instanceof CompositeNode) {
          CompositeNode parent = (CompositeNode) nodeContainer;
          Integer parentX = (Integer) parent.getMetaData().get("x");
          if (parentX != null) {
            parentOffsetX += parentX;
          }
          Integer parentY = (Integer) parent.getMetaData().get("y");
          if (parentY != null) {
            parentOffsetY += (Integer) parent.getMetaData().get("y");
          }
          nodeContainer = parent.getNodeContainer();
        }
        x += parentOffsetX;
        y += parentOffsetY;
      xmlDump.append(
        "      <bpmndi:BPMNShape bpmnElement=\"" + getUniqueNodeId(node) + "\" >" + EOL +
View Full Code Here

        return result;
      }
      result = node.getId() + "";
      NodeContainer nodeContainer = node.getNodeContainer();
      while (nodeContainer instanceof CompositeNode) {
        CompositeNode composite = (CompositeNode) nodeContainer;
        result = composite.getId() + "-" + result;
        nodeContainer = composite.getNodeContainer();
      }
      return "_" + result;
    }
View Full Code Here

                    errors.add(new ProcessValidationErrorImpl(process,
                        "Dynamic node '" + node.getName() + "' [" + node.getId() + "] has no outgoing connection"));
                }
                validateNodes(dynamicNode.getNodes(), errors, process);
            } else if (node instanceof CompositeNode) {
                final CompositeNode compositeNode = (CompositeNode) node;
                for (Map.Entry<String, NodeAndType> inType: compositeNode.getLinkedIncomingNodes().entrySet()) {
                    if (compositeNode.getIncomingConnections(inType.getKey()).size() == && !acceptsNoIncomingConnections(node)) {
                        errors.add(new ProcessValidationErrorImpl(process,
                            "Composite node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection for type " + inType.getKey()));
                    }
                  if (inType.getValue().getNode() == null && !acceptsNoOutgoingConnections(node)) {
                        errors.add(new ProcessValidationErrorImpl(process,
                            "Composite node '" + node.getName() + "' [" + node.getId() + "] has invalid linked incoming node for type " + inType.getKey()));
                  }
                }
                for (Map.Entry<String, NodeAndType> outType: compositeNode.getLinkedOutgoingNodes().entrySet()) {
                    if (compositeNode.getOutgoingConnections(outType.getKey()).size() == 0) {
                        errors.add(new ProcessValidationErrorImpl(process,
                            "Composite node '" + node.getName() + "' [" + node.getId() + "] has no outgoing connection for type " + outType.getKey()));
                    }
                  if (outType.getValue().getNode() == null) {
                        errors.add(new ProcessValidationErrorImpl(process,
                            "Composite node '" + node.getName() + "' [" + node.getId() + "] has invalid linked outgoing node for type " + outType.getKey()));
                  }
                }
                validateNodes(compositeNode.getNodes(), errors, process);
            } else if (node instanceof EventNode) {
                final EventNode eventNode = (EventNode) node;
                if (eventNode.getEventFilters().size() == 0) {
                    errors.add(new ProcessValidationErrorImpl(process,
                        "Event node '" + node.getName() + "' [" + node.getId() + "] should specify an event type"));
View Full Code Here

   
    public String getUniqueId() {
      String result = id + "";
      NodeContainer nodeContainer = getNodeContainer();
      while (nodeContainer instanceof CompositeNode) {
        CompositeNode composite = (CompositeNode) nodeContainer;
        result = composite.getId() + ":" + result;
        nodeContainer = composite.getNodeContainer();
      }
      return result;
    }
View Full Code Here

        StartNode startNode = new StartNode();
        startNode.setName("Start");
        startNode.setId(1);
        process.addNode(startNode);
       
        CompositeNode compositeNode = new CompositeNode();
        compositeNode.setName("CompositeNode");
        compositeNode.setId(2);
        process.addNode(compositeNode);
        new ConnectionImpl(
            startNode, Node.CONNECTION_DEFAULT_TYPE,
            compositeNode, Node.CONNECTION_DEFAULT_TYPE
        );
       
        MilestoneNode milestoneNode = new MilestoneNode();
        milestoneNode.setName("Milestone");
        milestoneNode.setConstraint("eval(false)");
        compositeNode.addNode(milestoneNode);
        compositeNode.linkIncomingConnections(Node.CONNECTION_DEFAULT_TYPE, milestoneNode.getId(), Node.CONNECTION_DEFAULT_TYPE);
       
        EventNode eventNode = new EventNode();
        EventTypeFilter eventFilter = new EventTypeFilter();
        eventFilter.setType("myEvent");
        eventNode.addEventFilter(eventFilter);
        eventNode.setVariableName("event");
        compositeNode.addNode(eventNode);
       
        final List<String> myList = new ArrayList<String>();
        ActionNode actionNode = new ActionNode();
        actionNode.setName("Print");
        DroolsAction action = new DroolsConsequenceAction("java", null);
        action.setMetaData("Action", new Action() {
            public void execute(ProcessContext context) throws Exception {
              System.out.println("Detected event for person " + ((Person) context.getVariable("event")).getName());
                myList.add("Executed action");
            }
        });
        actionNode.setAction(action);
        compositeNode.addNode(actionNode);
        new ConnectionImpl(
            eventNode, Node.CONNECTION_DEFAULT_TYPE,
            actionNode, Node.CONNECTION_DEFAULT_TYPE
        );
       
        Join join = new Join();
        join.setName("XOR Join");
        join.setType(Join.TYPE_XOR);
        compositeNode.addNode(join);
        new ConnectionImpl(
            milestoneNode, Node.CONNECTION_DEFAULT_TYPE,
            join, Node.CONNECTION_DEFAULT_TYPE
        );
        new ConnectionImpl(
            actionNode, Node.CONNECTION_DEFAULT_TYPE,
            join, Node.CONNECTION_DEFAULT_TYPE
        );
        compositeNode.linkOutgoingConnections(join.getId(), Node.CONNECTION_DEFAULT_TYPE, Node.CONNECTION_DEFAULT_TYPE);
   
        EndNode endNode = new EndNode();
        endNode.setName("EndNode");
        endNode.setId(3);
        process.addNode(endNode);
View Full Code Here

          "        // wait for timer to expire\n" +
            "        // for example, try { Thread.sleep(delay); } catch (Exception e) { /* Do nothing */ }";
        // TODO simulation time
        return processNodes(name, ((NodeImpl) currentNode).getTo().getTo(), testCode, cases, ongoingCases);
      } else if (currentNode instanceof ForEachNode) {
        CompositeNode compositeNode = ((ForEachNode) currentNode).getCompositeNode();
        testCode +=
          "        // --> triggering each element in the collection:\n";
        boolean done = true;
          for (Node node: compositeNode.getNodes()) {
          if (node instanceof StartNode) {
            StartNode startNode = (StartNode) node;
            if (startNode.getTriggers() == null || startNode.getTriggers().isEmpty()) {
              done = processNodes(name, startNode.getTo().getTo(), testCode, cases, ongoingCases);
              break;
            }
          }
          }
          if (done) {
            for (Map.Entry<String, String> c: cases.entrySet()) {
              if (c.getKey().startsWith(name)) {
                cases.put(c.getKey(), c.getValue() +
                    "        // <-- do this for one element in the collection:\n");
              }
            }
            return true;
          } else {
            if (ongoingCases.size() == 1) {
              testCode = ongoingCases.values().iterator().next() +
              "        // <-- do this for each element in the collection:\n";
              return processNodes(name + "Implicit", ((NodeImpl) currentNode).getTo().getTo(), testCode, cases, ongoingCases);
            } else {
              throw new IllegalArgumentException("Could not create implicit case: " + ongoingCases.size());
            }
          }
      } else if (currentNode instanceof CompositeNode) {
        CompositeNode compositeNode = (CompositeNode) currentNode;
        boolean done = true;
          for (Node node: compositeNode.getNodes()) {
          if (node instanceof StartNode) {
            StartNode startNode = (StartNode) node;
            if (startNode.getTriggers() == null || startNode.getTriggers().isEmpty()) {
              done = processNodes(name, startNode.getTo().getTo(), testCode, cases, ongoingCases);
              break;
View Full Code Here

    private static final long serialVersionUID = -1965605499505300424L;

    @Override
    public void internalTrigger(NodeInstance from, String type) {

        CompositeNode compositeNode = (CompositeNode) getNode();

        for (Node node: compositeNode.getNodes()) {
            if (node instanceof StartNode) {
                StartNode startNode = (StartNode) node;
                if (startNode.getTriggers() == null || startNode.getTriggers().isEmpty()) {
                    NodeInstance nodeInstance = getNodeInstance(startNode);
                    ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).trigger(null, null);
View Full Code Here

TOP

Related Classes of org.jbpm.workflow.core.node.CompositeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.