Examples of DroolsConsequenceAction


Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

            if ("dataInputAssociation".equals(nodeName)) {
                readDataInputAssociation(xmlNode, actionNode);
            } else if ("signalEventDefinition".equals(nodeName)) {
                String signalName = ((Element) xmlNode).getAttribute("signalRef");
                String variable = (String) actionNode.getMetaData("MappingVariable");
                actionNode.setAction(new DroolsConsequenceAction("mvel",
                    "kcontext.getKnowledgeRuntime().signalEvent(\""
                        + signalName + "\", " + (variable == null ? "null" : variable) + ")"));
            }
            xmlNode = xmlNode.getNextSibling();
        }
View Full Code Here

Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

                if (message == null) {
                    throw new IllegalArgumentException("Could not find message " + messageRef);
                }
                String variable = (String) actionNode.getMetaData("MappingVariable");
                actionNode.setMetaData("MessageType", message.getType());
                actionNode.setAction(new DroolsConsequenceAction("java",
                    "org.drools.process.instance.impl.WorkItemImpl workItem = new org.drools.process.instance.impl.WorkItemImpl();" + EOL +
                    "workItem.setName(\"Send Task\");" + EOL +
                    "workItem.setParameter(\"MessageType\", \"" + message.getType() + "\");" + EOL +
                    (variable == null ? "" : "workItem.setParameter(\"Message\", " + variable + ");" + EOL) +
                    "((org.drools.process.instance.WorkItemManager) kcontext.getKnowledgeRuntime().getWorkItemManager()).internalExecuteWorkItem(workItem);"));
