Package org.drools.lang.descr

Examples of org.drools.lang.descr.VariableRestrictionDescr


        assertEquals( 2,
                      descrs.getDescrs().size() );
        PatternDescr pat = (PatternDescr) descrs.getDescrs().get( 1 );
        FieldConstraintDescr fieldConstr = (FieldConstraintDescr) pat.getConstraint().getDescrs().get( 0 );
        VariableRestrictionDescr restr = (VariableRestrictionDescr) fieldConstr.getRestrictions().get( 0 );

        assertEquals( "memberOf",
                      restr.getEvaluator() );
        assertTrue( restr.isNegated() );
        assertEquals( "$cities",
                      restr.getIdentifier() );
    }
View Full Code Here


        assertEquals( 2,
                      descrs.getDescrs().size() );
        PatternDescr pat = (PatternDescr) descrs.getDescrs().get( 1 );
        FieldConstraintDescr fieldConstr = (FieldConstraintDescr) pat.getConstraint().getDescrs().get( 0 );
        VariableRestrictionDescr restr = (VariableRestrictionDescr) fieldConstr.getRestrictions().get( 0 );

        assertEquals( "contains",
                      restr.getEvaluator() );
        assertTrue( restr.isNegated() );
        assertEquals( "$city",
                      restr.getIdentifier() );
    }
