Search in sources :

Example 61 with BaseColumn

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

the class ColumnUtilitiesValueListLookUpsTest method testActionSetFieldCol52.

@Test
public void testActionSetFieldCol52() {
    final ActionSetFieldCol52 column = new ActionSetFieldCol52();
    column.setBoundName("p");
    column.setFactField("gender");
    final ArrayList<CompositeColumn<? extends BaseColumn>> conditions = new ArrayList<>();
    final Pattern52 pattern = new Pattern52();
    pattern.setFactType("Person");
    pattern.setBoundName("p");
    conditions.add(pattern);
    doReturn(conditions).when(model).getConditions();
    check(utilities.getValueListLookups(column));
}
Also used : Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) Test(org.junit.Test)

Example 62 with BaseColumn

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

the class AttributeColumnSynchronizer method moveColumnsTo.

@Override
public void moveColumnsTo(final List<MoveColumnToMetaData> metaData) throws VetoException {
    // Check operation is supported
    if (!handlesMoveColumnsTo(metaData)) {
        return;
    }
    final MoveColumnToMetaData md = metaData.get(0);
    final AttributeCol52 modelColumn = (AttributeCol52) md.getColumn();
    final List<AttributeCol52> modelAttributeColumns = model.getAttributeCols();
    final int modelAttributeColumnCount = modelAttributeColumns.size();
    if (modelAttributeColumnCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    final int minColumnIndex = allModelColumns.indexOf(modelAttributeColumns.get(0));
    final int maxColumnIndex = allModelColumns.indexOf(modelAttributeColumns.get(modelAttributeColumnCount - 1));
    final int targetColumnIndex = md.getTargetColumnIndex();
    final int sourceColumnIndex = md.getSourceColumnIndex();
    if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
    modelAttributeColumns.remove(modelColumn);
    modelAttributeColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
Also used : AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 63 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn 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) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint)

Example 64 with BaseColumn

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

the class BaseColumnSynchronizer method findTargetPatternIndex.

protected int findTargetPatternIndex(final MoveColumnToMetaData md) throws ModelSynchronizer.MoveVetoException {
    int tgtPatternIndex = -1;
    final int tgtColumnIndex = md.getTargetColumnIndex();
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    final List<CompositeColumn<? extends BaseColumn>> allModelConditions = model.getConditions();
    for (int patternIndex = 0; patternIndex < allModelConditions.size(); patternIndex++) {
        final CompositeColumn<? extends BaseColumn> cc = allModelConditions.get(patternIndex);
        final List<? extends BaseColumn> children = cc.getChildColumns();
        if (children == null || children.isEmpty()) {
            continue;
        }
        final BaseColumn firstChild = children.get(0);
        final BaseColumn lastChild = children.get(children.size() - 1);
        final int firstChildIndex = allModelColumns.indexOf(firstChild);
        final int lastChildIndex = allModelColumns.indexOf(lastChild);
        if (tgtColumnIndex >= firstChildIndex && tgtColumnIndex <= lastChildIndex) {
            tgtPatternIndex = patternIndex;
            break;
        }
    }
    if (tgtPatternIndex < 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    return tgtPatternIndex;
}
Also used : BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)

Example 65 with BaseColumn

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

the class ConditionColumnSynchronizer method doMovePattern.

private void doMovePattern(final List<MoveColumnToMetaData> metaData) throws VetoException {
    final MoveColumnToMetaData md = metaData.get(0);
    final ConditionCol52 srcModelColumn = (ConditionCol52) md.getColumn();
    final Pattern52 srcModelPattern = model.getPattern(srcModelColumn);
    if (srcModelPattern == null) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<ConditionCol52> srcModelPatternConditionColumns = srcModelPattern.getChildColumns();
    final int srcModelPatternConditionColumnCount = srcModelPatternConditionColumns.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(srcModelPatternConditionColumns.get(0)), allModelColumns.indexOf(srcModelPatternConditionColumns.get(0)) + srcModelPatternConditionColumnCount - 1);
    model.getConditions().remove(srcModelPattern);
    model.getConditions().add(tgtPatternIndex, srcModelPattern);
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)

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