mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Tweaked the updateTask method to only send notification emails if the assignee has changed (Explorer client always sends all properties on an update) and added check for null start task just in case!
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29945 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -699,6 +699,8 @@ public class WorkflowServiceImpl implements WorkflowService
|
|||||||
{
|
{
|
||||||
String engineId = BPMEngineRegistry.getEngineId(taskId);
|
String engineId = BPMEngineRegistry.getEngineId(taskId);
|
||||||
TaskComponent component = getTaskComponent(engineId);
|
TaskComponent component = getTaskComponent(engineId);
|
||||||
|
// get the current assignee before updating the task
|
||||||
|
String originalAsignee = (String)component.getTaskById(taskId).getProperties().get(ContentModel.PROP_OWNER);
|
||||||
WorkflowTask task = component.updateTask(taskId, properties, add, remove);
|
WorkflowTask task = component.updateTask(taskId, properties, add, remove);
|
||||||
if (add != null && add.containsKey(WorkflowModel.ASSOC_PACKAGE))
|
if (add != null && add.containsKey(WorkflowModel.ASSOC_PACKAGE))
|
||||||
{
|
{
|
||||||
@@ -706,17 +708,21 @@ public class WorkflowServiceImpl implements WorkflowService
|
|||||||
workflowPackageComponent.setWorkflowForPackage(instance);
|
workflowPackageComponent.setWorkflowForPackage(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the start task
|
// Get the 'new' assignee
|
||||||
|
String assignee = (String)properties.get(ContentModel.PROP_OWNER);
|
||||||
|
if (assignee != null && assignee.length() != 0)
|
||||||
|
{
|
||||||
|
// if the assignee has changed get the start task
|
||||||
|
if (!assignee.equals(originalAsignee))
|
||||||
|
{
|
||||||
String instanceId = task.getPath().getInstance().getId();
|
String instanceId = task.getPath().getInstance().getId();
|
||||||
WorkflowTask startTask = component.getStartTask(instanceId);
|
WorkflowTask startTask = component.getStartTask(instanceId);
|
||||||
|
|
||||||
|
if (startTask != null)
|
||||||
|
{
|
||||||
// Get the email notification flag
|
// Get the email notification flag
|
||||||
Boolean sendEMailNotification = (Boolean) startTask.getProperties().get(WorkflowModel.PROP_SEND_EMAIL_NOTIFICATIONS);
|
Boolean sendEMailNotification = (Boolean) startTask.getProperties().get(WorkflowModel.PROP_SEND_EMAIL_NOTIFICATIONS);
|
||||||
|
if (Boolean.TRUE.equals(sendEMailNotification) == true)
|
||||||
// Get the 'new' assignee
|
|
||||||
String assignee = (String)properties.get(ContentModel.PROP_OWNER);
|
|
||||||
if (assignee != null && assignee.length() != 0 &&
|
|
||||||
Boolean.TRUE.equals(sendEMailNotification) == true)
|
|
||||||
{
|
{
|
||||||
// Send the notification
|
// Send the notification
|
||||||
WorkflowNotificationUtils.sendWorkflowAssignedNotificationEMail(
|
WorkflowNotificationUtils.sendWorkflowAssignedNotificationEMail(
|
||||||
@@ -725,6 +731,9 @@ public class WorkflowServiceImpl implements WorkflowService
|
|||||||
assignee,
|
assignee,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user