Skip to content

Commit

Permalink
Merge pull request DSpace#9861 from AndrewAlesik/performance-fix-of-p…
Browse files Browse the repository at this point in the history
…ooltask-claiming

performance of claiming workflow task fix
  • Loading branch information
tdonohue authored Nov 11, 2024
2 parents 12c36da + 27dd5a2 commit 5854e93
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Set;

import org.apache.commons.collections4.CollectionUtils;
Expand Down Expand Up @@ -100,12 +101,17 @@ public PoolTask findByWorkflowIdAndEPerson(Context context, XmlWorkflowItem work
//If the user does not have a claimedtask yet, see whether one of the groups of the user has pooltasks
//for this workflow item
Set<Group> groups = groupService.allMemberGroupsSet(context, ePerson);
for (Group group : groups) {
poolTask = poolTaskDAO.findByWorkflowItemAndGroup(context, group, workflowItem);
if (poolTask != null) {
return poolTask;
}
List<PoolTask> generalTasks = poolTaskDAO.findByWorkflowItem(context, workflowItem);

Optional<PoolTask> firstClaimedTask = groups.stream()
.flatMap(group -> generalTasks.stream()
.filter(f -> f.getGroup().getID().equals(group.getID()))
.findFirst()
.stream())
.findFirst();

if (firstClaimedTask.isPresent()) {
return firstClaimedTask.get();
}
}
}
Expand Down

0 comments on commit 5854e93

Please sign in to comment.