Search in sources :

Example 36 with IntegerUiColumn

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

the class AttributeColumnSynchronizerTest method testMoveColumnTo_MoveLeft.

@Test
public void testMoveColumnTo_MoveLeft() throws VetoException {
    final AttributeCol52 column1 = new AttributeCol52();
    column1.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    final AttributeCol52 column2 = new AttributeCol52();
    column2.setAttribute(RuleAttributeWidget.AGENDA_GROUP_ATTR);
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 2, new BaseGridCellValue<Integer>(1));
    uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("smurf"));
    assertEquals(2, model.getAttributeCols().size());
    assertEquals(column1, model.getAttributeCols().get(0));
    assertEquals(column2, model.getAttributeCols().get(1));
    assertEquals(1, 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(RuleAttributeWidget.SALIENCE_ATTR, uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
    assertEquals(RuleAttributeWidget.AGENDA_GROUP_ATTR, uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_1 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
    assertEquals(2, uiModelColumn1_1.getIndex());
    assertEquals(3, uiModelColumn2_1.getIndex());
    assertEquals(1, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
    assertEquals("smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
    uiModel.moveColumnTo(2, uiModelColumn2_1);
    assertEquals(2, model.getAttributeCols().size());
    assertEquals(column2, model.getAttributeCols().get(0));
    assertEquals(column1, model.getAttributeCols().get(1));
    assertEquals("smurf", model.getData().get(0).get(2).getStringValue());
    assertEquals(1, model.getData().get(0).get(3).getNumericValue());
    assertEquals(4, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
    assertEquals(RuleAttributeWidget.AGENDA_GROUP_ATTR, uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_2 instanceof StringUiColumn);
    assertTrue(uiModelColumn2_2 instanceof IntegerUiColumn);
    assertEquals(3, uiModelColumn1_2.getIndex());
    assertEquals(2, uiModelColumn2_2.getIndex());
    assertEquals("smurf", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals(1, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) 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 37 with IntegerUiColumn

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

the class AttributeColumnSynchronizerTest method testUpdate2.

@Test
public void testUpdate2() throws VetoException {
    final AttributeCol52 column = spy(new AttributeCol52());
    column.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    modelSynchronizer.appendColumn(column);
    final AttributeCol52 edited = new AttributeCol52();
    edited.setWidth(column.getWidth());
    edited.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    edited.setHideColumn(true);
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
    assertEquals(1, diffs.size());
    verify(column).diff(edited);
    assertEquals(1, model.getAttributeCols().size());
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, model.getAttributeCols().get(0).getAttribute());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    assertEquals(false, uiModel.getColumns().get(2).isVisible());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) Test(org.junit.Test)

Example 38 with IntegerUiColumn

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

the class AttributeColumnSynchronizerTest method testMoveColumnTo_MoveRight.

@Test
public void testMoveColumnTo_MoveRight() throws VetoException {
    final AttributeCol52 column1 = new AttributeCol52();
    column1.setAttribute(RuleAttributeWidget.SALIENCE_ATTR);
    final AttributeCol52 column2 = new AttributeCol52();
    column2.setAttribute(RuleAttributeWidget.AGENDA_GROUP_ATTR);
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 2, new BaseGridCellValue<Integer>(1));
    uiModel.setCellValue(0, 3, new BaseGridCellValue<String>("smurf"));
    assertEquals(2, model.getAttributeCols().size());
    assertEquals(column1, model.getAttributeCols().get(0));
    assertEquals(column2, model.getAttributeCols().get(1));
    assertEquals(1, 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(RuleAttributeWidget.SALIENCE_ATTR, uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
    assertEquals(RuleAttributeWidget.AGENDA_GROUP_ATTR, uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_1 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
    assertEquals(2, uiModelColumn1_1.getIndex());
    assertEquals(3, uiModelColumn2_1.getIndex());
    assertEquals(1, 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, uiModelColumn1_1);
    assertEquals(2, model.getAttributeCols().size());
    assertEquals(column2, model.getAttributeCols().get(0));
    assertEquals(column1, model.getAttributeCols().get(1));
    assertEquals("smurf", model.getData().get(0).get(2).getStringValue());
    assertEquals(1, model.getData().get(0).get(3).getNumericValue());
    assertEquals(4, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
    assertEquals(RuleAttributeWidget.AGENDA_GROUP_ATTR, uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals(RuleAttributeWidget.SALIENCE_ATTR, uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_2 instanceof StringUiColumn);
    assertTrue(uiModelColumn2_2 instanceof IntegerUiColumn);
    assertEquals(3, uiModelColumn1_2.getIndex());
    assertEquals(2, uiModelColumn2_2.getIndex());
    assertEquals("smurf", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals(1, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) 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 39 with IntegerUiColumn

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

the class BRLConditionColumnSynchronizerTest method testAppend2.

@Test
public void testAppend2() throws VetoException {
    // Single Column, multiple variables
    final BRLConditionColumn column = new BRLConditionColumn();
    final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    final BRLConditionVariableColumn columnV1 = new BRLConditionVariableColumn("$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.getConditions().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
    assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
    assertEquals(2, uiModel.getColumns().get(2).getHeaderMetaData().size());
    assertEquals("$age", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
    assertEquals(2, uiModel.getColumns().get(3).getHeaderMetaData().size());
    assertEquals("$name", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) Test(org.junit.Test)

Example 40 with IntegerUiColumn

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

the class BRLConditionColumnSynchronizerTest method testMovePatternAfter.

@Test
public void testMovePatternAfter() throws VetoException {
    final Pattern52 column1 = new Pattern52();
    column1.setFactType("Address");
    final ConditionCol52 column1v0 = new ConditionCol52();
    column1v0.setBinding("$country");
    column1v0.setFactField("country");
    column1v0.setFieldType(DataType.TYPE_STRING);
    column1v0.setHeader("country");
    final CompositeColumn<BRLConditionVariableColumn> column2 = new BRLConditionColumn();
    final BRLConditionVariableColumn column2v0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    column2v0.setHeader("age");
    final BRLConditionVariableColumn column2v1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
    column2v1.setHeader("name");
    column2.getChildColumns().add(column2v0);
    column2.getChildColumns().add(column2v1);
    modelSynchronizer.appendColumn(column1, column1v0);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 2, new BaseGridCellValue<>("Canada"));
    uiModel.setCellValue(0, 3, new BaseGridCellValue<>(55));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<>("Smurf"));
    assertEquals(2, model.getConditions().size());
    assertEquals(column1, model.getConditions().get(0));
    assertEquals(column2, model.getConditions().get(1));
    assertEquals("Canada", model.getData().get(0).get(2).getStringValue());
    assertEquals(55, 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(2);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn3_1 = uiModel.getColumns().get(4);
    assertEquals("Address", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
    assertEquals("age", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn3_1.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_1 instanceof StringUiColumn);
    assertTrue(uiModelColumn2_1 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn3_1 instanceof StringUiColumn);
    assertEquals(2, uiModelColumn1_1.getIndex());
    assertEquals(3, uiModelColumn2_1.getIndex());
    assertEquals(4, uiModelColumn3_1.getIndex());
    assertEquals("Canada", uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
    assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
    assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn3_1.getIndex()).getValue().getValue());
    uiModel.moveColumnTo(4, uiModelColumn1_1);
    assertEquals(2, model.getConditions().size());
    assertEquals(column2, model.getConditions().get(0));
    assertEquals(column1, model.getConditions().get(1));
    assertEquals(55, model.getData().get(0).get(2).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
    assertEquals("Canada", model.getData().get(0).get(4).getStringValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn3_2 = uiModel.getColumns().get(4);
    assertEquals("age", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("Address", uiModelColumn3_2.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_2 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn2_2 instanceof StringUiColumn);
    assertTrue(uiModelColumn3_2 instanceof StringUiColumn);
    assertEquals(3, uiModelColumn1_2.getIndex());
    assertEquals(4, uiModelColumn2_2.getIndex());
    assertEquals(2, uiModelColumn3_2.getIndex());
    assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
    assertEquals("Canada", uiModel.getRow(0).getCells().get(uiModelColumn3_2.getIndex()).getValue().getValue());
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) 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) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) Test(org.junit.Test)

Aggregations

IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)48 Test (org.junit.Test)48 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)39 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)24 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)24 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)10 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)9 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)9 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)9 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)9 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)7 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)6 AttributeCol52 (org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52)5 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)4 LongUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.LongUiColumn)2