Package org.springframework.transaction.support

Examples of org.springframework.transaction.support.TransactionCallback


    public void testSaveOrUpdateProcessInstance() {
        System.out.println("--------saveOrUpdateProcessInstance--------");
        final String parentProcessInstanceId = "parent process instance 123";
        final String parentTaskInstanceId = "parent task instance 123";

        IProcessInstance processInstance1 = (IProcessInstance) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {

                ProcessInstance processInstance = new ProcessInstance();
                processInstance.setCreatedTime(createdTime);
View Full Code Here


     */
    @Test
    public void testSaveOrUpdateToken() {
        System.out.println("--------saveOrUpdateToken--------");

        IToken token1 = (IToken) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                Token token = new Token();
                token.setAlive(alive);
                token.setNodeId(activityId);
View Full Code Here

     */
    @Test
    public void testSaveOrUpdateTaskInstance() {
        System.out.println("--------saveOrUpdateTaskInstance--------");

        ITaskInstance taskInstance1 = (ITaskInstance) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                TaskInstance taskInstance = new TaskInstance();
                taskInstance.setActivityId(activityId);
                taskInstance.setAssignmentStrategy(assignmentStrategy);
View Full Code Here

     */
    @Test
    public void testSaveOrUpdateWorkItem() {
        System.out.println("--------saveOrUpdateWorkItem--------");

        IWorkItem workItem1 = (IWorkItem) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                WorkItem wi = new WorkItem();
                wi.setActorId(actorId);
                wi.setComments(comments);
View Full Code Here

     * Test of findDeadWorkItemsWithoutJoinForTaskInstance method, of class PersistenceServiceHibernateImpl.
     */
    @Test
    public void testFindDeadWorkItemsWithoutJoinForTaskInstance() {
        System.out.println("--------findDeadWorkItemsWithoutJoinForTaskInstance--------");
        IWorkItem workItem1 = (IWorkItem) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                WorkItem wi = new WorkItem();
                wi.setActorId(actorId);
                wi.setComments(comments);
View Full Code Here

    @Test
    public void testCancelAliveWorkItemsForTaskInstance() {
        System.out.println("--------cancelAliveWorkItemsForTaskInstance--------");

        IWorkItem workItem1 = (IWorkItem) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                WorkItem wi = new WorkItem();
                wi.setActorId(actorId);
                wi.setComments(comments);
View Full Code Here

     * �������ʵ��ִ��ʵ���run������
     */
    @Test
    public void testStartNewProcess() {
        System.out.println("--------------Start a new process ----------------");
        currentProcessInstance = (IProcessInstance) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                try {
                    IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();

View Full Code Here

    }
   
    @Test
    public void testCompleteWorkitem1() {
      currentProcessInstance = (IProcessInstance) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                try {
                    IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();

                    //��"/workflowdefinition/example_workflow.xml"�еġ��ͻ���̡�
                    IProcessInstance processInstance = workflowSession.createProcessInstance("MultiTasksPerActivity",CurrentUserAssignmentHandlerMock.ACTOR_ID);

                    processInstance.run();
                    return processInstance;
                } catch (EngineException ex) {
                    Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
                } catch (KernelException ex) {
                    Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
                }

                return null;
            }
        });
        assertNotNull(currentProcessInstance);

        IPersistenceService persistenceService = runtimeContext.getPersistenceService();
        List<ITaskInstance> taskInstanceList = persistenceService.findTaskInstancesForProcessInstance(currentProcessInstance.getId(), "MultiTasksPerActivity.Activity1");
        assertNotNull(taskInstanceList);
        assertEquals(1, taskInstanceList.size());
        assertEquals(new Integer(ITaskInstance.RUNNING), ((ITaskInstance) taskInstanceList.get(0)).getState());
        assertEquals(1,((ITaskInstance) taskInstanceList.get(0)).getStepNumber().intValue());

        List<IToken> tokenList = persistenceService.findTokensForProcessInstance(currentProcessInstance.getId(), null);
        assertNotNull(tokenList);
        assertEquals(1,tokenList.size());
        IToken token = (IToken)tokenList.get(0);
        assertEquals(1,token.getStepNumber().intValue());

        List<IWorkItem> workItemList = persistenceService.findTodoWorkItems(CurrentUserAssignmentHandlerMock.ACTOR_ID, "MultiTasksPerActivity", "MultiTasksPerActivity.Activity1.Task1");
        assertNotNull(workItemList);
        assertEquals(1, workItemList.size());
        assertEquals(new Integer(ITaskInstance.RUNNING), ((IWorkItem) workItemList.get(0)).getState());

        workItemId_1 = ((IWorkItem) workItemList.get(0)).getId();
        //-------------------------------------------
        transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                try {
                    IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
View Full Code Here

     * 创建流程实例,并使之执行到B环节。
     */
    @Test
    public void testStartNewProcess() {
        System.out.println("--------------Start a new process ----------------");
        IProcessInstance currentProcessInstance = (IProcessInstance) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                try {
                    IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
                    //启动"/workflowdefinition/Jump.xml
                    IProcessInstance processInstance = workflowSession.createProcessInstance("AbortTaskInstance",AssignToCurrentUserAndCompleteWorkItemHandler.ACTOR_ID);

                    processInstance.run();
                    return processInstance;
                } catch (EngineException ex) {
                    Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
                } catch (KernelException ex) {
                    Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
                }
                return null;
            }
        });
       
        this.refresh(currentProcessInstance);
       
        assertNotNull(currentProcessInstance);

        IPersistenceService persistenceService = runtimeContext.getPersistenceService();
        List<ITaskInstance> taskInstanceList = persistenceService.findTaskInstancesForProcessInstance(currentProcessInstance.getId(), "AbortTaskInstance.A");
        assertNotNull(taskInstanceList);
        assertEquals(1, taskInstanceList.size());
       

        List<IWorkItem> workItemList = persistenceService.findTodoWorkItems(AssignToCurrentUserAndCompleteWorkItemHandler.ACTOR_ID, "AbortTaskInstance", "AbortTaskInstance.A.TaskA");
        assertNotNull(workItemList);
        assertEquals(1, workItemList.size());
        assertEquals(new Integer(IWorkItem.INITIALIZED), ((IWorkItem) workItemList.get(0)).getState());
        final String workItemAId = ((IWorkItem) workItemList.get(0)).getId();
       
        //结束Activity A的工作项,使流程流转到B环节
        transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                try {
                    IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
                    IWorkItem wi = workflowSession.findWorkItemById(workItemAId);
View Full Code Here

    public void testAbortActivityB() {
     
      IPersistenceService persistenceService = runtimeContext.getPersistenceService();
     
      //准备测试数据
      IProcessInstance currentProcessInstance = (IProcessInstance) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                try {
                    IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
                    //启动"/workflowdefinition/Jump.xml
                    IProcessInstance processInstance = workflowSession.createProcessInstance("AbortTaskInstance",AssignToCurrentUserAndCompleteWorkItemHandler.ACTOR_ID);

                    processInstance.run();
                    return processInstance;
                } catch (EngineException ex) {
                    Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
                } catch (KernelException ex) {
                    Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
                }
                return null;
            }
        });

        List<IWorkItem> workItemList = persistenceService.findTodoWorkItems(AssignToCurrentUserAndCompleteWorkItemHandler.ACTOR_ID, "AbortTaskInstance", "AbortTaskInstance.A.TaskA");
        final String workItemAId = ((IWorkItem) workItemList.get(0)).getId();
       
        //结束Activity A的工作项,使流程流转到B环节
        transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                try {
                    IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
                    IWorkItem wi = workflowSession.findWorkItemById(workItemAId);
                    wi.claim();
                    wi.complete();
                    return null;
                } catch (EngineException ex) {
                    Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
                } catch (KernelException ex) {
                    Logger.getLogger(FireWorkflowEngineTest.class.getName()).log(Level.SEVERE, null, ex);
                }
                return null;
            }
        });       
        List<ITaskInstance> taskInstanceList = persistenceService.findTaskInstancesForProcessInstance(currentProcessInstance.getId(), "AbortTaskInstance.B");
        final String taskInstanceBId = ((ITaskInstance)taskInstanceList.get(0)).getId();
       
        //如下是测试用例
      //改变流程变量(即业务条件),使之流向C
        transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                try {
                    IWorkflowSession workflowSession = runtimeContext.getWorkflowSession();
                    ITaskInstance taskInstance = workflowSession.findTaskInstanceById(taskInstanceBId);
View Full Code Here

TOP

Related Classes of org.springframework.transaction.support.TransactionCallback

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.