Package org.drools.brms.client.modeldriven.brl

Examples of org.drools.brms.client.modeldriven.brl.RuleAttribute


     */
    private void marshalAttributes(StringBuffer buf,
                                   RuleModel model) {
        boolean hasDialect = false;
        for ( int i = 0; i < model.attributes.length; i++ ) {
            RuleAttribute attr = model.attributes[i];
           
            buf.append( "\t" );
            buf.append( attr );
           
            buf.append( "\n" );
            if (attr.attributeName.equals( "dialect" )) {
                hasDialect = true;
            }           
        }
//Un comment below for mvel       
        if (!hasDialect) {
            RuleAttribute attr = new RuleAttribute("dialect", "mvel");
            buf.append( "\t" );
            buf.append( attr );
            buf.append( "\n" );
        }
    }
View Full Code Here


     */
    private void marshalAttributes(StringBuffer buf,
                                   RuleModel model) {
        boolean hasDialect = false;
        for ( int i = 0; i < model.attributes.length; i++ ) {
            RuleAttribute attr = model.attributes[i];

            buf.append( "\t" );
            buf.append( attr );

            buf.append( "\n" );
            if (attr.attributeName.equals( "dialect" )) {
                hasDialect = true;
            }
        }
//Un comment below for mvel
        if (!hasDialect) {
            RuleAttribute attr = new RuleAttribute("dialect", "mvel");
            buf.append( "\t" );
            buf.append( attr );
            buf.append( "\n" );
        }
    }
View Full Code Here

        String expected = "rule \"my rule\"\n\tno-loop true\n\tdialect \"mvel\"\n\twhen\n\t\tPerson( )\n" +
                          "\t\tAccident( )\n\tthen\n\t\tinsert( new Report() );\nend\n";
        final RuleModel m = new RuleModel();
        m.addLhsItem( new FactPattern( "Person" ) );
        m.addLhsItem( new FactPattern( "Accident" ) );
        m.addAttribute( new RuleAttribute( "no-loop",
                                           "true" ) );

        m.addRhsItem( new ActionInsertFact( "Report" ) );
        m.name = "my rule";
View Full Code Here

    private RuleModel getComplexModel() {
        final RuleModel m = new RuleModel();
        m.name = "Complex Rule";

        m.addAttribute( new RuleAttribute( "no-loop",
                                           "true" ) );
        m.addAttribute( new RuleAttribute( "salience",
                                           "-10" ) );
        m.addAttribute( new RuleAttribute( "agenda-group",
                                           "aGroup" ) );

        final FactPattern pat = new FactPattern();
        pat.boundName = "p1";
        pat.factType = "Person";
View Full Code Here

        RuleModel m = new RuleModel();

        String s = BRDRLPersistence.getInstance().marshal( m );
        assertTrue(s.indexOf( "mvel" ) > -1);

        m.addAttribute( new RuleAttribute("dialect", "goober") );
        s = BRDRLPersistence.getInstance().marshal( m );
        assertFalse(s.indexOf( "mvel" ) > -1);
        assertTrue(s.indexOf( "goober" ) > -1);

    }
View Full Code Here

     */
    private void marshalAttributes(StringBuffer buf,
                                   RuleModel model) {
        boolean hasDialect = false;
        for ( int i = 0; i < model.attributes.length; i++ ) {
            RuleAttribute attr = model.attributes[i];

            buf.append( "\t" );
            buf.append( attr );

            buf.append( "\n" );
            if (attr.attributeName.equals( "dialect" )) {
                hasDialect = true;
            }
        }
//Un comment below for mvel
        if (!hasDialect) {
            RuleAttribute attr = new RuleAttribute("dialect", "mvel");
            buf.append( "\t" );
            buf.append( attr );
            buf.append( "\n" );
        }
    }
View Full Code Here

        String expected = "rule \"my rule\"\n\tno-loop true\n\tdialect \"mvel\"\n\twhen\n\t\tPerson( )\n" +
                          "\t\tAccident( )\n\tthen\n\t\tinsert( new Report() );\nend\n";
        final RuleModel m = new RuleModel();
        m.addLhsItem( new FactPattern( "Person" ) );
        m.addLhsItem( new FactPattern( "Accident" ) );
        m.addAttribute( new RuleAttribute( "no-loop",
                                           "true" ) );

        m.addRhsItem( new ActionInsertFact( "Report" ) );
        m.name = "my rule";
View Full Code Here

   
    private RuleModel getComplexModel() {
        final RuleModel m = new RuleModel();
        m.name = "Complex Rule";

        m.addAttribute( new RuleAttribute( "no-loop",
                                           "true" ) );
        m.addAttribute( new RuleAttribute( "salience",
                                           "-10" ) );
        m.addAttribute( new RuleAttribute( "agenda-group",
                                           "aGroup" ) );

        final FactPattern pat = new FactPattern();
        pat.boundName = "p1";
        pat.factType = "Person";
View Full Code Here

        RuleModel m = new RuleModel();
       
        String s = BRDRLPersistence.getInstance().marshal( m );
        assertTrue(s.indexOf( "mvel" ) > -1);
       
        m.addAttribute( new RuleAttribute("dialect", "goober") );
        s = BRDRLPersistence.getInstance().marshal( m );
        assertFalse(s.indexOf( "mvel" ) > -1);
        assertTrue(s.indexOf( "goober" ) > -1);
       
    }
View Full Code Here

                      model.rhs[1] );
    }

    public void testAttributes() {
        final RuleModel m = new RuleModel();
        final RuleAttribute at = new RuleAttribute( "salience",
                                              "42" );
        m.addAttribute( at );
        assertEquals( 1,
                      m.attributes.length );
        assertEquals( at,
                      m.attributes[0] );

        final RuleAttribute at2 = new RuleAttribute( "agenda-group",
                                               "x" );
        m.addAttribute( at2 );
        assertEquals( 2,
                      m.attributes.length );
        assertEquals( at2,
View Full Code Here

TOP

Related Classes of org.drools.brms.client.modeldriven.brl.RuleAttribute

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.