Search in sources :

Example 16 with BRLActionColumn

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;
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) IAction(org.drools.workbench.models.datamodel.rule.IAction) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) HashSet(java.util.HashSet)

Example 17 with BRLActionColumn

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());
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) IAction(org.drools.workbench.models.datamodel.rule.IAction) ArrayList(java.util.ArrayList) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Example 18 with BRLActionColumn

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));
}
Also used : VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) RuleNameColumn(org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn) VetoDeletePatternInUseException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoDeletePatternInUseException) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 19 with BRLActionColumn

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;
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionCallMethod(org.drools.workbench.models.datamodel.rule.ActionCallMethod) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 20 with BRLActionColumn

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);
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Aggregations

BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)78 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)56 Test (org.junit.Test)53 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)33 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)26 ArrayList (java.util.ArrayList)24 IAction (org.drools.workbench.models.datamodel.rule.IAction)22 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)20 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)20 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)19 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)18 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)17 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)17 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)17 ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)15 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)15 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)14 RuleNameColumn (org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn)14 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)13 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)12