Examples of SingleFieldConstraintEBLeftSide


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

        assertEquals( "Customer", constraint.getFactType() );
        assertEquals( "contact", constraint.getFieldName() );
        assertEquals( "Contact", constraint.getFieldType() );

        SingleFieldConstraintEBLeftSide constraint2 = (SingleFieldConstraintEBLeftSide) pattern.getFieldConstraints()[ 1 ];
        assertEquals( "tel1", constraint2.getFieldName() );
        assertEquals( "String", constraint2.getFieldType() );
        assertEquals( "15", constraint2.getValue() );
        assertEquals( ">", constraint2.getOperator() );

        assertEquals( 3, constraint2.getExpressionLeftSide().getParts().size() );
        ExpressionPart part1 = constraint2.getExpressionLeftSide().getParts().get( 0 );
        assertEquals( "Customer", part1.getName() );
        assertEquals( "Customer", part1.getClassType() );
        assertEquals( "Customer", part1.getGenericType() );

        ExpressionPart part2 = constraint2.getExpressionLeftSide().getParts().get( 1 );
        assertEquals( "contact", part2.getName() );
        assertEquals( "Contact", part2.getClassType() );
        assertEquals( "Contact", part2.getGenericType() );

        ExpressionPart part3 = constraint2.getExpressionLeftSide().getParts().get( 2 );
        assertEquals( "tel1", part3.getName() );
        assertEquals( "String", part3.getClassType() );
        assertEquals( "String", part3.getGenericType() );
    }
View Full Code Here

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

        FactPattern pattern = (FactPattern) m.lhs[ 0 ];
        assertEquals( 1,
                      pattern.getNumberOfConstraints() );
        assertTrue( pattern.getConstraint( 0 ) instanceof SingleFieldConstraintEBLeftSide );

        final SingleFieldConstraintEBLeftSide constraint = (SingleFieldConstraintEBLeftSide) pattern.getConstraint( 0 );
        assertEquals( 3,
                      constraint.getExpressionLeftSide().getParts().size() );

        assertTrue( constraint.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionUnboundFact );
        final ExpressionUnboundFact eubf = ( (ExpressionUnboundFact) constraint.getExpressionLeftSide().getParts().get( 0 ) );
        assertEquals( "OuterClassWithEnums",
                      eubf.getName() );
        assertEquals( "OuterClassWithEnums",
                      eubf.getClassType() );
        assertEquals( "OuterClassWithEnums",
                      eubf.getGenericType() );

        assertTrue( constraint.getExpressionLeftSide().getParts().get( 1 ) instanceof ExpressionField );
        final ExpressionField ef1 = ( (ExpressionField) constraint.getExpressionLeftSide().getParts().get( 1 ) );
        assertEquals( "innerClass",
                      ef1.getName() );
        assertEquals( "InnerClassWithEnums",
                      ef1.getClassType() );
        assertEquals( "InnerClassWithEnums",
                      ef1.getGenericType() );

        assertTrue( constraint.getExpressionLeftSide().getParts().get( 2 ) instanceof ExpressionField );
        final ExpressionField ef2 = ( (ExpressionField) constraint.getExpressionLeftSide().getParts().get( 2 ) );
        assertEquals( "innerField",
                      ef2.getName() );
        assertEquals( "TestEnum",
                      ef2.getClassType() );
        assertEquals( DataType.TYPE_COMPARABLE,
                      ef2.getGenericType() );

        assertEquals( "OuterClassWithEnums",
                      constraint.getFactType() );
        assertEquals( "innerField",
                      constraint.getFieldName() );
        assertEquals( "TestEnum",
                      constraint.getFieldType() );
        assertEquals( "==",
                      constraint.getOperator() );
        assertEquals( "TestEnum.VALUE1",
                      constraint.getValue() );
        assertEquals( BaseSingleFieldConstraint.TYPE_ENUM,
                      constraint.getConstraintValueType() );

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

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

        FactPattern pattern = (FactPattern) m.lhs[ 0 ];
        assertEquals( 1,
                      pattern.getNumberOfConstraints() );
        assertTrue( pattern.getConstraint( 0 ) instanceof SingleFieldConstraintEBLeftSide );

        final SingleFieldConstraintEBLeftSide constraint = (SingleFieldConstraintEBLeftSide) pattern.getConstraint( 0 );
        assertEquals( 3,
                      constraint.getExpressionLeftSide().getParts().size() );

        assertTrue( constraint.getExpressionLeftSide().getParts().get( 0 ) instanceof ExpressionUnboundFact );
        final ExpressionUnboundFact eubf = ( (ExpressionUnboundFact) constraint.getExpressionLeftSide().getParts().get( 0 ) );
        assertEquals( "OuterClassWithEnums",
                      eubf.getName() );
        assertEquals( "OuterClassWithEnums",
                      eubf.getClassType() );
        assertEquals( "OuterClassWithEnums",
                      eubf.getGenericType() );

        assertTrue( constraint.getExpressionLeftSide().getParts().get( 1 ) instanceof ExpressionField );
        final ExpressionField ef1 = ( (ExpressionField) constraint.getExpressionLeftSide().getParts().get( 1 ) );
        assertEquals( "innerClass",
                      ef1.getName() );
        assertEquals( "org.drools.workbench.models.commons.backend.rule.OuterClassWithEnums$InnerClassWithEnums",
                      ef1.getClassType() );
        assertEquals( "OuterClassWithEnums$InnerClassWithEnums",
                      ef1.getGenericType() );

        assertTrue( constraint.getExpressionLeftSide().getParts().get( 2 ) instanceof ExpressionField );
        final ExpressionField ef2 = ( (ExpressionField) constraint.getExpressionLeftSide().getParts().get( 2 ) );
        assertEquals( "innerField",
                      ef2.getName() );
        assertEquals( "TestEnum",
                      ef2.getClassType() );
        assertEquals( DataType.TYPE_COMPARABLE,
                      ef2.getGenericType() );

        assertEquals( "OuterClassWithEnums",
                      constraint.getFactType() );
        assertEquals( "innerField",
                      constraint.getFieldName() );
        assertEquals( "TestEnum",
                      constraint.getFieldType() );
        assertEquals( "==",
                      constraint.getOperator() );
        assertEquals( "TestEnum.VALUE1",
                      constraint.getValue() );
        assertEquals( BaseSingleFieldConstraint.TYPE_ENUM,
                      constraint.getConstraintValueType() );

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

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

        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

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( 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

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

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( 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

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

        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

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

                                            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

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

        }

        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
TOP
Copyright © 2018 www.massapi.com. 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.