mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Created jbpm-context.xml, extracted from workflow-context.xml to more easily allow switching on/off of jbpm engne. Also added more testing of Task properties on the workflow REST API.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@26214 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
30
config/alfresco/jbpm-context.xml
Normal file
30
config/alfresco/jbpm-context.xml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||||
|
|
||||||
|
<beans>
|
||||||
|
|
||||||
|
<bean id="jbpm_configuration"
|
||||||
|
class="org.alfresco.repo.workflow.jbpm.AlfrescoJbpmConfigurationFactoryBean">
|
||||||
|
<property name="sessionFactory" ref="sessionFactory" />
|
||||||
|
<property name="configuration" value="classpath:org/alfresco/repo/workflow/jbpm/jbpm.cfg.xml" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="jbpm_template"
|
||||||
|
class="org.alfresco.repo.workflow.jbpm.JBPMTransactionTemplate">
|
||||||
|
<constructor-arg index="0" ref="jbpm_configuration" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="jbpm_engine" class="org.alfresco.repo.workflow.jbpm.JBPMEngine" parent="bpm_engine">
|
||||||
|
<property name="engineId" value="jbpm" />
|
||||||
|
<property name="JBPMTemplate" ref="jbpm_template" />
|
||||||
|
<property name="nodeService" ref="nodeService" />
|
||||||
|
<property name="personService" ref="personService" />
|
||||||
|
<property name="authorityDAO" ref="authorityDAO" />
|
||||||
|
<!-- Creates JBPMNodes (ScriptNodes) which require the ServiceRegsitry -->
|
||||||
|
<property name="serviceRegistry" ref="ServiceRegistry" />
|
||||||
|
<property name="companyHomeStore" value="${spaces.store}" />
|
||||||
|
<property name="companyHomePath" value="/${spaces.company_home.childname}" />
|
||||||
|
<property name="unprotectedSearchService" ref="searchService" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
@@ -92,28 +92,7 @@
|
|||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- jBPM Implementation -->
|
<!-- jBPM Implementation -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
<import resource="classpath:alfresco/jbpm-context.xml" />
|
||||||
<bean id="jbpm_configuration" class="org.alfresco.repo.workflow.jbpm.AlfrescoJbpmConfigurationFactoryBean">
|
|
||||||
<property name="sessionFactory" ref="sessionFactory"/>
|
|
||||||
<property name="configuration" value="classpath:org/alfresco/repo/workflow/jbpm/jbpm.cfg.xml"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="jbpm_template" class="org.alfresco.repo.workflow.jbpm.JBPMTransactionTemplate">
|
|
||||||
<constructor-arg index="0" ref="jbpm_configuration"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="jbpm_engine" class="org.alfresco.repo.workflow.jbpm.JBPMEngine" parent="bpm_engine">
|
|
||||||
<property name="engineId" value="jbpm"/>
|
|
||||||
<property name="JBPMTemplate" ref="jbpm_template"/>
|
|
||||||
<property name="nodeService" ref="nodeService"/>
|
|
||||||
<property name="personService" ref="personService"/>
|
|
||||||
<property name="authorityDAO" ref="authorityDAO"/>
|
|
||||||
<!-- Creates JBPMNodes (ScriptNodes) which require the ServiceRegsitry -->
|
|
||||||
<property name="serviceRegistry" ref="ServiceRegistry"/>
|
|
||||||
<property name="companyHomeStore"><value>${spaces.store}</value></property>
|
|
||||||
<property name="companyHomePath"><value>/${spaces.company_home.childname}</value></property>
|
|
||||||
<property name="unprotectedSearchService" ref="searchService"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- Activiti Implementation -->
|
<!-- Activiti Implementation -->
|
||||||
|
@@ -696,6 +696,11 @@ public abstract class AbstractWorkflowServiceIntegrationTest extends BaseSpringT
|
|||||||
checkWorkflows(defId, instance1, instance2);
|
checkWorkflows(defId, instance1, instance2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testDeleteWorkflow() throws Exception
|
||||||
|
{
|
||||||
|
//TODO Implement this test!
|
||||||
|
}
|
||||||
public void checkWorkflows(String defId, String... expectedIds)
|
public void checkWorkflows(String defId, String... expectedIds)
|
||||||
{
|
{
|
||||||
List<WorkflowInstance> workflows = workflowService.getWorkflows(defId);
|
List<WorkflowInstance> workflows = workflowService.getWorkflows(defId);
|
||||||
|
@@ -50,7 +50,6 @@ public class StartWorkflowActionExecuter extends ActionExecuterAbstractBase
|
|||||||
public static final String PARAM_END_START_TASK = "endStartTask";
|
public static final String PARAM_END_START_TASK = "endStartTask";
|
||||||
public static final String PARAM_START_TASK_TRANSITION = "startTaskTransition";
|
public static final String PARAM_START_TASK_TRANSITION = "startTaskTransition";
|
||||||
|
|
||||||
|
|
||||||
// action dependencies
|
// action dependencies
|
||||||
private NamespaceService namespaceService;
|
private NamespaceService namespaceService;
|
||||||
private WorkflowService workflowService;
|
private WorkflowService workflowService;
|
||||||
|
@@ -26,11 +26,9 @@ import org.alfresco.repo.workflow.activiti.ActivitiSpringTransactionTest;
|
|||||||
import org.alfresco.repo.workflow.activiti.ActivitiTimerExecutionTest;
|
import org.alfresco.repo.workflow.activiti.ActivitiTimerExecutionTest;
|
||||||
import org.alfresco.repo.workflow.activiti.ActivitiWorkflowServiceIntegrationTest;
|
import org.alfresco.repo.workflow.activiti.ActivitiWorkflowServiceIntegrationTest;
|
||||||
import org.alfresco.repo.workflow.jbpm.AlfrescoJavaScriptIntegrationTest;
|
import org.alfresco.repo.workflow.jbpm.AlfrescoJavaScriptIntegrationTest;
|
||||||
import org.alfresco.repo.workflow.jbpm.JBPMDeleteProcessTest;
|
|
||||||
import org.alfresco.repo.workflow.jbpm.JBPMEngineTest;
|
import org.alfresco.repo.workflow.jbpm.JBPMEngineTest;
|
||||||
import org.alfresco.repo.workflow.jbpm.JBPMSpringTest;
|
import org.alfresco.repo.workflow.jbpm.JBPMSpringTest;
|
||||||
import org.alfresco.repo.workflow.jbpm.JbpmWorkflowServiceIntegrationTest;
|
import org.alfresco.repo.workflow.jbpm.JbpmWorkflowServiceIntegrationTest;
|
||||||
import org.alfresco.repo.workflow.jbpm.NodeListConverterTest;
|
|
||||||
import org.alfresco.repo.workflow.jbpm.ReviewAndApproveTest;
|
import org.alfresco.repo.workflow.jbpm.ReviewAndApproveTest;
|
||||||
import org.alfresco.util.ApplicationContextHelper;
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
|
||||||
@@ -55,8 +53,6 @@ public class WorkflowTestSuite extends TestSuite
|
|||||||
suite.addTestSuite( StartWorkflowActionExecuterTest.class );
|
suite.addTestSuite( StartWorkflowActionExecuterTest.class );
|
||||||
suite.addTestSuite( JbpmWorkflowServiceIntegrationTest.class );
|
suite.addTestSuite( JbpmWorkflowServiceIntegrationTest.class );
|
||||||
suite.addTestSuite( ReviewAndApproveTest.class );
|
suite.addTestSuite( ReviewAndApproveTest.class );
|
||||||
suite.addTestSuite( NodeListConverterTest.class );
|
|
||||||
suite.addTestSuite( JBPMDeleteProcessTest.class );
|
|
||||||
suite.addTestSuite( JBPMSpringTest.class );
|
suite.addTestSuite( JBPMSpringTest.class );
|
||||||
suite.addTestSuite( JBPMEngineTest.class );
|
suite.addTestSuite( JBPMEngineTest.class );
|
||||||
suite.addTestSuite( AlfrescoJavaScriptIntegrationTest.class );
|
suite.addTestSuite( AlfrescoJavaScriptIntegrationTest.class );
|
||||||
|
@@ -38,14 +38,14 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
*/
|
*/
|
||||||
public class ScriptNodeListVariableType extends SerializableType
|
public class ScriptNodeListVariableType extends SerializableType
|
||||||
{
|
{
|
||||||
public static final String TYPE_NAME = "alfrescoScriptNodeList";
|
public static final String TYPE = "alfrescoScriptNodeList";
|
||||||
|
|
||||||
private ServiceRegistry serviceRegistry;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeName()
|
public String getTypeName()
|
||||||
{
|
{
|
||||||
return TYPE_NAME;
|
return TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -93,20 +93,20 @@ public class AlfrescoAssignment extends JBPMSpringAssignmentHandler
|
|||||||
throw new WorkflowException("actor expression '" + actorValStr + "' evaluates to null");
|
throw new WorkflowException("actor expression '" + actorValStr + "' evaluates to null");
|
||||||
}
|
}
|
||||||
|
|
||||||
String actor = null;
|
String theActor = null;
|
||||||
if (eval instanceof String)
|
if (eval instanceof String)
|
||||||
{
|
{
|
||||||
actor = (String)eval;
|
theActor = (String)eval;
|
||||||
}
|
}
|
||||||
else if (eval instanceof JBPMNode)
|
else if (eval instanceof JBPMNode)
|
||||||
{
|
{
|
||||||
actor = mapAuthorityToName((JBPMNode)eval, false);
|
theActor = mapAuthorityToName((JBPMNode)eval, false);
|
||||||
}
|
}
|
||||||
if (actor == null)
|
if (theActor == null)
|
||||||
{
|
{
|
||||||
throw new WorkflowException("actor expression must evaluate to a person");
|
throw new WorkflowException("actor expression must evaluate to a person");
|
||||||
}
|
}
|
||||||
assignedActor = actor;
|
assignedActor = theActor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -140,30 +140,30 @@ public class AlfrescoAssignment extends JBPMSpringAssignmentHandler
|
|||||||
assignedPooledActors = new String[nodes.length];
|
assignedPooledActors = new String[nodes.length];
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ScriptNode node : (ScriptNode[])nodes)
|
for (ScriptNode node : nodes)
|
||||||
{
|
{
|
||||||
String actor = mapAuthorityToName(node, true);
|
String theActor = mapAuthorityToName(node, true);
|
||||||
if (actor == null)
|
if (theActor == null)
|
||||||
{
|
{
|
||||||
throw new WorkflowException("pooledactors expression does not evaluate to a collection of authorities");
|
throw new WorkflowException("pooledactors expression does not evaluate to a collection of authorities");
|
||||||
}
|
}
|
||||||
assignedPooledActors[i++] = actor;
|
assignedPooledActors[i++] = theActor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (eval instanceof Collection)
|
if (eval instanceof Collection)
|
||||||
{
|
{
|
||||||
List<String> actors = new ArrayList<String>();
|
List<String> actors = new ArrayList<String>();
|
||||||
Collection<Object> nodes = (Collection<Object>)eval;
|
Collection<?> nodes = (Collection<?>)eval;
|
||||||
for (Object node : nodes)
|
for (Object node : nodes)
|
||||||
{
|
{
|
||||||
if (node instanceof ScriptNode)
|
if (node instanceof ScriptNode)
|
||||||
{
|
{
|
||||||
String actor = mapAuthorityToName((ScriptNode)node, true);
|
String theActor = mapAuthorityToName((ScriptNode)node, true);
|
||||||
if (actor == null)
|
if (theActor == null)
|
||||||
{
|
{
|
||||||
throw new WorkflowException("pooledactors expression does not evaluate to a collection of authorities");
|
throw new WorkflowException("pooledactors expression does not evaluate to a collection of authorities");
|
||||||
}
|
}
|
||||||
actors.add(actor);
|
actors.add(theActor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assignedPooledActors = new String[actors.size()];
|
assignedPooledActors = new String[actors.size()];
|
||||||
@@ -172,12 +172,12 @@ public class AlfrescoAssignment extends JBPMSpringAssignmentHandler
|
|||||||
else if (eval instanceof ScriptNode)
|
else if (eval instanceof ScriptNode)
|
||||||
{
|
{
|
||||||
ScriptNode node = (ScriptNode)eval;
|
ScriptNode node = (ScriptNode)eval;
|
||||||
String actor = mapAuthorityToName(node, true);
|
String theActor = mapAuthorityToName(node, true);
|
||||||
if (actor == null)
|
if (theActor == null)
|
||||||
{
|
{
|
||||||
throw new WorkflowException("pooledactors expression does not evaluate to a collection of authorities");
|
throw new WorkflowException("pooledactors expression does not evaluate to a collection of authorities");
|
||||||
}
|
}
|
||||||
assignedPooledActors = new String[] {actor};
|
assignedPooledActors = new String[] {theActor};
|
||||||
}
|
}
|
||||||
else if (eval instanceof String)
|
else if (eval instanceof String)
|
||||||
{
|
{
|
||||||
|
@@ -41,7 +41,7 @@ import org.springmodules.workflow.jbpm31.JbpmFactoryLocator;
|
|||||||
* @author Costin Leau
|
* @author Costin Leau
|
||||||
* @author davidc
|
* @author davidc
|
||||||
*/
|
*/
|
||||||
public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, FactoryBean,
|
public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, FactoryBean<JbpmConfiguration>,
|
||||||
BeanFactoryAware, BeanNameAware, DisposableBean
|
BeanFactoryAware, BeanNameAware, DisposableBean
|
||||||
{
|
{
|
||||||
private JbpmConfiguration jbpmConfiguration;
|
private JbpmConfiguration jbpmConfiguration;
|
||||||
@@ -74,21 +74,16 @@ public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, F
|
|||||||
this.factoryLocator.setBeanFactory(beanFactory);
|
this.factoryLocator.setBeanFactory(beanFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
* {@inheritDoc}
|
||||||
* @see
|
|
||||||
* org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang
|
|
||||||
* .String)
|
|
||||||
*/
|
*/
|
||||||
public void setBeanName(final String name)
|
public void setBeanName(final String name)
|
||||||
{
|
{
|
||||||
this.factoryLocator.setBeanName(name);
|
this.factoryLocator.setBeanName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
* {@inheritDoc}
|
||||||
* @see
|
|
||||||
* org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
|
||||||
*/
|
*/
|
||||||
public void afterPropertiesSet() throws Exception
|
public void afterPropertiesSet() throws Exception
|
||||||
{
|
{
|
||||||
@@ -115,27 +110,24 @@ public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, F
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
* {@inheritDoc}
|
||||||
* @see org.springframework.beans.factory.FactoryBean#getObject()
|
|
||||||
*/
|
*/
|
||||||
public Object getObject() throws Exception
|
public JbpmConfiguration getObject() throws Exception
|
||||||
{
|
{
|
||||||
return this.jbpmConfiguration;
|
return this.jbpmConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
* {@inheritDoc}
|
||||||
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
|
||||||
*/
|
*/
|
||||||
public Class getObjectType()
|
public Class<JbpmConfiguration> getObjectType()
|
||||||
{
|
{
|
||||||
return JbpmConfiguration.class;
|
return JbpmConfiguration.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
* {@inheritDoc}
|
||||||
* @see org.springframework.beans.factory.FactoryBean#isSingleton()
|
|
||||||
*/
|
*/
|
||||||
public boolean isSingleton()
|
public boolean isSingleton()
|
||||||
{
|
{
|
||||||
@@ -206,9 +198,8 @@ public class AlfrescoJbpmConfigurationFactoryBean implements InitializingBean, F
|
|||||||
this.sessionFactory = sessionFactory;
|
this.sessionFactory = sessionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* (non-Javadoc)
|
* {@inheritDoc}
|
||||||
* @see org.springframework.beans.factory.DisposableBean#destroy()
|
|
||||||
*/
|
*/
|
||||||
public void destroy() throws Exception
|
public void destroy() throws Exception
|
||||||
{
|
{
|
||||||
|
@@ -101,10 +101,11 @@ public class AlfrescoJobExecutor extends JobExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.jbpm.job.executor.JobExecutor#startThread()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
protected synchronized void startThread()
|
protected synchronized void startThread()
|
||||||
{
|
{
|
||||||
String threadName = getNextThreadName();
|
String threadName = getNextThreadName();
|
||||||
|
@@ -82,7 +82,7 @@ public class AlfrescoJobExecutorThread extends JobExecutorThread
|
|||||||
this.jbpmConfiguration = jbpmConfiguration;
|
this.jbpmConfiguration = jbpmConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
protected Collection acquireJobs()
|
protected Collection acquireJobs()
|
||||||
{
|
{
|
||||||
@@ -291,17 +291,17 @@ public class AlfrescoJobExecutorThread extends JobExecutorThread
|
|||||||
|
|
||||||
private String getExecutorLock()
|
private String getExecutorLock()
|
||||||
{
|
{
|
||||||
String jobLockToken = null;
|
String lockToken = null;
|
||||||
|
|
||||||
if (alfrescoJobExecutor.getJobExecutorLockEnabled())
|
if (alfrescoJobExecutor.getJobExecutorLockEnabled())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
jobLockToken = alfrescoJobExecutor.getJobLockService().getLock(LOCK_QNAME, jobLockTTL, 3000, 10);
|
lockToken = alfrescoJobExecutor.getJobLockService().getLock(LOCK_QNAME, jobLockTTL, 3000, 10);
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace(Thread.currentThread().getName()+" got lock token: "+jobLockToken);
|
logger.trace(Thread.currentThread().getName()+" got lock token: "+lockToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (LockAcquisitionException e)
|
catch (LockAcquisitionException e)
|
||||||
@@ -314,51 +314,51 @@ public class AlfrescoJobExecutorThread extends JobExecutorThread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return jobLockToken;
|
return lockToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshExecutorLock(String jobLockToken)
|
private void refreshExecutorLock(String lockToken)
|
||||||
{
|
{
|
||||||
if (jobLockToken != null)
|
if (lockToken != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
alfrescoJobExecutor.getJobLockService().refreshLock(jobLockToken, LOCK_QNAME, jobLockTTL);
|
alfrescoJobExecutor.getJobLockService().refreshLock(lockToken, LOCK_QNAME, jobLockTTL);
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace(Thread.currentThread().getName()+" refreshed lock token: "+jobLockToken);
|
logger.trace(Thread.currentThread().getName()+" refreshed lock token: "+lockToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (LockAcquisitionException e)
|
catch (LockAcquisitionException e)
|
||||||
{
|
{
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("Failed to refresh Alfresco Job Executor lock - may no longer exist ("+jobLockToken+")");
|
logger.trace("Failed to refresh Alfresco Job Executor lock - may no longer exist ("+lockToken+")");
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void releaseExecutorLock(String jobLockToken)
|
private void releaseExecutorLock(String lockToken)
|
||||||
{
|
{
|
||||||
if (jobLockToken != null)
|
if (lockToken != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
alfrescoJobExecutor.getJobLockService().releaseLock(jobLockToken, LOCK_QNAME);
|
alfrescoJobExecutor.getJobLockService().releaseLock(lockToken, LOCK_QNAME);
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace(Thread.currentThread().getName()+" released lock token: "+jobLockToken);
|
logger.trace(Thread.currentThread().getName()+" released lock token: "+lockToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (LockAcquisitionException e)
|
catch (LockAcquisitionException e)
|
||||||
{
|
{
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
logger.trace("Failed to release Alfresco Job Executor lock - may no longer exist ("+jobLockToken+")");
|
logger.trace("Failed to release Alfresco Job Executor lock - may no longer exist ("+lockToken+")");
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@@ -1,161 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
|
||||||
*
|
|
||||||
* This file is part of Alfresco
|
|
||||||
*
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.alfresco.repo.workflow.jbpm;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.alfresco.util.BaseSpringTest;
|
|
||||||
import org.jbpm.JbpmConfiguration;
|
|
||||||
import org.jbpm.JbpmContext;
|
|
||||||
import org.jbpm.db.GraphSession;
|
|
||||||
import org.jbpm.db.TaskMgmtSession;
|
|
||||||
import org.jbpm.graph.def.ProcessDefinition;
|
|
||||||
import org.jbpm.graph.exe.ProcessInstance;
|
|
||||||
import org.jbpm.graph.exe.Token;
|
|
||||||
import org.jbpm.taskmgmt.exe.TaskInstance;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit Test for reproducing constraint violation during JBPM process deletion
|
|
||||||
*
|
|
||||||
* http://jira.jboss.com/jira/browse/JBPM-757
|
|
||||||
*
|
|
||||||
* @author davidc
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class JBPMDeleteProcessTest extends BaseSpringTest {
|
|
||||||
|
|
||||||
JbpmConfiguration jbpmConfiguration;
|
|
||||||
long processId = -1L;
|
|
||||||
String currentTokenPath;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSetUpInTransaction() throws Exception
|
|
||||||
{
|
|
||||||
jbpmConfiguration = (JbpmConfiguration) getApplicationContext().getBean("jbpm_configuration");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testDelete() {
|
|
||||||
deployProcessDefinition();
|
|
||||||
|
|
||||||
startProcess();
|
|
||||||
step2TaskEnd();
|
|
||||||
deleteProcess();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deployProcessDefinition() {
|
|
||||||
ProcessDefinition processDefinition = ProcessDefinition.parseXmlString
|
|
||||||
(
|
|
||||||
"<process-definition name='deletetest'>" +
|
|
||||||
" <start-state name='start'> " +
|
|
||||||
" <task name='startTask'> " +
|
|
||||||
" <controller> " +
|
|
||||||
" <variable name='var1' access='write'/> " +
|
|
||||||
" </controller> " +
|
|
||||||
" </task> " +
|
|
||||||
" <transition name='' to='step2'/> " +
|
|
||||||
" </start-state> " +
|
|
||||||
" <task-node name='step2'> " +
|
|
||||||
" <task name='step2Task'/> " +
|
|
||||||
" <transition name='' to='step3'/> " +
|
|
||||||
" </task-node>" +
|
|
||||||
" <task-node name='step3'> " +
|
|
||||||
" <task name='step3Task'/> " +
|
|
||||||
" <transition name='' to='end'/> " +
|
|
||||||
" </task-node> " +
|
|
||||||
" <end-state name='end' />" +
|
|
||||||
"</process-definition>"
|
|
||||||
);
|
|
||||||
|
|
||||||
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
|
|
||||||
try {
|
|
||||||
jbpmContext.deployProcessDefinition(processDefinition);
|
|
||||||
} finally {
|
|
||||||
jbpmContext.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startProcess() {
|
|
||||||
|
|
||||||
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
|
|
||||||
try {
|
|
||||||
|
|
||||||
GraphSession graphSession = jbpmContext.getGraphSession();
|
|
||||||
|
|
||||||
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("deletetest");
|
|
||||||
ProcessInstance processInstance = new ProcessInstance(processDefinition);
|
|
||||||
processId = processInstance.getId();
|
|
||||||
|
|
||||||
TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
|
|
||||||
taskInstance.setVariableLocally("var1", "var1Value");
|
|
||||||
taskInstance.end();
|
|
||||||
Token token = taskInstance.getToken();
|
|
||||||
currentTokenPath = token.getFullName();
|
|
||||||
|
|
||||||
jbpmContext.save(processInstance);
|
|
||||||
} finally {
|
|
||||||
jbpmContext.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void step2TaskEnd() {
|
|
||||||
|
|
||||||
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
|
|
||||||
try {
|
|
||||||
|
|
||||||
GraphSession graphSession = jbpmContext.getGraphSession();
|
|
||||||
ProcessInstance processInstance = graphSession.loadProcessInstance(processId);
|
|
||||||
Token token = processInstance.findToken(currentTokenPath);
|
|
||||||
TaskMgmtSession taskSession = jbpmContext.getTaskMgmtSession();
|
|
||||||
List tasks = taskSession.findTaskInstancesByToken(token.getId());
|
|
||||||
TaskInstance taskInstance = (TaskInstance)tasks.get(0);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Uncomment the following line to force constraint violation
|
|
||||||
//
|
|
||||||
taskInstance.setVariableLocally("var1", "var1TaskValue");
|
|
||||||
|
|
||||||
taskInstance.setVariableLocally("var2", "var2UpdatedValue");
|
|
||||||
taskInstance.end();
|
|
||||||
token = taskInstance.getToken();
|
|
||||||
currentTokenPath = token.getFullName();
|
|
||||||
|
|
||||||
jbpmContext.save(processInstance);
|
|
||||||
} finally {
|
|
||||||
jbpmContext.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void deleteProcess()
|
|
||||||
{
|
|
||||||
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
|
|
||||||
try {
|
|
||||||
|
|
||||||
GraphSession graphSession = jbpmContext.getGraphSession();
|
|
||||||
ProcessInstance processInstance = graphSession.loadProcessInstance(processId);
|
|
||||||
graphSession.deleteProcessInstance(processInstance, true, true);
|
|
||||||
} finally {
|
|
||||||
jbpmContext.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -2094,7 +2094,8 @@ public class JBPMEngine extends AlfrescoBpmEngine implements WorkflowEngine
|
|||||||
{
|
{
|
||||||
JBPMJpdlXmlReader jpdlReader = new JBPMJpdlXmlReader(definitionStream);
|
JBPMJpdlXmlReader jpdlReader = new JBPMJpdlXmlReader(definitionStream);
|
||||||
ProcessDefinition def = jpdlReader.readProcessDefinition();
|
ProcessDefinition def = jpdlReader.readProcessDefinition();
|
||||||
compiledDef = new CompiledProcessDefinition(def, jpdlReader.getProblems());
|
List<Problem> problems = jpdlReader.getProblems();
|
||||||
|
compiledDef = new CompiledProcessDefinition(def, problems);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
@@ -22,7 +22,6 @@ import java.io.InputStream;
|
|||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
@@ -32,6 +31,7 @@ import org.jbpm.graph.def.Event;
|
|||||||
import org.jbpm.graph.def.Node;
|
import org.jbpm.graph.def.Node;
|
||||||
import org.jbpm.instantiation.Delegation;
|
import org.jbpm.instantiation.Delegation;
|
||||||
import org.jbpm.jpdl.xml.JpdlXmlReader;
|
import org.jbpm.jpdl.xml.JpdlXmlReader;
|
||||||
|
import org.jbpm.jpdl.xml.Problem;
|
||||||
import org.jbpm.jpdl.xml.ProblemListener;
|
import org.jbpm.jpdl.xml.ProblemListener;
|
||||||
import org.jbpm.scheduler.def.CancelTimerAction;
|
import org.jbpm.scheduler.def.CancelTimerAction;
|
||||||
import org.jbpm.scheduler.def.CreateTimerAction;
|
import org.jbpm.scheduler.def.CreateTimerAction;
|
||||||
@@ -81,9 +81,10 @@ public class JBPMJpdlXmlReader extends JpdlXmlReader
|
|||||||
super(reader);
|
super(reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.jbpm.jpdl.xml.JpdlXmlReader#readNodeTimer(org.dom4j.Element, org.jbpm.graph.def.Node)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void readNodeTimer(Element timerElement, Node node)
|
protected void readNodeTimer(Element timerElement, Node node)
|
||||||
{
|
{
|
||||||
// NOTE: This method implementation is a copy from the JpdlXmlReader class
|
// NOTE: This method implementation is a copy from the JpdlXmlReader class
|
||||||
@@ -103,9 +104,10 @@ public class JBPMJpdlXmlReader extends JpdlXmlReader
|
|||||||
addAction(node, Event.EVENTTYPE_NODE_LEAVE, cancelTimerAction);
|
addAction(node, Event.EVENTTYPE_NODE_LEAVE, cancelTimerAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.jbpm.jpdl.xml.JpdlXmlReader#readTaskTimer(org.dom4j.Element, org.jbpm.taskmgmt.def.Task)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
protected void readTaskTimer(Element timerElement, Task task)
|
protected void readTaskTimer(Element timerElement, Task task)
|
||||||
{
|
{
|
||||||
// NOTE: This method implementation is a copy from the JpdlXmlReader class
|
// NOTE: This method implementation is a copy from the JpdlXmlReader class
|
||||||
@@ -133,7 +135,7 @@ public class JBPMJpdlXmlReader extends JpdlXmlReader
|
|||||||
addAction(task, Event.EVENTTYPE_TASK_CREATE, createTimerAction);
|
addAction(task, Event.EVENTTYPE_TASK_CREATE, createTimerAction);
|
||||||
|
|
||||||
// read the cancel-event types
|
// read the cancel-event types
|
||||||
Collection cancelEventTypes = new ArrayList();
|
Collection<String> cancelEventTypes = new ArrayList<String>();
|
||||||
|
|
||||||
String cancelEventTypeText = timerElement.attributeValue("cancel-event");
|
String cancelEventTypeText = timerElement.attributeValue("cancel-event");
|
||||||
if (cancelEventTypeText != null)
|
if (cancelEventTypeText != null)
|
||||||
@@ -150,11 +152,8 @@ public class JBPMJpdlXmlReader extends JpdlXmlReader
|
|||||||
// set the default
|
// set the default
|
||||||
cancelEventTypes.add(Event.EVENTTYPE_TASK_END);
|
cancelEventTypes.add(Event.EVENTTYPE_TASK_END);
|
||||||
}
|
}
|
||||||
|
for (String cancelEventType : cancelEventTypes)
|
||||||
Iterator iter = cancelEventTypes.iterator();
|
|
||||||
while (iter.hasNext())
|
|
||||||
{
|
{
|
||||||
String cancelEventType = (String) iter.next();
|
|
||||||
CancelTimerAction cancelTimerAction = new CancelTimerAction();
|
CancelTimerAction cancelTimerAction = new CancelTimerAction();
|
||||||
cancelTimerAction.setTimerName(name);
|
cancelTimerAction.setTimerName(name);
|
||||||
addAction(task, cancelEventType, cancelTimerAction);
|
addAction(task, cancelEventType, cancelTimerAction);
|
||||||
@@ -166,7 +165,8 @@ public class JBPMJpdlXmlReader extends JpdlXmlReader
|
|||||||
*
|
*
|
||||||
* @return problems
|
* @return problems
|
||||||
*/
|
*/
|
||||||
public List getProblems()
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<Problem> getProblems()
|
||||||
{
|
{
|
||||||
return problems;
|
return problems;
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,7 @@ import org.springmodules.workflow.jbpm31.JbpmFactoryLocator;
|
|||||||
*/
|
*/
|
||||||
public abstract class JBPMSpringActionHandler implements ActionHandler
|
public abstract class JBPMSpringActionHandler implements ActionHandler
|
||||||
{
|
{
|
||||||
|
private static final long serialVersionUID = 6848343645482681529L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct
|
* Construct
|
||||||
|
@@ -33,6 +33,7 @@ import org.springmodules.workflow.jbpm31.JbpmFactoryLocator;
|
|||||||
*/
|
*/
|
||||||
public abstract class JBPMSpringAssignmentHandler implements AssignmentHandler
|
public abstract class JBPMSpringAssignmentHandler implements AssignmentHandler
|
||||||
{
|
{
|
||||||
|
private static final long serialVersionUID = -2233750219905283562L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct
|
* Construct
|
||||||
|
@@ -43,59 +43,21 @@ public class JBPMSpringTest extends BaseSpringTest
|
|||||||
|
|
||||||
|
|
||||||
//@Override
|
//@Override
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Override
|
||||||
protected void onSetUpInTransaction() throws Exception
|
protected void onSetUpInTransaction() throws Exception
|
||||||
{
|
{
|
||||||
jbpmTemplate = (JbpmTemplate)applicationContext.getBean("jbpm_template");
|
jbpmTemplate = (JbpmTemplate)applicationContext.getBean("jbpm_template");
|
||||||
descriptorService = (DescriptorService)applicationContext.getBean("DescriptorService");
|
descriptorService = (DescriptorService)applicationContext.getBean("DescriptorService");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDummy()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testHelloWorld()
|
public void testHelloWorld()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
// Between the 3 method calls below, all data is passed via the
|
|
||||||
// database. Here, in this unit test, these 3 methods are executed
|
|
||||||
// right after each other because we want to test a complete process
|
|
||||||
// scenario. But in reality, these methods represent different
|
|
||||||
// requests to a server.
|
|
||||||
|
|
||||||
// Since we start with a clean, empty in-memory database, we have to
|
|
||||||
// deploy the process first. In reality, this is done once by the
|
|
||||||
// process developer.
|
|
||||||
deployProcessDefinition();
|
deployProcessDefinition();
|
||||||
|
|
||||||
// Suppose we want to start a process instance (=process execution)
|
|
||||||
// when a user submits a form in a web application...
|
|
||||||
processInstanceIsCreatedWhenUserSubmitsWebappForm();
|
processInstanceIsCreatedWhenUserSubmitsWebappForm();
|
||||||
|
|
||||||
// Then, later, upon the arrival of an asynchronous message the
|
|
||||||
// execution must continue.
|
|
||||||
theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testStep0()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
deployProcessDefinition();
|
|
||||||
setComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testStep1()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
processInstanceIsCreatedWhenUserSubmitsWebappForm();
|
|
||||||
setComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testStep2()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
|
theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
|
||||||
undeployProcessDefinition();
|
undeployProcessDefinition();
|
||||||
setComplete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deployProcessDefinition()
|
private void deployProcessDefinition()
|
||||||
@@ -192,7 +154,7 @@ public class JBPMSpringTest extends BaseSpringTest
|
|||||||
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("hello world");
|
ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("hello world");
|
||||||
|
|
||||||
// Now, we search for all process instances of this process definition.
|
// Now, we search for all process instances of this process definition.
|
||||||
List processInstances = graphSession.findProcessInstances(processDefinition.getId());
|
List<?> processInstances = graphSession.findProcessInstances(processDefinition.getId());
|
||||||
|
|
||||||
// Because we know that in the context of this unit test, there is
|
// Because we know that in the context of this unit test, there is
|
||||||
// only one execution. In real life, the processInstanceId can be
|
// only one execution. In real life, the processInstanceId can be
|
||||||
|
@@ -59,7 +59,7 @@ public class JBPMTestSpringActionHandler extends JBPMSpringActionHandler
|
|||||||
@Override
|
@Override
|
||||||
protected void initialiseHandler(BeanFactory factory)
|
protected void initialiseHandler(BeanFactory factory)
|
||||||
{
|
{
|
||||||
descriptorService = (DescriptorService)factory.getBean("DescriptorService", DescriptorService.class);
|
descriptorService = factory.getBean("DescriptorService", DescriptorService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -75,8 +75,8 @@ public class JBPMTransactionTemplate extends JbpmTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("synthetic-access")
|
@SuppressWarnings("synthetic-access")
|
||||||
@Override
|
@Override
|
||||||
@@ -93,8 +93,8 @@ public class JBPMTransactionTemplate extends JbpmTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.springmodules.workflow.jbpm31.JbpmTemplate#getContext()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected JbpmContext getContext()
|
protected JbpmContext getContext()
|
||||||
@@ -120,8 +120,8 @@ public class JBPMTransactionTemplate extends JbpmTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.springmodules.workflow.jbpm31.JbpmTemplate#releaseContext(org.jbpm.JbpmContext)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void releaseContext(JbpmContext jbpmContext)
|
protected void releaseContext(JbpmContext jbpmContext)
|
||||||
@@ -137,32 +137,35 @@ public class JBPMTransactionTemplate extends JbpmTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.repo.transaction.TransactionListener#flush()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void flush()
|
public void flush()
|
||||||
{
|
{
|
||||||
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.repo.transaction.TransactionListener#beforeCommit(boolean)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void beforeCommit(boolean readOnly)
|
public void beforeCommit(boolean readOnly)
|
||||||
{
|
{
|
||||||
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.repo.transaction.TransactionListener#beforeCompletion()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void beforeCompletion()
|
public void beforeCompletion()
|
||||||
{
|
{
|
||||||
|
//NOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.repo.transaction.TransactionListener#afterCommit()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void afterCommit()
|
public void afterCommit()
|
||||||
{
|
{
|
||||||
@@ -177,8 +180,8 @@ public class JBPMTransactionTemplate extends JbpmTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.alfresco.repo.transaction.TransactionListener#afterRollback()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void afterRollback()
|
public void afterRollback()
|
||||||
{
|
{
|
||||||
@@ -194,7 +197,7 @@ public class JBPMTransactionTemplate extends JbpmTemplate
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see java.lang.Object#hashCode()
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
@@ -203,7 +206,7 @@ public class JBPMTransactionTemplate extends JbpmTemplate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
|
@@ -40,6 +40,7 @@ public class Join extends org.jbpm.graph.node.Join
|
|||||||
*/
|
*/
|
||||||
public Join()
|
public Join()
|
||||||
{
|
{
|
||||||
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,16 +51,17 @@ public class Join extends org.jbpm.graph.node.Join
|
|||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.jbpm.jpdl.xml.Parsable#read(org.dom4j.Element, org.jbpm.jpdl.xml.JpdlXmlReader)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void read(Element element, JpdlXmlReader jpdlReader)
|
public void read(Element element, JpdlXmlReader jpdlReader)
|
||||||
{
|
{
|
||||||
// Add "on node leave" event handler which ends child tokens / tasks
|
// Add "on node leave" event handler which ends child tokens / tasks
|
||||||
Delegation delegation = new Delegation(JoinEndForkedTokens.class.getName());
|
Delegation delegation = new Delegation(JoinEndForkedTokens.class.getName());
|
||||||
Action action = new Action(delegation);
|
Action theAction = new Action(delegation);
|
||||||
Event event = new Event(Event.EVENTTYPE_NODE_LEAVE);
|
Event event = new Event(Event.EVENTTYPE_NODE_LEAVE);
|
||||||
event.addAction(action);
|
event.addAction(theAction);
|
||||||
addEvent(event);
|
addEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,15 +41,16 @@ public class JoinEndForkedTokens implements ActionHandler
|
|||||||
*/
|
*/
|
||||||
public JoinEndForkedTokens()
|
public JoinEndForkedTokens()
|
||||||
{
|
{
|
||||||
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.jbpm.graph.def.ActionHandler#execute(org.jbpm.graph.exe.ExecutionContext)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public void execute(ExecutionContext executionContext)
|
public void execute(ExecutionContext executionContext)
|
||||||
{
|
{
|
||||||
Token token = executionContext.getToken();
|
Token token = executionContext.getToken();
|
||||||
Map childTokens = token.getActiveChildren();
|
Map<?, ?> childTokens = token.getActiveChildren();
|
||||||
for (Object childToken : childTokens.values())
|
for (Object childToken : childTokens.values())
|
||||||
{
|
{
|
||||||
cancelToken(executionContext, (Token)childToken);
|
cancelToken(executionContext, (Token)childToken);
|
||||||
@@ -65,7 +66,7 @@ public class JoinEndForkedTokens implements ActionHandler
|
|||||||
protected void cancelToken(ExecutionContext executionContext, Token token)
|
protected void cancelToken(ExecutionContext executionContext, Token token)
|
||||||
{
|
{
|
||||||
// visit child tokens
|
// visit child tokens
|
||||||
Map childTokens = token.getActiveChildren();
|
Map<?, ?> childTokens = token.getActiveChildren();
|
||||||
for (Object childToken : childTokens.values())
|
for (Object childToken : childTokens.values())
|
||||||
{
|
{
|
||||||
cancelToken(executionContext, (Token)childToken);
|
cancelToken(executionContext, (Token)childToken);
|
||||||
@@ -90,7 +91,7 @@ public class JoinEndForkedTokens implements ActionHandler
|
|||||||
protected void cancelTokenTasks(ExecutionContext executionContext, Token token)
|
protected void cancelTokenTasks(ExecutionContext executionContext, Token token)
|
||||||
{
|
{
|
||||||
TaskMgmtInstance tms = executionContext.getTaskMgmtInstance();
|
TaskMgmtInstance tms = executionContext.getTaskMgmtInstance();
|
||||||
Collection tasks = tms.getUnfinishedTasks(token);
|
Collection<TaskInstance> tasks = tms.getUnfinishedTasks(token);
|
||||||
for (Object task : tasks)
|
for (Object task : tasks)
|
||||||
{
|
{
|
||||||
TaskInstance taskInstance = (TaskInstance)task;
|
TaskInstance taskInstance = (TaskInstance)task;
|
||||||
|
@@ -41,9 +41,10 @@ public class NodeListConverter extends SerializableToByteArrayConverter
|
|||||||
private static BeanFactoryLocator jbpmFactoryLocator = new JbpmFactoryLocator();
|
private static BeanFactoryLocator jbpmFactoryLocator = new JbpmFactoryLocator();
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.jbpm.context.exe.Converter#supports(java.lang.Object)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean supports(Object value)
|
public boolean supports(Object value)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
@@ -53,9 +54,10 @@ public class NodeListConverter extends SerializableToByteArrayConverter
|
|||||||
return (value.getClass() == JBPMNodeList.class);
|
return (value.getClass() == JBPMNodeList.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.jbpm.context.exe.Converter#convert(java.lang.Object)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Object convert(Object o)
|
public Object convert(Object o)
|
||||||
{
|
{
|
||||||
Object converted = null;
|
Object converted = null;
|
||||||
@@ -72,9 +74,10 @@ public class NodeListConverter extends SerializableToByteArrayConverter
|
|||||||
return converted;
|
return converted;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/**
|
||||||
* @see org.jbpm.context.exe.Converter#revert(java.lang.Object)
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public Object revert(Object o)
|
public Object revert(Object o)
|
||||||
{
|
{
|
||||||
|
@@ -1,150 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005-2010 Alfresco Software Limited.
|
|
||||||
*
|
|
||||||
* This file is part of Alfresco
|
|
||||||
*
|
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.alfresco.repo.workflow.jbpm;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.repo.workflow.BPMEngineRegistry;
|
|
||||||
import org.alfresco.repo.workflow.TaskComponent;
|
|
||||||
import org.alfresco.repo.workflow.WorkflowComponent;
|
|
||||||
import org.alfresco.repo.workflow.WorkflowModel;
|
|
||||||
import org.alfresco.service.ServiceRegistry;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.alfresco.service.cmr.repository.StoreRef;
|
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowDeployment;
|
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowPath;
|
|
||||||
import org.alfresco.service.cmr.workflow.WorkflowTask;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.util.BaseSpringTest;
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JBPM Engine Tests
|
|
||||||
*
|
|
||||||
* @author davidc
|
|
||||||
*/
|
|
||||||
public class NodeListConverterTest extends BaseSpringTest
|
|
||||||
{
|
|
||||||
AuthenticationComponent authenticationComponent;
|
|
||||||
PersonService personService;
|
|
||||||
WorkflowComponent workflowComponent;
|
|
||||||
TaskComponent taskComponent;
|
|
||||||
WorkflowDefinition testWorkflowDef;
|
|
||||||
NodeRef testNodeRef;
|
|
||||||
|
|
||||||
private static String taskId = null;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSetUpInTransaction() throws Exception
|
|
||||||
{
|
|
||||||
personService = (PersonService)applicationContext.getBean("personService");
|
|
||||||
BPMEngineRegistry registry = (BPMEngineRegistry)applicationContext.getBean("bpm_engineRegistry");
|
|
||||||
workflowComponent = registry.getWorkflowComponent("jbpm");
|
|
||||||
taskComponent = registry.getTaskComponent("jbpm");
|
|
||||||
|
|
||||||
// deploy latest review and approve process definition
|
|
||||||
ClassPathResource processDef = new ClassPathResource("alfresco/workflow/review_processdefinition.xml");
|
|
||||||
WorkflowDeployment deployment = workflowComponent.deployDefinition(processDef.getInputStream(), MimetypeMap.MIMETYPE_XML);
|
|
||||||
testWorkflowDef = deployment.definition;
|
|
||||||
assertNotNull(testWorkflowDef);
|
|
||||||
|
|
||||||
// run as system
|
|
||||||
authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
|
|
||||||
authenticationComponent.setSystemUserAsCurrentUser();
|
|
||||||
|
|
||||||
// get valid node ref
|
|
||||||
NodeService nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName());
|
|
||||||
testNodeRef = nodeService.getRootNode(new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void testStep1Start()
|
|
||||||
{
|
|
||||||
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
|
|
||||||
params.put(WorkflowModel.ASSOC_PACKAGE, testNodeRef);
|
|
||||||
Date reviewDueDate = new Date();
|
|
||||||
params.put(QName.createQName("http://www.alfresco.org/model/workflow/1.0", "reviewDueDate"), reviewDueDate);
|
|
||||||
NodeRef reviewer = personService.getPerson(AuthenticationUtil.getAdminUserName());
|
|
||||||
params.put(QName.createQName("http://www.alfresco.org/model/workflow/1.0", "reviewer"), reviewer);
|
|
||||||
|
|
||||||
WorkflowPath path = workflowComponent.startWorkflow(testWorkflowDef.id, params);
|
|
||||||
assertNotNull(path);
|
|
||||||
List<WorkflowTask> tasks1 = workflowComponent.getTasksForWorkflowPath(path.id);
|
|
||||||
assertNotNull(tasks1);
|
|
||||||
assertEquals(1, tasks1.size());
|
|
||||||
|
|
||||||
setComplete();
|
|
||||||
taskId = tasks1.get(0).id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void testSetNodeRefList()
|
|
||||||
{
|
|
||||||
List<NodeRef> nodeRefs = new ArrayList<NodeRef>();
|
|
||||||
nodeRefs.add(testNodeRef);
|
|
||||||
nodeRefs.add(testNodeRef);
|
|
||||||
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
|
|
||||||
params.put(WorkflowModel.PROP_COMPLETED_ITEMS, (Serializable)nodeRefs);
|
|
||||||
|
|
||||||
WorkflowTask task = taskComponent.getTaskById(taskId);
|
|
||||||
assertNull(task.properties.get(WorkflowModel.PROP_COMPLETED_ITEMS));
|
|
||||||
|
|
||||||
WorkflowTask updatedTask = taskComponent.updateTask(taskId, params, null, null);
|
|
||||||
assertNotNull(updatedTask);
|
|
||||||
assertTrue(updatedTask.properties.containsKey(WorkflowModel.PROP_COMPLETED_ITEMS));
|
|
||||||
assertEquals(2, ((List)updatedTask.properties.get(WorkflowModel.PROP_COMPLETED_ITEMS)).size());
|
|
||||||
|
|
||||||
setComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void testUpdateNodeRefList()
|
|
||||||
{
|
|
||||||
List<NodeRef> nodeRefs = new ArrayList<NodeRef>();
|
|
||||||
// nodeRefs.add(testNodeRef);
|
|
||||||
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
|
|
||||||
params.put(WorkflowModel.PROP_COMPLETED_ITEMS, (Serializable)nodeRefs);
|
|
||||||
|
|
||||||
// WorkflowTask task = taskComponent.getTaskById(taskId);
|
|
||||||
// assertNotNull(task);
|
|
||||||
// assertTrue(task.properties.containsKey(WorkflowModel.PROP_COMPLETED_ITEMS));
|
|
||||||
// assertEquals(2, ((List)task.properties.get(WorkflowModel.PROP_COMPLETED_ITEMS)).size());
|
|
||||||
|
|
||||||
WorkflowTask updatedTask = taskComponent.updateTask(taskId, params, null, null);
|
|
||||||
assertNotNull(updatedTask);
|
|
||||||
assertTrue(updatedTask.properties.containsKey(WorkflowModel.PROP_COMPLETED_ITEMS));
|
|
||||||
assertEquals(0, ((List)updatedTask.properties.get(WorkflowModel.PROP_COMPLETED_ITEMS)).size());
|
|
||||||
|
|
||||||
setComplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -61,8 +61,7 @@ public class ReviewAndApproveTest extends BaseSpringTest
|
|||||||
WorkflowDefinition testWorkflowDef;
|
WorkflowDefinition testWorkflowDef;
|
||||||
NodeRef testNodeRef;
|
NodeRef testNodeRef;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSetUpInTransaction() throws Exception
|
protected void onSetUpInTransaction() throws Exception
|
||||||
{
|
{
|
||||||
@@ -74,7 +73,7 @@ public class ReviewAndApproveTest extends BaseSpringTest
|
|||||||
// deploy latest review and approve process definition
|
// deploy latest review and approve process definition
|
||||||
ClassPathResource processDef = new ClassPathResource("alfresco/workflow/review_processdefinition.xml");
|
ClassPathResource processDef = new ClassPathResource("alfresco/workflow/review_processdefinition.xml");
|
||||||
WorkflowDeployment deployment = workflowComponent.deployDefinition(processDef.getInputStream(), MimetypeMap.MIMETYPE_XML);
|
WorkflowDeployment deployment = workflowComponent.deployDefinition(processDef.getInputStream(), MimetypeMap.MIMETYPE_XML);
|
||||||
testWorkflowDef = deployment.definition;
|
testWorkflowDef = deployment.getDefinition();
|
||||||
assertNotNull(testWorkflowDef);
|
assertNotNull(testWorkflowDef);
|
||||||
|
|
||||||
// run as system
|
// run as system
|
||||||
@@ -105,27 +104,27 @@ public class ReviewAndApproveTest extends BaseSpringTest
|
|||||||
params.put(WorkflowModel.ASSOC_ASSIGNEE, reviewer);
|
params.put(WorkflowModel.ASSOC_ASSIGNEE, reviewer);
|
||||||
params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "Test review");
|
params.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "Test review");
|
||||||
|
|
||||||
WorkflowPath path = workflowComponent.startWorkflow(workflowDef.id, params);
|
WorkflowPath path = workflowComponent.startWorkflow(workflowDef.getId(), params);
|
||||||
assertNotNull(path);
|
assertNotNull(path);
|
||||||
List<WorkflowTask> tasks1 = workflowComponent.getTasksForWorkflowPath(path.id);
|
List<WorkflowTask> tasks1 = workflowComponent.getTasksForWorkflowPath(path.getId());
|
||||||
assertNotNull(tasks1);
|
assertNotNull(tasks1);
|
||||||
assertEquals(1, tasks1.size());
|
assertEquals(1, tasks1.size());
|
||||||
|
|
||||||
WorkflowTask task = tasks1.get(0);
|
WorkflowTask task = tasks1.get(0);
|
||||||
assertTrue(task.properties.containsKey(WorkflowModel.ASSOC_PACKAGE));
|
assertTrue(task.getProperties().containsKey(WorkflowModel.ASSOC_PACKAGE));
|
||||||
WorkflowTask endedTask = taskComponent.endTask(task.id, null);
|
WorkflowTask endedTask = taskComponent.endTask(task.getId(), null);
|
||||||
assertNotNull(endedTask);
|
assertNotNull(endedTask);
|
||||||
assertTrue(endedTask.properties.containsKey(WorkflowModel.PROP_OUTCOME));
|
assertTrue(endedTask.getProperties().containsKey(WorkflowModel.PROP_OUTCOME));
|
||||||
assertEquals("", endedTask.properties.get(WorkflowModel.PROP_OUTCOME));
|
assertEquals("", endedTask.getProperties().get(WorkflowModel.PROP_OUTCOME));
|
||||||
assertEquals("Test review", endedTask.properties.get(WorkflowModel.PROP_DESCRIPTION));
|
assertEquals("Test review", endedTask.getProperties().get(WorkflowModel.PROP_DESCRIPTION));
|
||||||
assertEquals("Test review", endedTask.path.instance.description);
|
assertEquals("Test review", endedTask.getPath().getInstance().getDescription());
|
||||||
|
|
||||||
List<WorkflowTask> assignedTasks = taskComponent.getAssignedTasks(AuthenticationUtil.getAdminUserName(), WorkflowTaskState.IN_PROGRESS);
|
List<WorkflowTask> assignedTasks = taskComponent.getAssignedTasks(AuthenticationUtil.getAdminUserName(), WorkflowTaskState.IN_PROGRESS);
|
||||||
assertNotNull(assignedTasks);
|
assertNotNull(assignedTasks);
|
||||||
assignedTasks = filterTasksByWorkflowInstance(assignedTasks, path.instance.id);
|
assignedTasks = filterTasksByWorkflowInstance(assignedTasks, path.getInstance().getId());
|
||||||
|
|
||||||
assertEquals(testNodeRef, assignedTasks.get(0).properties.get(WorkflowModel.ASSOC_PACKAGE));
|
assertEquals(testNodeRef, assignedTasks.get(0).getProperties().get(WorkflowModel.ASSOC_PACKAGE));
|
||||||
assertEquals(reviewDueDate, assignedTasks.get(0).properties.get(WorkflowModel.PROP_DUE_DATE));
|
assertEquals(reviewDueDate, assignedTasks.get(0).getProperties().get(WorkflowModel.PROP_DUE_DATE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCompletedItems()
|
public void testCompletedItems()
|
||||||
@@ -144,15 +143,15 @@ public class ReviewAndApproveTest extends BaseSpringTest
|
|||||||
NodeRef reviewer = personService.getPerson(AuthenticationUtil.getAdminUserName());
|
NodeRef reviewer = personService.getPerson(AuthenticationUtil.getAdminUserName());
|
||||||
params.put(WorkflowModel.ASSOC_ASSIGNEE, reviewer);
|
params.put(WorkflowModel.ASSOC_ASSIGNEE, reviewer);
|
||||||
|
|
||||||
WorkflowPath path = workflowComponent.startWorkflow(workflowDef.id, params);
|
WorkflowPath path = workflowComponent.startWorkflow(workflowDef.getId(), params);
|
||||||
assertNotNull(path);
|
assertNotNull(path);
|
||||||
List<WorkflowTask> tasks1 = workflowComponent.getTasksForWorkflowPath(path.id);
|
List<WorkflowTask> tasks1 = workflowComponent.getTasksForWorkflowPath(path.getId());
|
||||||
assertNotNull(tasks1);
|
assertNotNull(tasks1);
|
||||||
assertEquals(1, tasks1.size());
|
assertEquals(1, tasks1.size());
|
||||||
|
|
||||||
WorkflowTask task = tasks1.get(0);
|
WorkflowTask task = tasks1.get(0);
|
||||||
assertTrue(task.properties.containsKey(WorkflowModel.PROP_COMPLETED_ITEMS));
|
assertTrue(task.getProperties().containsKey(WorkflowModel.PROP_COMPLETED_ITEMS));
|
||||||
assertEquals(2, ((List)task.properties.get(WorkflowModel.PROP_COMPLETED_ITEMS)).size());
|
assertEquals(2, ((List<?>)task.getProperties().get(WorkflowModel.PROP_COMPLETED_ITEMS)).size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -168,7 +167,7 @@ public class ReviewAndApproveTest extends BaseSpringTest
|
|||||||
List<WorkflowTask> filteredTasks = new ArrayList<WorkflowTask>();
|
List<WorkflowTask> filteredTasks = new ArrayList<WorkflowTask>();
|
||||||
for (WorkflowTask task : tasks)
|
for (WorkflowTask task : tasks)
|
||||||
{
|
{
|
||||||
if (task.path.instance.id.equals(workflowInstanceId))
|
if (task.getPath().getInstance().getId().equals(workflowInstanceId))
|
||||||
{
|
{
|
||||||
filteredTasks.add(task);
|
filteredTasks.add(task);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user