use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldPlugin method getPatterns.
@Override
public Set<PatternWrapper> getPatterns() {
final Set<PatternWrapper> patterns = new HashSet<>();
if (isNewColumn() || !isNewFactPattern()) {
final BRLRuleModel brlRuleModel = new BRLRuleModel(presenter.getModel());
final List<String> variables = brlRuleModel.getLHSPatternVariables();
variables.forEach(var -> {
final String factType = brlRuleModel.getLHSBoundFact(var).getFactType();
final boolean isNegated = brlRuleModel.getLHSBoundFact(var).isNegated();
patterns.add(new PatternWrapper(factType, var, isNegated));
});
}
if (isNewColumn() || isNewFactPattern()) {
final BRLRuleModel brlRuleModel = new BRLRuleModel(presenter.getModel());
final List<String> variables = brlRuleModel.getRHSBoundFacts();
variables.forEach(var -> {
final String factType = brlRuleModel.getRHSBoundFact(var).getFactType();
patterns.add(new PatternWrapper(factType, var));
});
}
return patterns;
}
use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.
the class ActionWorkItemSetFieldPlugin method isNewFactPattern.
boolean isNewFactPattern() {
final BRLRuleModel brlRuleModel = new BRLRuleModel(presenter.getModel());
final List<String> variables = brlRuleModel.getLHSPatternVariables();
return !variables.stream().anyMatch(b -> b.equals(patternWrapper().getBoundName()));
}
use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.
the class FieldPageTest method testSetupFieldWhenConstraintValueIsFormula.
@Test
public void testSetupFieldWhenConstraintValueIsFormula() {
final String factField = "age";
doReturn(oracle).when(presenter).getDataModelOracle();
doReturn(BaseSingleFieldConstraint.TYPE_RET_VALUE).when(plugin).constraintValue();
doReturn(new PatternWrapper("Person", "p")).when(plugin).patternWrapper();
doReturn(factField).when(page).getFactField();
page.setupField();
verify(view).enableListFieldView();
verify(view).setupEmptyFieldList();
verify(page).forEachFactField(any(Consumer.class));
verify(view).selectField(factField);
verify(view, never()).enablePredicateFieldView();
}
use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.
the class PatternPageTest method testSetupPatternWhenPatternCreationIsEnabled.
@Test
public void testSetupPatternWhenPatternCreationIsEnabled() {
final PatternWrapper pattern1 = newPattern("factType1", "boundName1", false);
final PatternWrapper pattern2 = newPattern("factType2", "boundName2", false);
final Set<PatternWrapper> patterns = new HashSet<PatternWrapper>() {
{
add(pattern1);
add(pattern2);
}
};
doReturn(pattern2.key()).when(page).currentPatternValue();
doReturn(patterns).when(page).getPatterns();
page.setupPattern();
verify(view).addItem("factType1 [boundName1]", "factType1 boundName1 false");
verify(view).addItem("factType2 [boundName2]", "factType2 boundName2 false");
verify(view).clearPatternList();
verify(view).selectPattern(pattern2.key());
verify(view).hidePatternListWhenItIsEmpty();
verify(view, never()).disablePatternCreation();
}
use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.
the class PatternPageTest method testSetupPatternWhenPatternCreationIsDisabled.
@Test
public void testSetupPatternWhenPatternCreationIsDisabled() {
final PatternWrapper pattern1 = newPattern("factType1", "boundName1", false);
final PatternWrapper pattern2 = newPattern("factType2", "boundName2", false);
final Set<PatternWrapper> patterns = new HashSet<PatternWrapper>() {
{
add(pattern1);
add(pattern2);
}
};
doReturn(pattern2.key()).when(page).currentPatternValue();
doReturn(patterns).when(page).getPatterns();
page.disablePatternCreation();
page.setupPattern();
verify(view).addItem("factType1 [boundName1]", "factType1 boundName1 false");
verify(view).addItem("factType2 [boundName2]", "factType2 boundName2 false");
verify(view).clearPatternList();
verify(view).selectPattern(pattern2.key());
verify(view).hidePatternListWhenItIsEmpty();
verify(view).disablePatternCreation();
}
Aggregations