Search in sources :

Example 21 with BRLConditionColumn

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

the class BRLConditionColumnSynchronizer method doMoveBRLFragment.

private void doMoveBRLFragment(final List<MoveColumnToMetaData> metaData) throws VetoException {
    final MoveColumnToMetaData md = metaData.get(0);
    final BRLConditionVariableColumn srcModelColumn = (BRLConditionVariableColumn) md.getColumn();
    final BRLConditionColumn srcModelBRLFragment = model.getBRLColumn(srcModelColumn);
    if (srcModelBRLFragment == null) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<BRLConditionVariableColumn> srcModelBRLFragmentColumns = srcModelBRLFragment.getChildColumns();
    final int srcModelPatternConditionColumnCount = srcModelBRLFragmentColumns.size();
    if (srcModelPatternConditionColumnCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    if (srcModelPatternConditionColumnCount != metaData.size()) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final int tgtColumnIndex = md.getTargetColumnIndex();
    final int tgtPatternIndex = findTargetPatternIndex(md);
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    moveModelData(tgtColumnIndex, allModelColumns.indexOf(srcModelBRLFragmentColumns.get(0)), allModelColumns.indexOf(srcModelBRLFragmentColumns.get(0)) + srcModelPatternConditionColumnCount - 1);
    model.getConditions().remove(srcModelBRLFragment);
    model.getConditions().add(tgtPatternIndex, srcModelBRLFragment);
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Example 22 with BRLConditionColumn

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

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

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

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

the class GuidedDecisionTablePresenterTest method addBrlConstraintToModel.

private void addBrlConstraintToModel(final GuidedDecisionTable52 model, final String factType, final String field) {
    final Pattern52 p = new Pattern52();
    p.setFactType(factType);
    final BRLConditionColumn conditionColumn = new BRLConditionColumn();
    conditionColumn.setFactField(field);
    p.getChildColumns().add(conditionColumn);
    model.getConditions().add(p);
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52)

Aggregations

BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)73 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)53 Test (org.junit.Test)49 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)30 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)26 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)26 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)24 ArrayList (java.util.ArrayList)22 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)22 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)22 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)21 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)17 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)16 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)15 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)14 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)14 IAction (org.drools.workbench.models.datamodel.rule.IAction)11 IOException (java.io.IOException)10 InputStream (java.io.InputStream)10 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)10