Search in sources :

Example 41 with ActionInsertFactCol52

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

the class DTCellValueWidgetFactoryTest method setUp.

@Before
public void setUp() throws Exception {
    ApplicationPreferences.setUp(new HashMap<String, String>() {

        {
            put(ApplicationPreferences.DATE_FORMAT, "dd-MM-yyyy");
        }
    });
    when(model.getTableFormat()).thenReturn(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
    factory = DTCellValueWidgetFactory.getInstance(model, oracle, false, false);
    insertFactCol52 = new ActionInsertFactCol52();
    cellValue = new DTCellValue52();
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Before(org.junit.Before)

Example 42 with ActionInsertFactCol52

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

the class ExtendedGuidedDecisionTableBuilder method createActionInsertFact.

public static ActionInsertFactCol52 createActionInsertFact(String factType, String boundName, String factField, String type) {
    ActionInsertFactCol52 column = new ActionInsertFactCol52();
    column.setFactType(factType);
    column.setBoundName(boundName);
    column.setFactField(factField);
    column.setType(type);
    return column;
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)

Example 43 with ActionInsertFactCol52

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

the class ModelMetaDataEnhancer method getHeaderMetaData.

public HeaderMetaData getHeaderMetaData() {
    int columnIndex = 0;
    final Map<Integer, ModelMetaData> map = new HashMap<>();
    for (final BaseColumn baseColumn : model.getExpandedColumns()) {
        if (baseColumn instanceof ConditionCol52) {
            map.put(columnIndex, new ModelMetaData(model.getPattern((ConditionCol52) baseColumn), PatternType.LHS));
        } else if (baseColumn instanceof ActionInsertFactCol52) {
            final ActionInsertFactCol52 aif = (ActionInsertFactCol52) baseColumn;
            map.put(columnIndex, new ModelMetaData(aif.getFactType(), aif.getBoundName(), PatternType.RHS));
        } else if (baseColumn instanceof ActionSetFieldCol52) {
            final ActionSetFieldCol52 asf = (ActionSetFieldCol52) baseColumn;
            map.put(columnIndex, new ModelMetaData(getFactType(asf), asf.getBoundName(), PatternType.RHS));
        }
        columnIndex++;
    }
    return new HeaderMetaData(map);
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) HashMap(java.util.HashMap) HeaderMetaData(org.drools.workbench.services.verifier.plugin.client.api.HeaderMetaData) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) ModelMetaData(org.drools.workbench.services.verifier.plugin.client.api.ModelMetaData)

Example 44 with ActionInsertFactCol52

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

the class DefaultValueDropDownManager method getCurrentValueMap.

@Override
public Map<String, String> getCurrentValueMap(Context context) {
    Map<String, String> currentValueMap = new HashMap<String, String>();
    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) {
        for (ConditionCol52 cc : basePattern.getChildColumns()) {
            currentValueMap.put(cc.getFactField(), getValue(cc));
        }
    } else if (baseColumn instanceof ActionSetFieldCol52) {
        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)) {
                    currentValueMap.put(asf.getFactField(), getValue(asf));
                }
            }
        }
    } else if (baseColumn instanceof ActionInsertFactCol52) {
        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)) {
                    currentValueMap.put(aif.getFactField(), getValue(aif));
                }
            }
        }
    }
    return currentValueMap;
}
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) HashMap(java.util.HashMap) 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)

Example 45 with ActionInsertFactCol52

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

Aggregations

ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)105 Test (org.junit.Test)74 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)43 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)40 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)39 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)38 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)32 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)24 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)20 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)20 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)20 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)20 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)20 Path (org.uberfire.backend.vfs.Path)20 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)19 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)19 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)15 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)14 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)13 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)13