Search in sources :

Example 66 with BRLConditionVariableColumn

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

the class GuidedDecisionTablePopulater method setCompositeColumnHeader.

private void setCompositeColumnHeader(final BRLConditionColumn column) {
    final List<BRLConditionVariableColumn> columnVariableColumns = column.getChildColumns();
    final StringBuilder sb = new StringBuilder();
    final List<String> variableColumnHeaders = new ArrayList<>();
    sb.append("Converted from [");
    for (int i = 0; i < columnVariableColumns.size(); i++) {
        final BRLConditionVariableColumn variableColumn = columnVariableColumns.get(i);
        final String header = variableColumn.getHeader();
        variableColumnHeaders.add(header);
        sb.append("'").append(header).append("'");
        sb.append(i < columnVariableColumns.size() - 1 ? ", " : "");
    }
    sb.append("]");
    column.setHeader(sb.toString());
    for (int i = 0; i < columnVariableColumns.size(); i++) {
        final BRLConditionVariableColumn variableColumn = columnVariableColumns.get(i);
        variableColumn.setHeader(variableColumnHeaders.get(i));
    }
}
Also used : ArrayList(java.util.ArrayList) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Example 67 with BRLConditionVariableColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn 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 68 with BRLConditionVariableColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn 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)

Example 69 with BRLConditionVariableColumn

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

the class GuidedDecisionTableLHSBuilder method addLiteralColumn.

private List<BRLVariableColumn> addLiteralColumn(final LiteralValueBuilder vb) {
    final List<BRLVariableColumn> variableColumns = new ArrayList<BRLVariableColumn>();
    final BRLConditionVariableColumn parameterColumn = new BRLConditionVariableColumn("", DataType.TYPE_BOOLEAN);
    variableColumns.add(parameterColumn);
    // Store DRL fragment for use by GuidedDecisionTableRHSBuilder
    drlFragments.add(vb.getTemplate());
    return variableColumns;
}
Also used : 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

BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)69 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)53 Test (org.junit.Test)39 ArrayList (java.util.ArrayList)28 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)24 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)23 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)23 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)23 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)23 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)23 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)18 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)15 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)15 IOException (java.io.IOException)11 InputStream (java.io.InputStream)11 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)11 DataListener (org.drools.template.parser.DataListener)11 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)11 ConversionResult (org.drools.workbench.models.guided.dtable.shared.conversion.ConversionResult)11 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)11