Commit 93508b07 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

getOverlayList moved to controller

parent 85f7b1fc
...@@ -25,11 +25,14 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -25,11 +25,14 @@ import org.springframework.web.bind.annotation.RestController;
import lcsb.mapviewer.api.BaseController; import lcsb.mapviewer.api.BaseController;
import lcsb.mapviewer.api.SerializationUtils; import lcsb.mapviewer.api.SerializationUtils;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.cache.FileEntry; import lcsb.mapviewer.model.cache.FileEntry;
import lcsb.mapviewer.model.overlay.DataOverlay; import lcsb.mapviewer.model.overlay.DataOverlay;
import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.services.ObjectNotFoundException; import lcsb.mapviewer.services.ObjectNotFoundException;
import lcsb.mapviewer.services.QueryException; import lcsb.mapviewer.services.QueryException;
import lcsb.mapviewer.services.interfaces.IDataOverlayService;
import lcsb.mapviewer.services.interfaces.IProjectService;
import lcsb.mapviewer.services.interfaces.IUserService; import lcsb.mapviewer.services.interfaces.IUserService;
@RestController @RestController
...@@ -40,11 +43,17 @@ public class OverlayController extends BaseController { ...@@ -40,11 +43,17 @@ public class OverlayController extends BaseController {
private OverlayRestImpl overlayRestImp; private OverlayRestImpl overlayRestImp;
private IUserService userService; private IUserService userService;
private IProjectService projectService;
private IDataOverlayService dataOverlayService;
public OverlayController(OverlayRestImpl overlayRestImp, public OverlayController(OverlayRestImpl overlayRestImp,
IUserService userService) { IUserService userService,
IProjectService projectService,
IDataOverlayService dataOverlayService) {
this.overlayRestImp = overlayRestImp; this.overlayRestImp = overlayRestImp;
this.userService = userService; this.userService = userService;
this.projectService = projectService;
this.dataOverlayService = dataOverlayService;
} }
@PreAuthorize("hasAnyAuthority('IS_ADMIN', 'READ_PROJECT:' + #projectId) " @PreAuthorize("hasAnyAuthority('IS_ADMIN', 'READ_PROJECT:' + #projectId) "
...@@ -58,7 +67,13 @@ public class OverlayController extends BaseController { ...@@ -58,7 +67,13 @@ public class OverlayController extends BaseController {
@RequestParam(value = "creator", defaultValue = "") String creator, @RequestParam(value = "creator", defaultValue = "") String creator,
@RequestParam(value = "publicOverlay", defaultValue = "false") boolean publicOverlay) @RequestParam(value = "publicOverlay", defaultValue = "false") boolean publicOverlay)
throws lcsb.mapviewer.services.ObjectNotFoundException { throws lcsb.mapviewer.services.ObjectNotFoundException {
return overlayRestImp.getOverlayList(projectId).stream() Project project = projectService.getProjectByProjectId(projectId);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist");
}
List<DataOverlay> result = dataOverlayService.getDataOverlaysByProject(project, true);
return result.stream()
.filter(overlay -> !publicOverlay || overlay.isPublic()) .filter(overlay -> !publicOverlay || overlay.isPublic())
.filter( .filter(
overlay -> creator.isEmpty() || overlay.getCreator() != null && overlay.getCreator().getLogin().equals(creator)) overlay -> creator.isEmpty() || overlay.getCreator() != null && overlay.getCreator().getLogin().equals(creator))
......
...@@ -61,14 +61,6 @@ public class OverlayRestImpl extends BaseRestImpl { ...@@ -61,14 +61,6 @@ public class OverlayRestImpl extends BaseRestImpl {
this.dataOverlayService = dataOverlayService; this.dataOverlayService = dataOverlayService;
} }
public List<DataOverlay> getOverlayList(String projectId) throws ObjectNotFoundException {
Project project = getProjectService().getProjectByProjectId(projectId);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist");
}
return dataOverlayService.getDataOverlaysByProject(project, true);
}
public List<Map<String, Object>> getOverlayElements(String projectId, int overlayId, String columns) public List<Map<String, Object>> getOverlayElements(String projectId, int overlayId, String columns)
throws QueryException { throws QueryException {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment