Package org.drools.workbench.models.commons.shared.rule

Examples of org.drools.workbench.models.commons.shared.rule.SingleFieldConstraint


                int endSquare = value.indexOf(']');
                operatorParams = value.substring(1, endSquare).trim();
                value = value.substring(endSquare+1).trim();
            }

            SingleFieldConstraint fieldConstraint = isExpression ?
                    createExpressionBuilderConstraint(factPattern, fieldName, operator, value) :
                    createSingleFieldConstraint(fieldName, operator, value);

            if (operatorParams != null) {
                int i = 0;
                for (String param : operatorParams.split(",")) {
                    ((BaseSingleFieldConstraint) fieldConstraint).setParameter("" + i++, param.trim());
                }
                ((BaseSingleFieldConstraint) fieldConstraint).setParameter("org.kie.guvnor.guided.editor.visibleParameterSet", "" + i);
                ((BaseSingleFieldConstraint) fieldConstraint).setParameter("org.kie.guvnor.guided.server.util.BRDRLPersistence.operatorParameterGenerator",
                                                                           "org.drools.workbench.models.commons.backend.rule.CEPOperatorParameterDRLBuilder");
            }

            if ( fieldName.equals("this") && (operator == null || operator.equals("!= null")) ) {
                fieldConstraint.setFieldType(DataType.TYPE_THIS);
            }
            fieldConstraint.setFactType( factPattern.getFactType() );

            return fieldConstraint;
        }
View Full Code Here


                                                                         String value ) {
            // TODO: we should find a way to know when the expression uses a getter and in this case create a plain SingleFieldConstraint
            //int dotPos = fieldName.lastIndexOf('.');
            //SingleFieldConstraint con = createSingleFieldConstraint(dotPos > 0 ? fieldName.substring(dotPos+1) : fieldName, operator, value);

            SingleFieldConstraint con = createSingleFieldConstraintEBLeftSide( factPattern, fieldName, operator, value );

            for (FieldConstraint fieldConstraint : factPattern.getFieldConstraints()) {
                if (fieldConstraint instanceof SingleFieldConstraint) {
                    SingleFieldConstraint sfc = (SingleFieldConstraint) fieldConstraint;
                    if (sfc.getOperator().equals("!= null")) {
                        int parentPos = fieldName.indexOf(sfc.getFieldName() + ".");
                        if (parentPos >= 0 && !fieldName.substring(parentPos + sfc.getFieldName().length()+1).contains(".")) {
                            con.setParent(sfc);
                            break;
                        }
                    }
                }
View Full Code Here

        }

        private SingleFieldConstraint createSingleFieldConstraint( String fieldName,
                                                                   String operator,
                                                                   String value ) {
            SingleFieldConstraint con = new SingleFieldConstraint();
            fieldName = setFieldBindingOnContraint( fieldName, con );
            con.setFieldName(fieldName);
            setOperatorAndValueOnConstraint( operator, value, con );
            return con;
        }
View Full Code Here

        }

        private SingleFieldConstraint createParentFor( FactPattern factPattern, String fieldName ) {
            int dotPos = fieldName.lastIndexOf('.');
            if (dotPos > 0) {
                SingleFieldConstraint constraint = createNullCheckFieldConstraint(factPattern, fieldName.substring(0, dotPos));
                factPattern.addConstraint( constraint );
                return constraint;
            }
            return null;
        }
View Full Code Here

        private EvalExpr( String expr ) {
            this.expr = expr;
        }

        public FieldConstraint asFieldConstraint( FactPattern factPattern ) {
            SingleFieldConstraint con = new SingleFieldConstraint();
            con.setConstraintValueType( SingleFieldConstraint.TYPE_PREDICATE );
            con.setValue( expr );
            return con;
        }
View Full Code Here

            this.factType = cc.getFactType();
            this.fieldName = cc.getFieldName();
            this.fieldType = cc.getFieldType();

        } else if ( con instanceof SingleFieldConstraint ) {
            SingleFieldConstraint sfc = (SingleFieldConstraint) con;
            this.factType = sfc.getFactType();
            this.fieldName = sfc.getFieldName();
            this.fieldType = sce.getFieldType( factType,
                                               fieldName );
        }

        refreshEditor();
