Search in sources :

Example 1 with Operation

use of io.automatiko.engine.workflow.bpmn2.core.Interface.Operation in project jbpm by kiegroup.

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) {
                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 : ForEachNode(org.jbpm.workflow.core.node.ForEachNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) Node(org.kie.api.definition.process.Node) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) NodeContainer(org.jbpm.workflow.core.NodeContainer) Operation(org.jbpm.bpmn2.core.Interface.Operation) Interface(org.jbpm.bpmn2.core.Interface)

Example 2 with Operation

use of io.automatiko.engine.workflow.bpmn2.core.Interface.Operation in project jbpm by kiegroup.

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(org.jbpm.bpmn2.core.Interface.Operation) Interface(org.jbpm.bpmn2.core.Interface)

Example 3 with Operation

use of io.automatiko.engine.workflow.bpmn2.core.Interface.Operation in project kogito-runtimes by kiegroup.

the class ServiceTaskHandler method handleNode.

@SuppressWarnings("unchecked")
protected Node handleNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    Node currentNode = super.handleNode(node, element, uri, localName, parser);
    WorkItemNode workItemNode = (WorkItemNode) node;
    String operationRef = element.getAttribute("operationRef");
    String implementation = element.getAttribute("implementation");
    List<Interface> interfaces = (List<Interface>) ((ProcessBuildData) parser.getData()).getMetaData("Interfaces");
    workItemNode.setMetaData("OperationRef", operationRef);
    workItemNode.setMetaData("Implementation", implementation);
    workItemNode.setMetaData("Type", "Service Task");
    if (interfaces != null) {
        Operation operation = null;
        for (Interface i : interfaces) {
            operation = i.getOperation(operationRef);
            if (operation != null) {
                break;
            }
        }
        if (operation == null) {
            throw new ProcessParsingValidationException("Could not find operation " + operationRef);
        }
        // avoid overriding parameters set by data input associations
        if (workItemNode.getWork().getParameter("Interface") == null) {
            String interfaceRef = operation.getInterface().getImplementationRef();
            workItemNode.getWork().setParameter("Interface", interfaceRef != null && !interfaceRef.isEmpty() ? interfaceRef : 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);
        }
    }
    return currentNode;
}
Also used : Node(org.jbpm.workflow.core.Node) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) List(java.util.List) Operation(org.jbpm.bpmn2.core.Interface.Operation) Interface(org.jbpm.bpmn2.core.Interface)

Example 4 with Operation

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

the class InMessageRefHandler method end.

@SuppressWarnings("unchecked")
public Object end(final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    Element element = parser.endElementBuilder();
    String messageId = element.getTextContent();
    Map<String, Message> messages = (Map<String, Message>) ((ProcessBuildData) parser.getData()).getMetaData("Messages");
    if (messages == null) {
        throw new IllegalArgumentException("No messages found");
    }
    Operation operation = (Operation) parser.getParent();
    Message message = messages.get(messageId);
    if (message != null) {
        operation.setMessage(message);
    }
    return parser.getCurrent();
}
Also used : Message(io.automatiko.engine.workflow.bpmn2.core.Message) Element(org.w3c.dom.Element) Operation(io.automatiko.engine.workflow.bpmn2.core.Interface.Operation) Map(java.util.Map)

Example 5 with Operation

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

the class ServiceTaskHandler method handleNode.

@SuppressWarnings("unchecked")
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);
    WorkItemNode workItemNode = (WorkItemNode) node;
    String operationRef = element.getAttribute("operationRef");
    String implementation = element.getAttribute("implementation");
    List<Interface> interfaces = (List<Interface>) ((ProcessBuildData) parser.getData()).getMetaData("Interfaces");
    workItemNode.setMetaData("OperationRef", operationRef);
    workItemNode.setMetaData("Implementation", implementation);
    workItemNode.setMetaData("Type", "Service Task");
    if (interfaces != null) {
        // throw new IllegalArgumentException("No interfaces found");
        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) {
            String interfaceRef = operation.getInterface().getImplementationRef();
            workItemNode.getWork().setParameter("Interface", interfaceRef != null && !interfaceRef.isEmpty() ? interfaceRef : 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 : WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) List(java.util.List) Operation(io.automatiko.engine.workflow.bpmn2.core.Interface.Operation) Interface(io.automatiko.engine.workflow.bpmn2.core.Interface)

Aggregations

Operation (org.jbpm.bpmn2.core.Interface.Operation)8 Interface (org.jbpm.bpmn2.core.Interface)6 Operation (io.automatiko.engine.workflow.bpmn2.core.Interface.Operation)4 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)4 Interface (io.automatiko.engine.workflow.bpmn2.core.Interface)3 List (java.util.List)3 Map (java.util.Map)3 Element (org.w3c.dom.Element)3 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)2 Message (org.jbpm.bpmn2.core.Message)2 NodeContainer (org.jbpm.workflow.core.NodeContainer)2 ForEachNode (org.jbpm.workflow.core.node.ForEachNode)2 Node (org.kie.api.definition.process.Node)2 Node (io.automatiko.engine.api.definition.process.Node)1 Message (io.automatiko.engine.workflow.bpmn2.core.Message)1 NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)1 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)1 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)1 Node (org.jbpm.workflow.core.Node)1