Search in sources :

Example 21 with StringUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn in project drools-wb by kiegroup.

the class BRLActionColumnSynchronizerTest method testAppend2.

@Test
public void testAppend2() throws VetoException {
    // Single Column, multiple variables
    final BRLActionColumn column = new BRLActionColumn();
    final BRLActionVariableColumn columnV0 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    final BRLActionVariableColumn columnV1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
    column.getChildColumns().add(columnV0);
    column.getChildColumns().add(columnV1);
    column.setHeader("col1");
    columnV0.setHeader("col1v0");
    columnV1.setHeader("col1v1");
    modelSynchronizer.appendColumn(column);
    assertEquals(4, model.getExpandedColumns().size());
    assertEquals(1, model.getActionCols().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
    assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
    assertEquals("col1v0", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    assertEquals("$age", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
    assertEquals("col1v1", uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
    assertEquals("$name", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Example 22 with StringUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn in project drools-wb by kiegroup.

the class ActionInsertFactColumnSynchronizerTest method testUpdate.

@Test
public void testUpdate() throws VetoException {
    final ActionInsertFactCol52 column = spy(new ActionInsertFactCol52());
    column.setHeader("col1");
    column.setBoundName("$a");
    column.setFactType("Applicant");
    column.setFactField("age");
    modelSynchronizer.appendColumn(column);
    final ActionInsertFactCol52 edited = new ActionInsertFactCol52();
    edited.setWidth(column.getWidth());
    edited.setBoundName("$a");
    edited.setFactType("Applicant");
    edited.setFactField("name");
    edited.setHideColumn(true);
    edited.setHeader("updated");
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
    assertEquals(3, diffs.size());
    verify(column).diff(edited);
    assertEquals(1, model.getActionCols().size());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof StringUiColumn);
    assertEquals("updated", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
    assertEquals(false, uiModel.getColumns().get(2).isVisible());
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) Test(org.junit.Test)

Example 23 with StringUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn in project drools-wb by kiegroup.

the class ActionInsertFactColumnSynchronizerTest method testMoveColumnTo_OutOfBounds.

@Test
public void testMoveColumnTo_OutOfBounds() throws VetoException {
    final ActionInsertFactCol52 column1 = new ActionInsertFactCol52();
    column1.setBoundName("$a");
    column1.setFactType("Applicant");
    column1.setFactField("age");
    column1.setHeader("age");
    final ActionInsertFactCol52 column2 = new ActionInsertFactCol52();
    column2.setBoundName("$a");
    column2.setFactType("Applicant");
    column2.setFactField("name");
    column2.setHeader("name");
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 2, new BaseGridCellValue<Integer>(45));
    uiModel.setCellValue(0, 3, 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(2).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
    assertEquals(4, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(2);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
    assertEquals("$a : Applicant", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
    assertEquals("age", uiModelColumn1_1.getHeaderMetaData().get(1).getTitle());
    assertEquals("$a : Applicant", 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(2, uiModelColumn1_1.getIndex());
    assertEquals(3, 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(0, uiModelColumn1_1);
    assertEquals(2, model.getActionCols().size());
    assertEquals(column1, model.getActionCols().get(0));
    assertEquals(column2, model.getActionCols().get(1));
    assertEquals(45, model.getData().get(0).get(2).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
    assertEquals(4, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
    assertEquals("$a : Applicant", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("age", uiModelColumn1_2.getHeaderMetaData().get(1).getTitle());
    assertEquals("$a : Applicant", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn2_2.getHeaderMetaData().get(1).getTitle());
    assertTrue(uiModelColumn1_2 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn2_2 instanceof StringUiColumn);
    assertEquals(2, uiModelColumn1_2.getIndex());
    assertEquals(3, uiModelColumn2_2.getIndex());
    assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Example 24 with StringUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn 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 25 with StringUiColumn

use of org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn in project drools-wb by kiegroup.

the class ActionSetFieldColumnSynchronizerTest method testMoveColumnTo_OutOfBounds.

@Test
public void testMoveColumnTo_OutOfBounds() 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(0, uiModelColumn1_1);
    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_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(4);
    assertEquals("$a", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("age", uiModelColumn1_2.getHeaderMetaData().get(1).getTitle());
    assertEquals("$a", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn2_2.getHeaderMetaData().get(1).getTitle());
    assertTrue(uiModelColumn1_2 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn2_2 instanceof StringUiColumn);
    assertEquals(3, uiModelColumn1_2.getIndex());
    assertEquals(4, uiModelColumn2_2.getIndex());
    assertEquals(45, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals("Smurf", 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)

Aggregations

StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)49 Test (org.junit.Test)49 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)39 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)25 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)25 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)13 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)8 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)8 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)8 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)8 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)7 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)6 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)4 MetadataCol52 (org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52)4 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)3 LongUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.LongUiColumn)2 GuidedDecisionTableView (org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView)1