diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index ec97b0bf23414c9ccfcbae64b67b35db1e5ee1b4..2fc5bff8e1d32a874b2a896f6d8994bfe290e985 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -292,11 +292,10 @@ ServerConnector.loginUrl = function() { }); }; -ServerConnector.getSuggestedQueryListUrl = function(params) { +ServerConnector.getSuggestedQueryListUrl = function(queryParams, filterParams) { return this.getApiUrl({ - type : "project", - method : "getSuggestedQueryList", - params : params, + url : this.getBioEntitiesUrl(queryParams) + "suggestedQueryList/", + params : filterParams, }); }; @@ -1345,7 +1344,8 @@ ServerConnector.getSuggestedQueryList = function(projectId) { return self.getToken(); }).then(function(token) { return self.readFile(self.getSuggestedQueryListUrl({ - projectId : projectId, + projectId : projectId + }, { token : token })); }).then(function(content) { diff --git a/frontend-js/testFiles/apiCalls/project/getSuggestedQueryList/projectId=sample&token=MOCK_TOKEN_ID& b/frontend-js/testFiles/apiCalls/projects/sample/models/all/bioEntities/suggestedQueryList/token=MOCK_TOKEN_ID& similarity index 100% rename from frontend-js/testFiles/apiCalls/project/getSuggestedQueryList/projectId=sample&token=MOCK_TOKEN_ID& rename to frontend-js/testFiles/apiCalls/projects/sample/models/all/bioEntities/suggestedQueryList/token=MOCK_TOKEN_ID& diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectController.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectController.java index 2af04a489c3fd13389c2fa6f2300a9564d4afceb..177eef63a2209ece6256cfb76c75198e13695f25 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectController.java @@ -1,9 +1,6 @@ package lcsb.mapviewer.api.projects; -import java.awt.geom.Point2D; import java.io.IOException; -import java.util.List; -import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; @@ -34,14 +31,6 @@ public class ProjectController extends BaseController { return projectController.getMetaData(projectId, token); } - @RequestMapping(value = "/project/getSuggestedQueryList", method = { RequestMethod.GET, RequestMethod.POST }, - produces = { MediaType.APPLICATION_JSON_VALUE }) - public String[] getSuggestedQueryList(@RequestParam(value = "projectId") String projectId, @RequestParam(value = "token") String token) - throws SecurityException { - return projectController.getSuggestedQueryList(projectId, token); - } - - @RequestMapping(value = "/project/getProjectSource", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity<byte[]> getProjectSource(@RequestParam(value = "token") String token, @RequestParam(value = "projectId") String projectId) throws SecurityException, QueryException { diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java index a92c21392ee8e3fd789c8d442f84619fa25ae0a2..ccc502800e3005fd29cbb7fcfd6e3731dd6d4f8b 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/ProjectRestImpl.java @@ -2,14 +2,12 @@ package lcsb.mapviewer.api.projects; import java.awt.geom.Path2D; import java.awt.geom.PathIterator; -import java.awt.geom.Point2D; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -31,7 +29,6 @@ import lcsb.mapviewer.commands.CommandExecutionException; import lcsb.mapviewer.commands.CopyCommand; import lcsb.mapviewer.commands.SubModelCommand; import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.converter.ConverterException; import lcsb.mapviewer.converter.IConverter; import lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params; @@ -49,17 +46,14 @@ import lcsb.mapviewer.model.map.layout.ColorSchema; import lcsb.mapviewer.model.map.layout.InvalidColorSchemaException; import lcsb.mapviewer.model.map.layout.Layout; import lcsb.mapviewer.model.map.model.Model; -import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.services.SecurityException; -import lcsb.mapviewer.services.UserAccessException; import lcsb.mapviewer.services.interfaces.ILayoutService; import lcsb.mapviewer.services.interfaces.IModelService; import lcsb.mapviewer.services.interfaces.IProjectService; import lcsb.mapviewer.services.interfaces.ISearchService; import lcsb.mapviewer.services.interfaces.IUserService; -import lcsb.mapviewer.services.search.data.ElementIdentifier.ElementIdentifierType; import lcsb.mapviewer.services.utils.ColorSchemaReader; import lcsb.mapviewer.services.utils.data.BuildInLayout; import lcsb.mapviewer.services.utils.gmap.CoordinationConverter; @@ -94,10 +88,7 @@ public class ProjectRestImpl extends BaseRestImpl { private PublicationsRestImpl publicationsRestImpl; @Autowired - private ISearchService searchService; - - @Autowired - AnnotationViewFactory annotationViewFactory; + private AnnotationViewFactory annotationViewFactory; @Autowired private ILayoutService layoutService; @@ -193,28 +184,6 @@ public class ProjectRestImpl extends BaseRestImpl { this.modelService = modelService; } - /** - * @return the searchService - * @see #searchService - */ - public ISearchService getSearchService() { - return searchService; - } - - /** - * @param searchService - * the searchService to set - * @see #searchService - */ - public void setSearchService(ISearchService searchService) { - this.searchService = searchService; - } - - public String[] getSuggestedQueryList(String projectId, String token) throws SecurityException { - Model model = modelService.getLastModelByProjectId(projectId, userService.getToken(token)); - return searchService.getSuggestedQueryList(model); - } - /** * @return the factory * @see #factory diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesController.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesController.java index 9bef963ef950cd2cdd027c5c9614056510419947..3f1760152dbd22c983f5070ca7198f3f4de8303e 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesController.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesController.java @@ -19,7 +19,7 @@ import lcsb.mapviewer.services.SecurityException; @RestController public class BioEntitiesController extends BaseController { @Autowired - private BioEntitiesRestImpl projectController; + private BioEntitiesRestImpl bioEntitiesRestImpl; @RequestMapping(value = "/projects/{projectId}/models/{modelId}/bioEntities:search", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE }) @@ -52,15 +52,22 @@ public class BioEntitiesController extends BaseController { throw new QueryException("Coordinates must be in the format: 'xxx.xx,yyy.yy'", e); } Point2D pointCoordinates = new Point2D.Double(x, y); - return projectController.getClosestElementsByCoordinates(projectId, modelId, token, pointCoordinates, Integer.valueOf(count), perfectMatch); + return bioEntitiesRestImpl.getClosestElementsByCoordinates(projectId, modelId, token, pointCoordinates, Integer.valueOf(count), perfectMatch); } else if (!query.trim().isEmpty()) { if (count.trim().isEmpty()) { count = "100"; } - return projectController.getElementsByQuery(projectId, token, modelId, query, Integer.valueOf(count), perfectMatch); + return bioEntitiesRestImpl.getElementsByQuery(projectId, token, modelId, query, Integer.valueOf(count), perfectMatch); } else { throw new QueryException("On of the parameters 'coordinates', 'query' is required"); } } + @RequestMapping(value = "/projects/{projectId}/models/{modelId}/bioEntities/suggestedQueryList", method = { RequestMethod.GET, RequestMethod.POST }, + produces = { MediaType.APPLICATION_JSON_VALUE }) + public String[] getSuggestedQueryList(@RequestParam(value = "projectId") String projectId, @RequestParam(value = "token") String token) + throws SecurityException { + return bioEntitiesRestImpl.getSuggestedQueryList(projectId, token); + } + } \ No newline at end of file diff --git a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesRestImpl.java b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesRestImpl.java index 12902400c5b291eda58cd84b29e347267aed7106..a82e66e114699e9ec8a1ca8a64c3323036b37bf2 100644 --- a/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesRestImpl.java +++ b/rest-api/src/main/java/lcsb/mapviewer/api/projects/models/bioEntities/BioEntitiesRestImpl.java @@ -52,8 +52,8 @@ public class BioEntitiesRestImpl extends BaseRestImpl { this.userService = userService; } - public List<Map<String, Object>> getClosestElementsByCoordinates(String projectId, String modelId, String token, Point2D coordinates, Integer count, String perfectMatch) - throws UserAccessException, SecurityException { + public List<Map<String, Object>> getClosestElementsByCoordinates(String projectId, String modelId, String token, Point2D coordinates, Integer count, + String perfectMatch) throws UserAccessException, SecurityException { List<Map<String, Object>> resultMap = new ArrayList<>(); Model model = modelService.getLastModelByProjectId(projectId, userService.getToken(token)); @@ -107,7 +107,7 @@ public class BioEntitiesRestImpl extends BaseRestImpl { List<Map<String, Object>> resultMap = new ArrayList<>(); Model model = modelService.getLastModelByProjectId(projectId, userService.getToken(token)); - + Integer limit = Integer.valueOf(maxElements); boolean match = perfectMatch.equals("true"); List<Object> elements = searchService.searchByQuery(model, query, limit, match); @@ -118,4 +118,9 @@ public class BioEntitiesRestImpl extends BaseRestImpl { return resultMap; } + public String[] getSuggestedQueryList(String projectId, String token) throws SecurityException { + Model model = modelService.getLastModelByProjectId(projectId, userService.getToken(token)); + return searchService.getSuggestedQueryList(model); + } + }