Package org.drools.definition.process

Examples of org.drools.definition.process.Connection


                triggerCompleted(org.drools.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()) {
                        if ( constraint.evaluate( this,
                                                  connection,
                                                  constraint ) ) {
                            selected = connection;
                            priority = constraint.getPriority();
                        }
                    }
                }
                ((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.drools.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.drools.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.drools.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()) {
View Full Code Here


      super.internalTrigger(from, type);
        CompositeNode.NodeAndType nodeAndType = getCompositeNode().internalGetLinkedIncomingNode(type);
        if (nodeAndType != null) {
          List<Connection> connections = nodeAndType.getNode().getIncomingConnections(nodeAndType.getType());
          for (Iterator<Connection> iterator = connections.iterator(); iterator.hasNext(); ) {
              Connection connection = iterator.next();
              if ((connection.getFrom() instanceof CompositeNode.CompositeNodeStart) &&
                  (from == null ||
              ((CompositeNode.CompositeNodeStart) connection.getFrom()).getInNode().getId() == from.getNodeId())) {
                  NodeInstance nodeInstance = getNodeInstance(connection.getFrom());
                  ((org.drools.workflow.instance.NodeInstance) nodeInstance).trigger(null, nodeAndType.getType());
                  return;
              }
          }
        } else {
View Full Code Here

   
  public void internalTrigger(NodeInstance from, String type) {
    super.internalTrigger(from, type);
        // TODO: composite states trigger
        StateNode stateNode = getStateNode();
        Connection selected = null;
        int priority = Integer.MAX_VALUE;
        for (Connection connection: stateNode.getOutgoingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE)) {
            Constraint constraint = stateNode.getConstraint(connection);
            if (constraint != null && constraint.getPriority() < priority) {
              String rule = "RuleFlowStateNode-" + getProcessInstance().getProcessId() + "-" +
View Full Code Here

        }
        return true;
    }
   
    public void activationCreated(ActivationCreatedEvent event) {
        Connection selected = null;
        for (Connection connection: getNode().getOutgoingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE)) {
            Constraint constraint = getStateNode().getConstraint(connection);
            if (constraint != null) {
              String constraintName =  getActivationEventType() + "-"
                + connection.getTo().getId() + "-" + connection.getToType();
View Full Code Here

                    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) {
                            errors.add(new ProcessValidationErrorImpl(process,
                                "Split node '" + node.getName() + "' [" + node.getId() + "] does not have a constraint for " + connection.toString() + "."));
                        }
                    }
                }
            } else if (node instanceof Join) {
                final Join join = (Join) node;
View Full Code Here

        if (CONSTRAINTS.equals(id)) {
            Iterator<Map.Entry<ConnectionRef, Constraint>> iterator = ((Map<ConnectionRef, Constraint>) value).entrySet().iterator();
            while (iterator.hasNext()) {
                Map.Entry<ConnectionRef, Constraint> element = iterator.next();
                ConnectionRef connectionRef = element.getKey();
                Connection outgoingConnection = null;
                for (Connection out: getStateNode().getOutgoingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE)) {
                    if (out.getToType().equals(connectionRef.getToType())
                        && out.getTo().getId() == connectionRef.getNodeId()) {
                        outgoingConnection = out;
                    }
View Full Code Here

        } else if (CONSTRAINTS.equals(id)) {
            Iterator<Map.Entry<ConnectionRef, Constraint>> iterator = ((Map<ConnectionRef, Constraint>) value).entrySet().iterator();
            while (iterator.hasNext()) {
                Map.Entry<ConnectionRef, Constraint> element = iterator.next();
                ConnectionRef connectionRef = element.getKey();
                Connection outgoingConnection = null;
                for (Connection out: getSplit().getDefaultOutgoingConnections()) {
                    if (out.getToType().equals(connectionRef.getToType())
                        && out.getTo().getId() == connectionRef.getNodeId()) {
                        outgoingConnection = out;
                    }
View Full Code Here

           
            for (String key : incomingConnectionsTypes) {
                Iterator<Connection> itConnections = node.getIncomingConnections(key).iterator();
                long fromNodeId = 0;
                while (itConnections.hasNext()) {
                    Connection connection = itConnections.next();
                    Node fromNode = connection.getFrom();

                    fromNodeId = connection.getTo().getId();
                    if(fromNode instanceof org.drools.jpdl.core.node.State){
                        System.out.println("<!-- Take a look at the State Node that is pointing here, " +
                                "you will need to change the constraint for signal it to the new JoinNode id -->");
                        System.out.println("<!-- in node id: "+fromNode.getId()+ " / name: "+fromNode.getName()+" -->");
                        System.out.println("<!-- you should change the fromId ("+fromNodeId+") attribute to: "+suggestedNodeId+"-->");
View Full Code Here

            System.out.println("<!-- END - This is a suggested Split Node -->");
            List<Connection> removeConnections = new ArrayList<Connection>();
            for (String key : outgoingConnectionsTypes) {
                Iterator<Connection> itConnections = node.getOutgoingConnections(key).iterator();
                while (itConnections.hasNext()) {
                    Connection connection = itConnections.next();
                    Node toNode = connection.getTo();
                    removeConnections.add(connection);
                    resultGeneratedConnection += "  <connection from=\"" + suggestedNodeId + "\" to=\"" + toNode.getId() + "\" />\n";
                }
               
View Full Code Here

                    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) {
                            errors.add(new ProcessValidationErrorImpl(process,
                                "Split node '" + node.getName() + "' [" + node.getId() + "] does not have a constraint for " + connection.toString() + "."));
                        }
                    }
                }
            } else if ( node instanceof Join ) {
                final Join join = (Join) node;
View Full Code Here

TOP

Related Classes of org.drools.definition.process.Connection

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.