Search in sources :

Example 16 with ActionCol52

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

the class LimitedEntryBRLActionColumnSynchronizer 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 LimitedEntryBRLActionColumn modelColumn = (LimitedEntryBRLActionColumn) md.getColumn();
    final List<ActionCol52> modelActionColumns = model.getActionCols();
    final int modelActionColumnCount = modelActionColumns.size();
    if (modelActionColumnCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    final int minColumnIndex = allModelColumns.indexOf(modelActionColumns.get(0));
    final int maxColumnIndex = allModelColumns.indexOf(modelActionColumns.get(modelActionColumnCount - 1));
    final int targetColumnIndex = md.getTargetColumnIndex();
    final int sourceColumnIndex = md.getSourceColumnIndex();
    if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
    modelActionColumns.remove(modelColumn);
    modelActionColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
Also used : LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 17 with ActionCol52

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

the class ActionColumnSynchronizer method isWorkItemFragmentBeforeInsertFactCol.

protected boolean isWorkItemFragmentBeforeInsertFactCol(final List<? extends MetaData> metaData) {
    final List<ActionCol52> columnsToMove = metaData.stream().map(c -> (MoveColumnToMetaData) c).map(MoveColumnToMetaData::getColumn).map(c -> (ActionCol52) c).collect(Collectors.toList());
    final List<String> bindingsUsedByWID = new ArrayList<>();
    bindingsUsedByWID.addAll(columnsToMove.stream().filter(c -> c instanceof ActionWorkItemInsertFactCol52).map(c -> (ActionWorkItemInsertFactCol52) c).map(ActionWorkItemInsertFactCol52::getBoundName).collect(Collectors.toList()));
    final AtomicBoolean result = new AtomicBoolean(true);
    final int tgtIndex = ((MoveColumnToMetaData) metaData.get(0)).getTargetColumnIndex();
    final List<BaseColumn> modelColumns = model.getExpandedColumns();
    // Cannot move "Insert and Set field" created by the WID to after other "Insert and Set field"
    for (String binding : bindingsUsedByWID) {
        model.getActionCols().stream().filter(c -> !columnsToMove.contains(c)).filter(c -> c instanceof ActionInsertFactCol52).filter(c -> !(c instanceof ActionWorkItemInsertFactCol52)).map(c -> (ActionInsertFactCol52) c).filter(c -> c.getBoundName().equals(binding)).map(modelColumns::indexOf).filter(i -> tgtIndex >= i).findFirst().ifPresent(i -> result.set(false));
    }
    return result.get();
}
Also used : IntStream(java.util.stream.IntStream) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) ColumnMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseColumnSynchronizer.ColumnMetaData) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) OptionalInt(java.util.OptionalInt) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Dependent(javax.enterprise.context.Dependent) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) Collections(java.util.Collections) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 18 with ActionCol52

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

the class ActionColumnSynchronizer method doMoveActionFragment.

protected void doMoveActionFragment(final List<MoveColumnToMetaData> metaData) throws VetoException {
    final MoveColumnToMetaData md = metaData.get(0);
    final BaseColumn firstColumnInFragment = md.getColumn();
    final BaseColumn lastColumnInFragment = metaData.get(metaData.size() - 1).getColumn();
    final int srcColumnFirstIndex = model.getExpandedColumns().indexOf(firstColumnInFragment);
    final int srcColumnLastIndex = model.getExpandedColumns().indexOf(lastColumnInFragment);
    final List<ActionCol52> srcModelFragmentColumns = IntStream.rangeClosed(srcColumnFirstIndex, srcColumnLastIndex).mapToObj(i -> model.getExpandedColumns().get(i)).map(column -> (ActionCol52) column).collect(Collectors.toList());
    final int srcModelFragmentColumnsCount = srcModelFragmentColumns.size();
    if (srcModelFragmentColumnsCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    if (srcModelFragmentColumnsCount != metaData.size()) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final int tgtColumnIndex = md.getTargetColumnIndex();
    final int tgtActionIndex = findTargetActionIndex(md);
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    moveModelData(tgtColumnIndex, allModelColumns.indexOf(srcModelFragmentColumns.get(0)), allModelColumns.indexOf(srcModelFragmentColumns.get(0)) + srcModelFragmentColumnsCount - 1);
    // Moving left
    if (tgtColumnIndex < srcColumnFirstIndex) {
        final AtomicInteger offset = new AtomicInteger(0);
        srcModelFragmentColumns.forEach(column -> {
            model.getActionCols().remove(column);
            model.getActionCols().add(tgtActionIndex + offset.getAndIncrement(), column);
        });
    }
    // Moving right
    if (tgtColumnIndex > srcColumnFirstIndex) {
        srcModelFragmentColumns.forEach(column -> {
            model.getActionCols().remove(column);
            model.getActionCols().add(tgtActionIndex, column);
        });
    }
}
Also used : IntStream(java.util.stream.IntStream) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) ColumnMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.BaseColumnSynchronizer.ColumnMetaData) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) OptionalInt(java.util.OptionalInt) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Dependent(javax.enterprise.context.Dependent) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) Collections(java.util.Collections) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 19 with ActionCol52

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

the class ActionColumnSynchronizer method delete.

@Override
public void delete(final ColumnMetaData metaData) throws VetoException {
    // Check operation is supported
    if (!handlesDelete(metaData)) {
        return;
    }
    final ActionCol52 column = (ActionCol52) metaData.getColumn();
    final int columnIndex = model.getExpandedColumns().indexOf(column);
    model.getActionCols().remove(column);
    synchroniseDeleteColumn(columnIndex);
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)

Example 20 with ActionCol52

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

the class ActionWorkItemExecuteColumnSynchronizer method append.

@Override
public void append(final ColumnMetaData metaData) throws VetoException {
    if (!handlesAppend(metaData)) {
        return;
    }
    final ActionCol52 column = (ActionCol52) metaData.getColumn();
    model.getActionCols().add(column);
    synchroniseAppendColumn(column);
}
Also used : ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)

Aggregations

ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)60 Test (org.junit.Test)31 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)27 ArrayList (java.util.ArrayList)17 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)16 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)13 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)13 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)12 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)12 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)12 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)11 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)11 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)10 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)9 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)8 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)8 List (java.util.List)6 ActionExecuteWorkItem (org.drools.workbench.models.datamodel.rule.ActionExecuteWorkItem)6 PortableBooleanParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableBooleanParameterDefinition)6 PortableFloatParameterDefinition (org.drools.workbench.models.datamodel.workitems.PortableFloatParameterDefinition)6