Search in sources :

Example 21 with BRLConditionVariableColumn

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

the class DecisionTableAnalyzerTest method testInsertBRLConditionColumn.

@Test
public void testInsertBRLConditionColumn() throws Exception {
    BRLConditionColumn brlConditionOne = new BRLConditionColumn();
    BRLConditionVariableColumn a = new BRLConditionVariableColumn();
    BRLConditionVariableColumn b = new BRLConditionVariableColumn();
    BRLConditionColumn brlConditionTwo = new BRLConditionColumn();
    BRLConditionVariableColumn c = new BRLConditionVariableColumn();
    BRLConditionVariableColumn d = new BRLConditionVariableColumn();
    brlConditionOne.setChildColumns(Arrays.asList(a, b));
    brlConditionTwo.setChildColumns(Arrays.asList(c, d));
    model.getConditions().addAll(Arrays.asList(brlConditionOne, brlConditionTwo));
    decisionTableAnalyzer.insertColumn(brlConditionTwo);
    verify(updateManager).newColumn(model, 4);
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) Test(org.junit.Test)

Example 22 with BRLConditionVariableColumn

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

the class DecisionTableAnalyzerTest method testInsertNonExistingColumn.

@Test(expected = IllegalArgumentException.class)
public void testInsertNonExistingColumn() throws Exception {
    ConditionCol52 a = new ConditionCol52();
    ConditionCol52 b = new ConditionCol52();
    pattern.setChildColumns(Arrays.asList(a));
    BRLConditionColumn brlCondition = new BRLConditionColumn();
    BRLConditionVariableColumn c = new BRLConditionVariableColumn();
    BRLConditionVariableColumn d = new BRLConditionVariableColumn();
    brlCondition.setChildColumns(Arrays.asList(c, d));
    model.getConditions().addAll(Arrays.asList(pattern, brlCondition));
    decisionTableAnalyzer.insertColumn(b);
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) Test(org.junit.Test)

Example 23 with BRLConditionVariableColumn

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

the class DecisionTableAnalyzerTest method testInsertBRLVariableColumn.

@Test
public void testInsertBRLVariableColumn() throws Exception {
    ConditionCol52 a = new ConditionCol52();
    ConditionCol52 b = new ConditionCol52();
    pattern.setChildColumns(Arrays.asList(a, b));
    BRLConditionColumn brlCondition = new BRLConditionColumn();
    BRLConditionVariableColumn c = new BRLConditionVariableColumn();
    BRLConditionVariableColumn d = new BRLConditionVariableColumn();
    brlCondition.setChildColumns(Arrays.asList(c, d));
    model.getConditions().addAll(Arrays.asList(pattern, brlCondition));
    decisionTableAnalyzer.insertColumn(d);
    verify(updateManager).newColumn(model, 5);
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) Test(org.junit.Test)

Example 24 with BRLConditionVariableColumn

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

the class BRLConditionColumnPlugin method cloneVariable.

BRLConditionVariableColumn cloneVariable(BRLConditionVariableColumn variable) {
    final BRLConditionVariableColumn clone = new BRLConditionVariableColumn(variable.getVarName(), variable.getFieldType(), variable.getFactType(), variable.getFactField());
    clone.setHeader(variable.getHeader());
    clone.setHideColumn(variable.isHideColumn());
    clone.setWidth(variable.getWidth());
    return clone;
}
Also used : BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Example 25 with BRLConditionVariableColumn

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

the class BRLConditionColumnPlugin method convertInterpolationVariables.

private List<BRLConditionVariableColumn> convertInterpolationVariables(Map<InterpolationVariable, Integer> ivs) {
    // If there are no variables add a boolean column to specify whether the fragment should apply
    if (ivs.isEmpty()) {
        BRLConditionVariableColumn variable = new BRLConditionVariableColumn("", DataType.TYPE_BOOLEAN);
        variable.setHeader(editingCol.getHeader());
        variable.setHideColumn(editingCol.isHideColumn());
        List<BRLConditionVariableColumn> variables = new ArrayList<BRLConditionVariableColumn>();
        variables.add(variable);
        return variables;
    }
    // Convert to columns for use in the Decision Table
    BRLConditionVariableColumn[] variables = new BRLConditionVariableColumn[ivs.size()];
    for (Map.Entry<InterpolationVariable, Integer> me : ivs.entrySet()) {
        InterpolationVariable iv = me.getKey();
        int index = me.getValue();
        BRLConditionVariableColumn variable = new BRLConditionVariableColumn(iv.getVarName(), iv.getDataType(), iv.getFactType(), iv.getFactField());
        variable.setHeader(editingCol.getHeader());
        variable.setHideColumn(editingCol.isHideColumn());
        variables[index] = variable;
    }
    // Convert the array into a mutable list (Arrays.toList provides an immutable list)
    List<BRLConditionVariableColumn> variableList = new ArrayList<BRLConditionVariableColumn>();
    for (BRLConditionVariableColumn variable : variables) {
        variableList.add(variable);
    }
    return variableList;
}
Also used : InterpolationVariable(org.drools.workbench.models.datamodel.rule.InterpolationVariable) ArrayList(java.util.ArrayList) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) HashMap(java.util.HashMap) Map(java.util.Map)

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