View Full Code Here

Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

                Escalation escalation = escalations.get(escalationRef);
                if (escalation == null) {
                    throw new IllegalArgumentException("Could not find escalation " + escalationRef);
                }
                String faultName = escalation.getEscalationCode();
                    actionNode.setAction(new DroolsConsequenceAction("java",
                        "org.jbpm.process.instance.context.exception.ExceptionScopeInstance scopeInstance = (org.jbpm.process.instance.context.exception.ExceptionScopeInstance) ((org.jbpm.workflow.instance.NodeInstance) kcontext.getNodeInstance()).resolveContextInstance(org.jbpm.process.core.context.exception.ExceptionScope.EXCEPTION_SCOPE, \"" + faultName + "\");" + EOL +
                        "if (scopeInstance != null) {" + EOL +
                        "  scopeInstance.handleException(\"" + faultName + "\", null);" + EOL +
                        "} else {" + EOL +
                        "    ((org.jbpm.process.instance.ProcessInstance) kcontext.getProcessInstance()).setState(org.jbpm.process.instance.ProcessInstance.STATE_ABORTED);" + EOL +
View Full Code Here

Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

            String nodeName = xmlNode.getNodeName();
            if ("compensateEventDefinition".equals(nodeName)) {
                String activityRef = ((Element) xmlNode).getAttribute("activityRef");
                if (activityRef != null && activityRef.trim().length() > 0) {
                  actionNode.setMetaData("Compensate", activityRef);
                  actionNode.setAction(new DroolsConsequenceAction("java",
                  "kcontext.getProcessInstance().signalEvent(\"Compensate-" + activityRef + "\", null);"));
                }
//                boolean waitForCompletion = true;
//                String waitForCompletionString = ((Element) xmlNode).getAttribute("waitForCompletion");
//                if ("false".equals(waitForCompletionString)) {
View Full Code Here

Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

public class ScriptTaskHandler extends AbstractNodeHandler {
   
    protected Node createNode(Attributes attrs) {
        ActionNode result = new ActionNode();
        result.setAction(new DroolsConsequenceAction());
        return result;
    }
View Full Code Here

Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

    protected void handleNode(final Node node, final Element element, final String uri,
            final String localName, final ExtensibleXmlParser parser) throws SAXException {
      super.handleNode(node, element, uri, localName, parser);
        ActionNode actionNode = (ActionNode) node;
        DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
        if (action == null) {
          action = new DroolsConsequenceAction();
          actionNode.setAction(action);
        }
    String language = element.getAttribute("scriptFormat");
    if (XmlBPMNProcessDumper.JAVA_LANGUAGE.equals(language)) {
      action.setDialect(JavaDialect.ID);
    }
    action.setConsequence("");
        org.w3c.dom.Node xmlNode = element.getFirstChild();
        while (xmlNode != null) {
          if (xmlNode instanceof Element && "script".equals(xmlNode.getNodeName())) {
            action.setConsequence(xmlNode.getTextContent());
          }
          xmlNode = xmlNode.getNextSibling();
        }
  }
View Full Code Here

Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

                            compositeNode.addContext(exceptionScope);
                            compositeNode.setDefaultContext(exceptionScope);
                        }
                        String escalationCode = (String) node.getMetaData().get("EscalationEvent");
                        ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
                        exceptionHandler.setAction(new DroolsConsequenceAction("java",
                            (cancelActivity ? "((org.jbpm.workflow.instance.NodeInstance) kcontext.getNodeInstance()).cancel();" : "") +
                            "kcontext.getProcessInstance().signalEvent(\"Escalation-" + attachedTo + "-" + escalationCode + "\", null);"));
                        exceptionScope.setExceptionHandler(escalationCode, exceptionHandler);
                    } else if (type.startsWith("Error-")) {
                        CompositeContextNode compositeNode = (CompositeContextNode) attachedNode;
                        ExceptionScope exceptionScope = (ExceptionScope)
                            compositeNode.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
                        if (exceptionScope == null) {
                            exceptionScope = new ExceptionScope();
                            compositeNode.addContext(exceptionScope);
                            compositeNode.setDefaultContext(exceptionScope);
                        }
                        String errorCode = (String) node.getMetaData().get("ErrorEvent");
                        ActionExceptionHandler exceptionHandler = new ActionExceptionHandler();
                        exceptionHandler.setAction(new DroolsConsequenceAction("java",
                            "((org.jbpm.workflow.instance.NodeInstance) kcontext.getNodeInstance()).cancel();" +
                            "kcontext.getProcessInstance().signalEvent(\"Error-" + attachedTo + "-" + errorCode + "\", null);"));
                        exceptionScope.setExceptionHandler(errorCode, exceptionHandler);
                    } else if (type.startsWith("Timer-")) {
                        boolean cancelActivity = (Boolean) node.getMetaData().get("CancelActivity");
                        CompositeContextNode compositeNode = (CompositeContextNode) attachedNode;
                        String timeDuration = (String) node.getMetaData().get("TimeDuration");
                        String timeCycle = (String) node.getMetaData().get("TimeCycle");
                        Timer timer = new Timer();
                        if (timeDuration != null) {
                          timer.setDelay(timeDuration);
                            compositeNode.addTimer(timer, new DroolsConsequenceAction("java",
                                (cancelActivity ? "((org.jbpm.workflow.instance.NodeInstance) kcontext.getNodeInstance()).cancel();" : "") +
                                "kcontext.getProcessInstance().signalEvent(\"Timer-" + attachedTo + "-" + timeDuration + "\", null);"));
                        } else if (timeCycle != null) {
                          int index = timeCycle.indexOf("###");
                          if (index != -1) {
                            String period = timeCycle.substring(index + 3);
                            timeCycle = timeCycle.substring(0, index);
                                timer.setPeriod(period);
                          }
                          timer.setDelay(timeCycle);
                            compositeNode.addTimer(timer, new DroolsConsequenceAction("java",
                                (cancelActivity ? "((org.jbpm.workflow.instance.NodeInstance) kcontext.getNodeInstance()).cancel();" : "") +
                                "kcontext.getProcessInstance().signalEvent(\"Timer-" + attachedTo + "-" + timeCycle + (timer.getPeriod() == null ? "" : "###" + timer.getPeriod()) + "\", null);"));
                        }
                    } else if (type.startsWith("Compensate-")) {
                      String uniqueId = (String) node.getMetaData().get("UniqueId");
View Full Code Here

Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

      if (exceptionScopes != null) {
        for (Context context: exceptionScopes) {
          ExceptionScope exceptionScope = (ExceptionScope) context;
          for (ExceptionHandler exceptionHandler: exceptionScope.getExceptionHandlers().values()) {
            if (exceptionHandler instanceof ActionExceptionHandler) {
              DroolsConsequenceAction action = (DroolsConsequenceAction)
                ((ActionExceptionHandler) exceptionHandler).getAction();
              ActionDescr actionDescr = new ActionDescr();
                  actionDescr.setText( action.getConsequence() );  
                  ProcessDialect dialect = ProcessDialectRegistry.getDialect( action.getDialect() );           
                  dialect.getActionBuilder().build( buildContext, action, actionDescr, (ProcessImpl) buildContext.getProcess() );
            }
          }
        }
      }
View Full Code Here

Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

                          "  <escalation id=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(escalationCode) + "\" escalationCode=\"" + XmlBPMNProcessDumper.replaceIllegalCharsAttribute(escalationCode) + "\" />" + EOL);
                }
                }
            } else if (node instanceof ActionNode) {
              ActionNode actionNode = (ActionNode) node;
              DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
            if (action != null) {
                String s = action.getConsequence();
                if (s.startsWith("org.drools.process.instance.context.exception.ExceptionScopeInstance scopeInstance = (org.drools.process.instance.context.exception.ExceptionScopeInstance) ((org.drools.workflow.instance.NodeInstance) kcontext.getNodeInstance()).resolveContextInstance(org.drools.process.core.context.exception.ExceptionScope.EXCEPTION_SCOPE, \"")) {
                  s = s.substring(327);
                      String type = s.substring(0, s.indexOf("\""));
                  if (!escalations.contains(type)) {
                    escalations.add(type);
View Full Code Here

Examples of org.jbpm.workflow.core.impl.DroolsConsequenceAction

                readEndDataInputAssociation(xmlNode, endNode);
            } else if ("signalEventDefinition".equals(nodeName)) {
                String signalName = ((Element) xmlNode).getAttribute("signalRef");
                String variable = (String) endNode.getMetaData("MappingVariable");
                List<DroolsAction> actions = new ArrayList<DroolsAction>();
                actions.add(new DroolsConsequenceAction("mvel",
                    "kcontext.getKnowledgeRuntime().signalEvent(\""
                        + signalName + "\", " + (variable == null ? "null" : variable) + ")"));
                endNode.setActions(EndNode.EVENT_NODE_ENTER, actions);
            }
            xmlNode = xmlNode.getNextSibling();
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.