use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testRHSActionWorkItemSetFields2.
@Test
public // Test only Actions set to "true" are correctly converted to RuleModel
void testRHSActionWorkItemSetFields2() {
GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
String[] row = new String[] { "1", "desc", "true", "true", "false" };
List<BaseColumn> allColumns = new ArrayList<BaseColumn>();
allColumns.add(new RowNumberCol52());
allColumns.add(new DescriptionCol52());
List<ActionCol52> cols = new ArrayList<ActionCol52>();
ActionWorkItemCol52 awi = new ActionWorkItemCol52();
PortableWorkDefinition pwd = new PortableWorkDefinition();
pwd.setName("WorkItem");
awi.setWorkItemDefinition(pwd);
PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
p1.setName("BooleanResult");
pwd.addResult(p1);
PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
p2.setName("FloatResult");
pwd.addResult(p2);
cols.add(awi);
ActionWorkItemSetFieldCol52 asf1 = new ActionWorkItemSetFieldCol52();
asf1.setBoundName("$r");
asf1.setFactField("ResultBooleanField");
asf1.setType(DataType.TYPE_BOOLEAN);
asf1.setWorkItemName("WorkItem");
asf1.setWorkItemResultParameterName("BooleanResult");
asf1.setParameterClassName(Boolean.class.getName());
cols.add(asf1);
ActionWorkItemSetFieldCol52 asf2 = new ActionWorkItemSetFieldCol52();
asf2.setBoundName("$r");
asf2.setFactField("ResultFloatField");
asf2.setType(DataType.TYPE_NUMERIC_FLOAT);
asf2.setWorkItemName("WorkItem");
asf2.setWorkItemResultParameterName("FloatResult");
asf2.setParameterClassName(Float.class.getName());
cols.add(asf2);
RuleModel rm = new RuleModel();
allColumns.addAll(cols);
List<DTCellValue52> rowData = DataUtilities.makeDataRowList(row);
TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider(allColumns, rowData);
p.doActions(allColumns, cols, rowDataProvider, rowData, rm);
assertEquals(2, rm.rhs.length);
// Examine RuleModel actions
ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[0];
assertNotNull(aw);
ActionSetField asf = (ActionSetField) rm.rhs[1];
assertNotNull(asf);
// Check ActionExecuteWorkItem
PortableWorkDefinition mpwd = aw.getWorkDefinition();
assertNotNull(mpwd);
assertEquals(2, mpwd.getResults().size());
PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getResult("BooleanResult");
assertNotNull(mp1);
PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getResult("FloatResult");
assertNotNull(mp2);
// Check ActionSetField
assertEquals(asf.getVariable(), "$r");
assertEquals(1, asf.getFieldValues().length);
ActionFieldValue fv1 = asf.getFieldValues()[0];
assertNotNull(fv1);
assertTrue(fv1 instanceof ActionWorkItemFieldValue);
ActionWorkItemFieldValue wifv1 = (ActionWorkItemFieldValue) fv1;
assertEquals("ResultBooleanField", wifv1.getField());
assertEquals(DataType.TYPE_BOOLEAN, wifv1.getType());
assertEquals("WorkItem", wifv1.getWorkItemName());
assertEquals("BooleanResult", wifv1.getWorkItemParameterName());
assertEquals(Boolean.class.getName(), wifv1.getWorkItemParameterClassName());
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class AuditLogEntryCellHelperTest method getSafeHtml_ActionWorkItemExecute_Simple.
@Test
public void getSafeHtml_ActionWorkItemExecute_Simple() {
ActionWorkItemCol52 originalColumn = new ActionWorkItemCol52();
originalColumn.setHeader("action1");
originalColumn.setHideColumn(false);
ActionWorkItemCol52 newColumn = new ActionWorkItemCol52();
newColumn.setHeader("action2");
newColumn.setHideColumn(true);
PortableStringParameterDefinition param1 = new PortableStringParameterDefinition();
param1.setName("param1");
param1.setValue("value1");
PortableWorkDefinition def1 = new PortableWorkDefinition();
def1.setName("def1name");
def1.addParameter(param1);
PortableStringParameterDefinition param3 = new PortableStringParameterDefinition();
param3.setName("param3");
param3.setValue("value3");
PortableWorkDefinition def2 = new PortableWorkDefinition();
def2.setName("def2name");
def2.addParameter(param3);
originalColumn.setWorkItemDefinition(def1);
newColumn.setWorkItemDefinition(def2);
List<BaseColumnFieldDiff> diffs = originalColumn.diff(newColumn);
SafeHtml result = helper.getSafeHtml(new UpdateColumnAuditLogEntry("mock user", originalColumn, newColumn, diffs));
assertEquals(getActionHeaderRepre(newColumn.getHeader()) + getDiffRepre(diffs), result.asString());
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition 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);
}
});
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition 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);
});
}
use of org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition in project drools-wb by kiegroup.
the class ActionWorkItemExecuteColumnConverter method makeHeaderMetaData.
@Override
public List<GridColumn.HeaderMetaData> makeHeaderMetaData(final BaseColumn column) {
final PortableWorkDefinition pwd = ((ActionWorkItemCol52) column).getWorkItemDefinition();
final String workItemName = pwd == null ? column.getHeader() : pwd.getName();
return new ArrayList<GridColumn.HeaderMetaData>() {
{
add(new BaseHeaderMetaData(workItemName, ActionCol52.class.getName()));
add(new BaseHeaderMetaData(column.getHeader(), workItemName + "-exec"));
}
};
}
Aggregations