Search in sources :

Example 16 with BRLRuleModel

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

the class BRLConditionColumnPlugin method newRuleModel.

private RuleModel newRuleModel() {
    final BRLRuleModel ruleModel = new BRLRuleModel(getModel());
    final List<IPattern> definition = editingCol.getDefinition();
    ruleModel.lhs = definition.toArray(new IPattern[definition.size()]);
    return ruleModel;
}
Also used : IPattern(org.drools.workbench.models.datamodel.rule.IPattern) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)

Example 17 with BRLRuleModel

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

the class ConditionColumnPlugin method makeBRLRuleModel.

BRLRuleModel makeBRLRuleModel() {
    final GuidedDecisionTable52 model = getPresenter().getModel();
    final BRLRuleModel brlRuleModel = new BRLRuleModel(model);
    final FactPattern pat = patternWrapper().makeFactPattern();
    brlRuleModel.addLhsItem(pat);
    return brlRuleModel;
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)

Example 18 with BRLRuleModel

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

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

the class BaseSynchronizerTest method setup.

@Before
public void setup() {
    // Setup model related classes
    model = new GuidedDecisionTable52();
    uiModel = new GuidedDecisionTableUiModel(modelSynchronizer);
    incrementalDataModelServiceCaller = new CallerMock<>(incrementalDataModelService);
    final BRLRuleModel rm = new BRLRuleModel(model);
    final CellUtilities cellUtilities = new CellUtilities();
    final ColumnUtilities columnUtilities = new ColumnUtilities(model, oracle);
    final DependentEnumsUtilities enumsUtilities = new DependentEnumsUtilities(model, oracle);
    final GridWidgetCellFactory gridWidgetCellFactory = new GridWidgetCellFactoryImpl();
    // Setup mocks
    final GuidedDecisionTableModellerView.Presenter modellerPresenter = mock(GuidedDecisionTableModellerView.Presenter.class);
    final GuidedDecisionTableModellerView modellerView = mock(GuidedDecisionTableModellerView.class);
    final GridLayer gridLayer = mock(GridLayer.class);
    final AbsolutePanel domElementContainer = mock(AbsolutePanel.class);
    final GuidedDecisionTableView.Presenter dtablePresenter = mock(GuidedDecisionTableView.Presenter.class);
    final EventBus eventBus = mock(EventBus.class);
    when(dtablePresenter.getModellerPresenter()).thenReturn(modellerPresenter);
    when(modellerPresenter.getView()).thenReturn(modellerView);
    when(modellerView.getGridLayerView()).thenReturn(gridLayer);
    when(gridLayer.getDomElementContainer()).thenReturn(domElementContainer);
    when(domElementContainer.iterator()).thenReturn(mock(Iterator.class));
    // Setup column converters
    final List<BaseColumnConverter> converters = getConverters();
    gridWidgetColumnFactory.setConverters(converters);
    gridWidgetColumnFactory.initialise(model, oracle, columnUtilities, dtablePresenter);
    // Setup synchronizers
    final List<Synchronizer<? extends MetaData, ? extends MetaData, ? extends MetaData, ? extends MetaData, ? extends MetaData>> synchronizers = getSynchronizers();
    modelSynchronizer.setSynchronizers(synchronizers);
    modelSynchronizer.initialise(model, uiModel, cellUtilities, columnUtilities, enumsUtilities, gridWidgetCellFactory, gridWidgetColumnFactory, view, rm, eventBus, editable);
    // Dummy columns for Row number and Description
    uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new RowNumberCol52(), readOnly, view));
    uiModel.appendColumn(gridWidgetColumnFactory.convertColumn(new DescriptionCol52(), readOnly, view));
    ApplicationPreferences.setUp(new HashMap<String, String>() {

        {
            put(ApplicationPreferences.DATE_FORMAT, "dd-MM-yyyy");
        }
    });
}
Also used : ColumnUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) GuidedDecisionTableModellerView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableModellerView) AbsolutePanel(com.google.gwt.user.client.ui.AbsolutePanel) EventBus(com.google.gwt.event.shared.EventBus) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) GridWidgetCellFactoryImpl(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.cell.impl.GridWidgetCellFactoryImpl) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) MetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer.MetaData) GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) Iterator(java.util.Iterator) BaseColumnConverter(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.column.BaseColumnConverter) Synchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.Synchronizer) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) DependentEnumsUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.DependentEnumsUtilities) CellUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.CellUtilities) GridLayer(org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer) GridWidgetCellFactory(org.drools.workbench.screens.guided.dtable.client.widget.table.model.converters.cell.GridWidgetCellFactory) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Before(org.junit.Before)

Example 20 with BRLRuleModel

use of org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel in project drools by kiegroup.

the class BRLRuleModelTest method testDecisionTableColumnsWithLHSBoundFieldsInConditionCol52.

@Test
public void testDecisionTableColumnsWithLHSBoundFieldsInConditionCol52() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    Pattern52 p1 = new Pattern52();
    p1.setFactType("Driver");
    p1.setBoundName("$p1");
    ConditionCol52 c1 = new ConditionCol52();
    c1.setFactField("name");
    c1.setFieldType(DataType.TYPE_STRING);
    c1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    c1.setBinding("$c1");
    p1.getChildColumns().add(c1);
    dt.getConditions().add(p1);
    BRLRuleModel model = new BRLRuleModel(dt);
    FieldConstraint fcr1 = model.getLHSBoundField("$c1");
    assertNotNull(fcr1);
    assertTrue(fcr1 instanceof ConditionCol52FieldConstraintAdaptor);
    ConditionCol52FieldConstraintAdaptor fcr1sfc = (ConditionCol52FieldConstraintAdaptor) fcr1;
    assertEquals("Driver", fcr1sfc.getFactType());
    assertEquals("name", fcr1sfc.getFieldName());
    assertEquals(DataType.TYPE_STRING, fcr1sfc.getFieldType());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BRLRuleModel(org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel) ConditionCol52FieldConstraintAdaptor(org.drools.workbench.models.guided.dtable.shared.model.adaptors.ConditionCol52FieldConstraintAdaptor) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Test(org.junit.Test)

Aggregations

BRLRuleModel (org.drools.workbench.models.guided.dtable.shared.model.BRLRuleModel)29 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)22 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)18 Test (org.junit.Test)17 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)10 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)10 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)9 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)7 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)7 PatternWrapper (org.drools.workbench.screens.guided.dtable.client.wizard.column.plugins.commons.PatternWrapper)6 HashSet (java.util.HashSet)5 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)5 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)4 ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)4 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)4 ActionInsertFactCol52ActionInsertFactAdaptor (org.drools.workbench.models.guided.dtable.shared.model.adaptors.ActionInsertFactCol52ActionInsertFactAdaptor)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 FieldConstraint (org.drools.workbench.models.datamodel.rule.FieldConstraint)3 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)3