use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.
the class GuidedDecisionTableModelVisitor method getConsumedModelClasses.
public Set<String> getConsumedModelClasses() {
final Set<String> factTypes = new HashSet<String>();
// Extract Fact Types from model
for (CompositeColumn<?> cc : model.getConditions()) {
if (cc instanceof BRLConditionColumn) {
final List<IPattern> definition = ((BRLConditionColumn) cc).getDefinition();
factTypes.addAll(getConditionFactTypesFromRuleModel(definition));
} else if (cc instanceof Pattern52) {
factTypes.add(((Pattern52) cc).getFactType());
}
}
for (ActionCol52 c : model.getActionCols()) {
if (c instanceof BRLActionColumn) {
final List<IAction> definition = ((BRLActionColumn) c).getDefinition();
factTypes.addAll(getActionFactTypesFromRuleModel(definition));
} else if (c instanceof ActionInsertFactCol52) {
factTypes.add(((ActionInsertFactCol52) c).getFactType());
}
}
// Convert Fact Types into Fully Qualified Class Names
final Set<String> fullyQualifiedClassNames = new HashSet<String>();
for (String factType : factTypes) {
fullyQualifiedClassNames.add(convertToFullyQualifiedClassName(factType));
}
return fullyQualifiedClassNames;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.
the class BRLActionColumnPluginTest method testSetupEditingColWhenColumnIsNotNew.
@Test
public void testSetupEditingColWhenColumnIsNotNew() throws Exception {
final BRLActionColumn originalColumn = mock(BRLActionColumn.class);
final BRLActionColumn editingColumn = mock(BRLActionColumn.class);
final String header = "header";
final ArrayList<IAction> definition = new ArrayList<>();
final ArrayList<BRLActionVariableColumn> childColumns = new ArrayList<>();
final boolean isHideColumn = false;
doReturn(false).when(plugin).isNewColumn();
doReturn(editingColumn).when(plugin).newBRLActionColumn();
doReturn(originalColumn).when(plugin).getOriginalColumnConfig52();
doReturn(header).when(originalColumn).getHeader();
doReturn(definition).when(originalColumn).getDefinition();
doReturn(childColumns).when(originalColumn).getChildColumns();
doReturn(isHideColumn).when(originalColumn).isHideColumn();
plugin.setupEditingCol();
verify(editingColumn).setHeader(header);
verify(editingColumn).setDefinition(definition);
verify(editingColumn).setChildColumns(childColumns);
verify(editingColumn).setHideColumn(isHideColumn);
assertEquals(editingColumn, plugin.editingCol());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn 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.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.
the class ConditionColumnSynchronizerTest method actionCallMethod.
private BRLActionColumn actionCallMethod(final String boundName) {
final ActionCallMethod action = new ActionCallMethod();
action.setVariable(boundName);
action.setMethodName("toString()");
final BRLActionColumn brl = new BRLActionColumn();
brl.setHeader("brl-action");
brl.setDefinition(Collections.singletonList(action));
brl.getChildColumns().add(new BRLActionVariableColumn() {
{
setHeader("brl-action-v0");
}
});
return brl;
}
use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn in project drools-wb by kiegroup.
the class BRLActionColumnDefinitionBuilderTest method setupBRLActionColumn.
private void setupBRLActionColumn() {
final BRLActionColumn brl = new BRLActionColumn();
final ActionInsertFact ifc1 = new ActionInsertFact();
ifc1.setFactType("Person");
ifc1.setBoundName("$a");
final ActionFieldValue afv1 = new ActionFieldValue();
afv1.setNature(FieldNatureType.TYPE_TEMPLATE);
afv1.setField("name");
afv1.setValue("f1");
ifc1.addFieldValue(afv1);
final ActionFieldValue afv2 = new ActionFieldValue();
afv2.setNature(FieldNatureType.TYPE_TEMPLATE);
afv2.setField("age");
afv2.setValue("f2");
ifc1.addFieldValue(afv2);
brl.getDefinition().add(ifc1);
brl.getChildColumns().add(new BRLActionVariableColumn("f1", DataType.TYPE_STRING));
brl.getChildColumns().add(new BRLActionVariableColumn("f2", DataType.TYPE_NUMERIC_INTEGER));
model.getActionCols().add(brl);
}
Aggregations