Search in sources :

Example 31 with ActionInsertFactCol52

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

the class GuidedDecisionTableTest method testNumeric.

@Test
@SuppressWarnings("serial")
public void testNumeric() {
    final GuidedDecisionTable52 model = new GuidedDecisionTable52();
    final ModuleDataModelOracle loader = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()).addFact("Driver").addField(new ModelField("age", Integer.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_NUMERIC_INTEGER)).addField(new ModelField("name", String.class.getName(), ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.BOTH, DataType.TYPE_STRING)).end().build();
    // Emulate server-to-client conversions
    final AsyncPackageDataModelOracle oracle = getOracle();
    final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
    dataModel.setModelFields(loader.getModuleModelFields());
    populateDataModelOracle(mock(Path.class), model, oracle, dataModel);
    final ColumnUtilities utils = new ColumnUtilities(model, oracle);
    final AttributeCol52 at = new AttributeCol52();
    at.setAttribute(Attribute.SALIENCE.getAttributeName());
    final AttributeCol52 at_ = new AttributeCol52();
    at_.setAttribute(Attribute.ENABLED.getAttributeName());
    model.getAttributeCols().add(at);
    model.getAttributeCols().add(at_);
    final ConditionCol52 c1 = new ConditionCol52();
    final Pattern52 p1 = new Pattern52();
    p1.setBoundName("c1");
    p1.setFactType("Driver");
    c1.setFactField("name");
    c1.setOperator("==");
    c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    p1.getChildColumns().add(c1);
    model.getConditions().add(p1);
    final ConditionCol52 c1_ = new ConditionCol52();
    final Pattern52 p1_ = new Pattern52();
    p1_.setBoundName("c1");
    p1_.setFactType("Driver");
    c1_.setFactField("age");
    c1_.setOperator("==");
    c1_.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    p1_.getChildColumns().add(c1_);
    model.getConditions().add(p1_);
    final ConditionCol52 c2 = new ConditionCol52();
    final Pattern52 p2 = new Pattern52();
    p2.setBoundName("c1");
    p2.setFactType("Driver");
    c2.setFactField("age");
    c2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    p2.getChildColumns().add(c2);
    model.getConditions().add(p2);
    final ActionSetFieldCol52 a = new ActionSetFieldCol52();
    a.setBoundName("c1");
    a.setFactField("name");
    model.getActionCols().add(a);
    final ActionSetFieldCol52 a2 = new ActionSetFieldCol52();
    a2.setBoundName("c1");
    a2.setFactField("age");
    model.getActionCols().add(a2);
    final ActionInsertFactCol52 ins = new ActionInsertFactCol52();
    ins.setBoundName("x");
    ins.setFactType("Driver");
    ins.setFactField("name");
    model.getActionCols().add(ins);
    final ActionInsertFactCol52 ins_ = new ActionInsertFactCol52();
    ins_.setBoundName("x");
    ins_.setFactType("Driver");
    ins_.setFactField("age");
    model.getActionCols().add(ins_);
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, utils.getType(at));
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, utils.getType(c1_));
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, utils.getType(a2));
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, utils.getType(ins_));
    assertEquals(DataType.TYPE_BOOLEAN, utils.getType(at_));
    assertEquals(DataType.TYPE_STRING, utils.getType(c1));
    assertEquals(DataType.TYPE_STRING, utils.getType(a));
    assertEquals(DataType.TYPE_STRING, utils.getType(ins));
    assertEquals(DataType.TYPE_STRING, utils.getType(c2));
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) Path(org.uberfire.backend.vfs.Path) ColumnUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ModuleDataModelOracle(org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) Test(org.junit.Test)

Example 32 with ActionInsertFactCol52

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

the class ActionInsertFactWrapperTest method testCloneAnActionInsert.

@Test
public void testCloneAnActionInsert() throws Exception {
    doReturn(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY).when(model).getTableFormat();
    final ActionInsertFactCol52 column = new ActionInsertFactCol52();
    column.setFactField("factField");
    column.setBoundName("boundName");
    column.setValueList("valueList");
    column.setHeader("header");
    column.setInsertLogical(false);
    column.setDefaultValue(new DTCellValue52("defaultValue"));
    column.setFactType("factType");
    column.setHideColumn(false);
    column.setType("type");
    final ActionInsertFactWrapper wrapper = new ActionInsertFactWrapper(plugin, column);
    final ActionInsertFactCol52 clone = wrapper.getActionCol52();
    assertEquals("factField", column.getFactField());
    assertEquals("boundName", column.getBoundName());
    assertEquals("valueList", column.getValueList());
    assertEquals("header", column.getHeader());
    assertEquals(false, column.isInsertLogical());
    assertEquals(new DTCellValue52("defaultValue"), column.getDefaultValue());
    assertEquals("factType", column.getFactType());
    assertEquals(false, column.isHideColumn());
    assertEquals("type", column.getType());
    assertNotSame(column, clone);
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 33 with ActionInsertFactCol52

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

the class ActionInsertFactFieldsPageViewImplTest method testSetFieldSelectionModel.

@Test
public void testSetFieldSelectionModel() throws Exception {
    verify(view.chosenFieldsContainer).add(chosenFieldsWidgetCaptor.capture());
    fieldSelectionModel = (MultiSelectionModel<ActionInsertFactCol52>) chosenFieldsWidgetCaptor.getValue().getSelectionModel();
    insertFactCol52 = new ActionInsertFactCol52();
    insertFactCol52.setType("Applicant");
    insertFactCol52.setFactField("age");
    insertFactCol52.setType("Integer");
    fieldSelectionModel.setSelected(insertFactCol52, true);
    assertTrue(fieldSelectionModel.isSelected(insertFactCol52));
    insertFactCol52.setDefaultValue(new DTCellValue52(18));
    assertTrue(fieldSelectionModel.isSelected(insertFactCol52));
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Test(org.junit.Test)

Example 34 with ActionInsertFactCol52

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

the class ColumnDefinitionFactoryTest method knownColumnType_ActionInsertFactCol52.

@Test
@SuppressWarnings("unchecked")
public void knownColumnType_ActionInsertFactCol52() {
    final BaseColumn column = new ActionInsertFactCol52();
    final Callback<String> callback = mock(Callback.class);
    columnDefinitionFactory.generateColumnDefinition(dtPresenter, column, callback);
    verify(actionInsertFactCol52DefinitionBuilder, times(1)).generateDefinition(eq(dtPresenter), eq(column), any(Callback.class));
    verify(callback, times(1)).callback(any(String.class));
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) Callback(org.uberfire.client.callbacks.Callback) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Test(org.junit.Test)

Example 35 with ActionInsertFactCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52 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

ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)105 Test (org.junit.Test)74 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)43 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)40 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)39 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)38 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)32 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)24 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)20 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)20 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)20 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)20 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)20 Path (org.uberfire.backend.vfs.Path)20 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)19 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)19 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)15 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)14 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)13 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)13