Search in sources :

Example 11 with Interface

use of io.automatiko.engine.workflow.bpmn2.core.Interface in project automatiko-engine by automatiko-io.

the class DefinitionsHandler method end.

public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Definitions definitions = (Definitions) parser.getCurrent();
    String namespace = element.getAttribute("targetNamespace");
    List<Process> processes = ((ProcessBuildData) parser.getData()).getProcesses();
    Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
    List<Interface> interfaces = (List<Interface>) ((ProcessBuildData) parser.getData()).getMetaData("Interfaces");
    for (Process process : processes) {
        ExecutableProcess ruleFlowProcess = (ExecutableProcess) process;
        ruleFlowProcess.setMetaData("TargetNamespace", namespace);
        postProcessItemDefinitions(ruleFlowProcess, itemDefinitions, parser.getClassLoader());
        postProcessInterfaces(ruleFlowProcess, interfaces);
        postProcessNodes(ruleFlowProcess, Collections.emptyList(), parser);
    }
    definitions.setTargetNamespace(namespace);
    return definitions;
}
Also used : Element(org.w3c.dom.Element) Definitions(io.automatiko.engine.workflow.bpmn2.core.Definitions) ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) WorkflowProcess(io.automatiko.engine.workflow.process.core.WorkflowProcess) Process(io.automatiko.engine.api.definition.process.Process) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) LinkedList(java.util.LinkedList) List(java.util.List) ExecutableProcess(io.automatiko.engine.workflow.process.executable.core.ExecutableProcess) Map(java.util.Map) Interface(io.automatiko.engine.workflow.bpmn2.core.Interface)

Example 12 with Interface

use of io.automatiko.engine.workflow.bpmn2.core.Interface in project automatiko-engine by automatiko-io.

the class DefinitionsHandler method postProcessInterfaces.

private void postProcessInterfaces(NodeContainer nodeContainer, List<Interface> interfaces) {
    for (Node node : nodeContainer.getNodes()) {
        if (node instanceof NodeContainer) {
            postProcessInterfaces((NodeContainer) node, interfaces);
        }
        if (node instanceof WorkItemNode && "Service Task".equals(((WorkItemNode) node).getMetaData("Type"))) {
            WorkItemNode workItemNode = (WorkItemNode) node;
            if (interfaces == null) {
                throw new IllegalArgumentException("No interfaces found");
            }
            String operationRef = (String) workItemNode.getMetaData("OperationRef");
            String implementation = (String) workItemNode.getMetaData("Implementation");
            Operation operation = null;
            for (Interface i : interfaces) {
                operation = i.getOperation(operationRef);
                if (operation != null) {
                    break;
                }
            }
            if (operation == null) {
                throw new IllegalArgumentException("Could not find operation " + operationRef);
            }
            // avoid overriding parameters set by data input associations
            if (workItemNode.getWork().getParameter("Interface") == null) {
                workItemNode.getWork().setParameter("Interface", operation.getInterface().getName());
            }
            if (workItemNode.getWork().getParameter("Operation") == null) {
                workItemNode.getWork().setParameter("Operation", operation.getName());
            }
            if (workItemNode.getWork().getParameter("ParameterType") == null && operation.getMessage() != null) {
                workItemNode.getWork().setParameter("ParameterType", operation.getMessage().getType());
            }
            // parameters to support web service invocation
            if (implementation != null) {
                workItemNode.getWork().setParameter("interfaceImplementationRef", operation.getInterface().getImplementationRef());
                workItemNode.getWork().setParameter("operationImplementationRef", operation.getImplementationRef());
                workItemNode.getWork().setParameter("implementation", implementation);
            }
        }
    }
}
Also used : Node(io.automatiko.engine.api.definition.process.Node) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) ActionNode(io.automatiko.engine.workflow.process.core.node.ActionNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) Operation(io.automatiko.engine.workflow.bpmn2.core.Interface.Operation) Interface(io.automatiko.engine.workflow.bpmn2.core.Interface)

Example 13 with Interface

use of io.automatiko.engine.workflow.bpmn2.core.Interface in project automatiko-engine by automatiko-io.

the class OperationHandler method start.

public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    String id = attrs.getValue("id");
    String name = attrs.getValue("name");
    String implRef = attrs.getValue("implementationRef");
    Interface i = (Interface) parser.getParent();
    Operation operation = i.addOperation(id, name);
    if (implRef != null) {
        operation.setImplementationRef(implRef);
    }
    return operation;
}
Also used : Operation(io.automatiko.engine.workflow.bpmn2.core.Interface.Operation) Interface(io.automatiko.engine.workflow.bpmn2.core.Interface)

Aggregations

Interface (org.jbpm.bpmn2.core.Interface)8 List (java.util.List)7 Operation (org.jbpm.bpmn2.core.Interface.Operation)6 Interface (io.automatiko.engine.workflow.bpmn2.core.Interface)5 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)4 Operation (io.automatiko.engine.workflow.bpmn2.core.Interface.Operation)3 Map (java.util.Map)3 Element (org.w3c.dom.Element)3 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)2 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)2 Definitions (org.jbpm.bpmn2.core.Definitions)2 ItemDefinition (org.jbpm.bpmn2.core.ItemDefinition)2 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)2 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)2 NodeContainer (org.jbpm.workflow.core.NodeContainer)2 ForEachNode (org.jbpm.workflow.core.node.ForEachNode)2 Node (org.kie.api.definition.process.Node)2 Process (org.kie.api.definition.process.Process)2 Node (io.automatiko.engine.api.definition.process.Node)1 Process (io.automatiko.engine.api.definition.process.Process)1