Search in sources :

Example 6 with BRLVariableColumn

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

the class GuidedDecisionTableRHSBuilder method getVariableColumns.

@Override
public List<BRLVariableColumn> getVariableColumns() {
    // Sort column builders by column index to ensure columns are added in the correct sequence
    final Set<Integer> sortedIndexes = new TreeSet<Integer>(this.valueBuilders.keySet());
    final List<BRLVariableColumn> variableColumns = new ArrayList<BRLVariableColumn>();
    for (Integer index : sortedIndexes) {
        final ParameterizedValueBuilder vb = this.valueBuilders.get(index);
        final List<BRLVariableColumn> vbVariableColumns = addColumn(vb);
        for (BRLVariableColumn vbVariableColumn : vbVariableColumns) {
            ((BRLActionVariableColumn) vbVariableColumn).setHeader(this.columnHeaders.get(index));
        }
        variableColumns.addAll(vbVariableColumns);
    }
    return variableColumns;
}
Also used : TreeSet(java.util.TreeSet) BRLVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn) ArrayList(java.util.ArrayList) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 7 with BRLVariableColumn

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

the class GuidedDecisionTablePopulater method createRHSChildColumns.

private void createRHSChildColumns(final RuleModel rm, final IAction action, final BRLActionColumn column, final List<BRLVariableColumn> variableColumns) {
    final Map<InterpolationVariable, Integer> templateKeys = new HashMap<>();
    final RuleModelVisitor rmv = new RuleModelVisitor(rm.lhs, templateKeys);
    rmv.visit(action);
    final List<InterpolationVariable> ivs = new ArrayList<>(templateKeys.keySet());
    for (BRLVariableColumn variableColumn : variableColumns) {
        final Iterator<InterpolationVariable> ivsIts = ivs.iterator();
        while (ivsIts.hasNext()) {
            final InterpolationVariable iv = ivsIts.next();
            if (iv.getVarName().equals(variableColumn.getVarName())) {
                final BRLActionVariableColumn source = (BRLActionVariableColumn) variableColumn;
                final BRLActionVariableColumn target = makeBRLActionVariableColumn(source, iv);
                column.getChildColumns().add(target);
                ivsIts.remove();
            }
        }
    }
}
Also used : RuleModelVisitor(org.drools.workbench.models.datamodel.rule.visitors.RuleModelVisitor) InterpolationVariable(org.drools.workbench.models.datamodel.rule.InterpolationVariable) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BRLVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 8 with BRLVariableColumn

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

the class GuidedDecisionTablePopulater method addIndirectSourceBuildersData.

private void addIndirectSourceBuildersData(final int maxRowCount) {
    final List<ParameterizedValueBuilder> valueBuilders = getOrderedValueBuilders();
    final List<BaseColumn> allColumns = dtable.getExpandedColumns();
    for (int iColIndex = 0; iColIndex < allColumns.size(); iColIndex++) {
        final BaseColumn column = allColumns.get(iColIndex);
        if (column instanceof BRLVariableColumn) {
            final String varName = ((BRLVariableColumn) column).getVarName();
            final String varDataType = ((BRLVariableColumn) column).getFieldType();
            assertDecisionTableData(varName, varDataType, valueBuilders, maxRowCount);
        }
    }
}
Also used : ParameterizedValueBuilder(org.drools.workbench.screens.dtablexls.backend.server.conversion.builders.ParameterizedValueBuilder) BRLVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 9 with BRLVariableColumn

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

the class GuidedDecisionTableLHSBuilder method addPatternColumn.

// A Pattern column adds constraints to a Pattern. It has a value in the OBJECT row
private List<BRLVariableColumn> addPatternColumn() {
    // Sort column builders by column index to ensure columns are added in the correct sequence
    final TreeSet<Integer> sortedIndexes = new TreeSet<Integer>(this.valueBuilders.keySet());
    final List<BRLVariableColumn> variableColumns = new ArrayList<BRLVariableColumn>();
    // DRL prefix
    final StringBuffer drl = new StringBuffer();
    drl.append(this.colDefPrefix);
    String sep = "";
    // DRL fragment
    for (Integer index : sortedIndexes) {
        final ParameterizedValueBuilder vb = this.valueBuilders.get(index);
        for (String parameter : vb.getParameters()) {
            final BRLConditionVariableColumn parameterColumn = new BRLConditionVariableColumn(parameter, DataType.TYPE_OBJECT);
            parameterColumn.setHeader(this.columnHeaders.get(index));
            variableColumns.add(parameterColumn);
        }
        drl.append(sep).append(vb.getTemplate());
        sep = this.andop;
    }
    // DRL suffix
    drl.append(this.colDefSuffix);
    // Store DRL fragment for use by GuidedDecisionTableRHSBuilder
    drlFragments.add(drl.toString());
    return variableColumns;
}
Also used : TreeSet(java.util.TreeSet) BRLVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn) ArrayList(java.util.ArrayList) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Example 10 with BRLVariableColumn

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

the class GuidedDecisionTableLHSBuilder method addExplicitColumns.

// An explicit column does not add constraints to a Pattern. It does not have a value in the OBJECT row
private List<BRLVariableColumn> addExplicitColumns() {
    // Sort column builders by column index to ensure Actions are added in the correct sequence
    final Set<Integer> sortedIndexes = new TreeSet<Integer>(this.valueBuilders.keySet());
    final List<BRLVariableColumn> variableColumns = new ArrayList<BRLVariableColumn>();
    for (Integer index : sortedIndexes) {
        final ParameterizedValueBuilder vb = this.valueBuilders.get(index);
        final List<BRLVariableColumn> vbVariableColumns = new ArrayList<BRLVariableColumn>();
        if (vb instanceof LiteralValueBuilder) {
            vbVariableColumns.addAll(addLiteralColumn((LiteralValueBuilder) vb));
            for (BRLVariableColumn vbVariableColumn : vbVariableColumns) {
                ((BRLConditionVariableColumn) vbVariableColumn).setHeader(this.columnHeaders.get(index));
            }
        } else {
            vbVariableColumns.addAll(addBRLFragmentColumn(vb));
            for (BRLVariableColumn vbVariableColumn : vbVariableColumns) {
                ((BRLConditionVariableColumn) vbVariableColumn).setHeader(this.columnHeaders.get(index));
            }
        }
        variableColumns.addAll(vbVariableColumns);
    }
    return variableColumns;
}
Also used : TreeSet(java.util.TreeSet) BRLVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn) ArrayList(java.util.ArrayList) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Aggregations

BRLVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn)13 ArrayList (java.util.ArrayList)10 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)6 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)6 TreeSet (java.util.TreeSet)3 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)3 HashMap (java.util.HashMap)2 InterpolationVariable (org.drools.workbench.models.datamodel.rule.InterpolationVariable)2 RuleModelVisitor (org.drools.workbench.models.datamodel.rule.visitors.RuleModelVisitor)2 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)2 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)2 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)2 GuidedDecisionTableRHSBuilder (org.drools.workbench.screens.dtablexls.backend.server.conversion.builders.GuidedDecisionTableRHSBuilder)2 GuidedDecisionTableSourceBuilder (org.drools.workbench.screens.dtablexls.backend.server.conversion.builders.GuidedDecisionTableSourceBuilder)2 ParameterizedValueBuilder (org.drools.workbench.screens.dtablexls.backend.server.conversion.builders.ParameterizedValueBuilder)2 List (java.util.List)1 ActionRetractFact (org.drools.workbench.models.datamodel.rule.ActionRetractFact)1 IAction (org.drools.workbench.models.datamodel.rule.IAction)1 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)1 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)1