Search in sources :

Example 46 with BaseColumn

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);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Example 47 with BaseColumn

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);
}
Also used : ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RefreshConditionsPanelEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.cdi.RefreshConditionsPanelEvent) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Example 48 with BaseColumn

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());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ArrayList(java.util.ArrayList) HeaderMetaData(org.drools.workbench.services.verifier.plugin.client.api.HeaderMetaData) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) Test(org.junit.Test)

Example 49 with BaseColumn

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);
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) HashMap(java.util.HashMap) HeaderMetaData(org.drools.workbench.services.verifier.plugin.client.api.HeaderMetaData) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) ModelMetaData(org.drools.workbench.services.verifier.plugin.client.api.ModelMetaData)

Example 50 with BaseColumn

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());
        }
    }
}
Also used : Condition(org.drools.verifier.core.index.model.Condition) Action(org.drools.verifier.core.index.model.Action) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) RuleAttribute(org.drools.verifier.core.index.model.RuleAttribute) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Aggregations

BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)126 Test (org.junit.Test)72 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)57 ArrayList (java.util.ArrayList)55 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)44 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)34 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)33 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)29 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)26 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)25 List (java.util.List)23 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)23 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)23 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)21 RuleNameColumn (org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn)21 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)20 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)20 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)20 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)19 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)19