CCM NG/ccm-cms: Removing roles from task

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

View File

@ -376,7 +376,7 @@ public class WorkflowAdminPaneController {
final Role role = roleRepo final Role role = roleRepo
.findById(Long.parseLong(roleId)) .findById(Long.parseLong(roleId))
.orElseThrow(() -> new IllegalArgumentException(String.format( .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))); roleId)));
final CmsTask theTask = (CmsTask) taskRepo final CmsTask theTask = (CmsTask) taskRepo

View File

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