View Full Code Here

    private Widget literalEditor() {

        //Custom screen
        if ( this.constraint instanceof SingleFieldConstraint ) {
            final SingleFieldConstraint con = (SingleFieldConstraint) this.constraint;
            CustomFormConfiguration customFormConfiguration = getWorkingSetManager().getCustomFormConfiguration( modeller.getPath(),
                                                                                                                 factType,
                                                                                                                 fieldName );
            if ( customFormConfiguration != null ) {
                Button btnCustom = new Button( con.getValue(),
                                               new ClickHandler() {

                                                   public void onClick( ClickEvent event ) {
                                                       showTypeChoice( (Widget) event.getSource(),
                                                                       constraint );
                                                   }
                                               } );
                btnCustom.setEnabled( !this.readOnly );
                return btnCustom;
            }
        }

        //Label if read-only
        if ( this.readOnly ) {
            return new SmallLabel( assertValue() );
        }

        //Enumeration (these support multi-select for "in" and "not in", so check before comma separated lists)
        if ( this.dropDownData != null ) {
            final String operator = constraint.getOperator();
            final boolean multipleSelect = OperatorsOracle.operatorRequiresList(operator);
            EnumDropDown enumDropDown = new EnumDropDown( constraint.getValue(),
                                                          new DropDownValueChanged() {

                                                              public void valueChanged( String newText,
                                                                                        String newValue ) {

                                                                  //Prevent recursion once value change has been applied
                                                                  if ( !newValue.equals( constraint.getValue() ) ) {
                                                                      constraint.setValue( newValue );
                                                                      executeOnValueChangeCommand();
                                                                      makeDirty();
                                                                  }
                                                              }
                                                          },
                                                          dropDownData,
                                                          multipleSelect );
            return enumDropDown;
        }

        //Comma separated value list (this will become a dedicated Widget but for now a TextBox suffices)
        String operator = null;
        if ( this.constraint instanceof SingleFieldConstraint ) {
            SingleFieldConstraint sfc = (SingleFieldConstraint) this.constraint;
            operator = sfc.getOperator();
        }
        if ( OperatorsOracle.operatorRequiresList( operator ) ) {
            final TextBox box = TextBoxFactory.getTextBox( DataType.TYPE_STRING );
            box.setStyleName( "constraint-value-Editor" );
            box.addChangeHandler( new ChangeHandler() {
View Full Code Here

            }
            final CustomFormPopUp customFormPopUp = new CustomFormPopUp( GuidedRuleEditorImages508.INSTANCE.Wizard(),
                                                                         Constants.INSTANCE.FieldValue(),
                                                                         customFormConfiguration );

            final SingleFieldConstraint sfc = (SingleFieldConstraint) con;

            customFormPopUp.addOkButtonHandler( new ClickHandler() {

                public void onClick( ClickEvent event ) {
                    sfc.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
                    sfc.setId( customFormPopUp.getFormId() );
                    sfc.setValue( customFormPopUp.getFormValue() );
                    doTypeChosen( customFormPopUp );
                }
            } );

            customFormPopUp.show( sfc.getId(),
                                  sfc.getValue() );
            return;
        }

        final FormStylePopup form = new FormStylePopup( GuidedRuleEditorImages508.INSTANCE.Wizard(),
                                                        Constants.INSTANCE.FieldValue() );

        Button lit = new Button( Constants.INSTANCE.LiteralValue() );
        lit.addClickHandler( new ClickHandler() {
            public void onClick( ClickEvent event ) {
                con.setConstraintValueType( isDropDownDataEnum && dropDownData != null ? SingleFieldConstraint.TYPE_ENUM : SingleFieldConstraint.TYPE_LITERAL );
                doTypeChosen( form );
            }
        } );

        boolean showLiteralSelector = true;
        boolean showFormulaSelector = !OperatorsOracle.operatorRequiresList( con.getOperator() );
        boolean showVariableSelector = !OperatorsOracle.operatorRequiresList( con.getOperator() );
        boolean showExpressionSelector = !OperatorsOracle.operatorRequiresList( con.getOperator() );

        if ( con instanceof SingleFieldConstraint ) {
            SingleFieldConstraint sfc = (SingleFieldConstraint) con;
            String fieldName = sfc.getFieldName();
            if ( fieldName.equals( DataType.TYPE_THIS ) ) {
                showLiteralSelector = CEPOracle.isCEPOperator( sfc.getOperator() );
                showFormulaSelector = showFormulaSelector && showLiteralSelector;
            }
        } else if ( con instanceof ConnectiveConstraint ) {
            ConnectiveConstraint cc = (ConnectiveConstraint) con;
            String fieldName = cc.getFieldName();
View Full Code Here

            final Map<String, String> currentValueMap = new HashMap<String, String>();

            if ( constraintList != null && constraintList.getConstraints() != null ) {
                for ( FieldConstraint con : constraintList.getConstraints() ) {
                    if ( con instanceof SingleFieldConstraint ) {
                        SingleFieldConstraint sfc = (SingleFieldConstraint) con;
                        String fieldName = sfc.getFieldName();
                        currentValueMap.put( fieldName,
                                             sfc.getValue() );
                    }
                }
            }

            this.dropDownData = sce.getEnums( this.factType,
View Full Code Here

                                                 HasConstraints hasConstraints,
                                                 int i ) {
        int tabs = -1;
        FieldConstraint current = sortedConst.get( i );
        if ( current instanceof SingleFieldConstraint ) {
            SingleFieldConstraint single = (SingleFieldConstraint) current;
            FieldConstraint parent = single.getParent();

            for ( int j = 0; j < parents.size(); j++ ) {
                FieldConstraint storedParent = parents.get( j );
                if ( storedParent != null && storedParent.equals( parent ) ) {
                    tabs = j + 1;
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.commons.shared.rule.SingleFieldConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.