use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class MetaDataColumnSynchronizer method update.
@Override
public List<BaseColumnFieldDiff> update(final BaseColumnSynchronizer.ColumnMetaData originalMetaData, final BaseColumnSynchronizer.ColumnMetaData editedMetaData) throws VetoException {
// Check operation is supported
if (!(handlesUpdate(originalMetaData) && handlesUpdate(editedMetaData))) {
return Collections.emptyList();
}
final MetadataCol52 originalColumn = (MetadataCol52) originalMetaData.getColumn();
final MetadataCol52 editedColumn = (MetadataCol52) editedMetaData.getColumn();
final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
update(originalColumn, editedColumn);
final boolean isMetaDataUpdated = BaseColumnFieldDiffImpl.hasChanged(MetadataCol52.FIELD_METADATA, diffs);
final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(DTColumnConfig52.FIELD_HIDE_COLUMN, diffs);
if (isMetaDataUpdated) {
setColumnHeader(originalColumn, originalColumn.getMetadata());
}
if (isHideUpdated) {
setColumnVisibility(originalColumn, originalColumn.isHideColumn());
}
return diffs;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ActionRetractFactColumnSynchronizer 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 ActionRetractFactCol52 originalColumn = (ActionRetractFactCol52) originalMetaData.getColumn();
final ActionRetractFactCol52 editedColumn = (ActionRetractFactCol52) editedMetaData.getColumn();
final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
update(originalColumn, editedColumn);
final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionRetractFactCol52.FIELD_HIDE_COLUMN, diffs);
final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionRetractFactCol52.FIELD_HEADER, diffs);
synchroniseUpdateColumn(originalColumn);
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 ActionWorkItemExecuteColumnSynchronizer 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 ActionWorkItemCol52 originalColumn = (ActionWorkItemCol52) originalMetaData.getColumn();
final ActionWorkItemCol52 editedColumn = (ActionWorkItemCol52) 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(ActionWorkItemCol52.FIELD_HIDE_COLUMN, diffs);
final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ActionWorkItemCol52.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 BRLConditionColumnSynchronizerTest method testUpdate3.
@Test
public void testUpdate3() throws VetoException {
// Single Column, multiple variables
final BRLConditionColumn column = spy(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(5, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(5, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof IntegerUiColumn);
assertTrue(uiModel.getColumns().get(4) instanceof StringUiColumn);
assertEquals("$age", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
final BRLConditionColumn edited = new BRLConditionColumn();
final BRLConditionVariableColumn editedColumnV0 = new BRLConditionVariableColumn("$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(4, model.getExpandedColumns().size());
assertEquals(1, model.getConditions().size());
assertEquals(4, uiModel.getColumns().size());
assertTrue(uiModel.getColumns().get(3) instanceof LongUiColumn);
assertEquals("updated", uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
assertEquals(false, uiModel.getColumns().get(3).isVisible());
assertEquals("$s", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class ActionWorkItemExecuteColumnSynchronizerTest method testUpdate.
@Test
public void testUpdate() throws VetoException {
final ActionWorkItemCol52 column = spy(new ActionWorkItemCol52());
column.setHeader("col1");
modelSynchronizer.appendColumn(column);
final ActionWorkItemCol52 edited = new ActionWorkItemCol52();
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(1, 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