Commit 566a859b authored by Piotr Gawron's avatar Piotr Gawron
Browse files

get backgrounds moved to controller

parent df041ebc
......@@ -680,7 +680,7 @@ public class ProjectController extends BaseController {
public List<ProjectBackground> getBackgrounds(
@PathVariable(value = "projectId") String projectId)
throws lcsb.mapviewer.services.ObjectNotFoundException {
return projectController.getBackgrounds(projectId);
return projectService.getBackgrounds(projectId, true);
}
@PreAuthorize("hasAnyAuthority('IS_ADMIN', 'READ_PROJECT:' + #projectId) "
......
......@@ -70,12 +70,4 @@ public class ProjectRestImpl extends BaseRestImpl {
return result;
}
public List<ProjectBackground> getBackgrounds(String projectId) throws ObjectNotFoundException {
List<ProjectBackground> result = getProjectByProjectId(projectId).getProjectBackgrounds();
for (ProjectBackground projectBackground : result) {
Hibernate.initialize(projectBackground.getProjectBackgroundImageLayer());
}
return result;
}
}
......@@ -1363,4 +1363,19 @@ public class ProjectService implements IProjectService {
Hibernate.initialize(project.getInputData());
return project.getInputData();
}
@Override
public List<ProjectBackground> getBackgrounds(String projectId, boolean initializeLazy) {
Project project = getProjectByProjectId(projectId);
if (project != null) {
for (ProjectBackground projectBackground : project.getProjectBackgrounds()) {
if (initializeLazy) {
Hibernate.initialize(projectBackground.getProjectBackgroundImageLayer());
}
}
return project.getProjectBackgrounds();
} else {
return new ArrayList<>();
}
}
}
......@@ -115,11 +115,13 @@ public interface IProjectService {
void removeBackground(ProjectBackground projectBackground);
ProjectBackground getBackgroundById(String projectId, Integer backgroundId, boolean b);
ProjectBackground getBackgroundById(String projectId, Integer backgroundId, boolean initializeLazy);
void updateBackground(ProjectBackground background);
long getNextId();
UploadedFileEntry getFileByProjectId(String projectId);
List<ProjectBackground> getBackgrounds(String projectId, boolean initializeLazy);
}
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