use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class BRLConditionColumnSynchronizerTest method checkBRLFragmentConditionCannotBeUpdatedWhenFieldBindingIsUsedInAction.
@Test
public void checkBRLFragmentConditionCannotBeUpdatedWhenFieldBindingIsUsedInAction() throws VetoException {
final BRLConditionColumn column = new BRLConditionColumn();
column.setDefinition(Collections.singletonList(new FactPattern("Applicant") {
{
setBoundName("$a");
addConstraint(new SingleFieldConstraint("age") {
{
setBoundName("$age");
}
});
}
}));
final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
column.getChildColumns().add(columnV0);
column.setHeader("col1");
columnV0.setHeader("col1v0");
modelSynchronizer.appendColumn(column);
final BRLActionColumn action = new BRLActionColumn();
action.setDefinition(Collections.singletonList(new ActionCallMethod() {
{
setVariable("$age");
setMethodName("toString()");
}
}));
final BRLActionVariableColumn columnV1 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
action.getChildColumns().add(columnV1);
action.setHeader("col2");
columnV1.setHeader("col2v0");
modelSynchronizer.appendColumn(action);
try {
final BRLConditionColumn editedColumn = new BRLConditionColumn();
editedColumn.setDefinition(Collections.singletonList(new FactPattern("Applicant") {
{
setBoundName("$a");
addConstraint(new SingleFieldConstraint("age") {
{
setBoundName("$age2");
}
});
}
}));
final BRLConditionVariableColumn editedColumnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
editedColumn.getChildColumns().add(editedColumnV0);
editedColumn.setHeader("col1");
editedColumnV0.setHeader("col1v0");
modelSynchronizer.updateColumn(column, editedColumn);
fail("Deletion of the column should have been vetoed.");
} catch (VetoUpdatePatternInUseException veto) {
// This is expected
} catch (VetoException veto) {
fail("VetoUpdatePatternInUseException 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(columnV0, 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 BRLConditionColumnSynchronizerTest method checkBRLFragmentConditionCannotBeDeletedWithAction.
@Test
public void checkBRLFragmentConditionCannotBeDeletedWithAction() throws VetoException {
final BRLConditionColumn column = new BRLConditionColumn();
column.setDefinition(Collections.singletonList(new FactPattern("Applicant") {
{
setBoundName("$a");
}
}));
final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
column.getChildColumns().add(columnV0);
column.setHeader("col1");
columnV0.setHeader("col1v0");
modelSynchronizer.appendColumn(column);
final ActionSetFieldCol52 action = new ActionSetFieldCol52() {
{
setBoundName("$a");
setFactField("age");
setHeader("action1");
}
};
modelSynchronizer.appendColumn(action);
try {
modelSynchronizer.deleteColumn(column);
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(columnV0, model.getExpandedColumns().get(3));
assertEquals(action, 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 ColumnManagementView method renderColumn.
HorizontalPanel renderColumn(final ActionCol52 actionColumn) {
HorizontalPanel action = newHorizontalPanel();
final ColumnLabelWidget actionLabel = makeColumnLabel(actionColumn);
action.add(actionLabel);
final FlowPanel buttons = new FlowPanel() {
{
add(editAnchor((clickEvent) -> {
presenter.getActiveDecisionTable().ifPresent(dt -> dt.editAction(actionColumn));
}));
if (presenter.isActiveDecisionTableEditable()) {
add(deleteAnchor(actionColumn.getHeader(), () -> {
try {
final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable();
if (dtPresenter.isPresent()) {
dtPresenter.get().deleteColumn(actionColumn);
}
} catch (VetoDeletePatternInUseException veto) {
presenter.getView().showUnableToDeleteColumnMessage(actionColumn);
} catch (VetoException veto) {
presenter.getView().showGenericVetoMessage();
}
}));
}
}
};
action.add(buttons);
return action;
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class BRLConditionColumnSynchronizerTest method checkBRLFragmentConditionCanBeUpdatedWithNewConstraintOnBoundPatternUsedInAction.
@Test
public void checkBRLFragmentConditionCanBeUpdatedWithNewConstraintOnBoundPatternUsedInAction() throws VetoException {
final BRLConditionColumn column = new BRLConditionColumn();
column.setDefinition(Collections.singletonList(new FactPattern("Applicant") {
{
setBoundName("$a");
}
}));
final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
column.getChildColumns().add(columnV0);
column.setHeader("col1");
columnV0.setHeader("col1v0");
modelSynchronizer.appendColumn(column);
final ActionSetFieldCol52 action = new ActionSetFieldCol52() {
{
setBoundName("$a");
setFactField("age");
setHeader("action1");
}
};
modelSynchronizer.appendColumn(action);
try {
final BRLConditionColumn editedColumn = new BRLConditionColumn();
editedColumn.setDefinition(Collections.singletonList(new FactPattern("Applicant") {
{
setBoundName("$a");
}
}));
final BRLConditionVariableColumn editedColumnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
final BRLConditionVariableColumn editedColumnV1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
editedColumn.getChildColumns().add(editedColumnV0);
editedColumn.getChildColumns().add(editedColumnV1);
editedColumn.setHeader("col1");
editedColumnV0.setHeader("col1v0");
editedColumnV1.setHeader("col1v1");
modelSynchronizer.updateColumn(column, editedColumn);
assertEquals(6, 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(editedColumnV0, model.getExpandedColumns().get(3));
assertEquals(editedColumnV1, model.getExpandedColumns().get(4));
assertEquals(action, model.getExpandedColumns().get(5));
} catch (VetoException veto) {
fail("VetoUpdatePatternInUseException was not expected.");
}
}
use of org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException in project drools-wb by kiegroup.
the class BRLConditionColumnSynchronizerTest method checkBRLFragmentConditionCannotBeDeletedWhenFieldBindingIsUsedInAction.
@Test
public void checkBRLFragmentConditionCannotBeDeletedWhenFieldBindingIsUsedInAction() throws VetoException {
final BRLConditionColumn column = new BRLConditionColumn();
column.setDefinition(Collections.singletonList(new FactPattern("Applicant") {
{
setBoundName("$a");
addConstraint(new SingleFieldConstraint("age") {
{
setBoundName("$age");
}
});
}
}));
final BRLConditionVariableColumn columnV0 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
column.getChildColumns().add(columnV0);
column.setHeader("col1");
columnV0.setHeader("col1v0");
modelSynchronizer.appendColumn(column);
final BRLActionColumn action = new BRLActionColumn();
action.setDefinition(Collections.singletonList(new ActionCallMethod() {
{
setVariable("$age");
setMethodName("toString()");
}
}));
final BRLActionVariableColumn columnV1 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
action.getChildColumns().add(columnV1);
action.setHeader("col2");
columnV1.setHeader("col2v0");
modelSynchronizer.appendColumn(action);
try {
modelSynchronizer.deleteColumn(column);
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(columnV0, model.getExpandedColumns().get(3));
assertEquals(action.getChildColumns().get(0), model.getExpandedColumns().get(4));
}
Aggregations