Commit aa051e2f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

ChemicalRestImpl removed

parent 477b10db
...@@ -4,8 +4,6 @@ import java.util.ArrayList; ...@@ -4,8 +4,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJacksonValue; import org.springframework.http.converter.json.MappingJacksonValue;
...@@ -38,17 +36,12 @@ import lcsb.mapviewer.services.search.chemical.IChemicalService; ...@@ -38,17 +36,12 @@ import lcsb.mapviewer.services.search.chemical.IChemicalService;
@RequestMapping(value = "/api/projects", produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/api/projects", produces = MediaType.APPLICATION_JSON_VALUE)
public class ChemicalController extends BaseController { public class ChemicalController extends BaseController {
private Logger logger = LogManager.getLogger();
private ChemicalRestImpl chemicalController;
private IProjectService projectService; private IProjectService projectService;
private IChemicalService chemicalService; private IChemicalService chemicalService;
private IElementService elementService; private IElementService elementService;
@Autowired @Autowired
public ChemicalController(ChemicalRestImpl chemicalController, IProjectService projectService, IChemicalService chemicalService, public ChemicalController(IProjectService projectService, IChemicalService chemicalService, IElementService elementService) {
IElementService elementService) {
this.chemicalController = chemicalController;
this.projectService = projectService; this.projectService = projectService;
this.chemicalService = chemicalService; this.chemicalService = chemicalService;
this.elementService = elementService; this.elementService = elementService;
...@@ -117,6 +110,10 @@ public class ChemicalController extends BaseController { ...@@ -117,6 +110,10 @@ public class ChemicalController extends BaseController {
@GetMapping(value = "/{projectId}/chemicals/suggestedQueryList") @GetMapping(value = "/{projectId}/chemicals/suggestedQueryList")
public List<String> getSuggestedQueryList(@PathVariable(value = "projectId") String projectId) public List<String> getSuggestedQueryList(@PathVariable(value = "projectId") String projectId)
throws ChemicalSearchException, ObjectNotFoundException { throws ChemicalSearchException, ObjectNotFoundException {
return chemicalController.getSuggestedQueryList(projectId); Project project = projectService.getProjectByProjectId(projectId);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist: " + projectId);
}
return chemicalService.getSuggestedQueryList(project, project.getDisease());
} }
} }
\ No newline at end of file
package lcsb.mapviewer.api.projects.chemicals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import lcsb.mapviewer.annotation.data.Chemical;
import lcsb.mapviewer.annotation.data.MeSH;
import lcsb.mapviewer.annotation.services.MeSHParser;
import lcsb.mapviewer.annotation.services.annotators.AnnotatorException;
import lcsb.mapviewer.annotation.services.dapi.ChemicalSearchException;
import lcsb.mapviewer.api.BaseRestImpl;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.services.ObjectNotFoundException;
import lcsb.mapviewer.services.interfaces.IElementService;
import lcsb.mapviewer.services.search.chemical.IChemicalService;
@Transactional
@Service
public class ChemicalRestImpl extends BaseRestImpl {
/**
* Default class logger.
*/
private Logger logger = LogManager.getLogger();
private IChemicalService chemicalService;
private IElementService elementService;
private MeSHParser meSHParser;
@Autowired
public ChemicalRestImpl(IChemicalService chemicalService, MeSHParser meSHParser, IElementService elementService) {
this.chemicalService = chemicalService;
this.meSHParser = meSHParser;
this.elementService = elementService;
}
public List<String> getSuggestedQueryList(String projectId) throws ChemicalSearchException, ObjectNotFoundException {
Project project = getProjectService().getProjectByProjectId(projectId);
if (project == null) {
throw new ObjectNotFoundException("Project with given id doesn't exist: " + projectId);
}
return chemicalService.getSuggestedQueryList(project, project.getDisease());
}
}
...@@ -53,7 +53,6 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; ...@@ -53,7 +53,6 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import lcsb.mapviewer.annotation.data.serializer.ChemicalSerializer; import lcsb.mapviewer.annotation.data.serializer.ChemicalSerializer;
import lcsb.mapviewer.api.projects.chemicals.ChemicalRestImpl;
import lcsb.mapviewer.common.MinervaLoggerAppender; import lcsb.mapviewer.common.MinervaLoggerAppender;
import lcsb.mapviewer.common.TextFileUtils; import lcsb.mapviewer.common.TextFileUtils;
import lcsb.mapviewer.common.UnitTestFailedWatcher; import lcsb.mapviewer.common.UnitTestFailedWatcher;
...@@ -174,9 +173,6 @@ abstract public class ControllerIntegrationTest { ...@@ -174,9 +173,6 @@ abstract public class ControllerIntegrationTest {
private String dapiLogin; private String dapiLogin;
private String dapiPassword; private String dapiPassword;
@Autowired
private ChemicalRestImpl chemicalRestImpl;
@PostConstruct @PostConstruct
public void construct() { public void construct() {
mockMvc = MockMvcBuilders.webAppContextSetup(context) mockMvc = MockMvcBuilders.webAppContextSetup(context)
......
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