Search in sources :

Example 1 with PortableObjectParameterDefinition

use of org.drools.workbench.models.datamodel.workitems.PortableObjectParameterDefinition 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 PortableObjectParameterDefinition

use of org.drools.workbench.models.datamodel.workitems.PortableObjectParameterDefinition in project drools by kiegroup.

the class RuleModelDRLPersistenceImpl method buildPortableParameterDefinition.

private PortableParameterDefinition buildPortableParameterDefinition(final String name, final String value, final Map<String, String> boundParams) {
    PortableParameterDefinition paramDef;
    String type = boundParams.get(value);
    if (type != null) {
        if (type.equals("Boolean")) {
            paramDef = new PortableBooleanParameterDefinition();
        } else if (type.equals("String")) {
            paramDef = new PortableStringParameterDefinition();
        } else if (type.equals("Float")) {
            paramDef = new PortableBooleanParameterDefinition();
        } else if (type.equals("Integer")) {
            paramDef = new PortableIntegerParameterDefinition();
        } else {
            paramDef = new PortableObjectParameterDefinition();
        }
        ((HasBinding) paramDef).setBinding(value);
    } else if (value.equals("true") || value.equals("false") || value.equals("Boolean.TRUE") || value.equals("Boolean.FALSE")) {
        paramDef = new PortableBooleanParameterDefinition();
        boolean b = value.equals("true") || value.equals("Boolean.TRUE");
        ((PortableBooleanParameterDefinition) paramDef).setValue(b);
    } else if (value.startsWith("\"")) {
        paramDef = new PortableStringParameterDefinition();
        ((PortableStringParameterDefinition) paramDef).setValue(value.substring(1, value.length() - 1));
    } else if (Character.isDigit(value.charAt(0))) {
        if (value.endsWith("f")) {
            paramDef = new PortableFloatParameterDefinition();
            ((PortableFloatParameterDefinition) paramDef).setValue(Float.parseFloat(value));
        } else {
            paramDef = new PortableIntegerParameterDefinition();
            ((PortableIntegerParameterDefinition) paramDef).setValue(Integer.parseInt(value));
        }
    } else {
        throw new RuntimeException("Unknown parameter " + value);
    }
    paramDef.setName(name.substring(1, name.length() - 1));
    return paramDef;
}
Also used : PortableStringParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition) PortableIntegerParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition) PortableFloatParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition) PortableObjectParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableObjectParameterDefinition) PortableParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition) HasBinding(org.drools.workbench.models.datamodel.workitems.HasBinding) PortableBooleanParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)

Aggregations

PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)2 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)2 PortableIntegerParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition)2 PortableObjectParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableObjectParameterDefinition)2 PortableParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition)2 PortableStringParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition)2 HashSet (java.util.HashSet)1 HasBinding (org.drools.workbench.models.datamodel.workitems.HasBinding)1 ParameterDefinition (org.jbpm.process.core.ParameterDefinition)1 DataType (org.jbpm.process.core.datatype.DataType)1 BooleanDataType (org.jbpm.process.core.datatype.impl.type.BooleanDataType)1 FloatDataType (org.jbpm.process.core.datatype.impl.type.FloatDataType)1 IntegerDataType (org.jbpm.process.core.datatype.impl.type.IntegerDataType)1 ObjectDataType (org.jbpm.process.core.datatype.impl.type.ObjectDataType)1 StringDataType (org.jbpm.process.core.datatype.impl.type.StringDataType)1