Search in sources :

Example 26 with ModelField

use of org.kie.soup.project.datamodel.oracle.ModelField in project drools-wb by kiegroup.

the class BRLActionColumnSynchronizerTest method getOracle.

@Override
protected AsyncPackageDataModelOracle getOracle() {
    final AsyncPackageDataModelOracle oracle = super.getOracle();
    oracle.addModelFields(new HashMap<String, ModelField[]>() {

        {
            put("Applicant", new ModelField[] { modelField("this", "Applicant"), modelField("age", DataType.TYPE_NUMERIC_INTEGER), modelField("salary", DataType.TYPE_NUMERIC_LONG), modelField("name", DataType.TYPE_STRING) });
            put("Address", new ModelField[] { modelField("this", "Address"), modelField("country", DataType.TYPE_STRING) });
        }
    });
    return oracle;
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ModelField(org.kie.soup.project.datamodel.oracle.ModelField)

Example 27 with ModelField

use of org.kie.soup.project.datamodel.oracle.ModelField in project drools-wb by kiegroup.

the class ActionSetFieldColumnSynchronizerTest method getOracle.

@Override
protected AsyncPackageDataModelOracle getOracle() {
    final AsyncPackageDataModelOracle oracle = super.getOracle();
    oracle.addModelFields(Collections.singletonMap("Applicant", new ModelField[] { modelField("this", "Applicant"), modelField("age", DataType.TYPE_NUMERIC_INTEGER), modelField("name", DataType.TYPE_STRING), modelField("approved", DataType.TYPE_BOOLEAN) }));
    return oracle;
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ModelField(org.kie.soup.project.datamodel.oracle.ModelField)

Example 28 with ModelField

use of org.kie.soup.project.datamodel.oracle.ModelField in project drools-wb by kiegroup.

the class BRLConditionColumnSynchronizerTest method getOracle.

@Override
protected AsyncPackageDataModelOracle getOracle() {
    final AsyncPackageDataModelOracle oracle = super.getOracle();
    oracle.addModelFields(new HashMap<String, ModelField[]>() {

        {
            put("Applicant", new ModelField[] { modelField("this", "Applicant"), modelField("age", DataType.TYPE_NUMERIC_INTEGER), modelField("salary", DataType.TYPE_NUMERIC_LONG), modelField("name", DataType.TYPE_STRING) });
            put("Address", new ModelField[] { modelField("this", "Address"), modelField("country", DataType.TYPE_STRING) });
        }
    });
    return oracle;
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ModelField(org.kie.soup.project.datamodel.oracle.ModelField)

Example 29 with ModelField

use of org.kie.soup.project.datamodel.oracle.ModelField in project drools-wb by kiegroup.

the class PopupCreator method showPatternPopup.

/**
 * This shows a popup allowing you to add field constraints to a pattern
 * (its a popup).
 */
public void showPatternPopup(final FactPattern fp, final SingleFieldConstraint con, final boolean isNested) {
    final String factType = getFactType(fp, con);
    String title = (con == null) ? GuidedRuleEditorResources.CONSTANTS.ModifyConstraintsFor0(fp.getFactType()) : GuidedRuleEditorResources.CONSTANTS.AddSubFieldConstraint();
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), title);
    final ListBox box = new ListBox();
    box.addItem("...");
    this.oracle.getFieldCompletions(factType, FieldAccessorsAndMutators.ACCESSOR, new Callback<ModelField[]>() {

        @Override
        public void callback(final ModelField[] fields) {
            for (int i = 0; i < fields.length; i++) {
                // You can't use "this" in a nested accessor
                final String fieldName = fields[i].getName();
                if (!isNested || !fieldName.equals(DataType.TYPE_THIS)) {
                    box.addItem(fieldName);
                }
            }
        }
    });
    box.setSelectedIndex(0);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String fieldName = box.getItemText(box.getSelectedIndex());
            if ("...".equals(fieldName)) {
                return;
            }
            String fieldType = oracle.getFieldType(factType, fieldName);
            fp.addConstraint(new SingleFieldConstraint(factType, fieldName, fieldType, con));
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddARestrictionOnAField(), box);
    final ListBox composites = new ListBox();
    composites.addItem("...");
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AllOfAnd(), CompositeFieldConstraint.COMPOSITE_TYPE_AND);
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR);
    composites.setSelectedIndex(0);
    composites.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            CompositeFieldConstraint comp = new CompositeFieldConstraint();
            comp.setCompositeJunctionType(composites.getValue(composites.getSelectedIndex()));
            fp.addConstraint(comp);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    InfoPopup infoComp = new InfoPopup(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraints(), GuidedRuleEditorResources.CONSTANTS.MultipleConstraintsTip1());
    HorizontalPanel horiz = new HorizontalPanel();
    horiz.add(composites);
    horiz.add(infoComp);
    if (con == null) {
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraint(), horiz);
    }
    if (con == null) {
        // NON-NLS
        popup.addRow(new SmallLabel("<i>" + GuidedRuleEditorResources.CONSTANTS.AdvancedOptionsColon() + "</i>"));
        Button predicate = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
        predicate.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                SingleFieldConstraint con = new SingleFieldConstraint();
                con.setConstraintValueType(SingleFieldConstraint.TYPE_PREDICATE);
                fp.addConstraint(con);
                modeller.refreshWidget();
                popup.hide();
            }
        });
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddANewFormulaStyleExpression(), predicate);
        final Button expressionEditorButton = makeExpressionEditorButton(fp, popup);
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), expressionEditorButton);
        doBindingEditor(popup);
    }
    popup.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 30 with ModelField