View Full Code Here

        final FieldConstraintDescr fcdB = (FieldConstraintDescr) or.getDescrs().get( 0 );
        assertEquals( 1,
                      fcdB.getRestrictions().size() );
        assertTrue( fcdB.getRestrictions().get( 0 ) instanceof VariableRestrictionDescr );
        final VariableRestrictionDescr rb = (VariableRestrictionDescr) fcdB.getRestrictions().get( 0 );
        assertEquals( "after",
                      rb.getEvaluator() );
        assertEquals( "$a",
                      rb.getText() );
        assertEquals( "1,10",
                      rb.getParameterText() );
        assertFalse( rb.isNegated() );

        final FieldConstraintDescr fcdB2 = (FieldConstraintDescr) or.getDescrs().get( 1 );
        assertEquals( 1,
                      fcdB2.getRestrictions().size() );
        assertTrue( fcdB2.getRestrictions().get( 0 ) instanceof VariableRestrictionDescr );
        final VariableRestrictionDescr rb2 = (VariableRestrictionDescr) fcdB2.getRestrictions().get( 0 );
        assertEquals( "after",
                      rb2.getEvaluator() );
        assertEquals( "$a",
                      rb2.getText() );
        assertEquals( "15,20",
                      rb2.getParameterText() );
        assertTrue( rb2.isNegated() );

        final PatternDescr eventC = (PatternDescr) rule.getLhs().getDescrs().get( 2 );
        assertEquals( "$c",
                      eventC.getIdentifier() );
        assertEquals( "EventC",
                      eventC.getObjectType() );
        assertEquals( 1,
                      eventC.getConstraint().getDescrs().size() );
        final FieldConstraintDescr fcdC = (FieldConstraintDescr) eventC.getConstraint().getDescrs().get( 0 );
        assertEquals( 1,
                      fcdC.getRestrictions().size() );
        assertTrue( fcdC.getRestrictions().get( 0 ) instanceof VariableRestrictionDescr );
        final VariableRestrictionDescr rc = (VariableRestrictionDescr) fcdC.getRestrictions().get( 0 );
        assertEquals( "finishes",
                      rc.getEvaluator() );
        assertEquals( "$b",
                      rc.getText() );
        assertNull( rc.getParameterText() );
        assertFalse( rc.isNegated() );

        final PatternDescr eventD = (PatternDescr) rule.getLhs().getDescrs().get( 3 );
        assertEquals( "$d",
                      eventD.getIdentifier() );
        assertEquals( "EventD",
                      eventD.getObjectType() );
        assertEquals( 1,
                      eventD.getConstraint().getDescrs().size() );
        final FieldConstraintDescr fcdD = (FieldConstraintDescr) eventD.getConstraint().getDescrs().get( 0 );
        assertEquals( 1,
                      fcdD.getRestrictions().size() );
        assertTrue( fcdD.getRestrictions().get( 0 ) instanceof VariableRestrictionDescr );
        final VariableRestrictionDescr rd = (VariableRestrictionDescr) fcdD.getRestrictions().get( 0 );
        assertEquals( "starts",
                      rd.getEvaluator() );
        assertEquals( "$a",
                      rd.getText() );
        assertNull( rd.getParameterText() );
        assertTrue( rd.isNegated() );

        final PatternDescr eventE = (PatternDescr) rule.getLhs().getDescrs().get( 4 );
        assertEquals( "$e",
                      eventE.getIdentifier() );
        assertEquals( "EventE",
                      eventE.getObjectType() );
        assertEquals( 2,
                      eventE.getConstraint().getDescrs().size() );

        final AndDescr and = (AndDescr) eventE.getConstraint();

        FieldConstraintDescr fcdE = (FieldConstraintDescr) and.getDescrs().get( 0 );
        assertEquals( 1,
                      fcdE.getRestrictions().size() );
        final RestrictionConnectiveDescr orrestr = (RestrictionConnectiveDescr) fcdE.getRestrictions().get( 0 );
        assertEquals( RestrictionConnectiveDescr.OR,
                      orrestr.getConnective() );
        assertEquals( 2,
                      orrestr.getRestrictions().size() );
        assertTrue( orrestr.getRestrictions().get( 0 ) instanceof VariableRestrictionDescr );
        VariableRestrictionDescr re = (VariableRestrictionDescr) orrestr.getRestrictions().get( 0 );
        assertEquals( "before",
                      re.getEvaluator() );
        assertEquals( "$b",
                      re.getText() );
        assertEquals( "1, 10",
                      re.getParameterText() );
        assertTrue( re.isNegated() );
        re = (VariableRestrictionDescr) orrestr.getRestrictions().get( 1 );
        assertEquals( "after",
                      re.getEvaluator() );
        assertEquals( "$c",
                      re.getText() );
        assertEquals( "1, 10",
                      re.getParameterText() );
        assertFalse( re.isNegated() );

        fcdE = (FieldConstraintDescr) and.getDescrs().get( 1 );
        assertEquals( 1,
                      fcdE.getRestrictions().size() );
        assertTrue( fcdE.getRestrictions().get( 0 ) instanceof VariableRestrictionDescr );
        re = (VariableRestrictionDescr) fcdE.getRestrictions().get( 0 );
        assertEquals( "after",
                      re.getEvaluator() );
        assertEquals( "$d",
                      re.getText() );
        assertEquals( "1, 5",
                      re.getParameterText() );
        assertFalse( re.isNegated() );
    }
View Full Code Here

        final String identifier = attrs.getValue( "identifier" );
       
        emptyAttributeCheck( localName, "evaluator", evaluator, parser );
        emptyAttributeCheck( localName, identifier, "identifier", parser );

        final VariableRestrictionDescr variableDescr = new VariableRestrictionDescr( evaluator,
                                                                                     identifier );

        return variableDescr;
    }
View Full Code Here

    public Object end(final String uri,
                      final String localName,
                      final ExtensibleXmlParser parser) throws SAXException {
        final Element element = parser.endElementBuilder();

        final VariableRestrictionDescr variableDescr = (VariableRestrictionDescr) parser.getCurrent();

        final Object parent = parser.getParent();

        if ( parent instanceof FieldConstraintDescr ) {
            final FieldConstraintDescr fieldConstraintDescr = (FieldConstraintDescr) parent;
View Full Code Here

TOP

Related Classes of org.drools.lang.descr.VariableRestrictionDescr

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.