Search in sources :

Example 1 with ItemDefinition

use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.

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);
        } 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 HashMap<String, String>(dataTypeInputs));
    workItemNode.setMetaData("DataOutputs", new HashMap<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);
        }
    }
}
Also used : ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition) WorkItemNode(org.jbpm.workflow.core.node.WorkItemNode) Work(org.jbpm.process.core.Work) WorkImpl(org.jbpm.process.core.impl.WorkImpl)

Example 2 with ItemDefinition

use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.

the class DataObjectHandler method start.

@SuppressWarnings("unchecked")
public Object start(final String uri, final String localName, final Attributes attrs, final ExtensibleXmlParser parser) throws SAXException {
    parser.startElementBuilder(localName, attrs);
    final String id = attrs.getValue("id");
    final String itemSubjectRef = attrs.getValue("itemSubjectRef");
    Object parent = parser.getParent();
    if (parent instanceof ContextContainer) {
        ContextContainer contextContainer = (ContextContainer) parent;
        VariableScope variableScope = (VariableScope) contextContainer.getDefaultContext(VariableScope.VARIABLE_SCOPE);
        List variables = variableScope.getVariables();
        Variable variable = new Variable();
        variable.setMetaData("DataObject", "true");
        variable.setName(id);
        // retrieve type from item definition
        DataType dataType = new ObjectDataType();
        Map<String, ItemDefinition> itemDefinitions = (Map<String, ItemDefinition>) ((ProcessBuildData) parser.getData()).getMetaData("ItemDefinitions");
        if (itemDefinitions != null) {
            ItemDefinition itemDefinition = itemDefinitions.get(itemSubjectRef);
            if (itemDefinition != null) {
                String structureRef = itemDefinition.getStructureRef();
                if ("java.lang.Boolean".equals(structureRef) || "Boolean".equals(structureRef)) {
                    dataType = new BooleanDataType();
                } else if ("java.lang.Integer".equals(structureRef) || "Integer".equals(structureRef)) {
                    dataType = new IntegerDataType();
                } else if ("java.lang.Float".equals(structureRef) || "Float".equals(structureRef)) {
                    dataType = new FloatDataType();
                } else if ("java.lang.String".equals(structureRef) || "String".equals(structureRef)) {
                    dataType = new StringDataType();
                } else if ("java.lang.Object".equals(structureRef) || "Object".equals(structureRef)) {
                    // use FQCN of Object
                    dataType = new ObjectDataType("java.lang.Object");
                } else {
                    dataType = new ObjectDataType(structureRef, parser.getClassLoader());
                }
            }
        }
        variable.setType(dataType);
        variables.add(variable);
        return variable;
    }
    return new Variable();
}
Also used : FloatDataType(org.jbpm.process.core.datatype.impl.type.FloatDataType) Variable(org.jbpm.process.core.context.variable.Variable) IntegerDataType(org.jbpm.process.core.datatype.impl.type.IntegerDataType) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) StringDataType(org.jbpm.process.core.datatype.impl.type.StringDataType) ContextContainer(org.jbpm.process.core.ContextContainer) DataType(org.jbpm.process.core.datatype.DataType) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) IntegerDataType(org.jbpm.process.core.datatype.impl.type.IntegerDataType) StringDataType(org.jbpm.process.core.datatype.impl.type.StringDataType) BooleanDataType(org.jbpm.process.core.datatype.impl.type.BooleanDataType) FloatDataType(org.jbpm.process.core.datatype.impl.type.FloatDataType) List(java.util.List) BooleanDataType(org.jbpm.process.core.datatype.impl.type.BooleanDataType) Map(java.util.Map) VariableScope(org.jbpm.process.core.context.variable.VariableScope)

Example 3 with ItemDefinition

use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.

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) {
        RuleFlowProcess ruleFlowProcess = (RuleFlowProcess) process;
        ruleFlowProcess.setMetaData("TargetNamespace", namespace);
        postProcessItemDefinitions(ruleFlowProcess, itemDefinitions, parser.getClassLoader());
        postProcessInterfaces(ruleFlowProcess, interfaces);
    }
    definitions.setTargetNamespace(namespace);
    return definitions;
}
Also used : RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) Element(org.w3c.dom.Element) Definitions(org.jbpm.bpmn2.core.Definitions) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition) Process(org.kie.api.definition.process.Process) RuleFlowProcess(org.jbpm.ruleflow.core.RuleFlowProcess) ProcessBuildData(org.jbpm.compiler.xml.ProcessBuildData) List(java.util.List) Map(java.util.Map) Interface(org.jbpm.bpmn2.core.Interface)

Example 4 with ItemDefinition

use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.

the class AbstractNodeHandler method getDataType.

