CCM NG/ccm-cms: Removing roles from task

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4630 8810af33-2d31-482b-a856-94f89814c4df
ccm-docs
jensp 2017-03-15 09:10:33 +00:00
parent 3552c04a1e
commit 4fb0dbcb40
2 changed files with 8 additions and 6 deletions

View File

@ -376,7 +376,7 @@ public class WorkflowAdminPaneController {
final Role role = roleRepo
.findById(Long.parseLong(roleId))
.orElseThrow(() -> new IllegalArgumentException(String.format(
"No Role with ID %d in the database. Where did that ID come from?",
"No Role with ID %s in the database. Where did that ID come from?",
roleId)));
final CmsTask theTask = (CmsTask) taskRepo

View File

@ -111,12 +111,14 @@ public class AssignableTaskManager {
"Can't retract a task from role null.");
}
final List<TaskAssignment> result = task.getAssignments().stream()
.filter(assigned -> role.equals(assigned.getRole()))
.collect(Collectors.toList());
final Optional<TaskAssignment> result = task
.getAssignments()
.stream()
.filter(assigned -> role.getRoleId() == assigned.getRole().getRoleId())
.findAny();
if (!result.isEmpty()) {
final TaskAssignment assignment = result.get(0);
if (result.isPresent()) {
final TaskAssignment assignment = result.get();
task.removeAssignment(assignment);
role.removeAssignedTask(assignment);
entityManager.remove(assignment);