use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class BRLConditionColumnSynchronizer 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();
}
// Check whether any discarded bindings were used. If so veto the update.
final BRLConditionColumn originalColumn = (BRLConditionColumn) originalMetaData.getColumn();
final BRLConditionColumn editedColumn = (BRLConditionColumn) editedMetaData.getColumn();
final Set<String> originalBindings = getPatternBindings(originalColumn);
final Set<String> editedBindings = getPatternBindings(editedColumn);
originalBindings.removeAll(editedBindings);
for (String binding : originalBindings) {
if (rm.isBoundFactUsed(binding)) {
throw new VetoUpdatePatternInUseException();
}
}
final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
// Copy existing data for re-use if applicable
final Map<String, List<DTCellValue52>> originalColumnsData = new HashMap<>();
for (BRLConditionVariableColumn variable : originalColumn.getChildColumns()) {
int iColumnIndex = model.getExpandedColumns().indexOf(variable);
final List<DTCellValue52> originalColumnData = new ArrayList<>();
final String key = makeUpdateBRLConditionColumnKey(variable);
for (List<DTCellValue52> row : model.getData()) {
originalColumnData.add(row.get(iColumnIndex));
}
originalColumnsData.put(key, originalColumnData);
}
// Insert new columns setting data from that above, if applicable. Column visibility is handled here too.
model.getConditions().add(model.getConditions().indexOf(originalColumn), editedColumn);
for (BRLConditionVariableColumn childModelColumn : editedColumn.getChildColumns()) {
final String key = makeUpdateBRLConditionColumnKey(childModelColumn);
if (originalColumnsData.containsKey(key)) {
final List<DTCellValue52> originalColumnData = originalColumnsData.get(key);
synchroniseAppendColumn(childModelColumn, originalColumnData);
} else {
synchroniseAppendColumn(childModelColumn);
}
}
// Delete columns for the original definition
doDelete(originalColumn);
// Signal patterns changed event to Decision Table Widget
final BoundFactsChangedEvent pce = new BoundFactsChangedEvent(rm.getLHSBoundFacts());
eventBus.fireEvent(pce);
return diffs;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff in project drools-wb by kiegroup.
the class LimitedEntryBRLActionColumnSynchronizer 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 LimitedEntryBRLActionColumn originalColumn = (LimitedEntryBRLActionColumn) originalMetaData.getColumn();
final LimitedEntryBRLActionColumn editedColumn = (LimitedEntryBRLActionColumn) editedMetaData.getColumn();
final List<BaseColumnFieldDiff> diffs = originalColumn.diff(editedColumn);
update(originalColumn, editedColumn);
// LimitedEntry columns are always represented with a BooleanUiColumn
final boolean isHideUpdated = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_HIDE_COLUMN, diffs);
final boolean isHeaderUpdated = BaseColumnFieldDiffImpl.hasChanged(ConditionCol52.FIELD_HIDE_COLUMN, 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 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;
}
Aggregations