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));
}
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);
}
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);
}
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;
}
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);
}
Aggregations