Search in sources :

Example 36 with Node

use of io.automatiko.engine.workflow.process.core.Node in project automatiko-engine by automatiko-io.

the class UserTaskHandler method handleNode.

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);
    HumanTaskNode humanTaskNode = (HumanTaskNode) node;
    Work work = humanTaskNode.getWork();
    work.setName("Human Task");
    ProcessBuildData buildData = (ProcessBuildData) parser.getData();
    Map<String, Resource> resources = (Map<String, Resource>) buildData.getMetaData("Resources");
    Map<String, String> dataInputs = new HashMap<String, String>();
    Map<String, String> dataOutputs = new HashMap<String, String>();
    List<String> owners = new ArrayList<String>();
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        // ioSpec and data{Input,Output}Spec handled in super.handleNode(...)
        if ("potentialOwner".equals(nodeName)) {
            String owner = readPotentialOwner(xmlNode, humanTaskNode);
            if (owner != null) {
                owners.add(owner);
            }
        } else if ("performer".equals(nodeName)) {
            org.w3c.dom.Node resourceNode = xmlNode.getFirstChild();
            if (resourceNode != null) {
                String resourceId = resourceNode.getTextContent();
                if (resources.containsKey(resourceId)) {
                    owners.add(resources.get(resourceId).getName());
                }
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
    if (owners.size() > 0) {
        String owner = owners.get(0);
        for (int i = 1; i < owners.size(); i++) {
            owner += "," + owners.get(i);
        }
        humanTaskNode.getWork().setParameter("ActorId", owner);
    }
    humanTaskNode.getWork().setParameter("NodeName", humanTaskNode.getName());
}
Also used : HashMap(java.util.HashMap) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) Node(io.automatiko.engine.workflow.process.core.Node) Resource(io.automatiko.engine.workflow.bpmn2.core.Resource) ArrayList(java.util.ArrayList) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) Work(io.automatiko.engine.workflow.base.core.Work) HashMap(java.util.HashMap) Map(java.util.Map) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode)

Aggregations

Node (io.automatiko.engine.workflow.process.core.Node)36 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)19 EndNode (io.automatiko.engine.workflow.process.core.node.EndNode)19 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)16 StartNode (io.automatiko.engine.workflow.process.core.node.StartNode)16 WorkItemNode (io.automatiko.engine.workflow.process.core.node.WorkItemNode)16 BoundaryEventNode (io.automatiko.engine.workflow.process.core.node.BoundaryEventNode)15 ArrayList (java.util.ArrayList)14 NodeContainer (io.automatiko.engine.workflow.process.core.NodeContainer)13 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)13 ExecutableProcess (io.automatiko.engine.workflow.process.executable.core.ExecutableProcess)13 CompositeNode (io.automatiko.engine.workflow.process.core.node.CompositeNode)12 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)11 Element (org.w3c.dom.Element)11 EventNode (io.automatiko.engine.workflow.process.core.node.EventNode)10 ForEachNode (io.automatiko.engine.workflow.process.core.node.ForEachNode)10 AbstractBaseTest (io.automatiko.engine.workflow.test.util.AbstractBaseTest)8 Test (org.junit.jupiter.api.Test)8 SubProcessNode (io.automatiko.engine.workflow.process.core.node.SubProcessNode)6 TimerNode (io.automatiko.engine.workflow.process.core.node.TimerNode)6