Search in sources :

Example 41 with ConditionCol52

use of org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52 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)

Example 42 with ConditionCol52

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

the class ConditionColumnSynchronizer method append.

@Override
public void append(final PatternConditionMetaData metaData) throws VetoException {
    // Check operation is supported
    if (!handlesAppend(metaData)) {
        return;
    }
    final Pattern52 pattern = metaData.getPattern();
    final ConditionCol52 column = (ConditionCol52) metaData.getColumn();
    // Add pattern if it does not already exist
    if (!model.getConditions().contains(pattern)) {
        model.getConditions().add(pattern);
        // Signal patterns changed event
        final BoundFactsChangedEvent bfce = new BoundFactsChangedEvent(rm.getLHSBoundFacts());
        eventBus.fireEvent(bfce);
    }
    pattern.getChildColumns().add(column);
    synchroniseAppendColumn(column);
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BoundFactsChangedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.gwt.BoundFactsChangedEvent)

Example 43 with ConditionCol52

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

the class ConditionColumnSynchronizer method doMoveSingleCondition.

// Move a single Condition column; it must remain within the bounds of it's parent Pattern's columns
private void doMoveSingleCondition(final MoveColumnToMetaData metaData) throws VetoException {
    final ConditionCol52 modelColumn = (ConditionCol52) metaData.getColumn();
    final Pattern52 modelPattern = model.getPattern(modelColumn);
    if (modelPattern == null) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<ConditionCol52> modelPatternConditionColumns = modelPattern.getChildColumns();
    final int modelPatternConditionColumnCount = modelPatternConditionColumns.size();
    if (modelPatternConditionColumnCount == 0) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    final List<BaseColumn> allModelColumns = model.getExpandedColumns();
    final int minColumnIndex = allModelColumns.indexOf(modelPatternConditionColumns.get(0));
    final int maxColumnIndex = allModelColumns.indexOf(modelPatternConditionColumns.get(modelPatternConditionColumnCount - 1));
    final int targetColumnIndex = metaData.getTargetColumnIndex();
    final int sourceColumnIndex = metaData.getSourceColumnIndex();
    if (targetColumnIndex < minColumnIndex || targetColumnIndex > maxColumnIndex) {
        throw new ModelSynchronizer.MoveVetoException();
    }
    moveModelData(targetColumnIndex, sourceColumnIndex, sourceColumnIndex);
    modelPatternConditionColumns.remove(modelColumn);
    modelPatternConditionColumns.add(targetColumnIndex - minColumnIndex, modelColumn);
}
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)

Example 44 with ConditionCol52

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

the class ConditionColumnSynchronizer method isPattern.

private boolean isPattern(final List<MoveColumnToMetaData> metaData) {
    if (!metaData.stream().allMatch((c) -> c.getColumn() instanceof ConditionCol52)) {
        return false;
    }
    final MoveColumnToMetaData md = metaData.get(0);
    final ConditionCol52 srcModelColumn = (ConditionCol52) md.getColumn();
    final Pattern52 srcModelPattern = model.getPattern(srcModelColumn);
    return srcModelPattern.getChildColumns().size() == metaData.size();
}
Also used : OperatorsOracle(org.kie.soup.project.datamodel.oracle.OperatorsOracle) Arrays(java.util.Arrays) BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) ArrayList(java.util.ArrayList) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) PatternConditionMetaData(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.impl.ConditionColumnSynchronizer.PatternConditionMetaData) BoundFactsChangedEvent(org.drools.workbench.screens.guided.dtable.client.widget.table.events.gwt.BoundFactsChangedEvent) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) PortablePreconditions(org.kie.soup.commons.validation.PortablePreconditions) VetoUpdatePatternInUseException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoUpdatePatternInUseException) BaseColumnFieldDiffImpl(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiffImpl) LimitedEntryCol(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol) ColumnUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) VetoDeletePatternInUseException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoDeletePatternInUseException) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) List(java.util.List) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Dependent(javax.enterprise.context.Dependent) Collections(java.util.Collections) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52)

Example 45 with ConditionCol52

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

the class GuidedDecisionTableTheme method getModelColumnType.

ModelColumnType getModelColumnType(final GridColumn<?> uiColumn) {
    final int uiColumnIndex = uiModel.getColumns().indexOf(uiColumn);
    final BaseColumn modelColumn = model.getExpandedColumns().get(uiColumnIndex);
    if (modelColumn instanceof RowNumberCol52) {
        return ModelColumnType.ROW_NUMBER;
    } else if (modelColumn instanceof DescriptionCol52) {
        return ModelColumnType.DESCRIPTION;
    } else if (modelColumn instanceof MetadataCol52) {
        return ModelColumnType.METADATA;
    } else if (modelColumn instanceof AttributeCol52) {
        return ModelColumnType.ATTRIBUTE;
    } else if (modelColumn instanceof ConditionCol52) {
        return ModelColumnType.CONDITION;
    } else if (modelColumn instanceof ActionCol52) {
        return ModelColumnType.ACTION;
    }
    // proof rendering than throw an exception.
    return ModelColumnType.UNKNOWN;
}
Also used : MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) AttributeCol52(org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

Aggregations

ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)229 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)184 Test (org.junit.Test)170 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)74 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)59 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)38 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)38 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)34 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)31 ArrayList (java.util.ArrayList)27 Path (org.uberfire.backend.vfs.Path)27 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)25 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)25 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)25 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)25 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)24 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)24 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)23 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)23 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)23