Search in sources :

Example 46 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools by kiegroup.

the class GuidedDTDRLPersistenceTest method testRHS.

@Test
public void testRHS() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] { "1", "desc", "a", "a condition", "actionsetfield1", "actionupdatefield2", "retract", "actioninsertfact1", "actioninsertfact2" };
    List<BaseColumn> allColumns = new ArrayList<BaseColumn>();
    allColumns.add(new RowNumberCol52());
    allColumns.add(new DescriptionCol52());
    allColumns.add(new MetadataCol52());
    allColumns.add(new ConditionCol52());
    List<ActionCol52> cols = new ArrayList<ActionCol52>();
    ActionSetFieldCol52 asf1 = new ActionSetFieldCol52();
    asf1.setBoundName("a");
    asf1.setFactField("field1");
    asf1.setType(DataType.TYPE_STRING);
    cols.add(asf1);
    ActionSetFieldCol52 asf2 = new ActionSetFieldCol52();
    asf2.setBoundName("a");
    asf2.setFactField("field2");
    asf2.setUpdate(true);
    asf2.setType(DataType.TYPE_NUMERIC_INTEGER);
    cols.add(asf2);
    ActionRetractFactCol52 ret = new ActionRetractFactCol52();
    cols.add(ret);
    ActionInsertFactCol52 ins1 = new ActionInsertFactCol52();
    ins1.setBoundName("ins");
    ins1.setFactType("Cheese");
    ins1.setFactField("price");
    ins1.setType(DataType.TYPE_NUMERIC_INTEGER);
    cols.add(ins1);
    ActionInsertFactCol52 ins2 = new ActionInsertFactCol52();
    ins2.setBoundName("ins");
    ins2.setFactType("Cheese");
    ins2.setFactField("type");
    ins2.setType(DataType.TYPE_NUMERIC_INTEGER);
    cols.add(ins2);
    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(4, rm.rhs.length);
    // examine the set field action that is produced
    ActionSetField a1 = (ActionSetField) rm.rhs[0];
    assertEquals("a", a1.getVariable());
    assertEquals(1, a1.getFieldValues().length);
    assertEquals("field1", a1.getFieldValues()[0].getField());
    assertEquals("actionsetfield1", a1.getFieldValues()[0].getValue());
    assertEquals(DataType.TYPE_STRING, a1.getFieldValues()[0].getType());
    ActionSetField a2 = (ActionSetField) rm.rhs[1];
    assertEquals("a", a2.getVariable());
    assertEquals(1, a2.getFieldValues().length);
    assertEquals("field2", a2.getFieldValues()[0].getField());
    assertEquals("actionupdatefield2", a2.getFieldValues()[0].getValue());
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, a2.getFieldValues()[0].getType());
    // examine the retract
    ActionRetractFact a3 = (ActionRetractFact) rm.rhs[2];
    assertEquals("retract", a3.getVariableName());
    // examine the insert
    ActionInsertFact a4 = (ActionInsertFact) rm.rhs[3];
    assertEquals("Cheese", a4.getFactType());
    assertEquals(2, a4.getFieldValues().length);
    assertEquals("price", a4.getFieldValues()[0].getField());
    assertEquals("actioninsertfact1", a4.getFieldValues()[0].getValue());
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, a4.getFieldValues()[0].getType());
    assertEquals("type", a4.getFieldValues()[1].getField());
    assertEquals("actioninsertfact2", a4.getFieldValues()[1].getValue());
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, a4.getFieldValues()[1].getType());
}
Also used : 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) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) 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) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) ActionRetractFact(org.drools.workbench.models.datamodel.rule.ActionRetractFact) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) ActionSetField(org.drools.workbench.models.datamodel.rule.ActionSetField) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) TemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider) Test(org.junit.Test)

Example 47 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools by kiegroup.

the class BRLRuleModelTest method testRuleModelWithRHSBoundFactsUsageWithActionSetField.

@Test
public void testRuleModelWithRHSBoundFactsUsageWithActionSetField() {
    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 ActionSetFieldCol52 set = new ActionSetFieldCol52();
    set.setBoundName("$d");
    set.setFactField("rating");
    dt.getActionCols().add(set);
    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) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) Test(org.junit.Test)

Example 48 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.

the class AuditLogEntryCellHelperTest method getSafeHtml_ActionSetField.

@Test
public void getSafeHtml_ActionSetField() {
    ActionSetFieldCol52 originalColumn = new ActionSetFieldCol52();
    originalColumn.setBoundName("bind1");
    originalColumn.setFactField("field1");
    originalColumn.setUpdate(false);
    originalColumn.setValueList("q,w,e");
    originalColumn.setHeader("action1");
    originalColumn.setHideColumn(false);
    originalColumn.setDefaultValue(new DTCellValue52("def1"));
    ActionSetFieldCol52 newColumn = new ActionSetFieldCol52();
    newColumn.setBoundName("bind2");
    newColumn.setFactField("field2");
    newColumn.setUpdate(true);
    newColumn.setValueList("a,s,d");
    newColumn.setHeader("action2");
    newColumn.setHideColumn(true);
    newColumn.setDefaultValue(new DTCellValue52("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());
}
Also used : UpdateColumnAuditLogEntry(org.drools.workbench.models.guided.dtable.shared.auditlog.UpdateColumnAuditLogEntry) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) Test(org.junit.Test)

Example 49 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.

the class DefaultWidgetFactory method dataType.

private DataType.DataTypes dataType() {
    final ColumnUtilities columnUtilities = columnUtilities();
    final DTColumnConfig52 column = getPlugin().editingCol();
    if (column instanceof ActionSetFieldCol52) {
        return columnUtilities.getDataType(getPlugin().editingPattern(), (ActionSetFieldCol52) column);
    } else if (column instanceof ConditionCol52) {
        return columnUtilities.getDataType(getPlugin().editingPattern(), (ConditionCol52) column);
    } else {
        return columnUtilities.getDataType(column);
    }
}
Also used : ColumnUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) DTColumnConfig52(org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Example 50 with ActionSetFieldCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52 in project drools-wb by kiegroup.

the class ActionSetFieldsPage method isComplete.

@Override
public void isComplete(final Callback<Boolean> callback) {
    // Have all Actions been defined?
    boolean areActionSetFieldsDefined = true;
    for (List<ActionSetFieldCol52> actions : patternToActionsMap.values()) {
        for (ActionSetFieldCol52 a : actions) {
            if (!getValidator().isActionValid(a)) {
                areActionSetFieldsDefined = false;
                break;
            }
        }
    }
    // Signal Action Set Fields definitions to other pages
    final ActionSetFieldsDefinedEvent event = new ActionSetFieldsDefinedEvent(areActionSetFieldsDefined);
    actionSetFieldsDefinedEvent.fire(event);
    callback.callback(areActionSetFieldsDefined);
}
Also used : ActionSetFieldsDefinedEvent(org.drools.workbench.screens.guided.dtable.client.wizard.table.pages.events.ActionSetFieldsDefinedEvent) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Aggregations

ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)75 Test (org.junit.Test)49 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)39 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)38 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)29 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)27 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)23 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)16 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)16 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)12 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)12 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)12 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)12 Path (org.uberfire.backend.vfs.Path)12 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)11 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)11 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)10 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)9 ActionRetractFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52)8 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)8