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