Search in sources :

Example 1 with BooleanDataType

use of org.jbpm.process.core.datatype.impl.type.BooleanDataType in project drools-wb by kiegroup.

the class WorkItemsEditorServiceImpl method convertWorkItemParameters.

private Set<PortableParameterDefinition> convertWorkItemParameters(final Set<ParameterDefinition> parameters) {
    final Set<PortableParameterDefinition> pps = new HashSet<PortableParameterDefinition>();
    for (ParameterDefinition pd : parameters) {
        final DataType pdt = pd.getType();
        PortableParameterDefinition ppd = null;
        if (pdt instanceof BooleanDataType) {
            ppd = new PortableBooleanParameterDefinition();
        } else if (pdt instanceof FloatDataType) {
            ppd = new PortableFloatParameterDefinition();
        } else if (pdt instanceof IntegerDataType) {
            ppd = new PortableIntegerParameterDefinition();
        } else if (pdt instanceof ObjectDataType) {
            ppd = new PortableObjectParameterDefinition();
            final PortableObjectParameterDefinition oppd = (PortableObjectParameterDefinition) ppd;
            final ObjectDataType odt = (ObjectDataType) pdt;
            oppd.setClassName(odt.getClassName());
        } else if (pd.getType() instanceof StringDataType) {
            ppd = new PortableStringParameterDefinition();
        }
        if (ppd != null) {
            ppd.setName(pd.getName());
            pps.add(ppd);
        }
    }
    return pps;
}
Also used : PortableIntegerParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition) FloatDataType(org.jbpm.process.core.datatype.impl.type.FloatDataType) PortableFloatParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition) IntegerDataType(org.jbpm.process.core.datatype.impl.type.IntegerDataType) PortableObjectParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableObjectParameterDefinition) PortableParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition) ObjectDataType(org.jbpm.process.core.datatype.impl.type.ObjectDataType) PortableStringParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition) StringDataType(org.jbpm.process.core.datatype.impl.type.StringDataType) DataType(org.jbpm.process.core.datatype.DataType) StringDataType(org.jbpm.process.core.datatype.impl.type.StringDataType) 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) BooleanDataType(org.jbpm.process.core.datatype.impl.type.BooleanDataType) PortableBooleanParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition) BooleanDataType(org.jbpm.process.core.datatype.impl.type.BooleanDataType) HashSet(java.util.HashSet) PortableObjectParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableObjectParameterDefinition) ParameterDefinition(org.jbpm.process.core.ParameterDefinition) PortableParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition) PortableStringParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition) PortableBooleanParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition) PortableIntegerParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition) PortableFloatParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)

Example 2 with BooleanDataType

use of org.jbpm.process.core.datatype.impl.type.BooleanDataType 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 BooleanDataType

use of org.jbpm.process.core.datatype.impl.type.BooleanDataType 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 4 with BooleanDataType

use of org.jbpm.process.core.datatype.impl.type.BooleanDataType in project jbpm by kiegroup.

the class DefinitionsHandler method setVariableDataType.

private void setVariableDataType(Variable variable, Map<String, ItemDefinition> itemDefinitions, ClassLoader cl) {
    // retrieve type from item definition
    String itemSubjectRef = (String) variable.getMetaData("ItemSubjectRef");
    if (UndefinedDataType.getInstance().equals(variable.getType()) && itemDefinitions != null && itemSubjectRef != null) {
        DataType dataType = new ObjectDataType();
        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, cl);
            }
        }
        variable.setType(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) UndefinedDataType(org.jbpm.process.core.datatype.impl.type.UndefinedDataType) 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)

Aggregations

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 ItemDefinition (org.jbpm.bpmn2.core.ItemDefinition)3 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)1 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)1 PortableIntegerParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition)1 PortableObjectParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableObjectParameterDefinition)1 PortableParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition)1 PortableStringParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition)1 ContextContainer (org.jbpm.process.core.ContextContainer)1 ParameterDefinition (org.jbpm.process.core.ParameterDefinition)1 Variable (org.jbpm.process.core.context.variable.Variable)1 VariableScope (org.jbpm.process.core.context.variable.VariableScope)1