Search in sources :

Example 21 with ActionInsertFactCol52

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

the class DefaultWidgetFactory method getWidget.

private Widget getWidget(final DTCellValue52 defaultValue) {
    final DTColumnConfig52 column = getPlugin().editingCol();
    final Pattern52 pattern = getPlugin().editingPattern();
    if (column instanceof ActionSetFieldCol52) {
        final ActionSetFieldCol52 col52 = (ActionSetFieldCol52) column;
        return factory().getWidget(pattern, col52, defaultValue);
    } else if (column instanceof ConditionCol52) {
        final ConditionCol52 col52 = (ConditionCol52) column;
        return factory().getWidget(pattern, col52, defaultValue);
    } else if (column instanceof ActionInsertFactCol52) {
        final ActionInsertFactCol52 col52 = (ActionInsertFactCol52) column;
        return factory().getWidget(col52, defaultValue);
    }
    throw new UnsupportedOperationException("The column type is not supported by the 'DefaultWidget'");
}
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) DTColumnConfig52(org.drools.workbench.models.guided.dtable.shared.model.DTColumnConfig52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

Example 22 with ActionInsertFactCol52

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

the class ActionInsertFactFieldsPage method initialise.

@Override
public void initialise() {
    view.init(this);
    view.setValidator(getValidator());
    patternToActionsMap.clear();
    // Set-up validator for the pattern-to-action mapping voodoo
    getValidator().setPatternToActionInsertFactFieldsMap(patternToActionsMap);
    // Set-up a factory for value editors
    view.setDTCellValueWidgetFactory(DTCellValueWidgetFactory.getInstance(model, oracle, false, allowEmptyValues()));
    // Available types
    final List<String> availableTypes = Arrays.asList(oracle.getFactTypes());
    view.setAvailableFactTypes(availableTypes);
    // Existing ActionInsertFactCols (should be empty for a new Decision Table)
    for (ActionCol52 a : model.getActionCols()) {
        if (a instanceof ActionInsertFactCol52) {
            final ActionInsertFactCol52 aif = (ActionInsertFactCol52) a;
            final ActionInsertFactFieldsPattern p = lookupExistingInsertFactPattern(aif.getBoundName());
            final List<ActionInsertFactCol52> actions = patternToActionsMap.get(p);
            getValidator().addActionPattern(p);
            actions.add(aif);
        }
    }
    view.setChosenPatterns(new ArrayList<ActionInsertFactFieldsPattern>());
    view.setAvailableFields(new ArrayList<AvailableField>());
    view.setChosenFields(new ArrayList<ActionInsertFactCol52>());
    content.setWidget(view);
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ActionInsertFactFieldsPattern(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactFieldsPattern)

Example 23 with ActionInsertFactCol52

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

the class ActionInsertFactFieldsPage method isComplete.

@Override
public void isComplete(final Callback<Boolean> callback) {
    // Do all Patterns have unique bindings?
    final boolean arePatternBindingsUnique = getValidator().arePatternBindingsUnique();
    // Signal duplicates to other pages
    final DuplicatePatternsEvent event = new DuplicatePatternsEvent(arePatternBindingsUnique);
    duplicatePatternsEvent.fire(event);
    // Are all Actions defined?
    boolean areActionInsertFieldsDefined = true;
    for (List<ActionInsertFactCol52> actions : patternToActionsMap.values()) {
        for (ActionInsertFactCol52 a : actions) {
            if (!getValidator().isActionValid(a)) {
                areActionInsertFieldsDefined = false;
                break;
            }
        }
    }
    // Signal Action Insert Fact Fields to other pages
    final ActionInsertFactFieldsDefinedEvent eventFactFields = new ActionInsertFactFieldsDefinedEvent(areActionInsertFieldsDefined);
    actionInsertFactFieldsDefinedEvent.fire(eventFactFields);
    callback.callback(arePatternBindingsUnique && areActionInsertFieldsDefined);
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionInsertFactFieldsDefinedEvent(org.drools.workbench.screens.guided.dtable.client.wizard.table.pages.events.ActionInsertFactFieldsDefinedEvent) DuplicatePatternsEvent(org.drools.workbench.screens.guided.dtable.client.wizard.table.pages.events.DuplicatePatternsEvent)

Example 24 with ActionInsertFactCol52

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

the class ActionInsertFactFieldsPage method makeResult.

@Override
public void makeResult(final GuidedDecisionTable52 model) {
    // Copy actions to decision table model
    int fi = 1;
    for (Map.Entry<ActionInsertFactFieldsPattern, List<ActionInsertFactCol52>> ps : patternToActionsMap.entrySet()) {
        final ActionInsertFactFieldsPattern p = ps.getKey();
        if (!getValidator().isPatternValid(p)) {
            String binding = NEW_FACT_PREFIX + (fi++);
            p.setBoundName(binding);
            while (!getValidator().isPatternBindingUnique(p)) {
                binding = NEW_FACT_PREFIX + (fi++);
                p.setBoundName(binding);
            }
        }
        final String factType = p.getFactType();
        final String boundName = p.getBoundName();
        final boolean isLogicalInsert = p.isInsertedLogically();
        for (ActionInsertFactCol52 aif : ps.getValue()) {
            aif.setFactType(factType);
            aif.setBoundName(boundName);
            aif.setInsertLogical(isLogicalInsert);
            model.getActionCols().add(aif);
        }
    }
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionInsertFactFieldsPattern(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactFieldsPattern) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) IdentityHashMap(java.util.IdentityHashMap) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)

Example 25 with ActionInsertFactCol52

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

the class RowExpander method addActionColumns.

private void addActionColumns() {
    for (ActionCol52 a : model.getActionCols()) {
        if (a instanceof ActionSetFieldCol52) {
            ActionSetFieldCol52 afc = (ActionSetFieldCol52) a;
            addColumn(afc);
        } else if (a instanceof ActionInsertFactCol52) {
            ActionInsertFactCol52 aif = (ActionInsertFactCol52) a;
            addColumn(aif);
        }
    }
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)

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