Search in sources :

Example 41 with DroolsAction

use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.

the class XmlWorkflowProcessDumper method visitExceptionHandlers.

public static void visitExceptionHandlers(Map<String, ExceptionHandler> exceptionHandlers, StringBuilder xmlDump) {
    if (exceptionHandlers != null && exceptionHandlers.size() > 0) {
        xmlDump.append("    <exceptionHandlers>" + EOL);
        for (Map.Entry<String, ExceptionHandler> entry : exceptionHandlers.entrySet()) {
            ExceptionHandler exceptionHandler = entry.getValue();
            if (exceptionHandler instanceof ActionExceptionHandler) {
                ActionExceptionHandler actionExceptionHandler = (ActionExceptionHandler) exceptionHandler;
                xmlDump.append("      <exceptionHandler faultName=\"" + entry.getKey() + "\" type=\"action\" ");
                String faultVariable = actionExceptionHandler.getFaultVariable();
                if (faultVariable != null && faultVariable.length() > 0) {
                    xmlDump.append("faultVariable=\"" + faultVariable + "\" ");
                }
                xmlDump.append(">" + EOL);
                DroolsAction action = actionExceptionHandler.getAction();
                if (action != null) {
                    AbstractNodeHandler.writeAction(action, xmlDump);
                }
                xmlDump.append("      </exceptionHandler>" + EOL);
            } else {
                throw new IllegalArgumentException("Unknown exception handler type: " + exceptionHandler);
            }
        }
        xmlDump.append("    </exceptionHandlers>" + EOL);
    }
}
Also used : ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler) ExceptionHandler(org.jbpm.process.core.context.exception.ExceptionHandler) DroolsAction(org.jbpm.workflow.core.DroolsAction) Map(java.util.Map) ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler)

Example 42 with DroolsAction

use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.

the class AbstractNodeHandler method handleAction.

protected void handleAction(final ExtendedNodeImpl node, final Element element, String type) {
    NodeList nodeList = element.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        org.w3c.dom.Node xmlNode = nodeList.item(i);
        String nodeName = xmlNode.getNodeName();
        if (nodeName.equals(type)) {
            List<DroolsAction> actions = new ArrayList<DroolsAction>();
            NodeList subNodeList = xmlNode.getChildNodes();
            for (int j = 0; j < subNodeList.getLength(); j++) {
                Element subXmlNode = (Element) subNodeList.item(j);
                DroolsAction action = extractAction(subXmlNode);
                actions.add(action);
            }
            node.setActions(type, actions);
            return;
        }
    }
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList)

Example 43 with DroolsAction

use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.

the class AbstractNodeHandler method writeActions.

protected void writeActions(final String type, List<DroolsAction> actions, final StringBuilder xmlDump) {
    if (actions != null && actions.size() > 0) {
        xmlDump.append("      <" + type + ">" + EOL);
        for (DroolsAction action : actions) {
            writeAction(action, xmlDump);
        }
        xmlDump.append("      </" + type + ">" + EOL);
    }
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction)

Example 44 with DroolsAction

use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.

the class ExceptionHandlerHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    ContextContainer contextContainer = (ContextContainer) parser.getParent();
    final String type = element.getAttribute("type");
    emptyAttributeCheck(localName, "type", type, parser);
    final String faultName = element.getAttribute("faultName");
    emptyAttributeCheck(localName, "faultName", type, parser);
    final String faultVariable = element.getAttribute("faultVariable");
    ActionExceptionHandler exceptionHandler = null;
    if ("action".equals(type)) {
        exceptionHandler = new ActionExceptionHandler();
        org.w3c.dom.Node xmlNode = element.getFirstChild();
        if (xmlNode instanceof Element) {
            Element actionXml = (Element) xmlNode;
            DroolsAction action = ActionNodeHandler.extractAction(actionXml);
            ((ActionExceptionHandler) exceptionHandler).setAction(action);
        }
    } else {
        throw new SAXParseException("Unknown exception handler type " + type, parser.getLocator());
    }
    if (faultVariable != null && faultVariable.length() > 0) {
        exceptionHandler.setFaultVariable(faultVariable);
    }
    ExceptionScope exceptionScope = (ExceptionScope) contextContainer.getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
    if (exceptionScope == null) {
        exceptionScope = new ExceptionScope();
        contextContainer.addContext(exceptionScope);
        contextContainer.setDefaultContext(exceptionScope);
    }
    exceptionScope.setExceptionHandler(faultName, exceptionHandler);
    return null;
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) ContextContainer(org.jbpm.process.core.ContextContainer) SAXParseException(org.xml.sax.SAXParseException) Element(org.w3c.dom.Element) ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope)

Example 45 with DroolsAction

use of org.jbpm.workflow.core.DroolsAction in project jbpm by kiegroup.

the class SubProcessNodeFactory method onExitAction.

public SubProcessNodeFactory onExitAction(String dialect, String action) {
    if (getSubProcessNode().getActions(dialect) != null) {
        getSubProcessNode().getActions(dialect).add(new DroolsConsequenceAction(dialect, action));
    } else {
        List<DroolsAction> actions = new ArrayList<DroolsAction>();
        actions.add(new DroolsConsequenceAction(dialect, action));
        getSubProcessNode().setActions(MilestoneNode.EVENT_NODE_EXIT, actions);
    }
    return this;
}
Also used : DroolsAction(org.jbpm.workflow.core.DroolsAction) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ArrayList(java.util.ArrayList)

Aggregations

DroolsAction (org.jbpm.workflow.core.DroolsAction)53 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)40 ArrayList (java.util.ArrayList)30 ActionNode (org.jbpm.workflow.core.node.ActionNode)25 Action (org.jbpm.process.instance.impl.Action)22 EndNode (org.jbpm.workflow.core.node.EndNode)22 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)19 Test (org.junit.Test)18 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)17 StartNode (org.jbpm.workflow.core.node.StartNode)17 KieSession (org.kie.api.runtime.KieSession)17 ProcessContext (org.kie.api.runtime.process.ProcessContext)17 EventTypeFilter (org.jbpm.process.core.event.EventTypeFilter)15 EventNode (org.jbpm.workflow.core.node.EventNode)14 ConnectionImpl (org.jbpm.workflow.core.impl.ConnectionImpl)13 Variable (org.jbpm.process.core.context.variable.Variable)10 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)10 TestProcessEventListener (org.jbpm.process.test.TestProcessEventListener)9 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)8 KnowledgePackageImpl (org.drools.core.definitions.impl.KnowledgePackageImpl)8