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;
}
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);
}
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);
}
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());
}
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);
}
Aggregations