Search in sources :

Example 46 with Pattern52

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

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

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

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

the class DependentEnumsUtilities method getDependentColumnIndexes.

@Override
public Set<Integer> getDependentColumnIndexes(final Context context) {
    final int iBaseColIndex = context.getColumnIndex();
    final Set<Integer> dependentColumnIndexes = new HashSet<Integer>();
    // Get the column for the cell being edited
    final List<BaseColumn> allColumns = this.model.getExpandedColumns();
    final BaseColumn baseColumn = allColumns.get(iBaseColIndex);
    // Get values for all Constraints or Actions on the same pattern as the baseColumn
    if (baseColumn instanceof BRLConditionVariableColumn) {
        final BRLConditionVariableColumn baseBRLConditionColumn = (BRLConditionVariableColumn) baseColumn;
        final BRLConditionColumn brl = model.getBRLColumn(baseBRLConditionColumn);
        final RuleModel rm = new RuleModel();
        IPattern[] lhs = new IPattern[brl.getDefinition().size()];
        brl.getDefinition().toArray(lhs);
        rm.lhs = lhs;
        final RuleModelPeerVariableVisitor peerVariableVisitor = new RuleModelPeerVariableVisitor(rm, baseBRLConditionColumn.getVarName());
        List<ValueHolder> peerVariables = peerVariableVisitor.getPeerVariables();
        // Add other variables values
        for (ValueHolder valueHolder : peerVariables) {
            switch(valueHolder.getType()) {
                case TEMPLATE_KEY:
                    if (oracle.isDependentEnum(baseBRLConditionColumn.getFactType(), baseBRLConditionColumn.getFactField(), valueHolder.getFieldName())) {
                        final BRLConditionVariableColumn vc = getConditionVariableColumnIndex(brl.getChildColumns(), valueHolder.getValue());
                        final int iCol = allColumns.indexOf(vc);
                        dependentColumnIndexes.add(iCol);
                    }
                    break;
            }
        }
    } else if (baseColumn instanceof BRLActionVariableColumn) {
        final BRLActionVariableColumn baseBRLActionColumn = (BRLActionVariableColumn) baseColumn;
        final BRLActionColumn brl = model.getBRLColumn(baseBRLActionColumn);
        final RuleModel rm = new RuleModel();
        IAction[] rhs = new IAction[brl.getDefinition().size()];
        brl.getDefinition().toArray(rhs);
        rm.rhs = rhs;
        final RuleModelPeerVariableVisitor peerVariableVisitor = new RuleModelPeerVariableVisitor(rm, baseBRLActionColumn.getVarName());
        List<ValueHolder> peerVariables = peerVariableVisitor.getPeerVariables();
        // Add other variables values
        for (ValueHolder valueHolder : peerVariables) {
            switch(valueHolder.getType()) {
                case TEMPLATE_KEY:
                    if (oracle.isDependentEnum(baseBRLActionColumn.getFactType(), baseBRLActionColumn.getFactField(), valueHolder.getFieldName())) {
                        final BRLActionVariableColumn vc = getActionVariableColumnIndex(brl.getChildColumns(), valueHolder.getValue());
                        final int iCol = allColumns.indexOf(vc);
                        dependentColumnIndexes.add(iCol);
                    }
                    break;
            }
        }
    } else if (baseColumn instanceof ConditionCol52) {
        final ConditionCol52 baseConditionColumn = (ConditionCol52) baseColumn;
        final Pattern52 basePattern = this.model.getPattern(baseConditionColumn);
        for (ConditionCol52 cc : basePattern.getChildColumns()) {
            if (oracle.isDependentEnum(basePattern.getFactType(), baseConditionColumn.getFactField(), cc.getFactField())) {
                dependentColumnIndexes.add(allColumns.indexOf(cc));
            }
        }
    } else if (baseColumn instanceof ActionSetFieldCol52) {
        final ActionSetFieldCol52 baseActionColumn = (ActionSetFieldCol52) baseColumn;
        final Pattern52 basePattern = model.getConditionPattern(baseActionColumn.getBoundName());
        final String binding = baseActionColumn.getBoundName();
        for (ActionCol52 ac : this.model.getActionCols()) {
            if (ac instanceof ActionSetFieldCol52) {
                final ActionSetFieldCol52 asf = (ActionSetFieldCol52) ac;
                if (asf.getBoundName().equals(binding)) {
                    if (oracle.isDependentEnum(basePattern.getFactType(), baseActionColumn.getFactField(), asf.getFactField())) {
                        dependentColumnIndexes.add(allColumns.indexOf(ac));
                    }
                }
            }
        }
    } else if (baseColumn instanceof ActionInsertFactCol52) {
        final ActionInsertFactCol52 baseActionColumn = (ActionInsertFactCol52) baseColumn;
        final String binding = baseActionColumn.getBoundName();
        for (ActionCol52 ac : this.model.getActionCols()) {
            if (ac instanceof ActionInsertFactCol52) {
                final ActionInsertFactCol52 aif = (ActionInsertFactCol52) ac;
                if (aif.getBoundName().equals(binding)) {
                    if (oracle.isDependentEnum(baseActionColumn.getFactType(), baseActionColumn.getFactField(), aif.getFactField())) {
                        dependentColumnIndexes.add(allColumns.indexOf(ac));
                    }
                }
            }
        }
    }
    return dependentColumnIndexes;
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ValueHolder(org.drools.workbench.screens.guided.template.client.editor.RuleModelPeerVariableVisitor.ValueHolder) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) RuleModelPeerVariableVisitor(org.drools.workbench.screens.guided.template.client.editor.RuleModelPeerVariableVisitor) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) List(java.util.List) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) HashSet(java.util.HashSet)

