use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldColumnSynchronizer method update.
@Override
public List<BaseColumnFieldDiff> update(final ColumnMetaData originalMetaData, final ColumnMetaData editedMetaData) throws VetoException {
// Check operation is supported
if (!(handlesUpdate(originalMetaData) && handlesUpdate(editedMetaData))) {
return Collections.emptyList();
}
// Get differences between original and edited column
final ActionWorkItemSetFieldCol52 originalColumn = (ActionWorkItemSetFieldCol52) originalMetaData.getColumn();
final ActionWorkItemSetFieldCol52 editedColumn = (ActionWorkItemSetFieldCol52) editedMetaData.getColumn();
final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
update(originalColumn, editedColumn);
// ActionWorkItem columns are always represented with a BooleanUiColumn
final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionWorkItemSetFieldCol52.FIELD_HIDE_COLUMN, diffs);
final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionWorkItemSetFieldCol52.FIELD_HEADER, diffs);
if (isHideUpdated) {
setColumnVisibility(originalColumn, originalColumn.isHideColumn());
}
if (isHeaderUpdated) {
setColumnHeader(originalColumn, originalColumn.getHeader());
}
return diffs;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldColumnSynchronizerTest method testUpdate.
@Test
public void testUpdate() throws VetoException {
final ActionWorkItemSetFieldCol52 column = spy(new ActionWorkItemSetFieldCol52());
column.setWorkItemName(WORK_ITEM_NAME);
column.setHeader("col1");
modelSynchronizer.appendColumn(column);
final ActionWorkItemSetFieldCol52 edited = new ActionWorkItemSetFieldCol52();
edited.setWorkItemName(WORK_ITEM_NAME);
edited.setWidth(column.getWidth());
edited.setHideColumn(true);
edited.setHeader("updated");
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
assertEquals(2, diffs.size());
verify(column).diff(edited);
assertEquals(2, model.getActionCols().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof BooleanUiColumn);
assertEquals("updated", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
assertEquals(false, uiModel.getColumns().get(3).isVisible());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class BRLActionColumnSynchronizerTest method testUpdate3.
@Test
public void testUpdate3() throws VetoException {
// Single Column, multiple variables
final BRLActionColumn column = spy(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);
final BRLActionColumn edited = new BRLActionColumn();
final BRLActionVariableColumn editedColumnV0 = new BRLActionVariableColumn("$s", DataType.TYPE_NUMERIC_LONG, "Applicant", "salary");
edited.getChildColumns().add(editedColumnV0);
edited.setHideColumn(true);
edited.setHeader("updated");
editedColumnV0.setHeader("updated");
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
assertEquals(6, // header, hide, field name, field type, binding, removed column
diffs.size());
verify(column).diff(edited);
assertEquals(3, model.getExpandedColumns().size());
assertEquals(1, model.getActionCols().size());
assertEquals(3, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(2) instanceof LongUiColumn);
assertEquals("updated", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
assertEquals("$s", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
assertEquals(false, uiModel.getColumns().get(2).isVisible());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ActionSetFieldColumnSynchronizerTest method testUpdate.
@Test
public void testUpdate() 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 = spy(new ActionSetFieldCol52());
column.setHeader("col1");
column.setBoundName("$a");
column.setFactField("age");
modelSynchronizer.appendColumn(column);
final ActionSetFieldCol52 edited = new ActionSetFieldCol52();
edited.setWidth(column.getWidth());
edited.setBoundName("$a");
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.getConditions().size());
assertEquals(1, model.getActionCols().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
assertEquals("updated", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
assertEquals(false, uiModel.getColumns().get(3).isVisible());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ActionWorkItemInsertFactColumnSynchronizerTest method testUpdate.
@Test
public void testUpdate() throws VetoException {
final ActionWorkItemInsertFactCol52 column = spy(new ActionWorkItemInsertFactCol52());
column.setWorkItemName(WORK_ITEM_NAME);
column.setHeader("col1");
modelSynchronizer.appendColumn(column);
final ActionWorkItemInsertFactCol52 edited = new ActionWorkItemInsertFactCol52();
edited.setWorkItemName(WORK_ITEM_NAME);
edited.setWidth(column.getWidth());
edited.setHideColumn(true);
edited.setHeader("updated");
List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
assertEquals(2, diffs.size());
verify(column).diff(edited);
assertEquals(2, model.getActionCols().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof BooleanUiColumn);
assertEquals("updated", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
assertEquals(false, uiModel.getColumns().get(3).isVisible());
}
Aggregations