Search in sources :

Example 26 with PortableWorkDefinition

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

the class ActionWorkItemSetFieldPluginTest method firstFakeWorkItem.

private ActionWorkItemCol52 firstFakeWorkItem() {
    final ActionWorkItemCol52 workItemCol52 = new ActionWorkItemCol52();
    final PortableWorkDefinition portableWorkDefinition = new PortableWorkDefinition();
    final PortableParameterDefinition portableStringParameterDefinition = new PortableStringParameterDefinition();
    portableStringParameterDefinition.setName("StringResult");
    portableWorkDefinition.setResults(Collections.singleton(portableStringParameterDefinition));
    portableWorkDefinition.setName("StringWorkItemName");
    portableWorkDefinition.setDisplayName("StringWorkItemDisplayName");
    workItemCol52.setWorkItemDefinition(portableWorkDefinition);
    return workItemCol52;
}
Also used : PortableStringParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition) 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)

Example 27 with PortableWorkDefinition

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

the class ActionWorkItemSetFieldColumnSynchronizerTest method setupWorkItemExecution.

@Before
public void setupWorkItemExecution() throws VetoException {
    final ActionWorkItemCol52 column = new ActionWorkItemCol52();
    final PortableWorkDefinition pwd = new PortableWorkDefinition();
    pwd.setName(WORK_ITEM_NAME);
    column.setWorkItemDefinition(pwd);
    column.setHeader("wid");
    modelSynchronizer.appendColumn(column);
}
Also used : ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) Before(org.junit.Before)

Example 28 with PortableWorkDefinition

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

the class ActionWorkItemCol52Test method testWorkItemDefinition_SimpleAndNull.

@Test
public void testWorkItemDefinition_SimpleAndNull() {
    PortableWorkDefinition def1 = new PortableWorkDefinition();
    def1.setName("def1name");
    column1.setWorkItemDefinition(def1);
    column2.setWorkItemDefinition(null);
    checkSingleDiff(FIELD_WORKITEM_DEFINITION_NAME, "def1name", null, column1, column2);
}
Also used : PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) Test(org.junit.Test)

Example 29 with PortableWorkDefinition

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

the class ActionWorkItemCol52Test method testWorkItemDefinition_TwoComplexDefs.

@Test
public void testWorkItemDefinition_TwoComplexDefs() {
    PortableStringParameterDefinition param1 = new PortableStringParameterDefinition();
    param1.setName("param1");
    param1.setValue("value1");
    PortableStringParameterDefinition param2 = new PortableStringParameterDefinition();
    param2.setName("param2");
    param2.setValue("value2");
    PortableWorkDefinition def1 = new PortableWorkDefinition();
    def1.setName("def1name");
    def1.addParameter(param1);
    def1.addParameter(param2);
    // different param -> diff + 2
    PortableStringParameterDefinition param3 = new PortableStringParameterDefinition();
    param3.setName("param3");
    param3.setValue("value3");
    // same as param1
    PortableStringParameterDefinition param4 = new PortableStringParameterDefinition();
    param4.setName("param1");
    param4.setValue("value1");
    // different param -> diff + 2
    PortableStringParameterDefinition param5 = new PortableStringParameterDefinition();
    param5.setName("param5");
    param5.setBinding("binding5");
    // as param2, different value -> diff + 1
    PortableStringParameterDefinition param6 = new PortableStringParameterDefinition();
    param6.setName("param2");
    param6.setValue("value6");
    PortableWorkDefinition def2 = new PortableWorkDefinition();
    def2.setName("def2name");
    def2.addParameter(param3);
    def2.addParameter(param4);
    def2.addParameter(param5);
    def2.addParameter(param6);
    column1.setWorkItemDefinition(def1);
    // different definition -> diff + 1
    column2.setWorkItemDefinition(def2);
    List<BaseColumnFieldDiff> diff = column1.diff(column2);
    assertNotNull(diff);
    for (BaseColumnFieldDiff item : diff) {
        System.out.println(item.getFieldName());
        System.out.println(item.getOldValue());
        System.out.println(item.getValue());
    }
    assertEquals(6, diff.size());
    assertEquals(FIELD_WORKITEM_DEFINITION_NAME, diff.get(0).getFieldName());
    assertEquals("def1name", diff.get(0).getOldValue());
    assertEquals("def2name", diff.get(0).getValue());
    assertEquals(FIELD_WORKITEM_DEFINITION_PARAMETER_NAME, diff.get(1).getFieldName());
    assertEquals(null, diff.get(1).getOldValue());
    assertEquals("param3", diff.get(1).getValue());
    assertEquals(FIELD_WORKITEM_DEFINITION_PARAMETER_VALUE, diff.get(2).getFieldName());
    assertEquals(null, diff.get(2).getOldValue());
    assertEquals("\"value3\"", diff.get(2).getValue());
    assertEquals(FIELD_WORKITEM_DEFINITION_PARAMETER_NAME, diff.get(3).getFieldName());
    assertEquals(null, diff.get(3).getOldValue());
    assertEquals("param5", diff.get(3).getValue());
    assertEquals(FIELD_WORKITEM_DEFINITION_PARAMETER_VALUE, diff.get(4).getFieldName());
    assertEquals(null, diff.get(4).getOldValue());
    assertEquals("binding5", diff.get(4).getValue());
    assertEquals(FIELD_WORKITEM_DEFINITION_PARAMETER_VALUE, diff.get(5).getFieldName());
    assertEquals("\"value2\"", diff.get(5).getOldValue());
    assertEquals("\"value6\"", diff.get(5).getValue());
}
Also used : PortableStringParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) Test(org.junit.Test)

