Commit 07b24b49 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

get project moved to controller

parent 477a3a8a
......@@ -87,7 +87,6 @@ public class ProjectController extends BaseController {
private Logger logger = LogManager.getLogger();
private ServletContext context;
private ProjectRestImpl projectController;
private IProjectService projectService;
private IConfigurationService configurationService;
private IModelService modelService;
......@@ -101,11 +100,10 @@ public class ProjectController extends BaseController {
private List<Converter> modelConverters;
@Autowired
public ProjectController(ServletContext context, ProjectRestImpl projectController, IUserService userService, IProjectService projectService,
public ProjectController(ServletContext context, IUserService userService, IProjectService projectService,
IMeshService meshService, List<Converter> modelConverters, IFileService fileService, IElementService elementService, IReactionService reactionService,
IModelService modelService, IConfigurationService configurationService) {
this.context = context;
this.projectController = projectController;
this.userService = userService;
this.projectService = projectService;
this.meshService = meshService;
......@@ -121,7 +119,11 @@ public class ProjectController extends BaseController {
@GetMapping(value = "/{projectId:.+}")
public Project getProject(@PathVariable(value = "projectId") String projectId)
throws ObjectNotFoundException {
return projectController.getProject(projectId);
Project project = projectService.getProjectByProjectId(projectId, true);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist");
}
return project;
}
static class UpdateProjectData {
......@@ -680,13 +682,13 @@ public class ProjectController extends BaseController {
public BioEntity from;
@JsonSerialize(using = ModelDataAsModelIdSerializer.class)
public ModelData to;
public SubmapConnection(Element element) {
from = element;
to = element.getSubmodel().getSubmodel();
}
}
@PreAuthorize("hasAnyAuthority('IS_ADMIN', 'READ_PROJECT:' + #projectId)")
@GetMapping(value = "/{projectId}/submapConnections")
public List<SubmapConnection> getSubmapConnections(@PathVariable(value = "projectId") String projectId)
......
package lcsb.mapviewer.api.projects;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.hibernate.Hibernate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lcsb.mapviewer.api.BaseRestImpl;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.layout.ProjectBackground;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.persist.dao.map.species.ElementProperty;
import lcsb.mapviewer.services.ObjectNotFoundException;
import lcsb.mapviewer.services.QueryException;
import lcsb.mapviewer.services.interfaces.IElementService;
import lcsb.mapviewer.services.interfaces.IReactionService;
@Transactional
@Service
public class ProjectRestImpl extends BaseRestImpl {
private IElementService elementService;
public ProjectRestImpl(
IElementService elementService) {
this.elementService = elementService;
}
public Project getProject(String projectId) throws ObjectNotFoundException {
return getProjectByProjectId(projectId);
}
private Project getProjectByProjectId(String projectId) throws ObjectNotFoundException {
Project project = getProjectService().getProjectByProjectId(projectId, true);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist");
}
return project;
}
}
package lcsb.mapviewer.api;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -15,11 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import lcsb.mapviewer.annotation.services.MiriamConnector;
import lcsb.mapviewer.annotation.services.PubmedParser;
import lcsb.mapviewer.annotation.services.annotators.ElementAnnotator;
import lcsb.mapviewer.api.projects.ProjectRestImpl;
import lcsb.mapviewer.converter.Converter;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.user.annotator.AnnotatorData;
public class BaseRestImplTest extends RestTestFunctions {
Logger logger = LogManager.getLogger();
......@@ -27,9 +25,6 @@ public class BaseRestImplTest extends RestTestFunctions {
@Autowired
MiriamConnector mc;
@Autowired
ProjectRestImpl restImpl;
@Autowired
PubmedParser pubmedParser;
......@@ -76,10 +71,4 @@ public class BaseRestImplTest extends RestTestFunctions {
assertNull(x);
}
@Test
public void testGetConverters() throws Exception {
List<Converter> list = restImpl.getModelConverters();
assertTrue(list.size() > 0);
}
}
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