Package org.drools.workbench.models.datamodel.rule

Examples of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide


                      fp.getFactType() );

        assertEquals( 1,
                      fp.getNumberOfConstraints() );
        assertTrue( fp.getConstraint( 0 ) instanceof SingleFieldConstraintEBLeftSide );
        final SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fp.getConstraint( 0 );
        assertEquals( "int",
                      exp.getFieldType() );
        assertEquals( ">",
                      exp.getOperator() );
        assertEquals( "5",
                      exp.getValue() );

        assertEquals( 3,
                      exp.getExpressionLeftSide().getParts().size() );
        assertTrue( exp.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionUnboundFact );
        final ExpressionUnboundFact expPart0 = (ExpressionUnboundFact) exp.getExpressionLeftSide().getParts().get( 0 );
        assertEquals( "Number",
                      expPart0.getFact().getFactType() );

        assertTrue( exp.getExpressionLeftSide().getParts().get( 1 ) instanceof ExpressionField );
        final ExpressionField expPart1 = (ExpressionField) exp.getExpressionLeftSide().getParts().get( 1 );
        assertEquals( "this",
                      expPart1.getName() );

        assertTrue( exp.getExpressionLeftSide().getParts().get( 2 ) instanceof ExpressionMethod );
        final ExpressionMethod expPart2 = (ExpressionMethod) exp.getExpressionLeftSide().getParts().get( 2 );
        assertEquals( "intValue",
                      expPart2.getName() );
    }
View Full Code Here


                      fp.getFactType() );

        assertEquals( 1,
                      fp.getNumberOfConstraints() );
        assertTrue( fp.getConstraint( 0 ) instanceof SingleFieldConstraintEBLeftSide );
        final SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fp.getConstraint( 0 );
        assertEquals( "int",
                      exp.getFieldType() );
        assertEquals( ">",
                      exp.getOperator() );
        assertEquals( "5",
                      exp.getValue() );

        assertEquals( 4,
                      exp.getExpressionLeftSide().getParts().size() );
        assertTrue( exp.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionUnboundFact );
        final ExpressionUnboundFact expPart0 = (ExpressionUnboundFact) exp.getExpressionLeftSide().getParts().get( 0 );
        assertEquals( "Parent",
                      expPart0.getFact().getFactType() );

        assertTrue( exp.getExpressionLeftSide().getParts().get( 1 ) instanceof ExpressionMethod );
        final ExpressionMethod expPart1 = (ExpressionMethod) exp.getExpressionLeftSide().getParts().get( 1 );
        assertEquals( "methodToGetChild1",
                      expPart1.getName() );

        assertTrue( exp.getExpressionLeftSide().getParts().get( 2 ) instanceof ExpressionMethod );
        final ExpressionMethod expPart2 = (ExpressionMethod) exp.getExpressionLeftSide().getParts().get( 2 );
        assertEquals( "methodToGetChild2",
                      expPart2.getName() );

        assertTrue( exp.getExpressionLeftSide().getParts().get( 3 ) instanceof ExpressionField );
        final ExpressionField expPart3 = (ExpressionField) exp.getExpressionLeftSide().getParts().get( 3 );
        assertEquals( "field1",
                      expPart3.getName() );
    }
