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

documentation for search by query and get suggested search queries API calls

parent eccebbf9
......@@ -145,3 +145,39 @@ include::{snippets}/projects/project_maps/get_reactions/response-body.adoc[]
=== CURL sample 2
include::{snippets}/projects/project_maps/get_reactions_limited_columns/curl-request.adoc[]
== Search for bio entities
Returns list of bio entities matching the query.
=== Path Parameters
include::{snippets}/projects/project_maps/search_by_query/path-parameters.adoc[]
=== Request Parameters
include::{snippets}/projects/project_maps/search_by_query/request-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_maps/search_by_query/response-fields.adoc[]
=== CURL sample 1
include::{snippets}/projects/project_maps/search_by_query/curl-request.adoc[]
=== Sample Response 1
include::{snippets}/projects/project_maps/search_by_query/response-body.adoc[]
=== CURL sample 2
include::{snippets}/projects/project_maps/search_by_coordinates/curl-request.adoc[]
== Get list of suggested search queries
=== Path Parameters
include::{snippets}/projects/project_maps/suggested_query_list/path-parameters.adoc[]
=== Response Fields
include::{snippets}/projects/project_maps/suggested_query_list/response-fields.adoc[]
=== CURL sample
include::{snippets}/projects/project_maps/suggested_query_list/curl-request.adoc[]
=== Sample Response
include::{snippets}/projects/project_maps/suggested_query_list/response-body.adoc[]
......@@ -26,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.google.gson.JsonParser;
import lcsb.mapviewer.api.ElementIdentifierType;
import lcsb.mapviewer.api.projects.models.bioEntities.elements.ElementsRestImpl;
import lcsb.mapviewer.api.projects.models.bioEntities.reactions.ReactionsRestImpl;
import lcsb.mapviewer.common.Configuration;
......@@ -264,6 +265,20 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
.optional());
}
private ResponseFieldsSnippet listSearchResults() {
return responseFields(
fieldWithPath("[].id")
.description("unique element identifier")
.type("number"),
fieldWithPath("[].modelId")
.description("map identifier")
.type("number"),
fieldWithPath("[].type")
.description("type of the bioEntity (available options: " + ElementIdentifierType.ALIAS + ", "
+ ElementIdentifierType.REACTION + ")")
.type("string"));
}
private RequestParametersSnippet getAllElementsFilter() {
return requestParameters(
parameterWithName("id")
......@@ -300,6 +315,22 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
.optional());
}
private RequestParametersSnippet getSearchParameters() {
return requestParameters(
parameterWithName("query")
.description("search term identifying bioEntity")
.optional(),
parameterWithName("coordinates")
.description("coordinates where bioEntity should be located")
.optional(),
parameterWithName("count")
.description("max number of bioEntities to return")
.optional(),
parameterWithName("perfectMatch")
.description("true when true query must be matched exactly, if false similar results are also acceptable")
.optional());
}
@Test
public void testGetAllElementsFiltereByType() throws Exception {
userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId());
......@@ -366,7 +397,8 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
public void testGetAllReactionsWithFilteredColumns() throws Exception {
userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId());
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/bioEntities/reactions/?columns=id,notes", TEST_PROJECT, "*");
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/bioEntities/reactions/?columns=id,notes",
TEST_PROJECT, "*");
String response = mockMvc.perform(request)
.andDo(document("projects/project_maps/get_reactions_limited_columns",
......@@ -393,9 +425,14 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId());
RequestBuilder request = get(
"/projects/" + TEST_PROJECT + "/models/" + map.getId() + "/bioEntities:search?coordinates=104.36,182.81");
"/projects/{projectId}/models/{mapId}/bioEntities:search?coordinates=104.36,182.81", TEST_PROJECT, map.getId());
mockMvc.perform(request)
.andDo(document("projects/project_maps/search_by_coordinates",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier")),
getSearchParameters(),
listSearchResults()))
.andExpect(status().is2xxSuccessful());
}
......@@ -452,9 +489,14 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId());
RequestBuilder request = get(
"/projects/" + TEST_PROJECT + "/models/*/bioEntities:search?query=s1");
"/projects/{projectId}/models/{mapId}/bioEntities:search?query=p1", TEST_PROJECT, "*");
mockMvc.perform(request)
.andDo(document("projects/project_maps/search_by_query",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier")),
getSearchParameters(),
listSearchResults()))
.andExpect(status().is2xxSuccessful());
}
......@@ -469,6 +511,25 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
.andExpect(status().isNotFound());
}
@Test
public void testSuggestedQueryList() throws Exception {
MockHttpSession session = createSession(ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_LOGIN,
ControllerIntegrationTest.BUILT_IN_TEST_ADMIN_PASSWORD);
RequestBuilder request = get("/projects/{projectId}/models/{mapId}/bioEntities/suggestedQueryList", TEST_PROJECT,
"*").session(session);
mockMvc.perform(request)
.andDo(document("projects/project_maps/suggested_query_list",
pathParameters(parameterWithName("projectId").description("project identifier"),
parameterWithName("mapId").description("map identifier")),
responseFields(
fieldWithPath("[]")
.description("list of all full search queries that could be used for quering the map")
.type("Array<String>"))))
.andExpect(status().is2xxSuccessful());
}
@Test
public void testGetMapById() throws Exception {
userService.grantUserPrivilege(anonymous, PrivilegeType.READ_PROJECT, project.getProjectId());
......
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