Search in sources :

Example 1 with PatternWrapper

use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.

the class ActionSetFactPlugin 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 : ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) ValueOptionsPageInitializer(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ValueOptionsPageInitializer) WizardPageStatusChangeEvent(org.uberfire.ext.widgets.core.client.wizards.WizardPageStatusChangeEvent) ActionWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionWrapper) DefaultWidgetFactory(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.DefaultWidgetFactory) LimitedWidgetFactory(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.LimitedWidgetFactory) 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) HasValueOptionsPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.commons.HasValueOptionsPage) HasPatternPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.commons.HasPatternPage) FieldAccessorsAndMutators(org.kie.soup.project.datamodel.oracle.FieldAccessorsAndMutators) IsWidget(com.google.gwt.user.client.ui.IsWidget) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) 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) 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) ActionInsertFactWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionInsertFactWrapper) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Set(java.util.Set) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) 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) List(java.util.List) ValueOptionsPage(org.drools.workbench.screens.guided.dtable.client.wizard.column.pages.ValueOptionsPage) WizardPage(org.uberfire.ext.widgets.core.client.wizards.WizardPage) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Dependent(javax.enterprise.context.Dependent) ActionSetFactWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.ActionSetFactWrapper) 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) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)

Example 2 with PatternWrapper

use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.

the class ActionSetFactPlugin 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 3 with PatternWrapper

use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper in project drools-wb by kiegroup.

the class ActionSetFactPlugin method newPatternWrapper.

PatternWrapper newPatternWrapper(final ActionWrapper actionWrapper) {
    final String boundName = actionWrapper.getBoundName();
    final String factType = actionWrapper.getFactType();
    final PatternWrapper defaultWrapper = new PatternWrapper(factType, boundName, false);
    return getPatterns().stream().filter(wrapper -> wrapper.getBoundName().equals(boundName)).findFirst().orElse(defaultWrapper);
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper)

Example 4 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 newPatternWrapper.

PatternWrapper newPatternWrapper(final ActionWorkItemWrapper actionWrapper) {
    final String boundName = actionWrapper.getBoundName();
    final String factType = actionWrapper.getFactType();
    final PatternWrapper defaultWrapper = new PatternWrapper(factType, boundName, false);
    return getPatterns().stream().filter(wrapper -> wrapper.getBoundName().equals(boundName)).findFirst().orElse(defaultWrapper);
}
Also used : PatternWrapper(org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper)

Example 5 with PatternWrapper

use of org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper 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)

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