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

new api call for suggested query list

parent f25fbc10
......@@ -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) {
......
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 {
......
......@@ -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
......
......@@ -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
......@@ -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);
}
}
Supports Markdown
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