Package org.kie.runtime.process

Examples of org.kie.runtime.process.WorkflowProcessInstance


                         myEntityMethods );
        parameters.put( "f",
                        myEntityOnlyFields );
        parameters.put( "z",
                         myVariableSerializable );
        WorkflowProcessInstance processInstance = (WorkflowProcessInstance) service.startProcess( "com.sample.ruleflow",
                                                                                                  parameters );
        log.info( "Started process instance {}",
                  processInstance.getId() );

        TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
        WorkItem workItem = handler.getWorkItem();
        assertNotNull( workItem );
        service.dispose();

        EntityManagerFactory emf = (EntityManagerFactory) ctx.getBean( "myEmf" );

        //        List< ? > result = emf.createEntityManager().createQuery( "select i from VariableInstanceInfo i" ).getResultList();
        //        assertEquals( 5,
        //                      result.size() );
        log.info( "### Retrieving process instance ###" );

/*        Environment env = KnowledgeBaseFactory.newEnvironment();
        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                 emf );
        env.set( EnvironmentName.TRANSACTION_MANAGER,
                 ctx.getBean( "txManager" ) );
        env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
                 new ObjectMarshallingStrategy[]{
                                                                  //  new JPAPlaceholderResolverStrategy(env),
                                                                  new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )
                                                                } );
*/
        final Environment env = (Environment) ctx.getBean("env2");
        KieStoreServices kstore = (KieStoreServices) ctx.getBean( "kstore1" );
        KieBase kbase1 = (KieBase) ctx.getBean( "kbase1" );
        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );

        processInstance = (WorkflowProcessInstance) service.getProcessInstance( processInstance.getId() );
        assertNotNull( processInstance );

        assertNotNull( processInstance );
        assertEquals( "SomeString",
                      processInstance.getVariable( "x" ) );
        assertEquals( "This is a test Entity with annotation in fields",
                      ((MyEntity) processInstance.getVariable( "y" )).getTest() );
        assertEquals( "This is a test Entity with annotations in methods",
                      ((MyEntityMethods) processInstance.getVariable( "m" )).getTest() );
        assertEquals( "This is a test Entity with annotations in fields and without accesors methods",
                      ((MyEntityOnlyFields) processInstance.getVariable( "f" )).test );
        assertEquals( "This is a test SerializableObject",
                      ((MyVariableSerializable) processInstance.getVariable( "z" )).getText() );
        assertNull( processInstance.getVariable( "a" ) );
        assertNull( processInstance.getVariable( "b" ) );
        assertNull( processInstance.getVariable( "c" ) );

        service.dispose();
    }
View Full Code Here


                         myEntityMethods );
        parameters.put( "f",
                        myEntityOnlyFields );
        parameters.put( "z",
                         myVariableSerializable );
        WorkflowProcessInstance processInstance = (WorkflowProcessInstance) service.startProcess( "com.sample.ruleflow",
                                                                                                  parameters );
        log.info( "Started process instance {}",
                  processInstance.getId() );

        TestWorkItemHandler handler = TestWorkItemHandler.getInstance();
        WorkItem workItem = handler.getWorkItem();
        assertNotNull( workItem );
        service.dispose();

        EntityManagerFactory emf = (EntityManagerFactory) ctx.getBean( "myEmf" );

        //        List< ? > result = emf.createEntityManager().createQuery( "select i from VariableInstanceInfo i" ).getResultList();
        //        assertEquals( 5,
        //                      result.size() );
        log.info( "### Retrieving process instance ###" );

        Environment env = KnowledgeBaseFactory.newEnvironment();
        env.set( EnvironmentName.ENTITY_MANAGER_FACTORY,
                 emf );
        env.set( EnvironmentName.TRANSACTION_MANAGER,
                 ctx.getBean( "txManager" ) );
        env.set( EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
                 new ObjectMarshallingStrategy[]{
                                                                  //  new JPAPlaceholderResolverStrategy(env),
                                                                  new SerializablePlaceholderResolverStrategy( ClassObjectMarshallingStrategyAcceptor.DEFAULT )
                                                                } );

        KieStoreServices kstore = (KieStoreServices) ctx.getBean( "kstore1" );
        KieBase kbase1 = (KieBase) ctx.getBean( "kbase1" );
        service = kstore.loadKieSession( sessionId,
                                         kbase1,
                                         null,
                                         env );

        processInstance = (WorkflowProcessInstance) service.getProcessInstance( processInstance.getId() );
        assertNotNull( processInstance );

        assertNotNull( processInstance );
        assertEquals( "SomeString",
                      processInstance.getVariable( "x" ) );
        assertEquals( "This is a test Entity with annotation in fields",
                      ((MyEntity) processInstance.getVariable( "y" )).getTest() );
        assertEquals( "This is a test Entity with annotations in methods",
                      ((MyEntityMethods) processInstance.getVariable( "m" )).getTest() );
        assertEquals( "This is a test Entity with annotations in fields and without accesors methods",
                      ((MyEntityOnlyFields) processInstance.getVariable( "f" )).test );
        assertEquals( "This is a test SerializableObject",
                      ((MyVariableSerializable) processInstance.getVariable( "z" )).getText() );
        assertNull( processInstance.getVariable( "a" ) );
        assertNull( processInstance.getVariable( "b" ) );
        assertNull( processInstance.getVariable( "c" ) );

        service.dispose();

        //        log.info("### Completing first work item ###");
        //        ksession.getWorkItemManager().completeWorkItem( workItem.getId(), null );
View Full Code Here

TOP

Related Classes of org.kie.runtime.process.WorkflowProcessInstance

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.