use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ColumnsPagePresenterTest method testRefresh.
@Test
public void testRefresh() {
final GuidedDecisionTable52 guidedDecisionTable52 = mock(GuidedDecisionTable52.class);
doReturn(Optional.of(guidedDecisionTable52)).when(presenter).getGuidedDecisionTable52();
doNothing().when(presenter).refreshAttributeWidget(any());
doNothing().when(presenter).refreshMetaDataWidget(any());
doNothing().when(presenter).refreshConditionsWidget(any());
doNothing().when(presenter).refreshActionsWidget(any());
final List<AttributeCol52> attributeCol52s = new ArrayList<>();
final List<MetadataCol52> metadataCol52s = new ArrayList<>();
final List<CompositeColumn<? extends BaseColumn>> compositeColumns = new ArrayList<>();
final List<ActionCol52> actionCol52s = new ArrayList<>();
doReturn(attributeCol52s).when(guidedDecisionTable52).getAttributeCols();
doReturn(metadataCol52s).when(guidedDecisionTable52).getAttributeCols();
doReturn(compositeColumns).when(guidedDecisionTable52).getAttributeCols();
doReturn(actionCol52s).when(guidedDecisionTable52).getAttributeCols();
presenter.refresh();
verify(presenter).refreshAttributeWidget(attributeCol52s);
verify(presenter).refreshMetaDataWidget(metadataCol52s);
verify(presenter).refreshConditionsWidget(compositeColumns);
verify(presenter).refreshActionsWidget(actionCol52s);
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ColumnsPagePresenterTest method testOnRefreshConditionsPanelEvent.
@Test
public void testOnRefreshConditionsPanelEvent() {
final RefreshConditionsPanelEvent event = mock(RefreshConditionsPanelEvent.class);
final GuidedDecisionTableView.Presenter eventPresenter = mock(GuidedDecisionTableView.Presenter.class);
final List<CompositeColumn<? extends BaseColumn>> columns = new ArrayList<>();
doReturn(eventPresenter).when(event).getPresenter();
doReturn(columns).when(event).getColumns();
doNothing().when(presenter).refreshConditionsWidget(any());
doNothing().when(presenter).refreshColumnsNoteInfo(any());
presenter.onRefreshConditionsPanelEvent(event);
verify(presenter).refreshConditionsWidget(columns);
verify(presenter).refreshColumnsNoteInfo(eventPresenter);
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ModelMetaDataEnhancerTest method conditionCol52Column.
@Test
public void conditionCol52Column() throws Exception {
final ArrayList<BaseColumn> columns = new ArrayList<>();
final ConditionCol52 conditionCol52 = new ConditionCol52();
final Pattern52 pattern52 = new Pattern52();
columns.add(conditionCol52);
when(model.getExpandedColumns()).thenReturn(columns);
when(model.getPattern(conditionCol52)).thenReturn(pattern52);
final HeaderMetaData headerMetaData = new ModelMetaDataEnhancer(model).getHeaderMetaData();
assertEquals(1, headerMetaData.size());
assertEquals(pattern52, headerMetaData.getPatternsByColumnNumber(0).getPattern());
assertEquals(PatternType.LHS, headerMetaData.getPatternsByColumnNumber(0).getPatternType());
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class ModelMetaDataEnhancer method getHeaderMetaData.
public HeaderMetaData getHeaderMetaData() {
int columnIndex = 0;
final Map<Integer, ModelMetaData> map = new HashMap<>();
for (final BaseColumn baseColumn : model.getExpandedColumns()) {
if (baseColumn instanceof ConditionCol52) {
map.put(columnIndex, new ModelMetaData(model.getPattern((ConditionCol52) baseColumn), PatternType.LHS));
} else if (baseColumn instanceof ActionInsertFactCol52) {
final ActionInsertFactCol52 aif = (ActionInsertFactCol52) baseColumn;
map.put(columnIndex, new ModelMetaData(aif.getFactType(), aif.getBoundName(), PatternType.RHS));
} else if (baseColumn instanceof ActionSetFieldCol52) {
final ActionSetFieldCol52 asf = (ActionSetFieldCol52) baseColumn;
map.put(columnIndex, new ModelMetaData(getFactType(asf), asf.getBoundName(), PatternType.RHS));
}
columnIndex++;
}
return new HeaderMetaData(map);
}
use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.
the class RuleBuilder method resolveColumns.
private void resolveColumns() throws BuildException {
int columnIndex = 0;
List<BaseColumn> expandedColumns = model.getExpandedColumns();
for (final BaseColumn baseColumn : expandedColumns) {
try {
if (baseColumn instanceof AttributeCol52) {
final String attribute = ((AttributeCol52) baseColumn).getAttribute();
final DTCellValue52 realCellValue = getRealCellValue((AttributeCol52) baseColumn, row.get(columnIndex));
final Optional<RuleAttribute> ruleAttribute = AttributeBuilder.build(columnIndex, configuration, attribute, realCellValue);
if (ruleAttribute.isPresent()) {
rule.addRuleAttribute(ruleAttribute.get());
}
} else if (baseColumn instanceof ConditionCol52) {
final Condition condition = builderFactory.getConditionBuilder().with((ConditionCol52) baseColumn).with(rule).with(row).with(columnIndex).build();
rule.getConditions().add(condition);
} else if (baseColumn instanceof ActionCol52) {
final Action action = builderFactory.getActionBuilder().with(rule).with((ActionCol52) baseColumn).with(row).with(columnIndex).build();
rule.getActions().add(action);
}
columnIndex++;
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException("Could not resolve column: Index: " + columnIndex + " header: " + baseColumn.getHeader() + " error message: " + e.getMessage());
}
}
}
Aggregations