Package org.drools.workflow.core

Examples of org.drools.workflow.core.Constraint


        // 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() + "-" +
                getStateNode().getUniqueId() + "-" +
                connection.getTo().getId() + "-" +
                connection.getToType();
            boolean isActive = ((InternalAgenda) getProcessInstance().getAgenda())
                .isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", rule, getProcessInstance().getId());
            if (isActive) {
                selected = connection;
                  priority = constraint.getPriority();
              }
            }
        }
        if (selected != null) {
            ((NodeInstanceContainer) getNodeInstanceContainer()).removeNodeInstance(this);
View Full Code Here


  public void signalEvent(String type, Object event) {
    if ("signal".equals(type)) {
      if (event instanceof String) {
        for (Connection connection: getStateNode().getOutgoingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE)) {
          boolean selected = false;
          Constraint constraint = getStateNode().getConstraint(connection);
          if (constraint == null) {
            if (((String) event).equals(connection.getTo().getName())) {
              selected = true;
            }
          } else if (((String) event).equals(constraint.getName())) {
            selected = true;
          }
          if (selected) {
            triggerEvent(ExtendedNodeImpl.EVENT_NODE_EXIT);
            removeEventListeners();
View Full Code Here

              + getProcessInstance().getProcessId() + "-" + getNode().getId();
            if (ruleName.startsWith(constraintNameStart)) {
                Connection selected = null;
                int priority = Integer.MAX_VALUE;
              for (Connection connection: getNode().getOutgoingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE)) {
                  Constraint constraint = getStateNode().getConstraint(connection);
                  if (constraint != null && constraint.getPriority() < priority) {
                  String constraintName =  constraintNameStart + "-"
                    + connection.getTo().getId() + "-" + connection.getToType();
                  if (constraintName.equals(ruleName) && checkProcessInstance(event.getActivation())) {
                    selected = connection;
                    priority = constraint.getPriority();
                  }
                  }
              }
              if (selected != null) {
                synchronized(getProcessInstance()) {
View Full Code Here

        split.setMetaData("y", 2);
        split.setMetaData("width", 3);
        split.setMetaData("height", 4);
        split.setType(Split.TYPE_XOR);
        Connection connection = new ConnectionImpl(split, Node.CONNECTION_DEFAULT_TYPE, actionNode, Node.CONNECTION_DEFAULT_TYPE);
        Constraint constraint = new ConstraintImpl();
        constraint.setName("constraint1");
        constraint.setPriority(1);
        constraint.setDialect("dialect1");
        constraint.setType("type1");
        constraint.setConstraint("constraint-text1");
        split.setConstraint(connection, constraint);
        connection = new ConnectionImpl(split, Node.CONNECTION_DEFAULT_TYPE, ruleSetNode, Node.CONNECTION_DEFAULT_TYPE);
        constraint = new ConstraintImpl();
        constraint.setName("constraint2");
        constraint.setPriority(2);
        constraint.setDialect("dialect2");
        constraint.setType("type2");
        constraint.setConstraint("constraint-text2");
        split.setConstraint(connection, constraint);
        process.addNode(split);
        new ConnectionImpl(startNode, Node.CONNECTION_DEFAULT_TYPE, split, Node.CONNECTION_DEFAULT_TYPE);
       
        EventNode eventNode = new EventNode();
View Full Code Here

        writeTimers(stateNode.getTimers(), xmlDump);
        if (!stateNode.getConstraints().isEmpty()) {
          xmlDump.append("      <constraints>" + EOL);
          for (Map.Entry<ConnectionRef, Constraint> entry: stateNode.getConstraints().entrySet()) {
              ConnectionRef connection = entry.getKey();
              Constraint constraint = entry.getValue();
              xmlDump.append("        <constraint "
                  + "toNodeId=\"" + connection.getNodeId() + "\" ");
              String name = constraint.getName();
              if (name != null && !"".equals(name)) {
                  xmlDump.append("name=\"" + XmlDumper.replaceIllegalChars(constraint.getName()) + "\" ");
              }
              int priority = constraint.getPriority();
              if (priority != 0) {
                  xmlDump.append("priority=\"" + constraint.getPriority() + "\" ");
              }
              String constraintString = constraint.getConstraint();
              if (constraintString != null) {
                  xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</constraint>" + EOL);
              } else {
                  xmlDump.append("/>" + EOL);
              }
View Full Code Here

        for ( int i = 0; i < nodes.length; i++ ) {
            if ( nodes[i] instanceof Split ) {
                Split split = (Split) nodes[i];
                if ( split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR ) {
                    for ( Connection connection : split.getDefaultOutgoingConnections() ) {
                        Constraint constraint = split.getConstraint( connection );
                        if ( "rule".equals( constraint.getType() ) ) {
                            builder.append( createSplitRule( process,
                                                             connection,
                                                             split.getConstraint( connection ).getConstraint() ) );
                        }
                    }
View Full Code Here

                      final String localName,
                      final ExtensibleXmlParser parser) throws SAXException {
        final Element element = parser.endElementBuilder();
         
      Constrainable parent = (Constrainable) parser.getParent();
        Constraint constraint = new ConstraintImpl();

        final String toNodeIdString = element.getAttribute("toNodeId");
        String toType = element.getAttribute("toType");
        ConnectionRef connectionRef = null;
        if (toNodeIdString != null && toNodeIdString.trim().length() > 0) {
          int toNodeId = new Integer(toNodeIdString);
          if (toType == null || toType.trim().length() == 0) {
            toType = NodeImpl.CONNECTION_DEFAULT_TYPE;
          }
          connectionRef = new ConnectionRef(toNodeId, toType);
        }

        final String name = element.getAttribute("name");
        constraint.setName(name);
        final String priority = element.getAttribute("priority");
        if (priority != null && priority.length() != 0) {
            constraint.setPriority(new Integer(priority));
        }

        final String type = element.getAttribute("type");
        constraint.setType(type);
        final String dialect = element.getAttribute("dialect");
        constraint.setDialect(dialect);
         
        String text = ((Text)element.getChildNodes().item( 0 )).getWholeText();
        if (text != null) {
            text = text.trim();
            if ("".equals(text)) {
                text = null;
            }
        }
        constraint.setConstraint(text);
        parent.addConstraint(connectionRef, constraint);
        return null;
    }
View Full Code Here

              writeMetaData(splitNode, xmlDump);
            }
            xmlDump.append("      <constraints>" + EOL);
            for (Map.Entry<ConnectionRef, Constraint> entry: splitNode.getConstraints().entrySet()) {
                ConnectionRef connection = entry.getKey();
                Constraint constraint = entry.getValue();
                xmlDump.append("        <constraint "
                    + "toNodeId=\"" + connection.getNodeId() + "\" "
                    + "toType=\"" + connection.getToType() + "\" ");
                String name = constraint.getName();
                if (name != null && !"".equals(name)) {
                    xmlDump.append("name=\"" + XmlDumper.replaceIllegalChars(constraint.getName()) + "\" ");
                }
                int priority = constraint.getPriority();
                if (priority != 0) {
                    xmlDump.append("priority=\"" + constraint.getPriority() + "\" ");
                }
                xmlDump.append("type=\"" + constraint.getType() + "\" ");
                String dialect = constraint.getDialect();
                if (dialect != null && !"".equals(dialect)) {
                    xmlDump.append("dialect=\"" + dialect + "\" ");
                }
                String constraintString = constraint.getConstraint();
                if (constraintString != null) {
                    xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</constraint>" + EOL);
                } else {
                    xmlDump.append("/>" + EOL);
                }
View Full Code Here

            SplitNode.ConnectionRef ref2 = new SplitNode.ConnectionRef();
            ref2.setNodeId( connection.getNodeId() );
            ref2.setToType( connection.getToType() );

            Constraint c1 = splitNode.internalGetConstraint( ref1 );
            SplitNode.Constraint c2 = stn.getConstraints().get( ref2 );

            updateConstraint( c1,
                              c2 );
        }
View Full Code Here

            for ( int i = 0; i < nodes.length; i++ ) {
                if ( nodes[i] instanceof Split ) {
                    Split split = (Split) nodes[i];
                    if ( split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR ) {
                        for ( Connection connection : split.getDefaultOutgoingConnections() ) {
                            Constraint constraint = split.getConstraint( connection );
                            if ( "rule".equals( constraint.getType() ) ) {
                                builder.append( createSplitRule( process,
                                                                 connection,
                                                                 split.getConstraint( connection ).getConstraint() ) );
                            }
                        }
View Full Code Here

TOP

Related Classes of org.drools.workflow.core.Constraint

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.