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:
@@ -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
|
||||
@@ -91,6 +92,12 @@ public class ActivitiTypeConverter
|
||||
this.propertyConverter =propertyConverter;
|
||||
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}.
|
||||
@@ -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);
|
||||
|
||||
if (defaultTitle == null)
|
||||
{
|
||||
defaultTitle = name;
|
||||
}
|
||||
if (defaultDescription == null)
|
||||
{
|
||||
defaultDescription = name;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
@@ -159,37 +162,33 @@ public class AddTaskListenerParseListener implements BpmnParseListener
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
|
||||
@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)
|
||||
public void parseMultiInstanceLoopCharacteristics(Element activityElement,
|
||||
Element multiInstanceLoopCharacteristicsElement, ActivityImpl activity)
|
||||
{
|
||||
// Nothing to do here
|
||||
}
|
||||
|
||||
|
||||
public void setCompleteTaskListener(TaskListener completeTaskListener)
|
||||
{
|
||||
this.completeTaskListener = completeTaskListener;
|
||||
@@ -199,9 +198,18 @@ public class AddTaskListenerParseListener implements BpmnParseListener
|
||||
{
|
||||
this.createTaskListener = createTaskListener;
|
||||
}
|
||||
|
||||
|
||||
public void setProcessCreateListener(ExecutionListener processCreateListener)
|
||||
{
|
||||
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