Example 50 with Pattern52

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

the class LimitedEntryDropDownManager method getDependentColumnIndexes.

@Override
public Set<Integer> getDependentColumnIndexes(Context context) {
    final Set<Integer> dependentColumnIndexes = new HashSet<Integer>();
    final Pattern52 basePattern = context.getBasePattern();
    final BaseColumn baseColumn = context.getBaseColumn();
    // Get values for all Constraints or Actions on the same pattern as the baseColumn
    if (baseColumn instanceof ConditionCol52 && basePattern != null) {
        final ConditionCol52 baseConditionColumn = (ConditionCol52) baseColumn;
        for (ConditionCol52 cc : basePattern.getChildColumns()) {
            if (oracle.isDependentEnum(basePattern.getFactType(), baseConditionColumn.getFactField(), cc.getFactField())) {
                dependentColumnIndexes.add(model.getExpandedColumns().indexOf(cc));
            }
        }
    } else if (baseColumn instanceof ActionSetFieldCol52 && basePattern != null) {
        final ActionSetFieldCol52 baseActionColumn = (ActionSetFieldCol52) baseColumn;
        final String binding = baseActionColumn.getBoundName();
        for (ActionCol52 ac : this.model.getActionCols()) {
            if (ac instanceof ActionSetFieldCol52) {
                final ActionSetFieldCol52 asf = (ActionSetFieldCol52) ac;
                if (asf.getBoundName().equals(binding)) {
                    if (oracle.isDependentEnum(basePattern.getFactType(), baseActionColumn.getFactField(), asf.getFactField())) {
                        dependentColumnIndexes.add(model.getExpandedColumns().indexOf(ac));
                    }
                }
            }
        }
    } else if (baseColumn instanceof ActionInsertFactCol52) {
        final ActionInsertFactCol52 baseActionColumn = (ActionInsertFactCol52) baseColumn;
        final String binding = baseActionColumn.getBoundName();
        for (ActionCol52 ac : this.model.getActionCols()) {
            if (ac instanceof ActionInsertFactCol52) {
                final ActionInsertFactCol52 aif = (ActionInsertFactCol52) ac;
                if (aif.getBoundName().equals(binding)) {
                    if (oracle.isDependentEnum(baseActionColumn.getFactType(), baseActionColumn.getFactField(), aif.getFactField())) {
                        dependentColumnIndexes.add(model.getExpandedColumns().indexOf(ac));
                    }
                }
            }
        }
    }
    return dependentColumnIndexes;
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) HashSet(java.util.HashSet)

Aggregations

Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)243 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)184 Test (org.junit.Test)180 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)92 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)66 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)45 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)39 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)34 ArrayList (java.util.ArrayList)31 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)31 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)28 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)27 Path (org.uberfire.backend.vfs.Path)27 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)26 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)26 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)25 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)24 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)24 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)24