Skip to content
Snippets Groups Projects

Draft: Resolve "Trying to view lab information after respective modules are deleted results in NullPointer"

3 files
+ 38
2
Compare changes
  • Side-by-side
  • Inline

Files

@@ -180,6 +180,8 @@ public class LabController {
List<? extends Request<?>> requests;
if (qSession instanceof Lab lab) {
requests = lrr.findAllByFilter(List.of(lab), filter, Language.ANY);
requests.removeIf(rq -> qSession.getRequests().stream().map(Request::getId)
.noneMatch(rId -> rId.equals(rq.getId())));
} else {
requests = qSession.getRequests();
}
@@ -816,7 +818,11 @@ public class LabController {
Set<Long> alreadyInGroup = sgCache.getByPerson(person.getId()).stream()
.map(g -> g.getModule().getId()).collect(Collectors.toSet());
Set<Long> hasEmptyGroups = qSession.getModules().stream()
Set<Long> hasEmptyGroups = mCache
.getAndHandle(new ArrayList<>(qSession.getModules()),
id -> ls.removeModuleForSession(qSession, id))
.stream().map(ModuleDetailsDTO::getId)
.filter(m -> !alreadyInGroup.contains(m))
.filter(m -> sgApi.getAllGroupsInModule(m).any(g -> g.getMemberUsernames().isEmpty())
.block())
@@ -834,7 +840,7 @@ public class LabController {
} else {
model.addAttribute("modules",
mCache.getAndHandle(qSession.getModules().stream(),
moduleID -> qSession.getModules().remove(moduleID))
moduleId -> ls.removeModuleForSession(qSession, moduleId))
.stream().sorted(Comparator.comparing(ModuleDetailsDTO::getName))
.collect(Collectors.toList()));
}
Loading