From 1070ddd7021aef23dd2690129f983c7b7287ee0d Mon Sep 17 00:00:00 2001 From: David Caruana Date: Fri, 5 Jun 2009 17:04:57 +0000 Subject: [PATCH] Merged BRANCHES/DEV/JBPM31UPGRADE to HEAD 14417: MOB-414 Upgrade to jBPM 3.3.1 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14567 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/hibernate-context.xml | 1 + .../workflow/WorkflowServiceImplTest.java | 35 +++++++++++++++++-- .../repo/workflow/jbpm/AlfrescoTimer.java | 9 ----- .../repo/workflow/jbpm/JBPMSpringTest.java | 16 +++++++++ .../jbpmresources/hibernate.cfg.xml | 5 ++- 5 files changed, 51 insertions(+), 15 deletions(-) diff --git a/config/alfresco/hibernate-context.xml b/config/alfresco/hibernate-context.xml index f276c7502d..d78f49c06b 100644 --- a/config/alfresco/hibernate-context.xml +++ b/config/alfresco/hibernate-context.xml @@ -180,6 +180,7 @@ org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml + org/jbpm/job/CleanUpProcessJob.hbm.xml diff --git a/source/java/org/alfresco/repo/workflow/WorkflowServiceImplTest.java b/source/java/org/alfresco/repo/workflow/WorkflowServiceImplTest.java index 3ae50c695e..c9ef5d1f08 100644 --- a/source/java/org/alfresco/repo/workflow/WorkflowServiceImplTest.java +++ b/source/java/org/alfresco/repo/workflow/WorkflowServiceImplTest.java @@ -129,7 +129,15 @@ public class WorkflowServiceImplTest extends BaseSpringTest assertNotNull(nodeRef); assertTrue(nodeService.hasAspect(nodeRef, WorkflowModel.ASPECT_WORKFLOW_PACKAGE)); ChildAssociationRef childAssoc = nodeService.createNode(rootRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "test"), ContentModel.TYPE_CONTENT, null); - nodeService.addChild(nodeRef, childAssoc.getChildRef(), ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "test")); + + List exisingInstances = workflowService.getWorkflowsForContent(childAssoc.getChildRef(), true); + int size = 0; + if (exisingInstances != null) + { + size = exisingInstances.size(); + } + + nodeService.addChild(nodeRef, childAssoc.getChildRef(), ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "test123")); // start workflow List workflowDefs = workflowService.getDefinitions(); @@ -154,8 +162,29 @@ public class WorkflowServiceImplTest extends BaseSpringTest // get workflows for content List instances = workflowService.getWorkflowsForContent(childAssoc.getChildRef(), true); assertNotNull(instances); - assertEquals(1, instances.size()); - assertEquals(instances.get(0).id, path.instance.id); + assertEquals(size + 1, instances.size()); + + for (WorkflowInstance instance : instances) + { + boolean fNew = true; + for (WorkflowInstance exisingInstance : exisingInstances) + { + if (instance.id.equals(exisingInstance.id)) + { + fNew = false; + break; + } + fNew = true; + break; + } + + if (fNew) + { + assertEquals(instance.id, path.instance.id); + } + + } + List completedInstances = workflowService.getWorkflowsForContent(childAssoc.getChildRef(), false); assertNotNull(completedInstances); assertEquals(0, completedInstances.size()); diff --git a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoTimer.java b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoTimer.java index d0be26505f..cfd84815be 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoTimer.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/AlfrescoTimer.java @@ -90,15 +90,6 @@ public class AlfrescoTimer extends Timer public Boolean doWork() throws Exception { boolean deleteTimer = AlfrescoTimer.super.execute(jbpmContext); - - // NOTE: there may be an issue in jBPM where a timer that causes a process to - // end is deleted twice (once via specific delete operation and once via - // delete DML statement) which causes a hibernate exception. - // Only delete timer if not at end of process - if (getProcessInstance().getEnd() != null) - { - deleteTimer = false; - } return deleteTimer; } }, (username == null) ? "system" : username); diff --git a/source/java/org/alfresco/repo/workflow/jbpm/JBPMSpringTest.java b/source/java/org/alfresco/repo/workflow/jbpm/JBPMSpringTest.java index 8ad8bc0a73..a33bbc966e 100644 --- a/source/java/org/alfresco/repo/workflow/jbpm/JBPMSpringTest.java +++ b/source/java/org/alfresco/repo/workflow/jbpm/JBPMSpringTest.java @@ -100,6 +100,7 @@ public class JBPMSpringTest extends BaseSpringTest throws Exception { theProcessInstanceContinuesWhenAnAsyncMessageIsReceived(); + undeployProcessDefinition(); setComplete(); } @@ -135,6 +136,21 @@ public class JBPMSpringTest extends BaseSpringTest }); } + + private void undeployProcessDefinition() + { + jbpmTemplate.execute(new JbpmCallback() + { + public Object doInJbpm(JbpmContext context) + { + GraphSession graphSession = context.getGraphSession(); + ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("hello world"); + graphSession.deleteProcessDefinition(processDefinition.getId()); + return null; + } + }); + } + private void processInstanceIsCreatedWhenUserSubmitsWebappForm() { jbpmTemplate.execute(new JbpmCallback() diff --git a/source/test-resources/jbpmresources/hibernate.cfg.xml b/source/test-resources/jbpmresources/hibernate.cfg.xml index 016c5fda65..396343c1ef 100644 --- a/source/test-resources/jbpmresources/hibernate.cfg.xml +++ b/source/test-resources/jbpmresources/hibernate.cfg.xml @@ -40,9 +40,8 @@ - - - + +