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;
}
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;
}
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;
}
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");
}
});
}
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());
}
Aggregations