Search in sources :

Example 1 with ActionRetractFactCol52

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;
    }
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) LimitedEntryCol(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol) LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn)

Example 2 with ActionRetractFactCol52

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"));
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) LimitedEntryActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionRetractFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) Test(org.junit.Test)

Example 3 with ActionRetractFactCol52

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);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) Test(org.junit.Test)

Example 4 with ActionRetractFactCol52

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;
}
Also used : ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52)

Example 5 with ActionRetractFactCol52

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);
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) DecisionTableColumnPlugin(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.DecisionTableColumnPlugin) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Aggregations

ActionRetractFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52)31 Test (org.junit.Test)24 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)11 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)10 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)8 LimitedEntryActionRetractFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionRetractFactCol52)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)4 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)4 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)4 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)4 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)4 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)4 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)4 BoundFactUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BoundFactUiColumn)4 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)3 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2