use of org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52 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.ActionRetractFactCol52 in project drools by kiegroup.
the class BRLRuleModelTest method testRuleModelWithRHSBoundFactsUsageWithActionRetractFact.
@Test
public void testRuleModelWithRHSBoundFactsUsageWithActionRetractFact() {
final GuidedDecisionTable52 dt = new GuidedDecisionTable52();
// Setup Decision Table columns
final Pattern52 p1 = new Pattern52();
p1.setFactType("Driver");
p1.setBoundName("$d");
dt.getConditions().add(p1);
final ActionRetractFactCol52 del = new ActionRetractFactCol52();
dt.getActionCols().add(del);
dt.getData().add(Arrays.asList(new DTCellValue52(1), new DTCellValue52("description"), new DTCellValue52("$d")));
final BRLRuleModel model = new BRLRuleModel(dt);
// Checks
assertTrue(model.isBoundFactUsed("$d"));
assertFalse(model.isBoundFactUsed("$cheese"));
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testInOperator.
@Test
public void testInOperator() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setTableName("michael");
AttributeCol52 attr = new AttributeCol52();
attr.setAttribute("salience");
attr.setDefaultValue(new DTCellValue52("66"));
dt.getAttributeCols().add(attr);
Pattern52 p1 = new Pattern52();
p1.setBoundName("f1");
p1.setFactType("Driver");
ConditionCol52 con = new ConditionCol52();
con.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
con.setFactField("age");
con.setHeader("Driver f1 age");
con.setOperator("==");
p1.getChildColumns().add(con);
ConditionCol52 con2 = new ConditionCol52();
con2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
con2.setFactField("name");
con2.setHeader("Driver f1 name");
con2.setOperator("in");
p1.getChildColumns().add(con2);
ConditionCol52 con3 = new ConditionCol52();
con3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_RET_VALUE);
con3.setFactField("rating");
con3.setHeader("Driver rating");
con3.setOperator("==");
p1.getChildColumns().add(con3);
ConditionCol52 con4 = new ConditionCol52();
con4.setConstraintValueType(BaseSingleFieldConstraint.TYPE_PREDICATE);
con4.setHeader("Driver 2 pimp");
con4.setFactField("(not needed)");
p1.getChildColumns().add(con4);
dt.getConditions().add(p1);
ActionInsertFactCol52 ins = new ActionInsertFactCol52();
ins.setBoundName("ins");
ins.setFactType("Cheese");
ins.setFactField("price");
ins.setType(DataType.TYPE_NUMERIC_INTEGER);
dt.getActionCols().add(ins);
ActionRetractFactCol52 ret = new ActionRetractFactCol52();
dt.getActionCols().add(ret);
ActionSetFieldCol52 set = new ActionSetFieldCol52();
set.setBoundName("f1");
set.setFactField("goo1");
set.setType(DataType.TYPE_STRING);
dt.getActionCols().add(set);
ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
set2.setBoundName("f1");
set2.setFactField("goo2");
set2.setDefaultValue(new DTCellValue52("whee"));
set2.setType(DataType.TYPE_STRING);
dt.getActionCols().add(set2);
dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc", "42", "33", "michael, manik", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", "f2" }, new String[] { "2", "desc", "", "39", "bob, frank", "age * 0.3", "age > 7", "6.60", "", "gooVal1", null } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
assertTrue(drl.indexOf("name in ( \"michael\",") > 0);
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52 in project drools-wb by kiegroup.
the class AbstractDecisionTableBuilder method withRetract.
public AbstractDecisionTableBuilder withRetract() {
final ActionRetractFactCol52 col52 = new ActionRetractFactCol52();
col52.setHeader("retract header");
table.getActionCols().add(col52);
return this;
}
use of org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52 in project drools-wb by kiegroup.
the class PluginHandler method edit.
public void edit(final ActionCol52 column) {
final DecisionTableColumnPlugin plugin;
if (column instanceof ActionWorkItemSetFieldCol52 || column instanceof ActionWorkItemInsertFactCol52) {
plugin = actionWorkItemSetFieldPlugin.get();
} else if (column instanceof ActionInsertFactCol52 || column instanceof ActionSetFieldCol52) {
plugin = actionSetFactPlugin.get();
} else if (column instanceof ActionRetractFactCol52) {
plugin = actionRetractFactPlugin.get();
} else if (column instanceof ActionWorkItemCol52) {
plugin = actionWorkItemPlugin.get();
} else if (column instanceof BRLActionColumn) {
plugin = brlActionColumnPlugin.get();
} else {
return;
}
plugin.setOriginalColumnConfig52(column);
openWizard(plugin);
}
Aggregations