use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistence method doActions.
void doActions(List<BaseColumn> allColumns, List<ActionCol52> actionCols, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, RuleModel rm) {
List<LabelledAction> actions = new ArrayList<LabelledAction>();
for (ActionCol52 c : actionCols) {
if (c instanceof LimitedEntryBRLActionColumn) {
doAction(allColumns, (LimitedEntryBRLActionColumn) c, actions, rowDataProvider, row, rm);
} else if (c instanceof BRLActionColumn) {
doAction(allColumns, (BRLActionColumn) c, actions, rowDataProvider, row, rm);
} else {
int index = allColumns.indexOf(c);
DTCellValue52 dcv = row.get(index);
String cell = "";
if (c instanceof LimitedEntryCol) {
if (dcv.getBooleanValue() == true) {
LimitedEntryCol lec = (LimitedEntryCol) c;
cell = GuidedDTDRLUtilities.convertDTCellValueToString(lec.getValue());
}
} else {
cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv);
}
if (validCell(cell, dcv.getDataType())) {
if (c instanceof ActionWorkItemInsertFactCol52) {
doAction(actions, (ActionWorkItemInsertFactCol52) c, cell);
} else if (c instanceof ActionInsertFactCol52) {
doAction(actions, (ActionInsertFactCol52) c, cell);
} else if (c instanceof ActionWorkItemSetFieldCol52) {
doAction(actions, (ActionWorkItemSetFieldCol52) c, cell);
} else if (c instanceof ActionSetFieldCol52) {
doAction(actions, (ActionSetFieldCol52) c, cell);
} else if (c instanceof ActionRetractFactCol52) {
doAction(actions, cell);
} else if (c instanceof ActionWorkItemCol52) {
doAction(actions, (ActionWorkItemCol52) c, cell);
}
}
}
}
rm.rhs = new IAction[actions.size()];
for (int i = 0; i < rm.rhs.length; i++) {
rm.rhs[i] = actions.get(i).action;
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testRHSExecuteWorkItem.
@Test
public void testRHSExecuteWorkItem() {
GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
String[] row = new String[] { "1", "desc", "true" };
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("work-item");
awi.setWorkItemDefinition(pwd);
PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
p1.setName("BooleanParameter");
p1.setValue(Boolean.TRUE);
pwd.addParameter(p1);
PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
p2.setName("FloatParameter");
p2.setValue(123.456f);
pwd.addParameter(p2);
PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
p3.setName("IntegerParameter");
p3.setValue(123);
pwd.addParameter(p3);
PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
p4.setName("StringParameter");
p4.setValue("hello");
pwd.addParameter(p4);
cols.add(awi);
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(1, rm.rhs.length);
// Examine RuleModel action
ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[0];
assertNotNull(aw);
PortableWorkDefinition mpwd = aw.getWorkDefinition();
assertNotNull(mpwd);
assertEquals(4, mpwd.getParameters().size());
PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getParameter("BooleanParameter");
assertNotNull(mp1);
assertEquals(Boolean.TRUE, mp1.getValue());
PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getParameter("FloatParameter");
assertNotNull(mp2);
assertEquals(new Float(123.456f), mp2.getValue());
PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getParameter("IntegerParameter");
assertNotNull(mp3);
assertEquals(new Integer(123), mp3.getValue());
PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getParameter("StringParameter");
assertNotNull(mp4);
assertEquals("hello", mp4.getValue());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testRHSExecuteWorkItemWithBindings.
@Test
public void testRHSExecuteWorkItemWithBindings() {
GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
String[] row = new String[] { "1", "desc", "true" };
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("work-item");
awi.setWorkItemDefinition(pwd);
PortableBooleanParameterDefinition p1 = new PortableBooleanParameterDefinition();
p1.setName("BooleanParameter");
p1.setValue(Boolean.TRUE);
p1.setBinding("$b");
pwd.addParameter(p1);
PortableFloatParameterDefinition p2 = new PortableFloatParameterDefinition();
p2.setName("FloatParameter");
p2.setValue(123.456f);
p2.setBinding("$f");
pwd.addParameter(p2);
PortableIntegerParameterDefinition p3 = new PortableIntegerParameterDefinition();
p3.setName("IntegerParameter");
p3.setValue(123);
p3.setBinding("$i");
pwd.addParameter(p3);
PortableStringParameterDefinition p4 = new PortableStringParameterDefinition();
p4.setName("StringParameter");
p4.setValue("hello");
p4.setBinding("$s");
pwd.addParameter(p4);
cols.add(awi);
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(1, rm.rhs.length);
// Examine RuleModel action
ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[0];
assertNotNull(aw);
PortableWorkDefinition mpwd = aw.getWorkDefinition();
assertNotNull(mpwd);
assertEquals(4, mpwd.getParameters().size());
PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getParameter("BooleanParameter");
assertNotNull(mp1);
assertEquals(Boolean.TRUE, mp1.getValue());
assertEquals("$b", mp1.getBinding());
PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getParameter("FloatParameter");
assertNotNull(mp2);
assertEquals(new Float(123.456f), mp2.getValue());
assertEquals("$f", mp2.getBinding());
PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getParameter("IntegerParameter");
assertNotNull(mp3);
assertEquals(new Integer(123), mp3.getValue());
assertEquals("$i", mp3.getBinding());
PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getParameter("StringParameter");
assertNotNull(mp4);
assertEquals("hello", mp4.getValue());
assertEquals("$s", mp4.getBinding());
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52 in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldPlugin method setupWorkItems.
void setupWorkItems() {
actionWorkItems().forEach(actionCol52 -> {
final PortableWorkDefinition workItemDefinition = ((ActionWorkItemCol52) actionCol52).getWorkItemDefinition();
workItemDefinition.getResults().stream().filter(this::acceptParameterType).forEach(parameterDefinition -> {
final String key = trim((workItemDefinition.getName() + ":" + parameterDefinition.getName()));
workItems.put(key, new WorkItemParameter(workItemDefinition, parameterDefinition));
});
});
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52 in project drools-wb by kiegroup.
the class ActionWorkItemPlugin method clone.
ActionWorkItemCol52 clone(final ActionWorkItemCol52 column) {
final ActionWorkItemCol52 clone = new ActionWorkItemCol52();
clone.setHeader(column.getHeader());
clone.setWorkItemDefinition(column.getWorkItemDefinition());
clone.setHideColumn(column.isHideColumn());
return clone;
}
Aggregations