use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.gwt.BoundFactsChangedEvent in project drools-wb by kiegroup.
the class ConditionColumnSynchronizer method append.
@Override
public void append(final PatternConditionMetaData metaData) throws VetoException {
// Check operation is supported
if (!handlesAppend(metaData)) {
return;
}
final Pattern52 pattern = metaData.getPattern();
final ConditionCol52 column = (ConditionCol52) metaData.getColumn();
// Add pattern if it does not already exist
if (!model.getConditions().contains(pattern)) {
model.getConditions().add(pattern);
// Signal patterns changed event
final BoundFactsChangedEvent bfce = new BoundFactsChangedEvent(rm.getLHSBoundFacts());
eventBus.fireEvent(bfce);
}
pattern.getChildColumns().add(column);
synchroniseAppendColumn(column);
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.gwt.BoundFactsChangedEvent in project drools-wb by kiegroup.
the class ConditionColumnSynchronizer method delete.
@Override
public void delete(final ColumnMetaData metaData) throws VetoException {
// Check operation is supported
if (!handlesDelete(metaData)) {
return;
}
final ConditionCol52 column = (ConditionCol52) metaData.getColumn();
final int columnIndex = model.getExpandedColumns().indexOf(column);
final Pattern52 pattern = model.getPattern(column);
// Check if pattern change can be applied to model
if (!isPotentialConditionDeletionSafe(column)) {
throw new VetoDeletePatternInUseException();
}
if (!isPotentialPatternDeletionSafe(pattern)) {
throw new VetoDeletePatternInUseException();
}
// Perform deletion
pattern.getChildColumns().remove(column);
// Remove pattern if it contains zero conditions
if (pattern.getChildColumns().isEmpty()) {
model.getConditions().remove(pattern);
// Signal patterns changed event to Decision Table Widget
final BoundFactsChangedEvent bfce = new BoundFactsChangedEvent(rm.getLHSBoundFacts());
eventBus.fireEvent(bfce);
}
synchroniseDeleteColumn(columnIndex);
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.events.gwt.BoundFactsChangedEvent 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;
}
Aggregations