Search in sources :

Example 1 with FactPatternPattern52Adaptor

use of org.drools.workbench.models.guided.dtable.shared.model.adaptors.FactPatternPattern52Adaptor in project drools-wb by kiegroup.

the class ConditionColumnPlugin method getPatterns.

@Override
public Set<PatternWrapper> getPatterns() {
    final Set<PatternWrapper> patterns = new HashSet<>();
    final BRLRuleModel brlRuleModel = makeBRLRuleModel();
    final List<String> variables = brlRuleModel.getLHSPatternVariables();
    variables.forEach(var -> {
        final Pattern52 pattern = getPresenter().getModel().getConditionPattern(var);
        if (!(pattern instanceof FactPatternPattern52Adaptor)) {
            final String factType = brlRuleModel.getLHSBoundFact(var).getFactType();
            final boolean isNegated = brlRuleModel.getLHSBoundFact(var).isNegated();
            patterns.add(new PatternWrapper(factType, var, isNegated));
        }
    });
    return patterns;
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) FactPatternPattern52Adaptor(org.drools.workbench.models.guided.dtable.shared.model.adaptors.FactPatternPattern52Adaptor) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) HashSet(java.util.HashSet)

Example 2 with FactPatternPattern52Adaptor

use of org.drools.workbench.models.guided.dtable.shared.model.adaptors.FactPatternPattern52Adaptor in project drools-wb by kiegroup.

the class ConditionColumnPluginTest method testGetPatternsWithBRLCondition.

@Test
public void testGetPatternsWithBRLCondition() throws Exception {
    final Pattern52 pattern = new Pattern52() {

        {
            setFactType("FactType");
            setBoundName("$fact");
        }
    };
    final BRLConditionColumn brlColumn = new BRLConditionColumn();
    final FactPattern fp = new FactPattern("AnotherFact") {

        {
            setBoundName("$another");
        }
    };
    brlColumn.setDefinition(Collections.singletonList(fp));
    doReturn(Arrays.asList(pattern, brlColumn)).when(model).getConditions();
    doReturn(pattern).when(model).getConditionPattern(eq("$fact"));
    doReturn(new FactPatternPattern52Adaptor(fp)).when(model).getConditionPattern(eq("$another"));
    final Set<PatternWrapper> patterns = plugin.getPatterns();
    assertEquals(1, patterns.size());
    assertTrue(patterns.contains(new PatternWrapper("FactType", "$fact", false)));
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) FactPatternPattern52Adaptor(org.drools.workbench.models.guided.dtable.shared.model.adaptors.FactPatternPattern52Adaptor) Test(org.junit.Test)

Aggregations

Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)2 FactPatternPattern52Adaptor (org.drools.workbench.models.guided.dtable.shared.model.adaptors.FactPatternPattern52Adaptor)2 PatternWrapper (org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper)2 HashSet (java.util.HashSet)1 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)1 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)1 BRLRuleModel (org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)1 Test (org.junit.Test)1