Search in sources :

Example 6 with PortableParameterDefinition

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

Example 7 with PortableParameterDefinition

use of org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition in project drools-wb by kiegroup.

the class ActionWorkItemSetFieldPlugin method setWorkItem.

@Override
public void setWorkItem(final String workItemKey) {
    setWorkItem("", "", "");
    getWorkItems().forEach((key, workItemParameter) -> {
        if (trim(key).equals(trim(workItemKey))) {
            final PortableWorkDefinition workDefinition = workItemParameter.getWorkDefinition();
            final PortableParameterDefinition parameterDefinition = workItemParameter.getWorkParameterDefinition();
            selectedWorkItemKey = trim(key);
            setWorkItem(workDefinition.getName(), parameterDefinition.getName(), parameterDefinition.getClassName());
            fireChangeEvent(workItemPage);
        }
    });
}
Also used : PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) PortableParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition)

Example 8 with PortableParameterDefinition

use of org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition in project drools-wb by kiegroup.

the class ActionWorkItemSetFieldPlugin method forEachWorkItem.

@Override
public void forEachWorkItem(BiConsumer<String, String> biConsumer) {
    setupWorkItems();
    workItems.forEach((key, workItemParameter) -> {
        final PortableWorkDefinition workItemDefinition = workItemParameter.getWorkDefinition();
        final PortableParameterDefinition parameterDefinition = workItemParameter.getWorkParameterDefinition();
        final String name = workItemDefinition.getDisplayName() + " - " + parameterDefinition.getName();
        biConsumer.accept(name, key);
    });
}
Also used : PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) PortableParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition)

Example 9 with PortableParameterDefinition

use of org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition in project drools-wb by kiegroup.

the class ActionWorkItemSetFieldPluginTest method secondFakeWorkItem.

private ActionWorkItemCol52 secondFakeWorkItem() {
    final ActionWorkItemCol52 workItemCol52 = new ActionWorkItemCol52();
    final PortableWorkDefinition portableWorkDefinition = new PortableWorkDefinition();
    final PortableParameterDefinition portableFloatParameterDefinition = new PortableFloatParameterDefinition();
    portableFloatParameterDefinition.setName("FloatResult");
    portableWorkDefinition.setResults(Collections.singleton(portableFloatParameterDefinition));
    portableWorkDefinition.setName("FloatWorkItemName");
    portableWorkDefinition.setDisplayName("FloatWorkItemDisplayName");
    workItemCol52.setWorkItemDefinition(portableWorkDefinition);
    return workItemCol52;
}
Also used : PortableFloatParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) PortableParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition)

Aggregations

PortableParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition)9 PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)6 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)3 PortableStringParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition)3 ArrayList (java.util.ArrayList)2 PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)2 PortableIntegerParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition)2 PortableObjectParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableObjectParameterDefinition)2 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 HasBinding (org.drools.workbench.models.datamodel.workitems.HasBinding)1 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)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