Search in sources :

Example 31 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class ActionValueEditorTest method testGetDropDownData.

@Test
public void testGetDropDownData() throws Exception {
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final String factType = "Car";
    final String factField = "color";
    final ActionFieldValue value = new ActionFieldValue() {

        {
            setField(factField);
        }
    };
    final ActionFieldValue[] values = new ActionFieldValue[0];
    final RuleModeller modeller = mock(RuleModeller.class);
    doReturn(oracle).when(modeller).getDataModelOracle();
    final EventBus eventBus = mock(EventBus.class);
    final String variableType = DataType.TYPE_STRING;
    final boolean readOnly = false;
    actionValueEditor = new ActionValueEditor(factType, value, values, modeller, eventBus, variableType, readOnly);
    // reset oracle due to calls in ActionValueEditor constructor
    reset(oracle);
    actionValueEditor.getDropDownData();
    final Map<String, String> fieldValues = new HashMap<>();
    verify(oracle).getEnums(eq(factType), eq(factField), eq(fieldValues));
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) HashMap(java.util.HashMap) EventBus(com.google.gwt.event.shared.EventBus) Test(org.junit.Test)

Example 32 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class DSLDropDownTest method testGetDropDown.

@Test
public void testGetDropDown() throws Exception {
    final String fact = "Fact";
    final String field = "field";
    final AsyncPackageDataModelOracle oracle = mock(AsyncPackageDataModelOracle.class);
    final RuleModeller ruleModeller = mock(RuleModeller.class);
    doReturn(oracle).when(ruleModeller).getDataModelOracle();
    final String variableDefinition = "varName:type:" + fact + "." + field;
    final DSLSentence dslSentence = mock(DSLSentence.class);
    final DSLVariableValue dslVariableValue = mock(DSLVariableValue.class);
    final boolean isMultipleSelect = false;
    final Callback<DSLDropDown> updateEnumsCallback = mock(Callback.class);
    testedDropDown = new DSLDropDown(ruleModeller, variableDefinition, dslSentence, dslVariableValue, isMultipleSelect, updateEnumsCallback);
    // reset oracle due to calls in DSLDropDown constructor
    reset(oracle);
    testedDropDown.getDropDownData();
    verify(oracle).getEnums(eq(fact), eq(field), anyMap());
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) RuleModeller(org.drools.workbench.screens.guided.rule.client.editor.RuleModeller) DSLVariableValue(org.drools.workbench.models.datamodel.rule.DSLVariableValue) DSLSentence(org.drools.workbench.models.datamodel.rule.DSLSentence) Test(org.junit.Test)

Example 33 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class FromAccumulateCompositeFactPatternWidget method showSourcePatternSelector.

/**
 * Pops up the fact selector.
 */
protected void showSourcePatternSelector() {
    final ListBox box = new ListBox();
    AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
    String[] facts = oracle.getFactTypes();
    box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
    for (int i = 0; i < facts.length; i++) {
        box.addItem(facts[i]);
    }
    box.setSelectedIndex(0);
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            getFromAccumulatePattern().setSourcePattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    final Button fromBtn = new Button(HumanReadableConstants.INSTANCE.From());
    final Button fromAccumulateBtn = new Button(HumanReadableConstants.INSTANCE.FromAccumulate());
    final Button fromCollectBtn = new Button(HumanReadableConstants.INSTANCE.FromCollect());
    final Button fromEntryPointBtn = new Button(HumanReadableConstants.INSTANCE.FromEntryPoint());
    ClickHandler btnsClickHandler = new ClickHandler() {

        public void onClick(ClickEvent event) {
            Widget sender = (Widget) event.getSource();
            if (sender == fromBtn) {
                getFromAccumulatePattern().setSourcePattern(new FromCompositeFactPattern());
            } else if (sender == fromAccumulateBtn) {
                getFromAccumulatePattern().setSourcePattern(new FromAccumulateCompositeFactPattern());
            } else if (sender == fromCollectBtn) {
                getFromAccumulatePattern().setSourcePattern(new FromCollectCompositeFactPattern());
            } else if (sender == fromEntryPointBtn) {
                getFromAccumulatePattern().setSourcePattern(new FromEntryPointFactPattern());
            } else {
                throw new IllegalArgumentException("Unknown sender: " + sender);
            }
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    };
    fromBtn.addClickHandler(btnsClickHandler);
    fromAccumulateBtn.addClickHandler(btnsClickHandler);
    fromCollectBtn.addClickHandler(btnsClickHandler);
    fromEntryPointBtn.addClickHandler(btnsClickHandler);
    popup.addAttribute("", fromBtn);
    popup.addAttribute("", fromAccumulateBtn);
    popup.addAttribute("", fromCollectBtn);
    popup.addAttribute("", fromEntryPointBtn);
    popup.show();
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) Widget(com.google.gwt.user.client.ui.Widget) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 34 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class FromAccumulateCompositeFactPatternWidget method showFactTypeSelector.

/**
 * Pops up the fact selector.
 */
@Override
protected void showFactTypeSelector() {
    final ListBox box = GWT.create(ListBox.class);
    AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
    String[] facts = oracle.getFactTypes();
    box.addItem(GuidedRuleEditorResources.CONSTANTS.Choose());
    for (int i = 0; i < facts.length; i++) {
        box.addItem(facts[i]);
    }
    box.setSelectedIndex(0);
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.NewFactPattern());
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.chooseFactType(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    popup.show();
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 35 with AsyncPackageDataModelOracle

use of org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle in project drools-wb by kiegroup.

the class ConditionColumnPlugin method assertDefaultValue.

void assertDefaultValue() {
    final CellUtilities cellUtilities = new CellUtilities();
    final AsyncPackageDataModelOracle oracle = presenter.getDataModelOracle();
    final ColumnUtilities columnUtilities = new ColumnUtilities(model(), oracle);
    final List<String> valueList = Arrays.asList(columnUtilities.getValueList(editingCol));
    if (valueList.size() > 0) {
        final String defaultValue = cellUtilities.asString(editingCol().getDefaultValue());
        if (!valueList.contains(defaultValue)) {
            editingCol.getDefaultValue().clearValues();
        }
    } else {
        // Ensure the Default Value has been updated to represent the column's data-type.
        final DTCellValue52 defaultValue = editingCol().getDefaultValue();
        final DataType.DataTypes dataType = columnUtilities.getDataType(editingPattern(), editingCol());
        cellUtilities.convertDTCellValueType(dataType, defaultValue);
    }
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ColumnUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities) CellUtilities(org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.CellUtilities) DataType(org.kie.soup.project.datamodel.oracle.DataType) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Aggregations

AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)62 Test (org.junit.Test)36 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)36 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)31 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)29 Path (org.uberfire.backend.vfs.Path)29 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)26 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)26 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)25 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)24 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)19 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)15 List (java.util.List)12 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)12 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)12 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)11 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)10 ArrayList (java.util.ArrayList)9 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)9 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)9