Search in sources :

Example 31 with ProcessBuildData

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

the class TaskHandler 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);
            // running in variable strict mode
            if (orignalNode instanceof WorkItemNode) {
                adjustNodeConfiguration(orignalNode, forEachNode);
            }
            break;
        }
        xmlNode = xmlNode.getNextSibling();
    }
    // replace node in case it's milestone
    if (node instanceof WorkItemNode && ((WorkItemNode) node).getWork().getName().equals("Milestone")) {
        WorkItemNode workItemNode = (WorkItemNode) node;
        String milestoneCondition = (String) ((WorkItemNode) node).getWork().getParameter(CONDITION);
        MilestoneNode milestoneNode = new MilestoneNode();
        milestoneNode.setId(workItemNode.getId());
        milestoneNode.setMetaData(workItemNode.getMetaData());
        milestoneNode.setConditionExpression(milestoneCondition);
        milestoneNode.setName(workItemNode.getName());
        milestoneNode.setParentContainer(workItemNode.getParentContainer());
        node = milestoneNode;
    }
    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) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) ForEachNode(io.automatiko.engine.workflow.process.core.node.ForEachNode) NodeContainer(io.automatiko.engine.workflow.process.core.NodeContainer) MilestoneNode(io.automatiko.engine.workflow.process.core.node.MilestoneNode)

Example 32 with ProcessBuildData

use of io.automatiko.engine.workflow.compiler.xml.ProcessBuildData 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

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