View Full Code Here

        private SingleFieldConstraintEBLeftSide createSingleFieldConstraintEBLeftSide( RuleModel m,
                                                                                       FactPattern factPattern,
                                                                                       String fieldName,
                                                                                       String operator,
                                                                                       String value ) {
            SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();

            fieldName = setFieldBindingOnContraint( factPattern.getFactType(),
                                                    fieldName,
                                                    m,
                                                    con,
                                                    boundParams );
            String classType = getFQFactType( m, factPattern.getFactType() );
            con.getExpressionLeftSide().appendPart( new ExpressionUnboundFact( factPattern ) );

            parseExpression( m, classType, fieldName, con.getExpressionLeftSide() );

            setOperatorAndValueOnConstraint( m,
                                             operator,
                                             value,
                                             factPattern,
View Full Code Here

                                            FactPattern factPattern,
                                            BaseSingleFieldConstraint con ) {
            String factType = null;
            String fieldName = null;
            if ( con instanceof SingleFieldConstraintEBLeftSide ) {
                SingleFieldConstraintEBLeftSide sfcex = (SingleFieldConstraintEBLeftSide) con;
                List<ExpressionPart> sfcexParts = sfcex.getExpressionLeftSide().getParts();
                factType = sfcexParts.get( sfcexParts.size() - 1 ).getPrevious().getClassType();
                fieldName = sfcex.getFieldName();
            } else if ( con instanceof SingleFieldConstraint ) {
                factType = factPattern.getFactType();
                fieldName = ( (SingleFieldConstraint) con ).getFieldName();
            } else if ( con instanceof ConnectiveConstraint ) {
                factType = factPattern.getFactType();
View Full Code Here

        }

        private void generateNormalFieldRestriction( SingleFieldConstraint constr,
                                                     Map<String, String> parameters ) {
            if ( constr instanceof SingleFieldConstraintEBLeftSide ) {
                SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) constr;
                addFieldRestriction( buf,
                                     sfexp.getConstraintValueType(),
                                     sfexp.getExpressionLeftSide().getGenericType(),
                                     sfexp.getOperator(),
                                     parameters,
                                     sfexp.getValue(),
                                     sfexp.getExpressionValue(),
                                     true );
            } else {
                addFieldRestriction( buf,
                                     constr.getConstraintValueType(),
                                     constr.getFieldType(),
View Full Code Here

                                                         GeneratorContext gctx ) {
            GeneratorContext cctx = generatorContextFactory.newChildGeneratorContext( gctx );
            preGenerateConstraints( cctx );
            cctx.setFieldConstraint( constr );
            if ( constr instanceof SingleFieldConstraintEBLeftSide ) {
                SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) constr;
                addConnectiveFieldRestriction( buf,
                                               sfexp.getConstraintValueType(),
                                               sfexp.getExpressionLeftSide().getGenericType(),
                                               sfexp.getOperator(),
                                               parameters,
                                               sfexp.getValue(),
                                               sfexp.getExpressionValue(),
                                               cctx,
                                               true );
            } else {
                addConnectiveFieldRestriction( buf,
                                               constr.getConstraintValueType(),
View Full Code Here

        private SingleFieldConstraintEBLeftSide createSingleFieldConstraintEBLeftSide( FactPattern factPattern,
                                                                                       String fieldName,
                                                                                       String operator,
                                                                                       String value ) {
            SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();

            fieldName = setFieldBindingOnContraint( fieldName, con );
            String classType = getFQFactType( factPattern.getFactType() );
            con.getExpressionLeftSide().appendPart( new ExpressionUnboundFact( factPattern,
                                                                               classType ) );

            String type = setOperatorAndValueOnConstraint( operator,
                                                           value,
                                                           con );

            parseExpression( classType, fieldName, type, con.getExpressionLeftSide() );

            return con;
        }
View Full Code Here

                        HasParameterizedOperator hop = 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

        assertEquals( 1,
                      m.lhs.length );
        FactPattern pattern = (FactPattern) m.lhs[ 0 ];
        assertEquals( 1,
                      pattern.getConstraintList().getConstraints().length );
        SingleFieldConstraintEBLeftSide constraint = (SingleFieldConstraintEBLeftSide) pattern.getConstraint( 0 );
        assertEquals( "size",
                      constraint.getFieldName() );
        assertEquals( "int",
                      constraint.getFieldType() );
        assertEquals( "0",
                      constraint.getValue() );
        assertEquals( "==",
                      constraint.getOperator() );
        assertEquals( 1,
                      constraint.getConstraintValueType() );

        assertTrue( constraint.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionUnboundFact );
        assertTrue( constraint.getExpressionLeftSide().getParts().get( 1 ) instanceof ExpressionCollection );
        assertTrue( constraint.getExpressionLeftSide().getParts().get( 2 ) instanceof ExpressionMethod );

        assertEqualsIgnoreWhitespace( drl, RuleModelDRLPersistenceImpl.getInstance().marshal( m ) );
    }
View Full Code Here

                      fp.getFactType() );

        assertEquals( 1,
                      fp.getNumberOfConstraints() );
        assertTrue( fp.getConstraint( 0 ) instanceof SingleFieldConstraintEBLeftSide );
        final SingleFieldConstraintEBLeftSide exp = (SingleFieldConstraintEBLeftSide) fp.getConstraint( 0 );
        assertEquals( "int",
                      exp.getFieldType() );
        assertEquals( ">",
                      exp.getOperator() );
        assertEquals( "5",
                      exp.getValue() );

        assertEquals( 2,
                      exp.getExpressionLeftSide().getParts().size() );
        assertTrue( exp.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionUnboundFact );
        final ExpressionUnboundFact expPart0 = (ExpressionUnboundFact) exp.getExpressionLeftSide().getParts().get( 0 );
        assertEquals( "Number",
                      expPart0.getFact().getFactType() );

        assertTrue( exp.getExpressionLeftSide().getParts().get( 1 ) instanceof ExpressionMethod );
        final ExpressionMethod expPart1 = (ExpressionMethod) exp.getExpressionLeftSide().getParts().get( 1 );
        assertEquals( "intValue",
                      expPart1.getName() );
    }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.datamodel.rule.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.