Search in sources :

Example 31 with ItemDefinition

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

the class TaskHandler 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);
    itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
    dataTypeInputs.clear();
    dataTypeOutputs.clear();
    WorkItemNode workItemNode = (WorkItemNode) node;
    String name = getTaskName(element);
    Work work = new WorkImpl();
    work.setName(name);
    workItemNode.setWork(work);
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("ioSpecification".equals(nodeName)) {
            readIoSpecification(xmlNode, dataInputs, dataOutputs, dataInputTypes);
        } else if ("dataInputAssociation".equals(nodeName)) {
            readDataInputAssociation(xmlNode, workItemNode, dataInputs);
        } else if ("dataOutputAssociation".equals(nodeName)) {
            readDataOutputAssociation(xmlNode, workItemNode, dataOutputs);
        }
        xmlNode = xmlNode.getNextSibling();
    }
    workItemNode.setMetaData("DataInputs", new LinkedHashMap<String, String>(dataTypeInputs));
    workItemNode.setMetaData("DataOutputs", new LinkedHashMap<String, String>(dataTypeOutputs));
    handleScript(workItemNode, element, "onEntry");
    handleScript(workItemNode, element, "onExit");
    String compensation = element.getAttribute("isForCompensation");
    if (compensation != null) {
        boolean isForCompensation = Boolean.parseBoolean(compensation);
        if (isForCompensation) {
            workItemNode.setMetaData("isForCompensation", isForCompensation);
        }
    }
    for (Entry<String, String> entryInputTypes : dataTypeInputs.entrySet()) {
        ParameterDefinition parameterDefinition = new ParameterDefinitionImpl();
        parameterDefinition.setName(entryInputTypes.getKey());
        parameterDefinition.setType(new ObjectDataType(constructClass(entryInputTypes.getValue()), entryInputTypes.getValue()));
        work.addParameterDefinition(parameterDefinition);
    }
}
Also used : ItemDefinition(io.automatiko.engine.workflow.bpmn2.core.ItemDefinition) ObjectDataType(io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType) ParameterDefinitionImpl(io.automatiko.engine.workflow.base.core.impl.ParameterDefinitionImpl) ProcessBuildData(io.automatiko.engine.workflow.compiler.xml.ProcessBuildData) WorkItemNode(io.automatiko.engine.workflow.process.core.node.WorkItemNode) Work(io.automatiko.engine.workflow.base.core.Work) WorkImpl(io.automatiko.engine.workflow.base.core.impl.WorkImpl) ParameterDefinition(io.automatiko.engine.workflow.base.core.ParameterDefinition)

Aggregations

Map (java.util.Map)19 ItemDefinition (org.jbpm.bpmn2.core.ItemDefinition)19 List (java.util.List)13 ItemDefinition (io.automatiko.engine.workflow.bpmn2.core.ItemDefinition)12 Element (org.w3c.dom.Element)10 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)7 ObjectDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.ObjectDataType)6 ProcessBuildData (io.automatiko.engine.workflow.compiler.xml.ProcessBuildData)6 DataType (org.jbpm.process.core.datatype.DataType)6 DataType (io.automatiko.engine.api.workflow.datatype.DataType)5 HashSet (java.util.HashSet)5 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)5 BooleanDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.BooleanDataType)4 FloatDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.FloatDataType)4 IntegerDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.IntegerDataType)4 StringDataType (io.automatiko.engine.workflow.base.core.datatype.impl.type.StringDataType)4 Definitions (org.jbpm.bpmn2.core.Definitions)4 Variable (org.jbpm.process.core.context.variable.Variable)4 BooleanDataType (org.jbpm.process.core.datatype.impl.type.BooleanDataType)4