protected DataType getDataType(String itemSubjectRef, Map<String, ItemDefinition> itemDefinitions, ClassLoader cl) {
    DataType dataType = new ObjectDataType();
    if (itemDefinitions == null) {
        return dataType;
    }
    ItemDefinition itemDefinition = itemDefinitions.get(itemSubjectRef);
    if (itemDefinition != null) {
        String structureRef = itemDefinition.getStructureRef();
        if ("java.lang.Boolean".equals(structureRef) || "Boolean".equals(structureRef)) {
            dataType = new BooleanDataType();
        } else if ("java.lang.Integer".equals(structureRef) || "Integer".equals(structureRef)) {
            dataType = new IntegerDataType();
        } else if ("java.lang.Float".equals(structureRef) || "Float".equals(structureRef)) {
            dataType = new FloatDataType();
        } else if ("java.lang.String".equals(structureRef) || "String".equals(structureRef)) {
            dataType = new StringDataType();
        } else if ("java.lang.Object".equals(structureRef) || "Object".equals(structureRef)) {
            dataType = new ObjectDataType(structureRef);
        } else {
            dataType = new ObjectDataType(structureRef, cl);
        }
    }
    return dataType;
}
Also used : StringDataType(org.jbpm.process.core.datatype.impl.type.StringDataType) FloatDataType(org.jbpm.process.core.datatype.impl.type.FloatDataType) IntegerDataType(org.jbpm.process.core.datatype.impl.type.IntegerDataType) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) IntegerDataType(org.jbpm.process.core.datatype.impl.type.IntegerDataType) FloatDataType(org.jbpm.process.core.datatype.impl.type.FloatDataType) DataType(org.jbpm.process.core.datatype.DataType) StringDataType(org.jbpm.process.core.datatype.impl.type.StringDataType) BooleanDataType(org.jbpm.process.core.datatype.impl.type.BooleanDataType) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) BooleanDataType(org.jbpm.process.core.datatype.impl.type.BooleanDataType)

Example 5 with ItemDefinition

use of org.jbpm.bpmn2.core.ItemDefinition in project jbpm by kiegroup.

the class ServicesProcessDataEventListener method onBuildComplete.

@SuppressWarnings("unchecked")
@Override
public void onBuildComplete(Process process) {
    // process java dialect types
    Set<String> referencedTypes = (Set<String>) process.getMetaData().get("JavaDialectReferencedTypes");
    if (referencedTypes != null && !referencedTypes.isEmpty()) {
        processDescriptor.getReferencedClasses().addAll(referencedTypes);
    }
    Set<String> unqualifiedClasses = (Set<String>) process.getMetaData().get("JavaDialectUnqualifiedTypes");
    if (unqualifiedClasses != null && !unqualifiedClasses.isEmpty()) {
        processDescriptor.getUnqualifiedClasses().addAll(unqualifiedClasses);
    }
    // process java return value types
    referencedTypes = (Set<String>) process.getMetaData().get("JavaReturnValueReferencedTypes");
    if (referencedTypes != null && !referencedTypes.isEmpty()) {
        processDescriptor.getReferencedClasses().addAll(referencedTypes);
    }
    unqualifiedClasses = (Set<String>) process.getMetaData().get("JavaReturnValueUnqualifiedTypes");
    if (unqualifiedClasses != null && !unqualifiedClasses.isEmpty()) {
        processDescriptor.getUnqualifiedClasses().addAll(unqualifiedClasses);
    }
    // process mvel dialect types
    referencedTypes = (Set<String>) process.getMetaData().get("MVELDialectReferencedTypes");
    if (referencedTypes != null && !referencedTypes.isEmpty()) {
        processDescriptor.getReferencedClasses().addAll(referencedTypes);
    }
    // process mvel return value types
    referencedTypes = (Set<String>) process.getMetaData().get("MVELReturnValueReferencedTypes");
    if (referencedTypes != null && !referencedTypes.isEmpty()) {
        processDescriptor.getReferencedClasses().addAll(referencedTypes);
    }
    // process unqualified classes
    resolveUnqualifiedClasses();
    // process variables
    if (variables != null) {
        for (Variable data : variables) {
            String type = data.getType().getStringType();
            String itemSubjectRef = (String) data.getMetaData("ItemSubjectRef");
            if (itemSubjectRef != null && itemDefinitions != null) {
                ItemDefinition itemDef = itemDefinitions.get(itemSubjectRef);
                type = itemDef.getStructureRef();
            }
            processDescriptor.getInputs().put(data.getName(), type);
        }
    }
    // process signals
    if (signals != null) {
        processDescriptor.setSignals(signals);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Variable(org.jbpm.process.core.context.variable.Variable) ItemDefinition(org.jbpm.bpmn2.core.ItemDefinition)

Aggregations

ItemDefinition (org.jbpm.bpmn2.core.ItemDefinition)11 Map (java.util.Map)5 List (java.util.List)4 DataType (org.jbpm.process.core.datatype.DataType)4 BooleanDataType (org.jbpm.process.core.datatype.impl.type.BooleanDataType)4 FloatDataType (org.jbpm.process.core.datatype.impl.type.FloatDataType)4 IntegerDataType (org.jbpm.process.core.datatype.impl.type.IntegerDataType)4 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)4 StringDataType (org.jbpm.process.core.datatype.impl.type.StringDataType)4 HashSet (java.util.HashSet)3 ProcessBuildData (org.jbpm.compiler.xml.ProcessBuildData)3 Variable (org.jbpm.process.core.context.variable.Variable)3 Element (org.w3c.dom.Element)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Definitions (org.jbpm.bpmn2.core.Definitions)2 VariableScope (org.jbpm.process.core.context.variable.VariableScope)2 RuleFlowProcess (org.jbpm.ruleflow.core.RuleFlowProcess)2 WorkItemNode (org.jbpm.workflow.core.node.WorkItemNode)2 Set (java.util.Set)1