Search in sources :

Example 6 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class IntermediateThrowEventHandler method handleEscalationNode.

@SuppressWarnings("unchecked")
public void handleEscalationNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    ActionNode actionNode = (ActionNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("dataInputAssociation".equals(nodeName)) {
            readDataInputAssociation(xmlNode, actionNode, parser);
        } else if ("escalationEventDefinition".equals(nodeName)) {
            String escalationRef = ((Element) xmlNode).getAttribute("escalationRef");
            if (escalationRef != null && escalationRef.trim().length() > 0) {
                Map<String, Escalation> escalations = (Map<String, Escalation>) ((ProcessBuildData) parser.getData()).getMetaData(ProcessHandler.ESCALATIONS);
                if (escalations == null) {
                    throw new IllegalArgumentException("No escalations found");
                }
                Escalation escalation = escalations.get(escalationRef);
                if (escalation == null) {
                    throw new IllegalArgumentException("Could not find escalation " + escalationRef);
                }
                String faultName = escalation.getEscalationCode();
                String variable = (String) actionNode.getMetaData(MAPPING_VARIABLE_KEY);
                ConsequenceAction action = createJavaAction(new HandleEscalationAction(faultName, variable));
                actionNode.setAction(action);
                actionNode.setMetaData("TriggerType", "Escalation");
            } else {
                throw new IllegalArgumentException("General escalation is not yet supported");
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Escalation(io.automatiko.engine.workflow.bpmn2.core.Escalation) ConsequenceAction(io.automatiko.engine.workflow.process.core.impl.ConsequenceAction) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) Map(java.util.Map) NamedNodeMap(org.w3c.dom.NamedNodeMap) HandleEscalationAction(io.automatiko.engine.workflow.base.instance.impl.actions.HandleEscalationAction)

Example 7 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class Bpmn2ImportHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    final String type = attrs.getValue("importType");
    final String location = attrs.getValue("location");
    final String namespace = attrs.getValue("namespace");
    ProcessBuildData buildData = (ProcessBuildData) parser.getData();
    if (type != null && location != null && namespace != null) {
        List<Bpmn2Import> typedImports = (List<Bpmn2Import>) buildData.getMetaData("Bpmn2Imports");
        if (typedImports == null) {
            typedImports = new ArrayList<Bpmn2Import>();
            buildData.setMetaData("Bpmn2Imports", typedImports);
        }
        typedImports.add(new Bpmn2Import(type, location, namespace));
    }
    return null;
}
Also used : Bpmn2Import(io.automatiko.engine.workflow.bpmn2.core.Bpmn2Import) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) ArrayList(java.util.ArrayList) List(java.util.List)

Example 8 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class BusinessRuleTaskHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    // determine type of event definition, so the correct type of node can be generated
    handleNode(node, element, uri, localName, parser);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    int uniqueIdGen = 1;
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("multiInstanceLoopCharacteristics".equals(nodeName)) {
            // create new timerNode
            ForEachNode forEachNode = new ForEachNode();
            forEachNode.setId(node.getId());
            String uniqueId = (String) node.getMetaData().get("UniqueId");
            forEachNode.setMetaData("UniqueId", uniqueId);
            node.setMetaData("UniqueId", uniqueId + ":" + uniqueIdGen++);
            forEachNode.addNode(node);
            forEachNode.linkIncomingConnections(NodeImpl.CONNECTION_DEFAULT_TYPE, node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.linkOutgoingConnections(node.getId(), NodeImpl.CONNECTION_DEFAULT_TYPE, NodeImpl.CONNECTION_DEFAULT_TYPE);
            forEachNode.setSequential(Boolean.parseBoolean(((Element) xmlNode).getAttribute("isSequential")));
            Node orignalNode = node;
            node = forEachNode;
            handleForEachNode(node, element, uri, localName, parser);
            // remove input/output collection data input/output of for each to avoid problems when running in variable strict mode
            if (orignalNode instanceof RuleSetNode) {
                adjustNodeConfiguration(orignalNode, forEachNode);
            }
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) Element(org.w3c.dom.Element) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) RuleSetNode(io.automatiko.engine.workflow.process.core.node.RuleSetNode) Node(io.automatiko.engine.workflow.process.core.Node) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer)

Example 9 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class AbstractNodeHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Node node = (Node) parser.getCurrent();
    handleNode(node, element, uri, localName, parser);
    NodeContainer nodeContainer = (NodeContainer) parser.getParent();
    nodeContainer.addNode(node);
    ((ProcessBuildData) parser.getData()).addNode(node);
    return node;
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Element(org.w3c.dom.Element) Node(io.automatiko.engine.workflow.process.core.Node) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) EndNode(io.automatiko.engine.workflow.process.core.node.EndNode) EventNode(io.automatiko.engine.workflow.process.core.node.EventNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer)

Example 10 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData in project automatiko-engine by automatiko-io.

the class ProcessHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    final String id = attrs.getValue("id");
    final String name = attrs.getValue("name");
    final String version = attrs.getValue("version");
    final String type = attrs.getValue("type");
    final String packageName = attrs.getValue("package-name");
    final String routerLayout = attrs.getValue("routerLayout");
    ExecutableProcess process = new ExecutableProcess();
    process.setId(id);
    process.setName(name);
    process.setVersion(version);
    process.setType(type);
    process.setPackageName(packageName);
    if (routerLayout != null) {
        process.setMetaData("routerLayout", new Integer(routerLayout));
    }
    ((ProcessBuildData) parser.getData()).addProcess(process);
    return process;
}
Also used : ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)

Aggregations

ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)32 Map (java.util.Map)14 Element (org.w3c.dom.Element)13 Node (io.automatiko.engine.workflow.process.core.Node)11 NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)10 HashMap (java.util.HashMap)9 List (java.util.List)8 ItemDefinition (io.automatiko.engine.workflow.bpmn2.core.ItemDefinition)6 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)6 ArrayList (java.util.ArrayList)6 Escalation (io.automatiko.engine.workflow.bpmn2.core.Escalation)4 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)4 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)4 Error (io.automatiko.engine.workflow.bpmn2.core.Error)3 Message (io.automatiko.engine.workflow.bpmn2.core.Message)3 Signal (io.automatiko.engine.workflow.bpmn2.core.Signal)3 ConsequenceAction (io.automatiko.engine.workflow.process.core.impl.ConsequenceAction)3 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)3 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)3 Process (io.automatiko.engine.api.definition.process.Process)2