Package org.drools.ide.common.client.modeldriven.brl

Examples of org.drools.ide.common.client.modeldriven.brl.SingleFieldConstraintEBLeftSide


                                         FactPattern pattern,
                                         String fieldName) {

        String valueType;
        if ( constraint instanceof SingleFieldConstraintEBLeftSide ) {
            SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) constraint;
            valueType = sfexp.getExpressionLeftSide().getGenericType();
        } else if ( constraint instanceof ConnectiveConstraint ) {
            ConnectiveConstraint cc = (ConnectiveConstraint) constraint;
            valueType = cc.getFieldType();
        } else {
            valueType = sce.getFieldType( pattern.getFactType(),
View Full Code Here


        this.model = modeller.getModel();
        this.modeller = modeller;
        this.readOnly = readOnly;

        if ( con instanceof SingleFieldConstraintEBLeftSide ) {
            SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) con;
            this.fieldName = sfexp.getExpressionLeftSide().getFieldName();
            this.fieldType = sfexp.getExpressionLeftSide().getGenericType();

        } else if ( con instanceof ConnectiveConstraint ) {
            ConnectiveConstraint cc = (ConnectiveConstraint) con;
            this.fieldName = cc.getFieldName();
            this.fieldType = cc.getFieldType();
View Full Code Here

        //Expressions' fieldName and hence fieldType can change without creating a new ConstraintValueEditor.
        //SingleFieldConstraints and their ConnectiveConstraints cannot have the fieldName or fieldType changed
        //without first deleting and re-creating.
        if ( this.constraint instanceof SingleFieldConstraintEBLeftSide ) {
            SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) this.constraint;
            this.fieldName = sfexp.getExpressionLeftSide().getFieldName();
            this.fieldType = sfexp.getExpressionLeftSide().getGenericType();
        }

        //Set applicable flags and reference data depending upon type
        this.isNumeric = SuggestionCompletionEngine.TYPE_NUMERIC.equals( this.fieldType );
        if ( SuggestionCompletionEngine.TYPE_BOOLEAN.equals( this.fieldType ) ) {
View Full Code Here

        model.lhs = new IPattern[1];
        FactPattern fp0 = new FactPattern();
        fp0.setBoundName( "$t0" );
        fp0.setFactType( "FT0" );

        SingleFieldConstraintEBLeftSide sfc0 = new SingleFieldConstraintEBLeftSide();

        ExpressionFormLine eflhs0 = new ExpressionFormLine();
        eflhs0.setBinding( "$eflhs0" );
        ExpressionText eflhs0p0 = new ExpressionText( "eflhs0p0" );
        eflhs0.appendPart( eflhs0p0 );
        sfc0.setExpressionLeftSide( eflhs0 );

        ExpressionFormLine efl0 = new ExpressionFormLine();
        efl0.setBinding( "$efl0" );
        ExpressionText efl0p0 = new ExpressionText( "efl0p0" );
        efl0.appendPart( efl0p0 );
        sfc0.setExpressionValue( efl0 );

        fp0.addConstraint( sfc0 );

        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
        assertNotNull( clone.lhs[0] );
        assertTrue( clone.lhs[0] instanceof FactPattern );
        FactPattern fp0Clone = (FactPattern) clone.lhs[0];
        assertEquals( fp0.getBoundName(),
                      fp0Clone.getBoundName() );
        assertEquals( fp0.getFactType(),
                      fp0Clone.getFactType() );

        assertEquals( 1,
                      fp0Clone.constraintList.constraints.length );

        assertNotSame( fp0.constraintList.constraints[0],
                       fp0Clone.constraintList.constraints[0] );
        assertNotNull( fp0Clone.constraintList.constraints[0] );
        assertTrue( fp0Clone.constraintList.constraints[0] instanceof SingleFieldConstraintEBLeftSide );
        SingleFieldConstraintEBLeftSide sfc0Clone = (SingleFieldConstraintEBLeftSide) fp0Clone.constraintList.constraints[0];

        assertNotSame( sfc0.getExpressionLeftSide(),
                       sfc0Clone.getExpressionLeftSide() );
        assertNotNull( sfc0Clone.getExpressionLeftSide() );
        assertTrue( sfc0Clone.getExpressionLeftSide() instanceof ExpressionFormLine );
        ExpressionFormLine eflhs0Clone = (ExpressionFormLine) sfc0Clone.getExpressionLeftSide();

        assertEquals( 1,
                      sfc0Clone.getExpressionLeftSide().getParts().size() );
        assertTrue( sfc0Clone.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionText );
        ExpressionText eflhs0p0Clone = (ExpressionText) sfc0Clone.getExpressionLeftSide().getParts().get( 0 );
        assertEquals( eflhs0p0.getClassType(),
                      eflhs0p0Clone.getClassType() );
        assertEquals( eflhs0p0.getName(),
                      eflhs0p0Clone.getName() );
        assertEquals( eflhs0p0.getGenericType(),
                      eflhs0p0Clone.getGenericType() );
        assertEquals( eflhs0p0.getParametricType(),
                      eflhs0p0Clone.getParametricType() );

        assertEquals( eflhs0.getBinding(),
                      eflhs0Clone.getBinding() );
        assertEquals( eflhs0.getClassType(),
                      eflhs0Clone.getClassType() );
        assertEquals( eflhs0.getFieldName(),
                      eflhs0Clone.getFieldName() );
        assertEquals( eflhs0.getGenericType(),
                      eflhs0Clone.getGenericType() );
        assertEquals( eflhs0.getParametricType(),
                      eflhs0Clone.getParametricType() );
        assertEquals( eflhs0.getCurrentName(),
                      eflhs0Clone.getCurrentName() );

        assertNotSame( sfc0.getExpressionValue(),
                       sfc0Clone.getExpressionValue() );
        assertNotNull( sfc0Clone.getExpressionValue() );
        assertTrue( sfc0Clone.getExpressionValue() instanceof ExpressionFormLine );
        ExpressionFormLine efl0Clone = (ExpressionFormLine) sfc0Clone.getExpressionValue();

        assertEquals( 1,
                      sfc0Clone.getExpressionValue().getParts().size() );
        assertTrue( sfc0Clone.getExpressionValue().getParts().get( 0 ) instanceof ExpressionText );
        ExpressionText efl0p0Clone = (ExpressionText) sfc0Clone.getExpressionValue().getParts().get( 0 );
        assertEquals( efl0p0.getClassType(),
                      efl0p0Clone.getClassType() );
        assertEquals( efl0p0.getName(),
                      efl0p0Clone.getName() );
        assertEquals( efl0p0.getGenericType(),
View Full Code Here

            Button ebBtn = new Button( constants.ExpressionEditor() );

            ebBtn.addClickHandler( new ClickHandler() {
                public void onClick(ClickEvent event) {
                    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
                    con.setConstraintValueType( SingleFieldConstraint.TYPE_UNDEFINED );
                    pattern.addConstraint( con );
                    con.setExpressionLeftSide( new ExpressionFormLine( new ExpressionUnboundFact( pattern ) ) );
                    modeller.refreshWidget();
                    popup.hide();
                }
            } );
            popup.addAttribute( constants.ExpressionEditor(),
View Full Code Here

                            variables.add( fp.getBoundName() );
                        }

                        for ( FieldConstraint fc : fp.getFieldConstraints() ) {
                            if ( fc instanceof SingleFieldConstraintEBLeftSide ) {
                                SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fc;
                                if ( exp.getExpressionLeftSide() != null && exp.getExpressionLeftSide().isBound() ) {
                                    variables.add( exp.getExpressionLeftSide().getBinding() );
                                }
                            } else if ( fc instanceof SingleFieldConstraint ) {
                                SingleFieldConstraint sfc = (SingleFieldConstraint) fc;
                                if ( sfc.isBound() ) {
                                    variables.add( sfc.getFieldBinding() );
View Full Code Here

                    HasParameterizedOperator hop = (HasParameterizedOperator) constr;
                    parameters = hop.getParameters();
                }

                if ( constr instanceof SingleFieldConstraintEBLeftSide ) {
                    SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) constr;
                    addFieldRestriction( buf,
                                         sfexp.getConstraintValueType(),
                                         sfexp.getExpressionLeftSide().getGenericType(),
                                         sfexp.getOperator(),
                                         parameters,
                                         sfexp.getValue(),
                                         sfexp.getExpressionValue() );
                } else {
                    addFieldRestriction( buf,
                                         constr.getConstraintValueType(),
                                         constr.getFieldType(),
                                         constr.getOperator(),
View Full Code Here

        clone.setValue( cc.getValue() );
        return clone;
    }

    private SingleFieldConstraintEBLeftSide visitSingleFieldConstraint(SingleFieldConstraintEBLeftSide sfexp) {
        SingleFieldConstraintEBLeftSide clone = new SingleFieldConstraintEBLeftSide();
        clone.setConstraintValueType( sfexp.getConstraintValueType() );
        clone.setExpressionLeftSide( (ExpressionFormLine) visit( sfexp.getExpressionLeftSide() ) );
        clone.setExpressionValue( (ExpressionFormLine) visit( sfexp.getExpressionValue() ) );
        clone.setFieldBinding( sfexp.getFieldBinding() );
        clone.setFieldName( sfexp.getFieldName() );
        clone.setFieldType( sfexp.getFieldType() );
        clone.setOperator( sfexp.getOperator() );
        for ( Map.Entry<String, String> entry : sfexp.getParameters().entrySet() ) {
            clone.setParameter( entry.getKey(),
                                entry.getValue() );
        }
        clone.setParent( sfexp.getParent() );
        clone.setValue( sfexp.getValue() );

        if ( sfexp.connectives != null ) {
            clone.connectives = new ConnectiveConstraint[sfexp.connectives.length];
            for ( int i = 0; i < sfexp.connectives.length; i++ ) {
                clone.connectives[i] = (ConnectiveConstraint) visit( sfexp.connectives[i] );
View Full Code Here

        model.lhs = new IPattern[1];
        final FactPattern fp = new FactPattern( "Car" );
        model.lhs[0] = fp;
        fp.setBoundName( "$c" );

        SingleFieldConstraint sfc = new SingleFieldConstraintEBLeftSide( "make" );
        sfc.getExpressionValue().appendPart( new ExpressionField("make", "java.lang.String", SuggestionCompletionEngine.TYPE_STRING) );
        sfc.setFieldBinding( "$m" );
        fp.addConstraint( sfc );

        List<String> vars = model.getAllVariables();
        assertEquals( 2,
                      vars.size() );
View Full Code Here

        RuleModel m = new RuleModel();
        m.name = "test expressionsString2";

        FactPattern p = new FactPattern( "Person" );
        SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
        con.getExpressionLeftSide().appendPart( new ExpressionUnboundFact( p ) );
        con.getExpressionLeftSide().appendPart( new ExpressionField( "field1",
                                                                     "java.lang.String",
                                                                     SuggestionCompletionEngine.TYPE_STRING ) );
        con.setOperator( "==" );
        con.setValue( "Cheddar" );
        con.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
        p.addConstraint( con );

        m.addLhsItem( p );

        String result = BRDRLPersistence.getInstance().marshal( m );
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.brl.SingleFieldConstraintEBLeftSide

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.