use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method checkConditionCannotBeDeletedWhenFieldBindingIsUsedInAction.
@Test
public void checkConditionCannotBeDeletedWhenFieldBindingIsUsedInAction() throws VetoException {
final Pattern52 pattern = boundApplicantPattern("$a");
final ConditionCol52 condition = ageEqualsCondition();
condition.setBinding("$age");
final BRLActionColumn action = actionCallMethod("$age");
modelSynchronizer.appendColumn(pattern, condition);
modelSynchronizer.appendColumn(action);
try {
modelSynchronizer.deleteColumn(condition);
fail("Deletion of the column should have been vetoed.");
} catch (VetoDeletePatternInUseException veto) {
// This is expected
} catch (VetoException veto) {
fail("VetoDeletePatternInUseException was expected.");
}
assertEquals(5, model.getExpandedColumns().size());
assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
assertTrue(model.getExpandedColumns().get(1) instanceof RuleNameColumn);
assertTrue(model.getExpandedColumns().get(2) instanceof DescriptionCol52);
assertEquals(condition, model.getExpandedColumns().get(3));
assertEquals(action.getChildColumns().get(0), model.getExpandedColumns().get(4));
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method checkConditionCanBeDeletedWithMultipleChildColumns.
@Test
public void checkConditionCanBeDeletedWithMultipleChildColumns() throws VetoException {
final Pattern52 pattern = boundApplicantPattern("$a");
final ConditionCol52 condition1 = ageEqualsCondition();
final ConditionCol52 condition2 = nameEqualsCondition();
modelSynchronizer.appendColumn(pattern, condition1);
modelSynchronizer.appendColumn(pattern, condition2);
try {
modelSynchronizer.deleteColumn(condition2);
} catch (VetoException veto) {
fail("Deletion should have been permitted.");
}
assertEquals(4, model.getExpandedColumns().size());
assertTrue(model.getExpandedColumns().get(0) instanceof RowNumberCol52);
assertTrue(model.getExpandedColumns().get(1) instanceof RuleNameColumn);
assertTrue(model.getExpandedColumns().get(2) instanceof DescriptionCol52);
assertEquals(condition1, model.getExpandedColumns().get(3));
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter method onAppendRow.
@Override
public void onAppendRow() {
if (isReadOnly()) {
return;
}
try {
synchronizer.appendRow();
lockManager.acquireLock();
refreshView();
// Log insertion of row
model.getAuditLog().add(new InsertRowAuditLogEntry(identity.getIdentifier(), model.getData().size() - 1));
} catch (VetoException e) {
getModellerPresenter().getView().showGenericVetoMessage();
}
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter method insertRow.
private void insertRow(final int rowIndex) {
try {
synchronizer.insertRow(rowIndex);
refreshView();
// Log insertion of row
model.getAuditLog().add(new InsertRowAuditLogEntry(identity.getIdentifier(), rowIndex));
} catch (VetoException e) {
getModellerPresenter().getView().showGenericVetoMessage();
}
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class GuidedDecisionTablePresenter method onDeleteSelectedColumns.
@Override
public void onDeleteSelectedColumns() {
if (isReadOnly()) {
return;
}
final Set<Integer> selectedColumnIndexes = getSelectedColumnIndexes();
final Set<BaseColumn> columnsToDelete = new HashSet<>();
for (int selectedColumnIndex : selectedColumnIndexes) {
final int columnIndex = findUiColumnIndex(selectedColumnIndex);
final BaseColumn column = model.getExpandedColumns().get(columnIndex);
if (!(column instanceof RowNumberCol52 || column instanceof DescriptionCol52 || column instanceof RuleNameColumn)) {
columnsToDelete.add(column);
}
}
for (BaseColumn columnToDelete : columnsToDelete) {
if (columnToDelete instanceof AttributeCol52) {
try {
deleteColumn((AttributeCol52) columnToDelete);
} catch (VetoException veto) {
getModellerPresenter().getView().showGenericVetoMessage();
}
} else if (columnToDelete instanceof MetadataCol52) {
try {
deleteColumn((MetadataCol52) columnToDelete);
} catch (VetoException veto) {
getModellerPresenter().getView().showGenericVetoMessage();
}
} else if (columnToDelete instanceof ConditionCol52) {
try {
deleteColumn((ConditionCol52) columnToDelete);
} catch (VetoException veto) {
getModellerPresenter().getView().showUnableToDeleteColumnMessage((ConditionCol52) columnsToDelete);
}
} else if (columnToDelete instanceof ActionCol52) {
try {
deleteColumn((ActionCol52) columnToDelete);
} catch (VetoException veto) {
getModellerPresenter().getView().showUnableToDeleteColumnMessage((ActionCol52) columnsToDelete);
}
}
}
}
Aggregations