Examples of Split


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

  public Class generateNodeFor() {
        return Split.class;
    }

  public void writeNode(Node node, StringBuilder xmlDump, int metaDataType) {
    Split split = (Split) node;
    switch (split.getType()) {
      case Split.TYPE_AND:
        writeNode("parallelGateway", node, xmlDump, metaDataType);
        break;
      case Split.TYPE_XOR:
        writeNode("exclusiveGateway", node, xmlDump, metaDataType);
        for (Map.Entry<ConnectionRef, Constraint> entry: split.getConstraints().entrySet()) {
          if (entry.getValue().isDefault()) {
            xmlDump.append("default=\"" +
              XmlBPMNProcessDumper.getUniqueNodeId(split) + "-" +
              XmlBPMNProcessDumper.getUniqueNodeId(node.getNodeContainer().getNode(entry.getKey().getNodeId())) +
              "\" ");
            break;
          }
        }
        break;
      case Split.TYPE_OR:
                writeNode("inclusiveGateway", node, xmlDump, metaDataType);
        for (Map.Entry<ConnectionRef, Constraint> entry: split.getConstraints().entrySet()) {
          if (entry.getValue().isDefault()) {
            xmlDump.append("default=\"" +
              XmlBPMNProcessDumper.getUniqueNodeId(split) + "-" +
              XmlBPMNProcessDumper.getUniqueNodeId(node.getNodeContainer().getNode(entry.getKey().getNodeId())) +
              "\" ");
View Full Code Here

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

    public SplitFactory(RuleFlowNodeContainerFactory nodeContainerFactory, NodeContainer nodeContainer, long id) {
        super(nodeContainerFactory, nodeContainer, id);
    }

    protected Node createNode() {
        return new Split();
    }
View Full Code Here

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

                  for (Timer timer: ruleSetNode.getTimers().keySet()) {
                    validateTimer(timer, node, process, errors);
                  }
                }
            } else if (node instanceof Split) {
                final Split split = (Split) node;
                if (split.getType() == Split.TYPE_UNDEFINED) {
                    errors.add(new ProcessValidationErrorImpl(process,
                        "Split node '" + node.getName() + "' [" + node.getId() + "] has no type."));
                }
                if (split.getFrom() == null && !acceptsNoIncomingConnections(node)) {
                    errors.add(new ProcessValidationErrorImpl(process,
                        "Split node '" + node.getName() + "' [" + node.getId() + "] has no incoming connection."));
                }
                if (split.getDefaultOutgoingConnections().size() < 2) {
                    errors.add(new ProcessValidationErrorImpl(process,
                        "Split node '" + node.getName() + "' [" + node.getId() + "] does not have more than one outgoing connection: " + split.getOutgoingConnections().size() + "."));
                }
                if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR ) {
                    for ( final Iterator<Connection> it = split.getDefaultOutgoingConnections().iterator(); it.hasNext(); ) {
                        final Connection connection = it.next();
                        if (split.getConstraint(connection) == null && !split.getConstraint(connection).isDefault() && (split.getConstraint(connection).getConstraint() == null || split.getConstraint(connection).getConstraint().trim().length() == 0)) {
                            errors.add(new ProcessValidationErrorImpl(process,
                                "Split node '" + node.getName() + "' [" + node.getId() + "] does not have a constraint for " + connection.toString() + "."));
                        }
                    }
                }
View Full Code Here

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

    public void internalTrigger(final NodeInstance from, String type) {
        if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) {
            throw new IllegalArgumentException(
                "A Split only accepts default incoming connections!");
        }
        final Split split = getSplit();
        // TODO make different strategies for each type
        switch ( split.getType() ) {
            case Split.TYPE_AND :
                triggerCompleted(org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE, true);
                break;
            case Split.TYPE_XOR :
                List<Connection> outgoing = split.getDefaultOutgoingConnections();
                int priority = Integer.MAX_VALUE;
                Connection selected = null;
                for ( final Iterator<Connection> iterator = outgoing.iterator(); iterator.hasNext(); ) {
                    final Connection connection = (Connection) iterator.next();
                    ConstraintEvaluator constraint = (ConstraintEvaluator) split.getConstraint( connection );
                    if ( constraint != null && constraint.getPriority() < priority && !constraint.isDefault()) {
                        try {
                          if ( constraint.evaluate( this,
                                                      connection,
                                                      constraint ) ) {
                            selected = connection;
                            priority = constraint.getPriority();
                          }
                        } catch (RuntimeException e) {
                          throw new RuntimeException(
                          "Exception when trying to evaluate constraint "
                              + constraint.getName() + " in split "
                              + split.getName(), e);
                        }
                    }
                }
                ((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this);
                if ( selected == null ) {
                  for ( final Iterator<Connection> iterator = outgoing.iterator(); iterator.hasNext(); ) {
                        final Connection connection = (Connection) iterator.next();
                        ConstraintEvaluator constraint = (ConstraintEvaluator) split.getConstraint( connection );
                        if ( constraint.isDefault() ) {
                            selected = connection;
                            break;
                        }
                    }
                }
                if ( selected == null ) {
                  throw new IllegalArgumentException( "XOR split could not find at least one valid outgoing connection for split " + getSplit().getName() );
                }
                triggerConnection(selected);
                break;
            case Split.TYPE_OR :
              ((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this);
                outgoing = split.getDefaultOutgoingConnections();
                boolean found = false;
                List<Connection> outgoingCopy = new ArrayList<Connection>(outgoing);
                while (!outgoingCopy.isEmpty()) {
                    priority = Integer.MAX_VALUE;
                    Connection selectedConnection = null;
                    ConstraintEvaluator selectedConstraint = null;
                    for ( final Iterator<Connection> iterator = outgoingCopy.iterator(); iterator.hasNext(); ) {
                        final Connection connection = (Connection) iterator.next();
                        ConstraintEvaluator constraint = (ConstraintEvaluator) split.getConstraint( connection );
   
                        if ( constraint != null 
                                && constraint.getPriority() < priority
                                && !constraint.isDefault() ) {
                            priority = constraint.getPriority();
                            selectedConnection = connection;
                            selectedConstraint = constraint;
                        }
                    }
                    if (selectedConstraint == null) {
                      break;
                    }
                    if (selectedConstraint.evaluate( this,
                                                     selectedConnection,
                                                     selectedConstraint ) ) {
                        triggerConnection(selectedConnection);
                        found = true;
                    }
                    outgoingCopy.remove(selectedConnection);
                }
                if ( !found ) {
                  for ( final Iterator<Connection> iterator = outgoing.iterator(); iterator.hasNext(); ) {
                        final Connection connection = (Connection) iterator.next();
                        ConstraintEvaluator constraint = (ConstraintEvaluator) split.getConstraint( connection );
                        if ( constraint.isDefault() ) {
                          triggerConnection(connection);
                          found = true;
                            break;
                        }
                    }
                }
                if ( !found ) {
                    throw new IllegalArgumentException( "OR split could not find at least one valid outgoing connection for split " + getSplit().getName() );
                }               
                break;
            case Split.TYPE_XAND :
              ((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this);
                Node node = getNode();
                List<Connection> connections = null;
                if (node != null) {
                  connections = node.getOutgoingConnections(type);
                }
                if (connections == null || connections.isEmpty()) {
                  ((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer())
                    .nodeInstanceCompleted(this, type);
                } else {
                  ExclusiveGroupInstance groupInstance = new ExclusiveGroupInstance();
                org.drools.runtime.process.NodeInstanceContainer parent = getNodeInstanceContainer();
                  if (parent instanceof ContextInstanceContainer) {
                    ((ContextInstanceContainer) parent).addContextInstance(ExclusiveGroup.EXCLUSIVE_GROUP, groupInstance);
                  } else {
                    throw new IllegalArgumentException(
                    "An Exclusive AND is only possible if the parent is a context instance container");
                  }
                  Map<NodeInstance, String> nodeInstances = new HashMap<NodeInstance, String>();
                  for (Connection connection: connections) {
                    nodeInstances.put(
                      ((org.jbpm.workflow.instance.NodeInstanceContainer) getNodeInstanceContainer())
                          .getNodeInstance(connection.getTo()),
                      connection.getToType());
                  }
                  for (NodeInstance nodeInstance: nodeInstances.keySet()) {
                    groupInstance.addNodeInstance(nodeInstance);
                  }
                  for (Map.Entry<NodeInstance, String> entry: nodeInstances.entrySet()) {
                    // stop if this process instance has been aborted / completed
                    if (getProcessInstance().getState() != ProcessInstance.STATE_ACTIVE) {
                      return;
                    }
                    boolean hidden = false;
                    if (getNode().getMetaData().get("hidden") != null) {
                      hidden = true;
                    }
                    InternalKnowledgeRuntime kruntime = getProcessInstance().getKnowledgeRuntime();
                    if (!hidden) {
                      ((InternalProcessRuntime) kruntime.getProcessRuntime())
                        .getProcessEventSupport().fireBeforeNodeLeft(this, kruntime);
                    }
                      ((org.jbpm.workflow.instance.NodeInstance) entry.getKey())
                      .trigger(this, entry.getValue());
                      if (!hidden) {
                        ((InternalProcessRuntime) kruntime.getProcessRuntime())
                          .getProcessEventSupport().fireAfterNodeLeft(this, kruntime);
                      }
                  }
                }
                break;
            default :
                throw new IllegalArgumentException( "Illegal split type " + split.getType() );
        }
    }
View Full Code Here

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

        log.debug( "Processing " + process.getId() );
        result = new HashMap<String, String[]>();
        StartNode start = process.getStart();
        Node target = start.getTo().getTo();
        if ( target instanceof Split ) {
            Split split = (Split) target;
            for ( Connection connection : split.getDefaultOutgoingConnections() ) {
                Constraint constraint = split.getConstraint( connection );
                if ( constraint != null ) {
                    System.out.println( "Found constraint to node " + connection.getTo().getName() + " [" + connection.getTo().getId() + "]: " + constraint.getConstraint() );
                    result.put( XmlBPMNProcessDumper.getUniqueNodeId( connection.getTo() ),
                                new String[]{connection.getTo().getName(), constraint.getConstraint()} );
                }
View Full Code Here

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

        } else {
            log.debug( "Processing " + process.getId() );
            StartNode start = process.getStart();
            Node target = start.getTo().getTo();
            if ( target instanceof Split ) {
                Split split = (Split) target;
                for ( Connection connection : split.getDefaultOutgoingConnections() ) {
                    String s = constraints.get( XmlBPMNProcessDumper.getUniqueNodeId( connection.getTo() ) );
                    if ( s != null ) {
                        System.out.println( "Found constraint to node " + connection.getTo().getName() + ": " + s );
                        Constraint constraint = split.getConstraint( connection );
                        if ( constraint == null ) {
                            constraint = new ConstraintImpl();
                            split.setConstraint( connection,
                                                 constraint );
                        }
                        constraint.setConstraint( s );
                    }
                }
View Full Code Here

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

   
    private static final long serialVersionUID = 510l;
    private transient IPropertyDescriptor[] descriptors;

    public SplitWrapper() {
        setNode(new Split());
        getSplit().setName("Split");
        setDescriptors();
    }
View Full Code Here

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

        }
    }
   
    private boolean processNodes(String name, Node currentNode, String testCode, Map<String, String> cases, Map<String, String> ongoingCases) {
      if (currentNode instanceof Split) {
        Split split = (Split) currentNode;
        switch (split.getType()) {
          case Split.TYPE_AND:
            boolean done = false;
            String startTestCode = testCode;
            int counter = 1;
            for (Connection c: split.getDefaultOutgoingConnections()) {
              if (processNodes(name + counter++, c.getTo(), startTestCode, cases, ongoingCases)) {
                done = true;
              }
            }
            if (!done) {
                String implicitCompleteTestCode = startTestCode;
              for (String ongoingCase: ongoingCases.values()) {
              implicitCompleteTestCode += ongoingCase.substring(startTestCode.length(), ongoingCase.length());
              }
              ongoingCases.clear();
              ongoingCases.put(name, implicitCompleteTestCode);
            }
            return done;
          case Split.TYPE_XOR:
          case Split.TYPE_OR:
            int i = 1;
            done = true;
            for (Connection c: split.getDefaultOutgoingConnections()) {
              String newTestCode = testCode +
                "        // please make sure that the following constraint is selected to node " + c.getTo().getName() + ":\n" +
              "        // " + split.getConstraint(c).getConstraint() + "\n";
              if (!processNodes(name + "Constraint" + i++, c.getTo(), newTestCode, cases, ongoingCases)) {
                done = false;
              }
            }
            return done;
          default:
            throw new IllegalArgumentException("Unknown split type " + split.getType());
        }
      } else if (currentNode instanceof EndNode) {
        EndNode endNode = (EndNode) currentNode;
        if (endNode.isTerminate()) {
          cases.put(name, testCode);
View Full Code Here

Examples of org.jdesktop.swingx.MultiSplitLayout.Split

    public static final String TOP = "top";
    public static final String BOTTOM = "bottom";
   
    /** Creates a new instance of DefaultSplitPaneLayout */
    public DefaultSplitPaneModel() {
        Split row = new Split();
        Split col = new Split();
        col.setRowLayout(false);
        setChildren(new Leaf(LEFT), new Divider(), col);
        col.setChildren(new Leaf(TOP), new Divider(), new Leaf(BOTTOM));
    }
View Full Code Here

Examples of org.noos.xing.mydoggy.plaf.ui.cmp.multisplit.MultiSplitLayout.Split

                            break;
                    }

                    boolean rowLayout = (aggregationPosition == AggregationPosition.LEFT || aggregationPosition == AggregationPosition.RIGHT);

                    Split split = new Split();
                    split.setRowLayout(rowLayout);
                    split.setBounds(split.getBounds());
                    split.setChildren(children);

                    // update the model
                    multiSplitPaneModelRoot = split;

                    if (!multiSplitPane.getMultiSplitLayout().getFloatingDividers())
                        multiSplitPane.getMultiSplitLayout().setFloatingDividers(true);

                    validateModel(multiSplitPaneModelRoot);
                    multiSplitPane.setModel(multiSplitPaneModelRoot);

                    // update the components in the container
                    Component wrapper;
                    if (rootLeaf.getDockables().size() > 1) {
                        wrapper = multiSplitPane.getComponent(0);
                    } else {
                        Dockable delegator = entries.values().iterator().next().dockable;
                        wrapper = getWrapperForComponent(delegator, getComponentFromWrapper(multiSplitPane.getComponent(0)), Action.ADD_DOCK);
                    }
                    multiSplitPane.removeAll();

                    multiSplitPane.add(wrapper, firstLeaf.getName());
                    multiSplitPane.add(getWrapperForComponent(dockable, content, Action.ADD_DOCK), secondLeaf.getName());
                }
            } else {
                // Take the root, it's a split
                Split splitRoot = (Split) multiSplitPaneModelRoot;

                // Build content to add
                boolean addCmp = true;
                String leafName = null;

                // Modify model
                if (aggregationOnDockable != null) {

                    // Search for aggregationOnDockable leaf
                    Stack<Split> stack = new Stack<Split>();
                    stack.push(splitRoot);

                    while (!stack.isEmpty()) {
                        Split split = stack.pop();

                        for (Node child : split.getChildren()) {
                            if (child instanceof DockableLeaf) {
                                DockableLeaf leaf = (DockableLeaf) child;

                                if (leaf.getDockables().contains(aggregationOnDockable.getId())) {
                                    if (invalidAggregationPosition) {
                                        // The requeste is to add more than one dockable on the same leaf...
                                        addToWrapper(multiSplitPane.getMultiSplitLayout().getChildMap().get(leaf.getName()),
                                                dockable,
                                                aggregationIndexLocation,
                                                content);

                                        leaf.addDockable(dockable.getId());

                                        addCmp = false;
                                        resetB = false;
                                    } else {
                                        leafName = getNextLeanName();
                                        boolean step1Failed = false;

                                        // Check for concordance to leaf.getParent().isRowLayout and aggregationPosition
                                        Split parent = leaf.getParent();
                                        boolean rowLayout = parent.isRowLayout();

                                        List<Node> parentChildren = parent.getChildren();
                                        int startIndex = parentChildren.indexOf(leaf);
                                        if (rowLayout) {
                                            boolean finalize = false;
                                            switch (aggregationPosition) {
                                                case LEFT:
                                                    parentChildren.add(startIndex, new DockableLeaf(leafName, dockable.getId()));
                                                    parentChildren.add(startIndex + 1, new Divider());
                                                    finalize = true;
                                                    break;
                                                case RIGHT:
                                                    parentChildren.add(startIndex + 1, new Divider());
                                                    parentChildren.add(startIndex + 2, new DockableLeaf(leafName, dockable.getId()));
                                                    finalize = true;
                                                    break;
                                                default:
                                                    step1Failed = true;
                                            }

                                            if (finalize) {
                                                // Set new children
                                                forceWeight(parentChildren);
                                                parent.setChildren(parentChildren);
                                            }
                                        } else {
                                            boolean finalize = false;
                                            switch (aggregationPosition) {
                                                case TOP:
                                                    parentChildren.add(startIndex, new DockableLeaf(leafName, dockable.getId()));
                                                    parentChildren.add(startIndex + 1, new Divider());
                                                    finalize = true;
                                                    break;
                                                case BOTTOM:
                                                    parentChildren.add(startIndex + 1, new Divider());
                                                    parentChildren.add(startIndex + 2, new DockableLeaf(leafName, dockable.getId()));
                                                    finalize = true;
                                                    break;
                                                default:
                                                    step1Failed = true;
                                            }

                                            if (finalize) {
                                                // Set new children
                                                forceWeight(parentChildren);
                                                parent.setChildren(parentChildren);
                                            }
                                        }


                                        if (step1Failed) {
                                            // Create two leafs

                                            Leaf newleaf = new DockableLeaf(leafName, dockable.getId());
                                            newleaf.setWeight(0.5);

                                            // Creat the split
                                            Split newSplit = new Split();
                                            newSplit.setBounds(leaf.getBounds());
                                            newSplit.setRowLayout((aggregationPosition == AggregationPosition.LEFT || aggregationPosition == AggregationPosition.RIGHT));
                                            newSplit.setWeight(leaf.getWeight());
                                            leaf.getParent().removeNode(leaf);
                                            switch (aggregationPosition) {
                                                case LEFT:
                                                case TOP:
                                                    newSplit.setChildren(Arrays.asList(newleaf,
                                                            new Divider(),
                                                            leaf));
                                                    break;
                                                default:
                                                    newSplit.setChildren(Arrays.asList(leaf,
                                                            new Divider(),
                                                            newleaf));
                                                    break;
                                            }

                                            leaf.setWeight(0.5);

                                            // Switch the leaf with the new split
                                            parentChildren.set(startIndex, newSplit);
                                            parent.setChildren(parentChildren);
                                        }
                                    }

                                    stack.clear();
                                    break;
                                }
                            } else if (child instanceof Split) {
                                stack.push((Split) child);
                            }
                        }
                    }

                    if (!multiSplitPane.getMultiSplitLayout().getFloatingDividers())
                        multiSplitPane.getMultiSplitLayout().setFloatingDividers(true);
                } else {
                    leafName = getNextLeanName();
                    boolean rowLayout = (aggregationPosition == AggregationPosition.LEFT || aggregationPosition == AggregationPosition.RIGHT);

                    if (splitRoot.isRowLayout() == rowLayout) {
                        List<Node> children = splitRoot.getChildren();

                        switch (aggregationPosition) {
                            case LEFT:
                            case TOP:
                                children.add(0, new DockableLeaf(leafName, dockable.getId()));
                                children.add(1, new Divider());
                                break;
                            case RIGHT:
                            case BOTTOM:
                                children.add(new Divider());
                                children.add(new DockableLeaf(leafName, dockable.getId()));
                                break;
                        }

                        forceWeight(children);

                        splitRoot.setChildren(children);
                    } else {
                        Split newRoot = new Split();
                        newRoot.setRowLayout(rowLayout);
                        newRoot.setBounds(multiSplitPaneModelRoot.getBounds());

                        Leaf leaf = new DockableLeaf(leafName, dockable.getId());
                        leaf.setWeight(0.5);
                        multiSplitPaneModelRoot.setWeight(0.5);

                        List<Node> children = null;
                        switch (aggregationPosition) {
                            case LEFT:
                            case TOP:
                                children = Arrays.asList(leaf,
                                        new Divider(),
                                        multiSplitPaneModelRoot);
                                break;
                            case RIGHT:
                            case BOTTOM:
                                children = Arrays.asList(multiSplitPaneModelRoot,
                                        new Divider(),
                                        leaf);
                                break;
                        }
                        forceWeight(children);
                        newRoot.setChildren(children);

                        multiSplitPaneModelRoot = newRoot;
                    }

                    if (!multiSplitPane.getMultiSplitLayout().getFloatingDividers())
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.