Search in sources :

Example 26 with PatternWrapper

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;
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) HashSet(java.util.HashSet)

Example 27 with PatternWrapper

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()));
}
Also used : WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) ActionWorkItemWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWorkItemWrapper) HashMap(java.util.HashMap) WorkItemPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.pages.WorkItemPage) PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) DecisionTableColumnViewUtils.nil(org.drools.workbench.screens.guided.dtable.client.wizard.column.pages.common.DecisionTableColumnViewUtils.nil) HasPatternPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.commons.HasPatternPage) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) HasWorkItemPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.commons.HasWorkItemPage) FieldAccessorsAndMutators(org.kie.soup.project.datamodel.oracle.FieldAccessorsAndMutators) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) PortableWorkDefinition(org.drools.workbench.models.datamodel.workitems.PortableWorkDefinition) HasFieldPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.commons.HasFieldPage) DTColumnConfig52(org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52) AdditionalInfoPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.pages.AdditionalInfoPage) Event(javax.enterprise.event.Event) ActionWorkItemInsertWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWorkItemInsertWrapper) PatternPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.pages.PatternPage) HasAdditionalInfoPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.commons.HasAdditionalInfoPage) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Set(java.util.Set) AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) AdditionalInfoPageInitializer(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.AdditionalInfoPageInitializer) BaseDecisionTableColumnPlugin(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.BaseDecisionTableColumnPlugin) Collectors(java.util.stream.Collectors) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) List(java.util.List) WizardPage(org.uberfire.ext.widgets.core.client.wizards.WizardPage) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) ActionWorkItemSetWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWorkItemSetWrapper) Dependent(javax.enterprise.context.Dependent) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) NewGuidedDecisionTableColumnWizard(org.drools.workbench.screens.guided.dtable.client.wizard.column.NewGuidedDecisionTableColumnWizard) Optional(java.util.Optional) GuidedDecisionTableErraiConstants(org.drools.workbench.screens.guided.dtable.client.resources.i18n.GuidedDecisionTableErraiConstants) FieldPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.pages.FieldPage) PortableParameterDefinition(org.drools.workbench.models.datamodel.workitems.PortableParameterDefinition) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)

Example 28 with PatternWrapper

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();
}
Also used : Consumer(java.util.function.Consumer) PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) Test(org.junit.Test)

Example 29 with PatternWrapper

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();
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 30 with PatternWrapper

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();
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

PatternWrapper (org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper)52 Test (org.junit.Test)41 HashSet (java.util.HashSet)11 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)9 BRLRuleModel (org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)6 Mockito.anyString (org.mockito.Mockito.anyString)6 DTColumnConfig52 (org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52)4 ActionWrapper (org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWrapper)4 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)3 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)3 ActionWorkItemWrapper (org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWorkItemWrapper)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Dependent (javax.enterprise.context.Dependent)2 Event (javax.enterprise.event.Event)2 Inject (javax.inject.Inject)2 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)2