Search in sources :

Example 71 with Pattern52

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

the class ColumnManagementViewTest method testRenderColumnPatternEditable.

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

        {
            setBoundName("p");
            setFactType("Person");
            getChildColumns().add(new ConditionCol52() {

                {
                    setHeader("one");
                }
            });
            getChildColumns().add(new ConditionCol52() {

                {
                    setHeader("two");
                }
            });
            getChildColumns().add(new ConditionCol52() {

                {
                    setHeader("three");
                }
            });
        }
    };
    final Map<String, List<BaseColumn>> columnGroups = new HashMap<String, List<BaseColumn>>() {

        {
            put("Person [p]", Collections.singletonList(pattern));
        }
    };
    final ColumnLabelWidget columnLabel = mockColumnLabelWidget();
    doReturn(columnLabel).when(view).newColumnLabelWidget(anyString());
    doReturn(true).when(modellerPresenter).isActiveDecisionTableEditable();
    view.renderColumns(columnGroups);
    verify(view).renderColumn(pattern);
    // Pattern has three child columns
    verify(horizontalPanel, times(3)).add(columnLabel);
    verify(view, times(3)).editAnchor(clickHandlerCaptor.capture());
    verify(view).deleteAnchor(eq("one"), any(Command.class));
    verify(view).deleteAnchor(eq("two"), any(Command.class));
    verify(view).deleteAnchor(eq("three"), any(Command.class));
    clickHandlerCaptor.getAllValues().get(0).onClick(mock(ClickEvent.class));
    verify(decisionTablePresenter).editCondition(eq(pattern), eq(pattern.getChildColumns().get(0)));
    clickHandlerCaptor.getAllValues().get(1).onClick(mock(ClickEvent.class));
    verify(decisionTablePresenter).editCondition(eq(pattern), eq(pattern.getChildColumns().get(1)));
    clickHandlerCaptor.getAllValues().get(2).onClick(mock(ClickEvent.class));
    verify(decisionTablePresenter).editCondition(eq(pattern), eq(pattern.getChildColumns().get(2)));
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) HashMap(java.util.HashMap) Command(com.google.gwt.user.client.Command) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) List(java.util.List) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 72 with Pattern52

use of org.drools.workbench.models.guided.dtable.shared.model.Pattern52 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 73 with Pattern52

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

the class DefaultWidgetFactory method makeNewValue.

private DTCellValue52 makeNewValue() {
    final DTColumnConfig52 column = getPlugin().editingCol();
    final Pattern52 pattern = getPlugin().editingPattern();
    if (column instanceof ActionSetFieldCol52) {
        return factory().makeNewValue(pattern, (ActionSetFieldCol52) column);
    } else if (column instanceof ConditionCol52) {
        return factory().makeNewValue(pattern, (ConditionCol52) column);
    } else {
        return factory().makeNewValue(column);
    }
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) DTColumnConfig52(org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Example 74 with Pattern52

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

the class DefaultWidgetFactory method getWidget.

private Widget getWidget(final DTCellValue52 defaultValue) {
    final DTColumnConfig52 column = getPlugin().editingCol();
    final Pattern52 pattern = getPlugin().editingPattern();
    if (column instanceof ActionSetFieldCol52) {
        final ActionSetFieldCol52 col52 = (ActionSetFieldCol52) column;
        return factory().getWidget(pattern, col52, defaultValue);
    } else if (column instanceof ConditionCol52) {
        final ConditionCol52 col52 = (ConditionCol52) column;
        return factory().getWidget(pattern, col52, defaultValue);
    } else if (column instanceof ActionInsertFactCol52) {
        final ActionInsertFactCol52 col52 = (ActionInsertFactCol52) column;
        return factory().getWidget(col52, defaultValue);
    }
    throw new UnsupportedOperationException("The column type is not supported by the 'DefaultWidget'");
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) DTColumnConfig52(org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Example 75 with Pattern52

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

the class FactPatternConstraintsPage method isComplete.

@Override
public void isComplete(final Callback<Boolean> callback) {
    // Have all patterns conditions been defined?
    boolean areConditionsDefined = true;
    for (Pattern52 p : model.getPatterns()) {
        for (ConditionCol52 c : p.getChildColumns()) {
            if (!getValidator().isConditionValid(c)) {
                areConditionsDefined = false;
                break;
            }
        }
    }
    // Signal Condition definitions to other pages
    final ConditionsDefinedEvent event = new ConditionsDefinedEvent(areConditionsDefined);
    conditionsDefinedEvent.fire(event);
    callback.callback(areConditionsDefined);
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ConditionsDefinedEvent(org.drools.workbench.screens.guided.dtable.client.wizard.table.pages.events.ConditionsDefinedEvent)

Aggregations

Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)243 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)184 Test (org.junit.Test)180 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)92 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)66 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)45 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)39 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)34 ArrayList (java.util.ArrayList)31 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)31 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)28 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)27 Path (org.uberfire.backend.vfs.Path)27 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)26 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)26 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)25 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)24 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)24 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)24