use of org.kie.soup.project.datamodel.oracle.ModelField in project drools-wb by kiegroup.

the class PopupCreator method showPatternPopupForComposite.

/**
 * This shows a popup for adding fields to a composite
 */
public void showPatternPopupForComposite(final HasConstraints hasConstraints) {
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddFieldsToThisConstraint());
    final ListBox box = new ListBox();
    box.addItem("...");
    this.oracle.getFieldCompletions(this.pattern.getFactType(), new Callback<ModelField[]>() {

        @Override
        public void callback(final ModelField[] fields) {
            for (int i = 0; i < fields.length; i++) {
                final String fieldName = fields[i].getName();
                box.addItem(fieldName);
            }
        }
    });
    box.setSelectedIndex(0);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String factType = pattern.getFactType();
            String fieldName = box.getItemText(box.getSelectedIndex());
            String fieldType = getDataModelOracle().getFieldType(factType, fieldName);
            hasConstraints.addConstraint(new SingleFieldConstraint(factType, fieldName, fieldType, null));
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddARestrictionOnAField(), box);
    final ListBox composites = new ListBox();
    // NON-NLS
    composites.addItem("...");
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AllOfAnd(), CompositeFieldConstraint.COMPOSITE_TYPE_AND);
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR);
    composites.setSelectedIndex(0);
    composites.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            CompositeFieldConstraint comp = new CompositeFieldConstraint();
            comp.setCompositeJunctionType(composites.getValue(composites.getSelectedIndex()));
            hasConstraints.addConstraint(comp);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    InfoPopup infoComp = new InfoPopup(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraints(), GuidedRuleEditorResources.CONSTANTS.MultipleConstraintsTip());
    HorizontalPanel horiz = new HorizontalPanel();
    horiz.add(composites);
    horiz.add(infoComp);
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraint(), horiz);
    // Include Expression Editor
    popup.addRow(new SmallLabel("<i>" + GuidedRuleEditorResources.CONSTANTS.AdvancedOptionsColon() + "</i>"));
    Button predicate = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
    predicate.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            SingleFieldConstraint con = new SingleFieldConstraint();
            con.setConstraintValueType(SingleFieldConstraint.TYPE_PREDICATE);
            hasConstraints.addConstraint(con);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddANewFormulaStyleExpression(), predicate);
    final Button expressionEditorButton = makeExpressionEditorButton(hasConstraints, popup);
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), expressionEditorButton);
    popup.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Aggregations

ModelField (org.kie.soup.project.datamodel.oracle.ModelField)70 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)36 Test (org.junit.Test)34 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)34 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)25 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)24 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)24 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)24 Path (org.uberfire.backend.vfs.Path)24 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)23 ArrayList (java.util.ArrayList)20 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)19 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)14 List (java.util.List)13 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)11 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)11 ModuleDataModelOracleImpl (org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl)10 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)9 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)9 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)9