mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30270 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -30,11 +30,11 @@
|
||||
|
||||
<!-- BPMN Parse listener which adds tasklisteners to all userTasks -->
|
||||
<bean id="activitiParseListener"
|
||||
class="org.alfresco.repo.workflow.activiti.AddTaskListenerParseListener">
|
||||
class="org.alfresco.repo.workflow.activiti.AlfrescoBpmnParseListener">
|
||||
<property name="createTaskListener" ref="activitiCreateTaskListener" />
|
||||
<property name="completeTaskListener" ref="activitiCompleteTaskListener" />
|
||||
<property name="processCreateListener" ref="activitiProcessCreateListener" />
|
||||
|
||||
<property name="tenantService" ref="tenantService" />
|
||||
</bean>
|
||||
|
||||
<!-- -->
|
||||
|
@@ -799,6 +799,7 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri
|
||||
{
|
||||
invitationService.approve(invitationId, "No Way Hosea!");
|
||||
assertTrue("excetion not thrown", false);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -867,6 +868,7 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri
|
||||
{
|
||||
invitationService.reject(invitationId, "No Way Hosea!");
|
||||
assertTrue("excetion not thrown", false);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -967,9 +969,16 @@ public abstract class AbstractInvitationServiceImplTest extends BaseAlfrescoSpri
|
||||
* Search with an empty criteria - should find all open invitations
|
||||
*/
|
||||
InvitationSearchCriteria crit2 = new InvitationSearchCriteriaImpl();
|
||||
|
||||
invitationService.searchInvitation(crit2);
|
||||
assertTrue("search everything returned 0 elements", resFive.size() > 0);
|
||||
|
||||
InvitationSearchCriteriaImpl crit3 = new InvitationSearchCriteriaImpl();
|
||||
crit3.setInviter(USER_MANAGER);
|
||||
crit3.setInvitationType(InvitationSearchCriteria.InvitationType.NOMINATED);
|
||||
|
||||
List<Invitation> res3 = invitationService.searchInvitation(crit3);
|
||||
assertEquals("user one does not have 2 nominated", 2, res3.size());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -273,12 +273,12 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
{
|
||||
WorkflowTask startTask = getStartTask(invitationId);
|
||||
NominatedInvitation invitation = getNominatedInvitation(startTask);
|
||||
if (invitation == null)
|
||||
if(invitation == null)
|
||||
{
|
||||
throw new InvitationException("State error, accept may only be called on a nominated invitation.");
|
||||
}
|
||||
// Check invitationId and ticket match
|
||||
if (invitation.getTicket().equals(ticket)==false)
|
||||
if(invitation.getTicket().equals(ticket)==false)
|
||||
{
|
||||
//TODO localise msg
|
||||
String msg = "Response to invite has supplied an invalid ticket. The response to the invitation could thus not be processed";
|
||||
@@ -293,12 +293,12 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
private void endInvitation(WorkflowTask startTask, String transition, Map<QName, Serializable> properties, QName... taskTypes )
|
||||
{
|
||||
List<WorkflowTask> tasks = workflowService.getTasksForWorkflowPath(startTask.getPath().getId());
|
||||
if (tasks.size()==1)
|
||||
if(tasks.size()==1)
|
||||
{
|
||||
WorkflowTask task = tasks.get(0);
|
||||
if (taskTypeMatches(task, taskTypes))
|
||||
if(taskTypeMatches(task, taskTypes))
|
||||
{
|
||||
if (properties != null)
|
||||
if(properties != null)
|
||||
{
|
||||
workflowService.updateTask(task.getId(), properties, null, null);
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
{
|
||||
WorkflowTask startTask = getStartTask(invitationId);
|
||||
ModeratedInvitation invitation = getModeratedInvitation(startTask);
|
||||
if (invitation == null)
|
||||
if(invitation == null)
|
||||
{
|
||||
String msg = "State error, can only call approve on a Moderated invitation.";
|
||||
throw new InvitationException(msg);
|
||||
@@ -349,7 +349,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
public Invitation reject(String invitationId, String reason)
|
||||
{
|
||||
WorkflowTask startTask = getStartTask(invitationId);
|
||||
if (taskTypeMatches(startTask, WorkflowModelModeratedInvitation.WF_START_TASK))
|
||||
if(taskTypeMatches(startTask, WorkflowModelModeratedInvitation.WF_START_TASK))
|
||||
{
|
||||
return rejectModeratedInvitation(startTask, reason);
|
||||
}
|
||||
@@ -392,7 +392,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
public Invitation cancel(String invitationId)
|
||||
{
|
||||
WorkflowTask startTask = getStartTask(invitationId);
|
||||
if (taskTypeMatches(startTask, WorkflowModelModeratedInvitation.WF_START_TASK))
|
||||
if(taskTypeMatches(startTask, WorkflowModelModeratedInvitation.WF_START_TASK))
|
||||
{
|
||||
return cancelModeratedInvitation(startTask);
|
||||
}
|
||||
@@ -445,7 +445,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
private Invitation getInvitation(WorkflowTask startTask)
|
||||
{
|
||||
Invitation invitation = getNominatedInvitation(startTask);
|
||||
if (invitation == null)
|
||||
if(invitation == null)
|
||||
{
|
||||
invitation = getModeratedInvitation(startTask);
|
||||
}
|
||||
@@ -576,12 +576,12 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
return false;
|
||||
}
|
||||
String inviter = criteria.getInviter();
|
||||
if (inviter!= null)
|
||||
if(inviter!= null)
|
||||
{
|
||||
if (invitation instanceof NominatedInvitation)
|
||||
{
|
||||
NominatedInvitation modInvite = (NominatedInvitation) invitation;
|
||||
if(inviter.equals(modInvite.getInviterUserName()))
|
||||
if(false == inviter.equals(modInvite.getInviterUserName()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -627,20 +627,20 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
|
||||
// query for invite workflow tasks
|
||||
List<WorkflowTask> results = new ArrayList<WorkflowTask>();
|
||||
if (workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||
if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||
{
|
||||
query.setTaskName(WorkflowModelModeratedInvitation.WF_REVIEW_TASK);
|
||||
List<WorkflowTask> jbpmTasks = this.workflowService.queryTasks(query);
|
||||
if (jbpmTasks != null)
|
||||
if(jbpmTasks !=null)
|
||||
{
|
||||
results.addAll(jbpmTasks);
|
||||
}
|
||||
}
|
||||
if (workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||
{
|
||||
query.setTaskName(WorkflowModelModeratedInvitation.WF_ACTIVITI_REVIEW_TASK);
|
||||
List<WorkflowTask> jbpmTasks = this.workflowService.queryTasks(query);
|
||||
if (jbpmTasks != null)
|
||||
if(jbpmTasks !=null)
|
||||
{
|
||||
results.addAll(jbpmTasks);
|
||||
}
|
||||
@@ -654,7 +654,7 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
query.setTaskState(WorkflowTaskState.IN_PROGRESS);
|
||||
|
||||
String invitee = criteria.getInvitee();
|
||||
if (invitee != null)
|
||||
if(invitee != null)
|
||||
{
|
||||
query.setActorId(invitee);
|
||||
}
|
||||
@@ -682,20 +682,20 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
query.setProcessCustomProps(queryProps);
|
||||
|
||||
List<WorkflowTask> results = new ArrayList<WorkflowTask>();
|
||||
if (workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||
if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||
{
|
||||
query.setTaskName(WorkflowModelNominatedInvitation.WF_TASK_INVITE_PENDING);
|
||||
List<WorkflowTask> jbpmTasks = this.workflowService.queryTasks(query);
|
||||
if (jbpmTasks != null)
|
||||
if(jbpmTasks !=null)
|
||||
{
|
||||
results.addAll(jbpmTasks);
|
||||
}
|
||||
}
|
||||
if (workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||
{
|
||||
query.setTaskName(WorkflowModelNominatedInvitation.WF_TASK_ACTIVIT_INVITE_PENDING);
|
||||
List<WorkflowTask> jbpmTasks = this.workflowService.queryTasks(query);
|
||||
if (jbpmTasks != null)
|
||||
if(jbpmTasks !=null)
|
||||
{
|
||||
results.addAll(jbpmTasks);
|
||||
}
|
||||
@@ -1180,29 +1180,27 @@ public class InvitationServiceImpl implements InvitationService, NodeServicePoli
|
||||
|
||||
private String getNominatedDefinitionName()
|
||||
{
|
||||
if (workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||
{
|
||||
return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI;
|
||||
}
|
||||
else if (workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||
else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||
{
|
||||
return WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME;
|
||||
}
|
||||
|
||||
throw new IllegalStateException("None of the Workflow engines supported by teh InvitationService are currently enabled!");
|
||||
}
|
||||
|
||||
private String getModeratedDefinitionName()
|
||||
{
|
||||
if (workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||
if(workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
|
||||
{
|
||||
return WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI;
|
||||
}
|
||||
else if (workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||
else if(workflowAdminService.isEngineEnabled(JBPMEngine.ENGINE_ID))
|
||||
{
|
||||
return WorkflowModelModeratedInvitation.WORKFLOW_DEFINITION_NAME;
|
||||
}
|
||||
|
||||
throw new IllegalStateException("None of the Workflow engines supported by teh InvitationService are currently enabled!");
|
||||
}
|
||||
|
||||
|
@@ -82,7 +82,6 @@ import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.cmr.version.VersionHistory;
|
||||
import org.alfresco.service.cmr.version.VersionServiceException;
|
||||
import org.alfresco.service.cmr.version.VersionType;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||
@@ -118,7 +117,7 @@ import org.springframework.extensions.surf.util.URLEncoder;
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResolverProvider
|
||||
public class ScriptNode implements Scopeable, NamespacePrefixResolverProvider
|
||||
{
|
||||
private static final long serialVersionUID = -3378946227712939601L;
|
||||
|
||||
@@ -880,6 +879,15 @@ public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResol
|
||||
return getParentAssocs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the {@link ScriptNode} exists in the repository.
|
||||
* @return
|
||||
*/
|
||||
public boolean exists()
|
||||
{
|
||||
return nodeService.exists(nodeRef);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the properties known about this node. The Map returned implements the Scriptable interface to
|
||||
* allow access to the properties via JavaScript associative array access. This means properties of a node can
|
||||
|
@@ -31,10 +31,10 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.springframework.extensions.surf.util.ParameterCheck;
|
||||
|
||||
/*
|
||||
* MT Service implementation
|
||||
@@ -537,6 +537,11 @@ public class MultiTServiceImpl implements TenantService
|
||||
* @see org.alfresco.repo.tenant.TenantService#isTenantName(java.lang.String)
|
||||
*/
|
||||
public boolean isTenantName(String name)
|
||||
{
|
||||
return getMultiTenantDomainName(name) != null;
|
||||
}
|
||||
|
||||
public static String getMultiTenantDomainName(String name)
|
||||
{
|
||||
// Check that all the passed values are not null
|
||||
ParameterCheck.mandatory("name", name);
|
||||
@@ -547,11 +552,12 @@ public class MultiTServiceImpl implements TenantService
|
||||
int idx2 = name.indexOf(SEPARATOR, 1);
|
||||
if (idx2 != -1)
|
||||
{
|
||||
return true;
|
||||
return name.substring(1, idx2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@@ -333,7 +333,17 @@ public class WorkflowDeployer extends AbstractLifecycleBean
|
||||
catch(Throwable e)
|
||||
{
|
||||
// rollback the transaction
|
||||
try { if (userTransaction != null) {userTransaction.rollback();} } catch (Exception ex) { /* NOOP */ }
|
||||
try
|
||||
{
|
||||
if (userTransaction != null)
|
||||
{
|
||||
userTransaction.rollback();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
throw new AlfrescoRuntimeException("Workflow deployment failed", e);
|
||||
}
|
||||
finally
|
||||
|
@@ -21,10 +21,12 @@ package org.alfresco.repo.workflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.repo.i18n.MessageService;
|
||||
import org.alfresco.repo.jscript.ScriptNode;
|
||||
import org.alfresco.repo.tenant.MultiTServiceImpl;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||
@@ -41,6 +43,9 @@ import org.alfresco.service.cmr.workflow.WorkflowTaskState;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTimer;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTransition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.collections.CollectionUtils;
|
||||
import org.alfresco.util.collections.Filter;
|
||||
import org.alfresco.util.collections.Function;
|
||||
|
||||
/**
|
||||
* @author Nick Smith
|
||||
@@ -158,7 +163,7 @@ public class WorkflowObjectFactory
|
||||
|
||||
workflowInstance.priority = (Integer) getVariable(variables, WorkflowModel.PROP_WORKFLOW_PRIORITY);
|
||||
Date dueDate = (Date) getVariable(variables, WorkflowModel.PROP_WORKFLOW_DUE_DATE);
|
||||
if (dueDate != null)
|
||||
if(dueDate != null)
|
||||
{
|
||||
workflowInstance.dueDate = dueDate;
|
||||
}
|
||||
@@ -190,7 +195,7 @@ public class WorkflowObjectFactory
|
||||
public WorkflowTaskDefinition createTaskDefinition(String id, WorkflowNode node, String typeName, boolean isStart)
|
||||
{
|
||||
TypeDefinition metaData = getTaskTypeDefinition(typeName, isStart);
|
||||
if (id == null)
|
||||
if(id == null)
|
||||
{
|
||||
id = qNameConverter.mapQNameToName(metaData.getName());
|
||||
}
|
||||
@@ -217,13 +222,13 @@ public class WorkflowObjectFactory
|
||||
}
|
||||
|
||||
public WorkflowTimer createWorkflowTimer(String id, String name, String error,
|
||||
Date dueDate, WorkflowPath workflowPath, WorkflowTask workflowTask)
|
||||
Date dueDate, WorkflowPath workflowPath, WorkflowTask workflowTask)
|
||||
{
|
||||
String actualId = buildGlobalId(id);
|
||||
return new WorkflowTimer(actualId, name, workflowPath, workflowTask, dueDate, error);
|
||||
}
|
||||
|
||||
private String getProcessKey(String defName)
|
||||
public String getProcessKey(String defName)
|
||||
{
|
||||
String processKey = defName;
|
||||
if (isGlobalId(defName))
|
||||
@@ -260,7 +265,7 @@ public class WorkflowObjectFactory
|
||||
String key = keyBase+ "." + labelKey;
|
||||
String label = messageService.getMessage(key);
|
||||
int i = 0;
|
||||
while (label == null && i < defaults.length)
|
||||
while(label==null && i<defaults.length)
|
||||
{
|
||||
label = defaults[i];
|
||||
i++;
|
||||
@@ -271,11 +276,11 @@ public class WorkflowObjectFactory
|
||||
private NodeRef getNodeVariable(Map<String, Object> variables, QName qName)
|
||||
{
|
||||
Object obj = getVariable(variables, qName);
|
||||
if (obj == null)
|
||||
if (obj==null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (obj instanceof ScriptNode)
|
||||
if(obj instanceof ScriptNode)
|
||||
{
|
||||
ScriptNode scriptNode = (ScriptNode) obj;
|
||||
return scriptNode.getNodeRef();
|
||||
@@ -286,7 +291,7 @@ public class WorkflowObjectFactory
|
||||
|
||||
private Object getVariable(Map<String, Object> variables, QName qName)
|
||||
{
|
||||
if (variables == null || qName == null)
|
||||
if(variables == null || qName == null)
|
||||
return null;
|
||||
String varName = qNameConverter.mapQNameToName(qName);
|
||||
return variables.get(varName);
|
||||
@@ -294,7 +299,7 @@ public class WorkflowObjectFactory
|
||||
|
||||
private Object getVariable(Map<String, Object> variables, String key)
|
||||
{
|
||||
if (variables == null || key == null)
|
||||
if(variables == null || key == null)
|
||||
return null;
|
||||
return variables.get(key);
|
||||
}
|
||||
@@ -303,7 +308,7 @@ public class WorkflowObjectFactory
|
||||
* Throws exception if domain mismatch
|
||||
* @param defName
|
||||
*/
|
||||
private void checkDomain(String defName)
|
||||
public void checkDomain(String defName)
|
||||
{
|
||||
if (tenantService.isEnabled())
|
||||
{
|
||||
@@ -316,6 +321,29 @@ public class WorkflowObjectFactory
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends Object> List<T> filterByDomain(List<T> values, final Function<T, String> processKeyGetter)
|
||||
{
|
||||
final boolean enabled = tenantService.isEnabled();
|
||||
final String currentDomain = tenantService.getCurrentUserDomain();
|
||||
return CollectionUtils.filter(values, new Filter<T>()
|
||||
{
|
||||
public Boolean apply(T value)
|
||||
{
|
||||
String key = processKeyGetter.apply(value);
|
||||
String domain = MultiTServiceImpl.getMultiTenantDomainName(key);
|
||||
if(enabled && false == currentDomain.equals(domain))
|
||||
{
|
||||
return false; // The domains do not match so ignore.
|
||||
}
|
||||
else if(domain!=null)
|
||||
{
|
||||
return false; // Ignore domain-specific definitions
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an anonymous {@link TypeDefinition} for the given name with all
|
||||
* the mandatory aspects applied.
|
||||
@@ -342,7 +370,7 @@ public class WorkflowObjectFactory
|
||||
public TypeDefinition getTaskTypeDefinition(String name, boolean isStart)
|
||||
{
|
||||
TypeDefinition typeDef = null;
|
||||
if (name!=null)
|
||||
if(name!=null)
|
||||
{
|
||||
QName typeName = qNameConverter.mapNameToQName(name);
|
||||
typeDef = dictionaryService.getType(typeName);
|
||||
@@ -360,7 +388,7 @@ public class WorkflowObjectFactory
|
||||
return typeDef;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Map QName to jBPM variable name
|
||||
*
|
||||
* @param name QName
|
||||
|
@@ -56,6 +56,7 @@ import org.alfresco.service.cmr.workflow.WorkflowTaskDefinition;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTaskState;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowTransition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.collections.Function;
|
||||
|
||||
/**
|
||||
* @author Nick Smith
|
||||
@@ -92,6 +93,12 @@ public class ActivitiTypeConverter
|
||||
this.activitiUtil = new ActivitiUtil(processEngine);
|
||||
}
|
||||
|
||||
public <F, T> List<T> filterByDomainAndConvert(List<F> values, Function<F, String> processKeyGetter)
|
||||
{
|
||||
List<F> filtered = factory.filterByDomain(values, processKeyGetter);
|
||||
return convert(filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a {@link Deployment} into a {@link WorkflowDeployment}.
|
||||
* @param deployment
|
||||
@@ -99,7 +106,7 @@ public class ActivitiTypeConverter
|
||||
*/
|
||||
public WorkflowDeployment convert(Deployment deployment)
|
||||
{
|
||||
if (deployment == null)
|
||||
if(deployment == null)
|
||||
return null;
|
||||
|
||||
List<ProcessDefinition> processDefs = repoService.createProcessDefinitionQuery()
|
||||
@@ -117,7 +124,7 @@ public class ActivitiTypeConverter
|
||||
*/
|
||||
public WorkflowDefinition convert(ProcessDefinition definition)
|
||||
{
|
||||
if (definition==null)
|
||||
if(definition==null)
|
||||
return null;
|
||||
|
||||
String defId = definition.getId();
|
||||
@@ -127,7 +134,7 @@ public class ActivitiTypeConverter
|
||||
|
||||
String startTaskName = null;
|
||||
StartFormData startFormData = formService.getStartFormData(definition.getId());
|
||||
if (startFormData != null)
|
||||
if(startFormData != null)
|
||||
{
|
||||
startTaskName = startFormData.getFormKey();
|
||||
}
|
||||
@@ -147,7 +154,7 @@ public class ActivitiTypeConverter
|
||||
String startTitle = (String) activity.getProperty(ActivitiConstants.NODE_NAME);
|
||||
String startDescription= (String) activity.getProperty(ActivitiConstants.NODE_DESCRIPTION);
|
||||
String startType = (String) activity.getProperty(ActivitiConstants.NODE_TYPE);
|
||||
if (taskFormKey == null)
|
||||
if(taskFormKey == null)
|
||||
{
|
||||
taskFormKey = startId;
|
||||
}
|
||||
@@ -163,20 +170,20 @@ public class ActivitiTypeConverter
|
||||
|
||||
public WorkflowInstance convertAndSetVariables(ProcessInstance instance, Map<String, Object> collectedvariables)
|
||||
{
|
||||
if (instance == null)
|
||||
if(instance == null)
|
||||
return null;
|
||||
|
||||
HistoricProcessInstance historicInstance = historyService
|
||||
.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(instance.getId())
|
||||
.singleResult();
|
||||
.createHistoricProcessInstanceQuery()
|
||||
.processInstanceId(instance.getId())
|
||||
.singleResult();
|
||||
|
||||
return convertToInstanceAndSetVariables(historicInstance, collectedvariables);
|
||||
}
|
||||
|
||||
public WorkflowInstance convert(HistoricProcessInstance instance, Map<String, Object> collectedvariables)
|
||||
{
|
||||
if (instance == null)
|
||||
if(instance == null)
|
||||
return null;
|
||||
|
||||
HistoricProcessInstance historicInstance = historyService
|
||||
@@ -196,7 +203,7 @@ public class ActivitiTypeConverter
|
||||
|
||||
public WorkflowPath convert(Execution execution, ProcessInstance instance)
|
||||
{
|
||||
if (execution == null)
|
||||
if(execution == null)
|
||||
return null;
|
||||
|
||||
boolean isActive = !execution.isEnded();
|
||||
@@ -221,22 +228,22 @@ public class ActivitiTypeConverter
|
||||
|
||||
public WorkflowNode convert(PvmActivity activity, boolean forceIsTaskNode)
|
||||
{
|
||||
String procDefId = activity.getProcessDefinition().getId();
|
||||
String key = activitiUtil.getProcessDefinition(procDefId).getKey();
|
||||
String name = activity.getId();
|
||||
String defaultTitle = (String) activity.getProperty(ActivitiConstants.NODE_NAME);
|
||||
String defaultDescription = (String) activity.getProperty(ActivitiConstants.NODE_DESCRIPTION);
|
||||
String type = (String) activity.getProperty(ActivitiConstants.NODE_TYPE);
|
||||
boolean isTaskNode = forceIsTaskNode || ActivitiConstants.USER_TASK_NODE_TYPE.equals(type);
|
||||
String procDefId = activity.getProcessDefinition().getId();
|
||||
String key = activitiUtil.getProcessDefinition(procDefId).getKey();
|
||||
String name = activity.getId();
|
||||
String defaultTitle = (String) activity.getProperty(ActivitiConstants.NODE_NAME);
|
||||
String defaultDescription = (String) activity.getProperty(ActivitiConstants.NODE_DESCRIPTION);
|
||||
String type = (String) activity.getProperty(ActivitiConstants.NODE_TYPE);
|
||||
boolean isTaskNode = forceIsTaskNode || ActivitiConstants.USER_TASK_NODE_TYPE.equals(type);
|
||||
|
||||
if (defaultTitle == null)
|
||||
{
|
||||
defaultTitle = name;
|
||||
}
|
||||
if (defaultDescription == null)
|
||||
{
|
||||
defaultDescription = name;
|
||||
}
|
||||
if(defaultTitle == null)
|
||||
{
|
||||
defaultTitle = name;
|
||||
}
|
||||
if(defaultDescription == null)
|
||||
{
|
||||
defaultDescription = name;
|
||||
}
|
||||
|
||||
return factory.createNode(name, key, defaultTitle, defaultDescription, type, isTaskNode, NEXT_TRANSITION);
|
||||
}
|
||||
@@ -263,7 +270,7 @@ public class ActivitiTypeConverter
|
||||
for (Object in : inputs)
|
||||
{
|
||||
T out = (T) convert(in);
|
||||
if (out != null)
|
||||
if(out != null)
|
||||
{
|
||||
results.add(out);
|
||||
}
|
||||
@@ -279,7 +286,7 @@ public class ActivitiTypeConverter
|
||||
*/
|
||||
private Object convert(Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
if(obj == null)
|
||||
return null;
|
||||
|
||||
if (obj instanceof Deployment)
|
||||
@@ -306,11 +313,11 @@ public class ActivitiTypeConverter
|
||||
{
|
||||
return convert( (Task) obj);
|
||||
}
|
||||
if (obj instanceof HistoricTaskInstance)
|
||||
if(obj instanceof HistoricTaskInstance)
|
||||
{
|
||||
return convert((HistoricTaskInstance) obj);
|
||||
}
|
||||
if (obj instanceof HistoricProcessInstance)
|
||||
if(obj instanceof HistoricProcessInstance)
|
||||
{
|
||||
return convert((HistoricProcessInstance) obj);
|
||||
}
|
||||
@@ -320,9 +327,8 @@ public class ActivitiTypeConverter
|
||||
|
||||
public WorkflowTask convert(Task task)
|
||||
{
|
||||
if (task == null)
|
||||
if(task == null)
|
||||
return null;
|
||||
|
||||
String id = task.getId();
|
||||
String defaultTitle = task.getName();
|
||||
String defaultDescription = task.getDescription();
|
||||
@@ -338,14 +344,14 @@ public class ActivitiTypeConverter
|
||||
|
||||
TaskFormData taskFormData =formService.getTaskFormData(task.getId());
|
||||
String taskDefId = null;
|
||||
if (taskFormData != null)
|
||||
if(taskFormData != null)
|
||||
{
|
||||
taskDefId = taskFormData.getFormKey();
|
||||
}
|
||||
WorkflowTaskDefinition taskDef = factory.createTaskDefinition(taskDefId, node, taskDefId, false);
|
||||
|
||||
// All task-properties should be fetched, not only local
|
||||
Map<QName, Serializable> properties = propertyConverter.getTaskProperties(task, false);
|
||||
Map<QName, Serializable> properties = propertyConverter.getTaskProperties(task);
|
||||
|
||||
return factory.createTask(id,
|
||||
taskDef, taskDef.getId(), defaultTitle, defaultDescription, state, path, properties);
|
||||
@@ -361,7 +367,7 @@ public class ActivitiTypeConverter
|
||||
String id = ActivitiConstants.START_TASK_PREFIX + execution.getProcessInstanceId();
|
||||
|
||||
WorkflowTaskState state = null;
|
||||
if (inProgress)
|
||||
if(inProgress)
|
||||
{
|
||||
state = WorkflowTaskState.IN_PROGRESS;
|
||||
}
|
||||
@@ -378,7 +384,7 @@ public class ActivitiTypeConverter
|
||||
|
||||
StartFormData startFormData = formService.getStartFormData(processInstance.getProcessDefinitionId());
|
||||
String taskDefId = null;
|
||||
if (startFormData != null)
|
||||
if(startFormData != null)
|
||||
{
|
||||
taskDefId = startFormData.getFormKey();
|
||||
}
|
||||
@@ -402,7 +408,7 @@ public class ActivitiTypeConverter
|
||||
|
||||
public WorkflowTask getVirtualStartTask(HistoricProcessInstance historicProcessInstance)
|
||||
{
|
||||
if (historicProcessInstance == null)
|
||||
if(historicProcessInstance == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -413,7 +419,7 @@ public class ActivitiTypeConverter
|
||||
WorkflowTaskState state = null;
|
||||
|
||||
boolean completed = historicProcessInstance.getEndTime() != null;
|
||||
if (completed)
|
||||
if(completed)
|
||||
{
|
||||
state = WorkflowTaskState.COMPLETED;
|
||||
}
|
||||
@@ -424,7 +430,7 @@ public class ActivitiTypeConverter
|
||||
|
||||
// We use the process-instance ID as execution-id. It's ended anyway
|
||||
WorkflowPath path = buildCompletedPath(processInstanceId, processInstanceId);
|
||||
if (path == null)
|
||||
if(path == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -448,7 +454,7 @@ public class ActivitiTypeConverter
|
||||
|
||||
public WorkflowTask convert(HistoricTaskInstance historicTaskInstance)
|
||||
{
|
||||
if (historicTaskInstance == null)
|
||||
if(historicTaskInstance == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -456,7 +462,7 @@ public class ActivitiTypeConverter
|
||||
// Check to see if the instance is still running
|
||||
Execution execution = activitiUtil.getExecution(historicTaskInstance.getExecutionId());
|
||||
|
||||
if (execution != null)
|
||||
if(execution != null)
|
||||
{
|
||||
// Process execution still running
|
||||
path = convert(execution);
|
||||
@@ -467,7 +473,7 @@ public class ActivitiTypeConverter
|
||||
path = buildCompletedPath(historicTaskInstance.getExecutionId(), historicTaskInstance.getProcessInstanceId());
|
||||
}
|
||||
|
||||
if (path == null)
|
||||
if(path == null)
|
||||
{
|
||||
// When path is null, workflow is deleted or cancelled. Task should
|
||||
// not be used
|
||||
@@ -497,16 +503,16 @@ public class ActivitiTypeConverter
|
||||
|
||||
private WorkflowNode buildHistoricTaskWorkflowNode(HistoricTaskInstance historicTaskInstance)
|
||||
{
|
||||
ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(historicTaskInstance.getProcessDefinitionId());
|
||||
PvmActivity taskActivity = procDef.findActivity(historicTaskInstance.getTaskDefinitionKey());
|
||||
return convert(taskActivity);
|
||||
}
|
||||
ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(historicTaskInstance.getProcessDefinitionId());
|
||||
PvmActivity taskActivity = procDef.findActivity(historicTaskInstance.getTaskDefinitionKey());
|
||||
return convert(taskActivity);
|
||||
}
|
||||
|
||||
public WorkflowPath buildCompletedPath(String executionId, String processInstanceId)
|
||||
public WorkflowPath buildCompletedPath(String executionId, String processInstanceId)
|
||||
{
|
||||
WorkflowInstance wfInstance = null;
|
||||
ProcessInstance processInstance = activitiUtil.getProcessInstance(processInstanceId);
|
||||
if (processInstance != null)
|
||||
if(processInstance != null)
|
||||
{
|
||||
wfInstance = convert(processInstance);
|
||||
}
|
||||
@@ -516,10 +522,10 @@ public class ActivitiTypeConverter
|
||||
if(historicProcessInstance!= null)
|
||||
wfInstance = convert(historicProcessInstance);
|
||||
}
|
||||
if (wfInstance == null)
|
||||
if(wfInstance == null)
|
||||
{
|
||||
// When workflow is cancelled or deleted, WorkflowPath should not be returned
|
||||
return null;
|
||||
// When workflow is cancelled or deleted, WorkflowPath should not be returned
|
||||
return null;
|
||||
}
|
||||
WorkflowNode node = null;
|
||||
return factory.createPath(executionId, wfInstance, node, false);
|
||||
@@ -539,9 +545,9 @@ public class ActivitiTypeConverter
|
||||
Date endDate = historicProcessInstance.getEndTime();
|
||||
|
||||
// Copy all variables to map, if not null
|
||||
if (collectedVariables != null)
|
||||
if(collectedVariables != null)
|
||||
{
|
||||
collectedVariables.putAll(variables);
|
||||
collectedVariables.putAll(variables);
|
||||
}
|
||||
|
||||
boolean isActive = historicProcessInstance.getEndTime() == null;
|
||||
@@ -551,6 +557,7 @@ public class ActivitiTypeConverter
|
||||
|
||||
public WorkflowInstance convert(HistoricProcessInstance historicProcessInstance)
|
||||
{
|
||||
return convertToInstanceAndSetVariables(historicProcessInstance, null);
|
||||
return convertToInstanceAndSetVariables(historicProcessInstance, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -29,129 +29,132 @@ import org.activiti.engine.impl.pvm.process.ScopeImpl;
|
||||
import org.activiti.engine.impl.pvm.process.TransitionImpl;
|
||||
import org.activiti.engine.impl.util.xml.Element;
|
||||
import org.activiti.engine.impl.variable.VariableDeclaration;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
|
||||
/**
|
||||
* A {@link BpmnParseListener} that adds a start- and endTaskListener to
|
||||
* all parsed userTasks.
|
||||
* A {@link BpmnParseListener} that adds a start- and endTaskListener to all
|
||||
* parsed userTasks.
|
||||
*
|
||||
* This is used to wire in custom logic when task is created and completed.
|
||||
*
|
||||
* @author Frederik Heremans
|
||||
* @author Nick Smith
|
||||
* @since 3.4.e
|
||||
*/
|
||||
public class AddTaskListenerParseListener implements BpmnParseListener
|
||||
public class AlfrescoBpmnParseListener implements BpmnParseListener
|
||||
{
|
||||
private TaskListener completeTaskListener;
|
||||
private TaskListener createTaskListener;
|
||||
private TaskListener completeTaskListener;
|
||||
private TaskListener createTaskListener;
|
||||
private ExecutionListener processCreateListener;
|
||||
private TenantService tenantService;
|
||||
|
||||
@Override
|
||||
public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
ActivityBehavior activitybehaviour = activity.getActivityBehavior();
|
||||
if (activitybehaviour instanceof UserTaskActivityBehavior)
|
||||
{
|
||||
UserTaskActivityBehavior userTaskActivity = (UserTaskActivityBehavior) activitybehaviour;
|
||||
if (createTaskListener != null)
|
||||
{
|
||||
userTaskActivity.getTaskDefinition().addTaskListener(TaskListener.EVENTNAME_CREATE, createTaskListener);
|
||||
}
|
||||
if (completeTaskListener != null)
|
||||
{
|
||||
userTaskActivity.getTaskDefinition().addTaskListener(TaskListener.EVENTNAME_COMPLETE, completeTaskListener);
|
||||
}
|
||||
}
|
||||
ActivityBehavior activitybehaviour = activity.getActivityBehavior();
|
||||
if (activitybehaviour instanceof UserTaskActivityBehavior)
|
||||
{
|
||||
UserTaskActivityBehavior userTaskActivity = (UserTaskActivityBehavior) activitybehaviour;
|
||||
if (createTaskListener != null)
|
||||
{
|
||||
userTaskActivity.getTaskDefinition().addTaskListener(TaskListener.EVENTNAME_CREATE, createTaskListener);
|
||||
}
|
||||
if (completeTaskListener != null)
|
||||
{
|
||||
userTaskActivity.getTaskDefinition().addTaskListener(TaskListener.EVENTNAME_COMPLETE,
|
||||
completeTaskListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseProcess(Element processElement, ProcessDefinitionEntity processDefinition)
|
||||
{
|
||||
processDefinition.addExecutionListener(ExecutionListener.EVENTNAME_START, processCreateListener);
|
||||
if (tenantService.isEnabled())
|
||||
{
|
||||
String key = tenantService.getName(processDefinition.getKey());
|
||||
processDefinition.setKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseStartEvent(Element startEventElement, ScopeImpl scope,
|
||||
ActivityImpl startEventActivity)
|
||||
public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope,
|
||||
ActivityImpl activity)
|
||||
public void parseExclusiveGateway(Element exclusiveGwElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseParallelGateway(Element parallelGwElement, ScopeImpl scope,
|
||||
ActivityImpl activity)
|
||||
public void parseParallelGateway(Element parallelGwElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseScriptTask(Element scriptTaskElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseServiceTask(Element serviceTaskElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseTask(Element taskElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseManualTask(Element manualTaskElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseEndEvent(Element endEventElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseBoundaryTimerEventDefinition(Element timerEventDefinition,
|
||||
boolean interrupting, ActivityImpl timerActivity)
|
||||
public void parseBoundaryTimerEventDefinition(Element timerEventDefinition, boolean interrupting,
|
||||
ActivityImpl timerActivity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseSubProcess(Element subProcessElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseCallActivity(Element callActivityElement, ScopeImpl scope,
|
||||
ActivityImpl activity)
|
||||
public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration,
|
||||
ActivityImpl activity)
|
||||
public void parseProperty(Element propertyElement, VariableDeclaration variableDeclaration, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement,
|
||||
TransitionImpl transition)
|
||||
public void parseSequenceFlow(Element sequenceFlowElement, ScopeImpl scopeElement, TransitionImpl transition)
|
||||
{
|
||||
// Nothing to do here
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,31 +164,27 @@ public class AddTaskListenerParseListener implements BpmnParseListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope,
|
||||
ActivityImpl activity)
|
||||
public void parseBusinessRuleTask(Element businessRuleTaskElement, ScopeImpl scope, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseBoundaryErrorEventDefinition(Element errorEventDefinition,
|
||||
boolean interrupting, ActivityImpl activity,
|
||||
ActivityImpl nestedErrorEventActivity)
|
||||
public void parseBoundaryErrorEventDefinition(Element errorEventDefinition, boolean interrupting,
|
||||
ActivityImpl activity, ActivityImpl nestedErrorEventActivity)
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseIntermediateTimerEventDefinition(
|
||||
Element timerEventDefinition, ActivityImpl timerActivity)
|
||||
public void parseIntermediateTimerEventDefinition(Element timerEventDefinition, ActivityImpl timerActivity)
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseMultiInstanceLoopCharacteristics(Element activityElement,
|
||||
Element multiInstanceLoopCharacteristicsElement,
|
||||
ActivityImpl activity)
|
||||
Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
@@ -204,4 +203,13 @@ public class AddTaskListenerParseListener implements BpmnParseListener
|
||||
{
|
||||
this.processCreateListener = processCreateListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenantService
|
||||
* the tenantService to set
|
||||
*/
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
}
|
@@ -34,10 +34,11 @@ import org.alfresco.repo.workflow.activiti.ActivitiConstants;
|
||||
*/
|
||||
public class ProcessStartExecutionListener implements ExecutionListener
|
||||
{
|
||||
|
||||
public void notify(DelegateExecution execution) throws Exception
|
||||
{
|
||||
// Add the workflow ID
|
||||
execution.setVariable(WorkflowConstants.PROP_WORKFLOW_INSTANCE_ID, BPMEngineRegistry
|
||||
.createGlobalId(ActivitiConstants.ENGINE_ID, execution.getId()));
|
||||
String instanceId = BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, execution.getId());
|
||||
execution.setVariable(WorkflowConstants.PROP_WORKFLOW_INSTANCE_ID, instanceId);
|
||||
}
|
||||
}
|
||||
|
@@ -103,7 +103,7 @@ public class ActivitiPropertyConverter
|
||||
this.typeManager = new ActivitiTaskTypeManager(factory, activitiUtil.getFormService());
|
||||
}
|
||||
|
||||
public Map<QName, Serializable> getTaskProperties(Task task, boolean localOnly)
|
||||
public Map<QName, Serializable> getTaskProperties(Task task)
|
||||
{
|
||||
// retrieve type definition for task
|
||||
TypeDefinition taskDef = typeManager.getFullTaskDefinition(task);
|
||||
@@ -112,42 +112,21 @@ public class ActivitiPropertyConverter
|
||||
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
|
||||
TaskService taskService = activitiUtil.getTaskService();
|
||||
// Get the local task variables
|
||||
Map<String, Object> localVariables = taskService.getVariablesLocal(task.getId());
|
||||
Map<String, Object> variables = null;
|
||||
|
||||
if (!localOnly)
|
||||
{
|
||||
variables = new HashMap<String, Object>();
|
||||
variables.putAll(localVariables);
|
||||
|
||||
// Execution-variables should also be added, if no value is present locally
|
||||
Map<String, Object> executionVariables = activitiUtil.getExecutionVariables(task.getExecutionId());
|
||||
|
||||
for (Entry<String, Object> entry : executionVariables.entrySet())
|
||||
{
|
||||
if (!localVariables.containsKey(entry.getKey()))
|
||||
{
|
||||
variables.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Only local variables should be used.
|
||||
variables = localVariables;
|
||||
}
|
||||
// Get all task variables including execution vars.
|
||||
Map<String, Object> variables = taskService.getVariables(task.getId());
|
||||
|
||||
// Map the arbitrary properties
|
||||
Map<String, Object> localVariables = taskService.getVariablesLocal(task.getId());
|
||||
mapArbitraryProperties(variables, properties, localVariables, taskProperties, taskAssociations);
|
||||
|
||||
// Map activiti task instance fields to properties
|
||||
properties.put(WorkflowModel.PROP_TASK_ID, task.getId());
|
||||
properties.put(WorkflowModel.PROP_DESCRIPTION, task.getDescription());
|
||||
|
||||
// Since the task is never started explicitally, we use the create time
|
||||
properties.put(WorkflowModel.PROP_START_DATE, task.getCreateTime());
|
||||
|
||||
// Due date is present on the process instance
|
||||
// Due date is present on the task
|
||||
properties.put(WorkflowModel.PROP_DUE_DATE, task.getDueDate());
|
||||
|
||||
// Since this is a runtime-task, it's not completed yet
|
||||
@@ -158,7 +137,7 @@ public class ActivitiPropertyConverter
|
||||
|
||||
// Be sure to fetch the outcome
|
||||
String outcomeVarName = factory.mapQNameToName(WorkflowModel.PROP_OUTCOME);
|
||||
if (variables.get(outcomeVarName) != null)
|
||||
if(variables.get(outcomeVarName) != null)
|
||||
{
|
||||
properties.put(WorkflowModel.PROP_OUTCOME, (Serializable) variables.get(outcomeVarName));
|
||||
}
|
||||
@@ -185,14 +164,14 @@ public class ActivitiPropertyConverter
|
||||
public List<NodeRef> getPooledActorsReference(Collection<IdentityLink> links)
|
||||
{
|
||||
List<NodeRef> pooledActorRefs = new ArrayList<NodeRef>();
|
||||
if (links != null)
|
||||
if(links != null)
|
||||
{
|
||||
for (IdentityLink link : links)
|
||||
for(IdentityLink link : links)
|
||||
{
|
||||
if (IdentityLinkType.CANDIDATE.equals(link.getType()))
|
||||
if(IdentityLinkType.CANDIDATE.equals(link.getType()))
|
||||
{
|
||||
String id = link.getGroupId();
|
||||
if (id == null)
|
||||
if(id == null)
|
||||
{
|
||||
id = link.getUserId();
|
||||
}
|
||||
@@ -227,7 +206,7 @@ public class ActivitiPropertyConverter
|
||||
Map<String, Object> localVariables = task.getVariablesLocal();
|
||||
Map<String, Object> variables = null;
|
||||
|
||||
if (localOnly == false)
|
||||
if(localOnly==false)
|
||||
{
|
||||
variables = new HashMap<String, Object>();
|
||||
variables.putAll(localVariables);
|
||||
@@ -235,7 +214,7 @@ public class ActivitiPropertyConverter
|
||||
// Execution-variables should also be added, if no value is present locally
|
||||
Map<String, Object> executionVariables = task.getExecution().getVariables();
|
||||
|
||||
for (Entry<String, Object> entry : executionVariables.entrySet())
|
||||
for(Entry<String, Object> entry : executionVariables.entrySet())
|
||||
{
|
||||
String key = entry.getKey();
|
||||
if(localVariables.containsKey(key)==false)
|
||||
@@ -307,7 +286,7 @@ public class ActivitiPropertyConverter
|
||||
|
||||
// Be sure to fetch the outcome
|
||||
String outcomeVarName = factory.mapQNameToName(WorkflowModel.PROP_OUTCOME);
|
||||
if (variables.get(outcomeVarName) != null)
|
||||
if(variables.get(outcomeVarName) != null)
|
||||
{
|
||||
properties.put(WorkflowModel.PROP_OUTCOME, (Serializable) variables.get(outcomeVarName));
|
||||
}
|
||||
@@ -315,16 +294,15 @@ public class ActivitiPropertyConverter
|
||||
// History of pooled actors is stored in task variable
|
||||
List<NodeRef> pooledActors = new ArrayList<NodeRef>();
|
||||
List<String> pooledActorRefIds = (List<String>) variables.get(ActivitiConstants.PROP_POOLED_ACTORS_HISTORY);
|
||||
if (pooledActorRefIds != null)
|
||||
if(pooledActorRefIds != null)
|
||||
{
|
||||
for (String nodeId : pooledActorRefIds)
|
||||
for(String nodeId : pooledActorRefIds)
|
||||
{
|
||||
pooledActors.add(new NodeRef(nodeId));
|
||||
}
|
||||
}
|
||||
|
||||
// Add pooled actors. When no actors are found, set empty list
|
||||
properties.put(WorkflowModel.ASSOC_POOLED_ACTORS, (Serializable) pooledActors);
|
||||
properties.put(WorkflowModel.ASSOC_POOLED_ACTORS, (Serializable) pooledActors);
|
||||
|
||||
return filterTaskProperties(properties);
|
||||
}
|
||||
@@ -448,7 +426,7 @@ public class ActivitiPropertyConverter
|
||||
String wfDueDateKey = factory.mapQNameToName(WorkflowModel.PROP_WORKFLOW_DUE_DATE);
|
||||
String dueDateKey = factory.mapQNameToName(WorkflowModel.PROP_DUE_DATE);
|
||||
Serializable dueDate = (Serializable) variables.get(wfDueDateKey);
|
||||
if (dueDate == null)
|
||||
if(dueDate == null)
|
||||
{
|
||||
dueDate = (Serializable) variables.get(dueDateKey);
|
||||
}
|
||||
@@ -460,7 +438,7 @@ public class ActivitiPropertyConverter
|
||||
// Use workflow priority at the time of starting the process
|
||||
String priorityKey = factory.mapQNameToName(WorkflowModel.PROP_PRIORITY);
|
||||
Serializable priority = (Serializable) variables.get(priorityKey);
|
||||
if (priority == null)
|
||||
if(priority == null)
|
||||
{
|
||||
String wfPriorityKey = factory.mapQNameToName(WorkflowModel.PROP_WORKFLOW_PRIORITY);
|
||||
priority = (Serializable) variables.get(wfPriorityKey);
|
||||
@@ -471,12 +449,12 @@ public class ActivitiPropertyConverter
|
||||
|
||||
// Use initiator username as owner
|
||||
ActivitiScriptNode ownerNode = (ActivitiScriptNode) variables.get(WorkflowConstants.PROP_INITIATOR);
|
||||
if (ownerNode != null)
|
||||
if(ownerNode != null && ownerNode.exists())
|
||||
{
|
||||
properties.put(ContentModel.PROP_OWNER, (Serializable) ownerNode.getProperties().get("userName"));
|
||||
}
|
||||
|
||||
if (completed)
|
||||
if(completed)
|
||||
{
|
||||
// Override default 'Not Yet Started' when start-task is completed
|
||||
properties.put(WorkflowModel.PROP_STATUS, WorkflowConstants.TASK_STATUS_COMPLETED);
|
||||
@@ -557,8 +535,11 @@ public class ActivitiPropertyConverter
|
||||
return convertHistoricDetails(historicDetails);
|
||||
}
|
||||
|
||||
private void mapArbitraryProperties(Map<String, Object> variables, Map<QName, Serializable> properties,
|
||||
Map<String, Object> localVariables, Map<QName, PropertyDefinition> taskProperties, Map<QName, AssociationDefinition> taskAssociations)
|
||||
private void mapArbitraryProperties(Map<String, Object> variables,
|
||||
Map<QName, Serializable> properties,
|
||||
Map<String, Object> localVariables,
|
||||
Map<QName, PropertyDefinition> taskProperties,
|
||||
Map<QName, AssociationDefinition> taskAssociations)
|
||||
{
|
||||
// Map arbitrary task variables
|
||||
for (Entry<String, Object> entry : variables.entrySet())
|
||||
@@ -568,7 +549,9 @@ public class ActivitiPropertyConverter
|
||||
|
||||
// Add variable, only if part of task definition or locally defined
|
||||
// on task
|
||||
if (taskProperties.containsKey(qname) || taskAssociations.containsKey(qname) || localVariables.containsKey(key))
|
||||
if (taskProperties.containsKey(qname)
|
||||
|| taskAssociations.containsKey(qname)
|
||||
|| localVariables.containsKey(key))
|
||||
{
|
||||
Serializable value = convertPropertyValue(entry.getValue());
|
||||
properties.put(qname, value);
|
||||
@@ -589,7 +572,7 @@ public class ActivitiPropertyConverter
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (nodeConverter.isSupported(value))
|
||||
if(nodeConverter.isSupported(value))
|
||||
{
|
||||
return nodeConverter.convert(value);
|
||||
}
|
||||
@@ -611,7 +594,7 @@ public class ActivitiPropertyConverter
|
||||
{
|
||||
TypeDefinition taskDef = typeManager.getFullTaskDefinition(task);
|
||||
PropertyDefinition propDef = taskDef.getProperties().get(propertyName);
|
||||
if (propDef != null)
|
||||
if(propDef != null)
|
||||
{
|
||||
return (Serializable) DefaultTypeConverter.INSTANCE.convert(propDef.getDataType(), value);
|
||||
}
|
||||
@@ -622,7 +605,7 @@ public class ActivitiPropertyConverter
|
||||
private Map<QName, Serializable> getNewTaskProperties(Task task, Map<QName, Serializable> properties, Map<QName, List<NodeRef>> add,
|
||||
Map<QName, List<NodeRef>> remove)
|
||||
{
|
||||
// create properties to set on task instance
|
||||
// create properties to set on task instance
|
||||
Map<QName, Serializable> newProperties = properties;
|
||||
|
||||
if (add != null || remove != null)
|
||||
@@ -632,7 +615,7 @@ public class ActivitiPropertyConverter
|
||||
newProperties = new HashMap<QName, Serializable>(10);
|
||||
}
|
||||
|
||||
Map<QName, Serializable> existingProperties = getTaskProperties(task, false);
|
||||
Map<QName, Serializable> existingProperties = getTaskProperties(task);
|
||||
|
||||
if (add != null)
|
||||
{
|
||||
@@ -694,12 +677,11 @@ public class ActivitiPropertyConverter
|
||||
|
||||
public void setTaskProperties(DelegateTask task, Map<QName, Serializable> properties)
|
||||
{
|
||||
if (properties==null || properties.isEmpty())
|
||||
if(properties==null || properties.isEmpty())
|
||||
return;
|
||||
|
||||
TypeDefinition type = typeManager.getFullTaskDefinition(task);
|
||||
Map<String, Object> variablesToSet = handlerRegistry.handleVariablesToSet(properties, type, task, DelegateTask.class);
|
||||
if (variablesToSet.size() > 0)
|
||||
if(variablesToSet.size() > 0)
|
||||
{
|
||||
task.setVariablesLocal(variablesToSet);
|
||||
}
|
||||
@@ -711,7 +693,7 @@ public class ActivitiPropertyConverter
|
||||
*/
|
||||
public void setTaskProperties(Task task, Map<QName, Serializable> properties)
|
||||
{
|
||||
if (properties == null || properties.isEmpty())
|
||||
if(properties==null || properties.isEmpty())
|
||||
return;
|
||||
|
||||
TypeDefinition type = typeManager.getFullTaskDefinition(task);
|
||||
@@ -745,7 +727,7 @@ public class ActivitiPropertyConverter
|
||||
String currentAssignee = task.getAssignee();
|
||||
// Only set the assignee if the value has changes to prevent
|
||||
// triggering assignementhandlers when not needed
|
||||
if (ObjectUtils.equals(currentAssignee, assignee) == false)
|
||||
if (ObjectUtils.equals(currentAssignee, assignee)==false)
|
||||
{
|
||||
activitiUtil.getTaskService().setAssignee(task.getId(), assignee);
|
||||
}
|
||||
@@ -767,7 +749,7 @@ public class ActivitiPropertyConverter
|
||||
private Map<QName, Serializable> filterTaskProperties(
|
||||
Map<QName, Serializable> properties)
|
||||
{
|
||||
if (properties != null)
|
||||
if(properties != null)
|
||||
{
|
||||
properties.remove(QName.createQName(null, ActivitiConstants.PROP_POOLED_ACTORS_HISTORY));
|
||||
properties.remove(QName.createQName(null, ActivitiConstants.PROP_TASK_FORM_KEY));
|
||||
@@ -793,11 +775,11 @@ public class ActivitiPropertyConverter
|
||||
}
|
||||
});
|
||||
Map<String, Object> variables = new HashMap<String, Object>();
|
||||
for (HistoricDetail detail : details)
|
||||
for(HistoricDetail detail : details)
|
||||
{
|
||||
HistoricVariableUpdate varUpdate = (HistoricVariableUpdate) detail;
|
||||
// First value for a single key is used
|
||||
if (!variables.containsKey(varUpdate.getVariableName()))
|
||||
if(!variables.containsKey(varUpdate.getVariableName()))
|
||||
{
|
||||
variables.put(varUpdate.getVariableName(), varUpdate.getValue());
|
||||
}
|
||||
@@ -835,7 +817,7 @@ public class ActivitiPropertyConverter
|
||||
// Special case for task description default value
|
||||
// Use the shared description set in the workflowinstance
|
||||
String description = (String) defaultProperties.get(WorkflowModel.PROP_DESCRIPTION);
|
||||
if (description == null)
|
||||
if(description == null)
|
||||
{
|
||||
String wfDescription = (String) defaultProperties.get(WorkflowModel.PROP_WORKFLOW_DESCRIPTION);
|
||||
String procDefKey = procDef.getKey();
|
||||
@@ -912,7 +894,7 @@ public class ActivitiPropertyConverter
|
||||
|
||||
private boolean isMandatory(ClassAttributeDefinition definition)
|
||||
{
|
||||
if (definition instanceof PropertyDefinition)
|
||||
if(definition instanceof PropertyDefinition)
|
||||
{
|
||||
PropertyDefinition propDef = (PropertyDefinition) definition;
|
||||
return propDef.isMandatory();
|
||||
@@ -927,7 +909,7 @@ public class ActivitiPropertyConverter
|
||||
*/
|
||||
private boolean isEmptyString(Object value)
|
||||
{
|
||||
if (value instanceof String)
|
||||
if(value instanceof String)
|
||||
{
|
||||
String str = (String)value;
|
||||
return str.isEmpty();
|
||||
|
Reference in New Issue
Block a user