Search in sources :

Example 31 with ActionSetFieldCol52

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

the class GridWidgetColumnFactoryImplTest method columnResizingListenerSetup_ActionSetFieldColumn.

@Test
public void columnResizingListenerSetup_ActionSetFieldColumn() {
    final Pattern52 pattern = mock(Pattern52.class);
    final ActionSetFieldCol52 column = new ActionSetFieldCol52();
    column.setFactField("MyField");
    column.setHeader("MyColumn");
    column.setBoundName("$f");
    when(model.getConditions()).thenReturn(new ArrayList<CompositeColumn<? extends BaseColumn>>() {

        {
            add(pattern);
        }
    });
    when(pattern.getFactType()).thenReturn("MyFact");
    when(pattern.getBoundName()).thenReturn("$f");
    when(pattern.isBound()).thenReturn(true);
    when(oracle.getFieldType("MyFact", "MyField")).thenReturn(DataType.TYPE_STRING);
    final GridColumn<?> uiColumn = factory.convertColumn(column, access, gridWidget);
    assertTrue(uiColumn instanceof BaseUiColumn);
    assertEquals((int) uiColumn.getWidth(), column.getWidth());
    uiColumn.setWidth(200.0);
    assertEquals(200, column.getWidth());
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BaseUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BaseUiColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Example 32 with ActionSetFieldCol52

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

the class ActionSetFieldColumnSynchronizerTest method testAppend.

@Test
public void testAppend() throws VetoException {
    // Add a Pattern to be updated
    final Pattern52 pattern = new Pattern52();
    pattern.setBoundName("$a");
    pattern.setFactType("Applicant");
    final ConditionCol52 condition = new ConditionCol52();
    condition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    condition.setHeader("col1");
    condition.setFactField("age");
    condition.setOperator("==");
    modelSynchronizer.appendColumn(pattern, condition);
    final ActionSetFieldCol52 column = new ActionSetFieldCol52();
    column.setHeader("col1");
    column.setBoundName("$a");
    column.setFactField("age");
    modelSynchronizer.appendColumn(column);
    assertEquals(1, model.getConditions().size());
    assertEquals(1, model.getActionCols().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof IntegerUiColumn);
    assertEquals(true, ((BaseSingletonDOMElementUiColumn) uiModel.getColumns().get(2)).isEditable());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) Test(org.junit.Test)

Example 33 with ActionSetFieldCol52

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

the class ActionSetFieldColumnSynchronizerTest method testMoveColumnTo_MoveLeft.

@Test
public void testMoveColumnTo_MoveLeft() throws VetoException {
    // Add a Pattern to be updated
    final Pattern52 pattern = new Pattern52();
    pattern.setBoundName("$a");
    pattern.setFactType("Applicant");
    final ConditionCol52 condition = new ConditionCol52();
    condition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    condition.setHeader("col1");
    condition.setFactField("age");
    condition.setOperator("==");
    modelSynchronizer.appendColumn(pattern, condition);
    final ActionSetFieldCol52 column1 = new ActionSetFieldCol52();
    column1.setBoundName("$a");
    column1.setFactField("age");
    column1.setHeader("age");
    final ActionSetFieldCol52 column2 = new ActionSetFieldCol52();
    column2.setBoundName("$a");
    column2.setFactField("name");
    column2.setHeader("name");
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 3, new BaseGridCellValue<Integer>(45));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<String>("Smurf"));
    assertEquals(2, model.getActionCols().size());
    assertEquals(column1, model.getActionCols().get(0));
    assertEquals(column2, model.getActionCols().get(1));
    assertEquals(45, model.getData().get(0).get(3).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(4).getStringValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(4);
    assertEquals("$a", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
    assertEquals("age", uiModelColumn1_1.getHeaderMetaData().get(1).getTitle());
    assertEquals("$a", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn2_1.getHeaderMetaData().get(1).getTitle());
    assertTrue(uiModelColumn1_1 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
    assertEquals(3, uiModelColumn1_1.getIndex());
    assertEquals(4, uiModelColumn2_1.getIndex());
    assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
    assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
    uiModel.moveColumnTo(3, uiModelColumn2_1);
    assertEquals(2, model.getActionCols().size());
    assertEquals(column2, model.getActionCols().get(0));
    assertEquals(column1, model.getActionCols().get(1));
    assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
    assertEquals(45, model.getData().get(0).get(4).getNumericValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(4);
    assertEquals("$a", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn1_2.getHeaderMetaData().get(1).getTitle());
    assertEquals("$a", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("age", uiModelColumn2_2.getHeaderMetaData().get(1).getTitle());
    assertTrue(uiModelColumn1_2 instanceof StringUiColumn);
    assertTrue(uiModelColumn2_2 instanceof IntegerUiColumn);
    assertEquals(4, uiModelColumn1_2.getIndex());
    assertEquals(3, uiModelColumn2_2.getIndex());
    assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) Test(org.junit.Test)

Example 34 with ActionSetFieldCol52

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

the class ActionSetFieldColumnSynchronizerTest method testAppendBoolean.

@Test
public void testAppendBoolean() throws VetoException {
    // Add a Pattern to be updated
    final Pattern52 pattern = new Pattern52();
    pattern.setBoundName("$a");
    pattern.setFactType("Applicant");
    final ConditionCol52 condition = new ConditionCol52();
    condition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    condition.setHeader("col1");
    condition.setFactField("age");
    condition.setOperator("==");
    // Test column append
    modelSynchronizer.appendColumn(pattern, condition);
    final ActionSetFieldCol52 column = new ActionSetFieldCol52();
    column.setHeader("col1");
    column.setBoundName("$a");
    column.setFactField("approved");
    modelSynchronizer.appendColumn(column);
    assertEquals(1, model.getConditions().size());
    assertEquals(1, model.getActionCols().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof BooleanUiColumn);
    assertEquals(true, ((BaseSingletonDOMElementUiColumn) uiModel.getColumns().get(2)).isEditable());
    // Test row append (boolean cells should be instantiated for Model and UiModel)
    modelSynchronizer.appendRow();
    assertFalse(model.getData().get(0).get(3).getBooleanValue());
    assertFalse(((Boolean) uiModel.getRow(0).getCells().get(3).getValue().getValue()));
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) Test(org.junit.Test)

Example 35 with ActionSetFieldCol52

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

the class ActionSetFieldColumnSynchronizerTest method testDelete.

@Test
public void testDelete() throws VetoException {
    // Add a Pattern to be updated
    final Pattern52 pattern = new Pattern52();
    pattern.setBoundName("$a");
    pattern.setFactType("Applicant");
    final ConditionCol52 condition = new ConditionCol52();
    condition.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    condition.setHeader("col1");
    condition.setFactField("age");
    condition.setOperator("==");
    modelSynchronizer.appendColumn(pattern, condition);
    final ActionSetFieldCol52 column = new ActionSetFieldCol52();
    column.setHeader("col1");
    column.setBoundName("$a");
    column.setFactField("age");
    modelSynchronizer.appendColumn(column);
    assertEquals(1, model.getConditions().size());
    assertEquals(1, model.getActionCols().size());
    assertEquals(4, uiModel.getColumns().size());
    modelSynchronizer.deleteColumn(column);
    assertEquals(1, model.getConditions().size());
    assertEquals(0, model.getActionCols().size());
    assertEquals(3, uiModel.getColumns().size());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) Test(org.junit.Test)

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