Example 30 with PortableWorkDefinition

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

the class RuleModelDRLPersistenceTest method testRHSExecuteWorkItemWithBindings.

@Test
public // populated in the RHS if the Pattern is bound to the same variable
void testRHSExecuteWorkItemWithBindings() {
    RuleModel m = new RuleModel();
    m.name = "WorkItem";
    FactPattern fp1 = new FactPattern("Person");
    fp1.setBoundName("$p");
    SingleFieldConstraint con1 = new SingleFieldConstraint();
    con1.setFieldType(DataType.TYPE_STRING);
    con1.setFieldName("name");
    con1.setOperator("==");
    con1.setValue("Michael");
    con1.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    fp1.addConstraint(con1);
    m.addLhsItem(fp1);
    FactPattern fp2 = new FactPattern("Boolean");
    fp2.setBoundName("$b");
    SingleFieldConstraint con2 = new SingleFieldConstraint();
    con2.setFieldType(DataType.TYPE_BOOLEAN);
    con2.setFieldName("this");
    con2.setOperator("==");
    con2.setValue("true");
    con2.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    fp2.addConstraint(con2);
    m.addLhsItem(fp2);
    FactPattern fp3 = new FactPattern("Float");
    fp3.setBoundName("$f");
    SingleFieldConstraint con3 = new SingleFieldConstraint();
    con3.setFieldType(DataType.TYPE_NUMERIC_FLOAT);
    con3.setFieldName("this");
    con3.setOperator("==");
    con3.setValue("123.456f");
    con3.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    fp3.addConstraint(con3);
    m.addLhsItem(fp3);
    FactPattern fp4 = new FactPattern("Integer");
    fp4.setBoundName("$i");
    SingleFieldConstraint con4 = new SingleFieldConstraint();
    con4.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    con4.setFieldName("this");
    con4.setOperator("==");
    con4.setValue("123");
    con4.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    fp4.addConstraint(con4);
    m.addLhsItem(fp4);
    FactPattern fp5 = new FactPattern("String");
    fp5.setBoundName("$s");
    SingleFieldConstraint con5 = new SingleFieldConstraint();
    con5.setFieldType(DataType.TYPE_STRING);
    con5.setFieldName("this");
    con5.setOperator("==");
    con5.setValue("hello");
    con5.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    fp5.addConstraint(con5);
    m.addLhsItem(fp5);
    ActionExecuteWorkItem awi = new ActionExecuteWorkItem();
    PortableWorkDefinition pwd = new PortableWorkDefinition();
    pwd.setName("WorkItem");
    awi.setWorkDefinition(pwd);
    PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
    p1.setName("BooleanParameter");
    p1.setBinding("$b");
    p1.setValue(Boolean.TRUE);
    pwd.addParameter(p1);
    PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
    p2.setName("FloatParameter");
    p2.setBinding("$f");
    p2.setValue(123.456f);
    pwd.addParameter(p2);
    PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
    p3.setName("IntegerParameter");
    p3.setBinding("$i");
    p3.setValue(123);
    pwd.addParameter(p3);
    PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
    p4.setName("StringParameter");
    p4.setBinding("$s");
    p4.setValue("hello");
    pwd.addParameter(p4);
    m.addRhsItem(awi);
    String result = RuleModelDRLPersistenceImpl.getInstance().marshal(m);
    assertTrue(result.indexOf("org.drools.core.process.instance.WorkItemManager wim = (org.drools.core.process.instance.WorkItemManager) drools.getWorkingMemory().getWorkItemManager();") != -1);
    assertTrue(result.indexOf("org.drools.core.process.instance.impl.WorkItemImpl wiWorkItem = new org.drools.core.process.instance.impl.WorkItemImpl();") != -1);
    assertTrue(result.indexOf("wiWorkItem.getParameters().put( \"BooleanParameter\", $b );") != -1);
    assertTrue(result.indexOf("wiWorkItem.getParameters().put( \"FloatParameter\", $f );") != -1);
    assertTrue(result.indexOf("wiWorkItem.getParameters().put( \"IntegerParameter\", $i );") != -1);
    assertTrue(result.indexOf("wiWorkItem.getParameters().put( \"StringParameter\", $s );") != -1);
    assertTrue(result.indexOf("wim.internalExecuteWorkItem( wiWorkItem );") != -1);
    checkMarshalling(null, m);
}
Also used : SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) PortableStringParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition) PortableIntegerParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition) PortableFloatParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) PortableBooleanParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition) ActionExecuteWorkItem(org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Aggregations

PortableWorkDefinition (org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition)48 Test (org.junit.Test)30 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)17 PortableStringParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableStringParameterDefinition)16 ActionExecuteWorkItem (org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem)14 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)14 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)13 PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)13 ArrayList (java.util.ArrayList)11 PortableIntegerParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableIntegerParameterDefinition)11 HashSet (java.util.HashSet)7 HashMap (java.util.HashMap)6 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)6 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)6 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)6 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)6 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)6 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)6 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)6 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)6