Package org.drools.smf

Examples of org.drools.smf.ObjectTypeFactory


        Configuration config = this.ruleSetReader.endConfiguration( );

        SemanticModule module = this.ruleSetReader.lookupSemanticModule( uri,
                                                                         localName );

        ObjectTypeFactory factory = module.getObjectTypeFactory( localName );

        try
        {
            Rule rule = (Rule) this.ruleSetReader.getParent( Rule.class );
            Declaration declaration = (Declaration) this.ruleSetReader.getParent( Declaration.class );
            ((DefaultConfiguration) config).setAttribute( "identifier",
                                                          declaration.getIdentifier( ) );
     
            ObjectType objectType = factory.newObjectType( rule,
                                                           this.ruleSetReader.getFactoryContext( ),
                                                           config );

            declaration.setObjectType( objectType );
        }
View Full Code Here


                                    ruleSet );

        Importer importer = new DefaultImporter( );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassFieldObjectTypeFactory( );

        try
        {
            ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                            ruleBaseContext,
                                                                            configuration );
            fail( "Should fail, no field name has been specified" );
        }
        catch ( FactoryException e )
        {
            assertEquals( "no class name specified",
                          e.getMessage( ) );
        }

        configuration.setText( "org.drools.semantics.base.Person" );
        try
        {
            ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                            ruleBaseContext,
                                                                            configuration );
            fail( "Should fail, no field name has been specified" );
        }
        catch ( FactoryException e )
        {
            assertEquals( "no field name specified",
                          e.getMessage( ) );
        }

        configuration.setAttribute( "field",
                                    "name" );
        try
        {
            ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                            ruleBaseContext,
                                                                            configuration );
            fail( "Should fail, no field value has been specified" );
        }
        catch ( FactoryException e )
View Full Code Here

                                    ruleSet );

        Importer importer = new DefaultImporter( );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassFieldObjectTypeFactory( );

        ClassFieldObjectType type = (ClassFieldObjectType) factory.newObjectType( rule,
                                                                                  ruleBaseContext,
                                                                                  configuration );

        assertEquals( Person.class,
                      type.getType( ) );
View Full Code Here

        Importer importer = new DefaultImporter( );
        importer.addImport( new DefaultImportEntry( "org.drools.semantics.base.Person" ) );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassFieldObjectTypeFactory( );

        ClassFieldObjectType type = (ClassFieldObjectType) factory.newObjectType( rule,
                                                                                  ruleBaseContext,
                                                                                  configuration );

        assertEquals( Person.class,
                      type.getType( ) );
View Full Code Here

        Importer importer = new DefaultImporter( );
        importer.addImport( new DefaultImportEntry( "org.drools.semantics.base.*" ) );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassFieldObjectTypeFactory( );

        ClassFieldObjectType type = (ClassFieldObjectType) factory.newObjectType( rule,
                                                                                  ruleBaseContext,
                                                                                  configuration );

        assertEquals( Person.class,
                      type.getType( ) );
View Full Code Here

                                    ruleSet );

        Importer importer = new DefaultImporter( );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassObjectTypeFactory( );

        try
        {
            ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                            ruleBaseContext,
                                                                            configuration );
            fail( "Should fail, no class name has been specified" );
        }
        catch ( FactoryException e )
View Full Code Here

                                    ruleSet );

        Importer importer = new DefaultImporter( );      
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassObjectTypeFactory( );

        ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                        ruleBaseContext,
                                                                        configuration );

        assertEquals( java.util.HashMap.class,
                      type.getType( ) );
View Full Code Here

        Importer importer = new DefaultImporter( );
        importer.addImport( new DefaultImportEntry( "java.util.HashMap" ) );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassObjectTypeFactory( );

        ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                        ruleBaseContext,
                                                                        configuration );

        assertEquals( java.util.HashMap.class,
                      type.getType( ) );
View Full Code Here

        final Rule rule = new Rule( "Test Rule 1",
                                    ruleSet );

        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassObjectTypeFactory( );

        ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                        ruleBaseContext,
                                                                        configuration );

        assertEquals( java.util.HashMap.class,
                      type.getType( ) );
View Full Code Here

                                    ruleSet );

        Importer importer = new DefaultImporter( );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new SemaphoreFactory( );

        try
        {
            ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                            ruleBaseContext,
                                                                            configuration );
            fail( "SemaphoreFactory should throw an exception as no type is specified" );
        }
        catch ( FactoryException e )
        {
            assertEquals( "no Semaphore type specified",
                          e.getMessage( ) );
        }

        configuration.setAttribute( "type",
                                    "Person" );
        try
        {
            ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                            ruleBaseContext,
                                                                            configuration );
            fail( "SemaphoreFactory should throw an exception as no identifier is specified" );
        }
        catch ( FactoryException e )
        {
            assertEquals( "no Semaphore identifier specified",
                          e.getMessage( ) );
        }

        configuration.setAttribute( "type",
                                    "NoneExistingClass" );
        configuration.setAttribute( "identifier",
                                    "state" );
        try
        {
            ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                            ruleBaseContext,
                                                                            configuration );
            fail( "SemaphoreFactory should throw an exception as class NoneExistingClass does not exist." );
        }
        catch ( FactoryException e )
        {
            assertEquals( "Unable create Semaphore for type 'NoneExistingClass'",
                          e.getMessage( ) );
        }

        configuration.setAttribute( "type",
                                    "Person" );
        configuration.setAttribute( "identifier",
                                    "state" );
        try
        {
            ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
                                                                            ruleBaseContext,
                                                                            configuration );
            fail( "SemaphoreFactory should throw an exception as class Person has no identifier field." );
        }
        catch ( FactoryException e )
View Full Code Here

TOP

Related Classes of org.drools.smf.ObjectTypeFactory

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.