Package org.drools.workflow.core

Examples of org.drools.workflow.core.Constraint


        } else {
            xmlDump.append(">" + EOL);
            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


        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

        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

          source, NodeImpl.CONNECTION_DEFAULT_TYPE,
          target, NodeImpl.CONNECTION_DEFAULT_TYPE);
        result.setMetaData("bendpoints", connection.getBendpoints());
        if (source instanceof Split) {
          Split split = (Split) source;
          Constraint constraint = new ConstraintImpl();
          String defaultConnection = (String) split.getMetaData("Default");
          if (defaultConnection != null && defaultConnection.equals(connection.getId())) {
            constraint.setDefault(true);
          }
          if (connection.getName() != null) {
            constraint.setName(connection.getName());
          } else {
            constraint.setName("");
          }
          if (connection.getType() != null) {
            constraint.setType(connection.getType());
          } else {
            constraint.setType("code");
          }
          if (connection.getLanguage() != null) {
            constraint.setDialect(connection.getLanguage());
          }
          if (connection.getExpression() != null) {
            constraint.setConstraint(connection.getExpression());
          }
          split.addConstraint(
            new ConnectionRef(target.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE),
            constraint);
        }
View Full Code Here

    private void postProcessNodes(NodeContainer container) {
        for (Node node: container.getNodes()) {
            if (node instanceof StateNode) {
                StateNode stateNode = (StateNode) node;
                String condition = (String) stateNode.getMetaData().get("Condition");
                Constraint constraint = new ConstraintImpl();
                constraint.setConstraint(condition);
                constraint.setType("rule");
                for (org.drools.definition.process.Connection connection: stateNode.getDefaultOutgoingConnections()) {
                    stateNode.setConstraint(connection, constraint);
                }
            } else if (node instanceof NodeContainer) {
                postProcessNodes((NodeContainer) node);
View Full Code Here

//            }
//        }
        if (connection.getFrom() instanceof Split) {
          Split split = (Split) connection.getFrom();
          if (split.getType() == Split.TYPE_XOR || split.getType() == Split.TYPE_OR) {
            Constraint constraint = split.getConstraint(connection);
            if (constraint == null) {
                xmlDump.append(">" + EOL +
              "      <conditionExpression xs:type=\"tFormalExpression\" />");
            } else {
                    if (constraint.getName() != null && constraint.getName().trim().length() > 0) {
                  xmlDump.append("name=\"" + XmlDumper.replaceIllegalChars(constraint.getName()) + "\" ");
                }
                xmlDump.append(">" + EOL +
            "      <conditionExpression xs:type=\"tFormalExpression\" ");
                    if ("code".equals(constraint.getType())) {
                        if (JavaDialect.ID.equals(constraint.getDialect())) {
                            xmlDump.append("language=\"" + JAVA_LANGUAGE + "\" ");
                        } else if (XPathDialect.ID.equals(constraint.getDialect())) {
                            xmlDump.append("language=\"" + XPATH_LANGUAGE + "\" ");
                        }
                    } else {
                        xmlDump.append("language=\"" + RULE_LANGUAGE + "\" ");
                    }
                    String constraintString = constraint.getConstraint();
                    if (constraintString == null) {
                        constraintString = "";
                    }
                    xmlDump.append(">" + XmlDumper.replaceIllegalChars(constraintString) + "</conditionExpression>");
            }
View Full Code Here

        // 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

    }
   
    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();
              if (constraintName.equals(event.getActivation().getRule().getName()) && checkProcessInstance(event.getActivation())) {
                selected = connection;
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.