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

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


    @Test
    public void testLockOnActive() {
        RuleModel m = new RuleModel();

        m.addAttribute( new RuleAttribute( "lock-on-active",
                                           "true" ) );
        m.addAttribute( new RuleAttribute( "auto-focus",
                                           "true" ) );
        m.addAttribute( new RuleAttribute( "duration",
                                           "42" ) );

        String s = RuleModelDRLPersistenceImpl.getInstance().marshal( m );

        assertTrue( s.indexOf( "lock-on-active true" ) > -1 );
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() );\n\t\tresults.add(f);\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" ) );
        ActionGlobalCollectionAdd add = new ActionGlobalCollectionAdd();
        add.setGlobalName( "results" );
View Full Code Here

            System.setProperty( "drools.dateformat",
                                "dd-MMM-yyyy" );

            RuleModel m = new RuleModel();
            m.name = "RHS SetMethodCallsMethod";
            m.addAttribute( new RuleAttribute( "dialect",
                                               "mvel" ) );

            FactPattern p = new FactPattern( "Person" );
            p.setBoundName( "$p" );
            m.addLhsItem( p );
View Full Code Here

            System.setProperty( "drools.dateformat",
                                "dd-MMM-yyyy" );

            RuleModel m = new RuleModel();
            m.name = "RHS SetMethodCallsMethod";
            m.addAttribute( new RuleAttribute( "dialect",
                                               "java" ) );

            FactPattern p = new FactPattern( "Person" );
            p.setBoundName( "$p" );
            m.addLhsItem( p );
View Full Code Here

    public void testBasics2() {
        final RuleModelPersistence p = RuleModelDRLPersistenceImpl.getInstance();
        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" ) );
        ActionGlobalCollectionAdd ag = new ActionGlobalCollectionAdd();
        ag.setFactName( "x" );
View Full Code Here

        assertEquals( m.rhs.length,
                      m2.rhs.length );
        assertEquals( 1,
                      m.attributes.length );

        final RuleAttribute at = m.attributes[ 0 ];
        assertEquals( "no-loop",
                      at.getAttributeName() );
        assertEquals( "true",
                      at.getValue() );

        final String drl2 = RuleModelDRLPersistenceImpl.getInstance().marshal( m2 );
        assertEquals( drl,
                      drl2 );
View Full Code Here

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

        m.addAttribute( new RuleAttribute( "no-loop",
                                           "true" ) );

        final FactPattern pat = new FactPattern( "Person" );
        pat.setBoundName( "p1" );
        final SingleFieldConstraint con = new SingleFieldConstraint();
View Full Code Here

        RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal( drl,
                                                                           Collections.EMPTY_LIST,
                                                                           dmo );

        assertNotNull( m.attributes[ 0 ] );
        RuleAttribute attribute = m.attributes[ 0 ];
        assertEquals( "calendars", attribute.getAttributeName() );
        assertEquals( "a, b", attribute.getValue() );
    }
View Full Code Here

        }
        throw new IllegalArgumentException( "Class " + o.getClass().getName() + " is not recognised" );
    }

    private RuleAttribute visitRuleAttribute( RuleAttribute attr ) {
        RuleAttribute clone = new RuleAttribute();
        clone.setAttributeName( attr.getAttributeName() );
        clone.setValue( attr.getValue() );
        return clone;
    }
View Full Code Here

        clone.setNegated( model.isNegated() );

        if ( model.attributes != null ) {
            clone.attributes = new RuleAttribute[ model.attributes.length ];
            for ( int i = 0; i < model.attributes.length; i++ ) {
                RuleAttribute attr = model.attributes[ i ];
                clone.attributes[ i ] = (RuleAttribute) visit( attr );
            }
        }
        if ( model.metadataList != null ) {
            clone.metadataList = new RuleMetadata[ model.metadataList.length ];
View Full Code Here

TOP

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