CCM NG/ccm-core: WorkflowManager added multiple TaskAssignments for same task and assignee
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4799 8810af33-2d31-482b-a856-94f89814c4dfpull/2/head
parent
2abe7aeb2c
commit
f1419ab8ea
|
|
@ -49,7 +49,9 @@ import javax.inject.Inject;
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.TypedQuery;
|
import javax.persistence.TypedQuery;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
|
import org.libreccm.security.Role;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manager for {@link Workflow}s. The logic of some of these classes has been
|
* Manager for {@link Workflow}s. The logic of some of these classes has been
|
||||||
|
|
@ -82,6 +84,9 @@ public class WorkflowManager {
|
||||||
@Inject
|
@Inject
|
||||||
private TaskManager taskManager;
|
private TaskManager taskManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssignableTaskManager assignableTaskManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Shiro shiro;
|
private Shiro shiro;
|
||||||
|
|
||||||
|
|
@ -138,6 +143,8 @@ public class WorkflowManager {
|
||||||
.forEach((locale, str) -> description.addValue(locale, str));
|
.forEach((locale, str) -> description.addValue(locale, str));
|
||||||
workflow.setDescription(description);
|
workflow.setDescription(description);
|
||||||
|
|
||||||
|
workflowRepo.save(workflow);
|
||||||
|
|
||||||
final Map<Long, Task> tasks = new HashMap<>();
|
final Map<Long, Task> tasks = new HashMap<>();
|
||||||
|
|
||||||
template
|
template
|
||||||
|
|
@ -147,7 +154,7 @@ public class WorkflowManager {
|
||||||
.getTasks()
|
.getTasks()
|
||||||
.forEach(taskTemplate -> {
|
.forEach(taskTemplate -> {
|
||||||
fixTaskDependencies(taskTemplate,
|
fixTaskDependencies(taskTemplate,
|
||||||
tasks.get(taskTemplate.getTaskId()),
|
tasks.get(taskTemplate.getTaskId()),
|
||||||
tasks);
|
tasks);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -169,10 +176,10 @@ public class WorkflowManager {
|
||||||
* @param template The template for the task from the workflow template.
|
* @param template The template for the task from the workflow template.
|
||||||
* @param tasks A map for storing the new tasks.
|
* @param tasks A map for storing the new tasks.
|
||||||
*/
|
*/
|
||||||
private void createTask(final Workflow workflow,
|
private void createTask(final Workflow workflow,
|
||||||
final Task template,
|
final Task template,
|
||||||
final Map<Long, Task> tasks) {
|
final Map<Long, Task> tasks) {
|
||||||
|
|
||||||
final Class<? extends Task> templateClass = template.getClass();
|
final Class<? extends Task> templateClass = template.getClass();
|
||||||
final Task task;
|
final Task task;
|
||||||
try {
|
try {
|
||||||
|
|
@ -224,10 +231,24 @@ public class WorkflowManager {
|
||||||
| InvocationTargetException ex) {
|
| InvocationTargetException ex) {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
workflow.addTask(task);
|
workflow.addTask(task);
|
||||||
task.setWorkflow(workflow);
|
task.setWorkflow(workflow);
|
||||||
tasks.put(template.getTaskId(), task);
|
tasks.put(template.getTaskId(), task);
|
||||||
|
|
||||||
|
if (template instanceof AssignableTask) {
|
||||||
|
final AssignableTask assignableTemplate
|
||||||
|
= (AssignableTask) template;
|
||||||
|
final AssignableTask assignableTask = (AssignableTask) task;
|
||||||
|
|
||||||
|
assignableTemplate
|
||||||
|
.getAssignments()
|
||||||
|
.stream()
|
||||||
|
.map(TaskAssignment::getRole)
|
||||||
|
.forEach(role -> {
|
||||||
|
assignableTaskManager.assignTask(assignableTask, role);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue