Skip to content

Commit

Permalink
Hide redundant end points. Merge Variant and Variation. Default limit…
Browse files Browse the repository at this point in the history
… is 10 and default skip is 0. CamelCase instead of snake_case. #522
  • Loading branch information
julie-sullivan committed Jan 24, 2020
1 parent da745c5 commit c15fc75
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 348 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ public class GenericRestWSServer implements IWSServer {
+ " Please note that this parameter may not be enabled for all web services.")
protected String include;

@DefaultValue("-1")
@DefaultValue("10")
@QueryParam("limit")
@ApiParam(name = "limit", value = "Max number of results to be returned. No limit applied when -1."
@ApiParam(name = "limit", value = "Max number of results to be returned. Cannot exceed 5,000."
+ " Please note that this option may not be available for all web services.")
protected int limit;

@DefaultValue("-1")
@DefaultValue("0")
@QueryParam("skip")
@ApiParam(name = "skip", value = "Number of results to be skipped. No skip applied when -1. "
@ApiParam(name = "skip", value = "Number of results to be skipped. No skip applied when 0. "
+ " Please note that this option may not be available for all web services.")
protected int skip;

Expand Down Expand Up @@ -252,7 +252,7 @@ private void checkPathParams(boolean checkSpecies) throws VersionException, Spec
}

@Override
public void parseQueryParams() {
public void parseQueryParams() throws CellbaseException {
MultivaluedMap<String, String> multivaluedMap = uriInfo.getQueryParameters();

queryOptions.put("metadata", multivaluedMap.get("metadata") == null || multivaluedMap.get("metadata").get(0).equals("true"));
Expand All @@ -276,9 +276,18 @@ public void parseQueryParams() {
queryOptions.put(QueryOptions.SORT, sort);
}

queryOptions.put(QueryOptions.LIMIT, (limit > 0) ? Math.min(limit, LIMIT_MAX) : LIMIT_DEFAULT);
queryOptions.put(QueryOptions.SKIP, (skip >= 0) ? skip : -1);
// queryOptions.put(QueryOptions.SKIP_COUNT, StringUtils.isNotBlank(skipCount) && Boolean.parseBoolean(skipCount));
if (limit < 0) {
throw new CellbaseException("Limit is not valid. Expected a number greater than zero but was " + limit);
} else if (limit > LIMIT_MAX) {
throw new CellbaseException("Limit is not valid. Expected a number less than " + LIMIT_MAX + " but was " + limit);
}

if (skip < 0) {
throw new CellbaseException("Skip is not valid. Expected a number greater than zero but was " + skip);
}

queryOptions.put(QueryOptions.LIMIT, limit);
queryOptions.put(QueryOptions.SKIP, skip);
queryOptions.put(QueryOptions.COUNT, StringUtils.isNotBlank(count) && Boolean.parseBoolean(count));

// Add all the others QueryParams from the URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

package org.opencb.cellbase.server.rest;

import org.opencb.cellbase.core.exception.CellbaseException;

import javax.ws.rs.core.Response;

public interface IWSServer {


void parseQueryParams();
void parseQueryParams() throws CellbaseException;

default Response first() {
default Response first() throws Exception {
return Response.ok("No implemented yet").build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public Response getAll() {
}

@GET
@Path("/variant/allele_origin_labels")
@Path("/variant/alleleOriginLabels")
@ApiOperation(httpMethod = "GET", notes = "",
value = "Retrieves all available allele origin labels", response = Variant.class,
responseContainer = "QueryResponse")
Expand All @@ -143,7 +143,7 @@ public Response getAlleleOriginLabels() {
}

@GET
@Path("/variant/mode_inheritance_labels")
@Path("/variant/modeInheritanceLabels")
@ApiOperation(httpMethod = "GET", notes = "",
value = "Retrieves all available mode of inheritance labels", response = Variant.class,
responseContainer = "QueryResponse")
Expand All @@ -158,7 +158,7 @@ public Response getModeInheritanceLabels() {
}

@GET
@Path("/variant/clinsig_labels")
@Path("/variant/clinsigLabels")
@ApiOperation(httpMethod = "GET", notes = "",
value = "Retrieves all available clinical significance labels", response = Variant.class,
responseContainer = "QueryResponse")
Expand All @@ -173,7 +173,7 @@ public Response getClinicalSignificanceLabels() {
}

@GET
@Path("/variant/consistency_labels")
@Path("/variant/consistencyLabels")
@ApiOperation(httpMethod = "GET", notes = "",
value = "Retrieves all available consistency labels", response = Variant.class,
responseContainer = "QueryResponse")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Response getModel() {
@Override
@Deprecated
@ApiOperation(httpMethod = "GET", value = "Get the first object in the database", response = Gene.class,
responseContainer = "QueryResponse")
responseContainer = "QueryResponse", hidden = true)
public Response first() {
GeneDBAdaptor geneDBAdaptor = dbAdaptorFactory.getGeneDBAdaptor(this.species, this.assembly);
return createOkResponse(geneDBAdaptor.first(queryOptions));
Expand All @@ -86,7 +86,7 @@ public Response first() {
@Path("/count")
@Deprecated
@ApiOperation(httpMethod = "GET", value = "Get the number of genes in the database", response = Integer.class,
responseContainer = "QueryResponse")
responseContainer = "QueryResponse", hidden = true)
@ApiImplicitParams({
@ApiImplicitParam(name = "region",
value = "Comma separated list of genomic regions to be queried, e.g.: 1:6635137-6635325",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public Response getAllXrefsByFeatureId(@PathParam("id")
}

@GET
@Path("/{id}/starts_with")
@Path("/{id}/startsWith")
@ApiOperation(httpMethod = "GET", value = "Get the gene HGNC symbols of genes for which there is an Xref id that "
+ "matches the beginning of the given string", response = Map.class, responseContainer = "QueryResponse")
public Response getByLikeQuery(@PathParam("id")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public Response getAll() {
}

@GET
@Path("/{proteinId}/substitution_scores")
@Path("/{proteinId}/substitutionScores")
@ApiOperation(httpMethod = "GET", value = "Get the gene corresponding substitution scores for the input protein",
notes = "Schema of returned objects will vary depending on provided query parameters. If the amino acid "
+ " position is provided, all scores will be returned for every possible amino acid"
Expand All @@ -161,7 +161,6 @@ public Response getSubstitutionScores(@PathParam("proteinId")
required = true) String id) {
try {
parseQueryParams();
// query.put(ProteinDBAdaptor.QueryParams.XREFS.key(), id);

// Fetch Ensembl transcriptId to query substiturion scores
TranscriptDBAdaptor transcriptDBAdaptor = dbAdaptorFactory.getTranscriptDBAdaptor(this.species, this.assembly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public Response getModel() {
@Override
@Deprecated
@ApiOperation(httpMethod = "GET", value = "Get the first transcript in the database", response = Transcript.class,
responseContainer = "QueryResponse")
public Response first() {
responseContainer = "QueryResponse", hidden = true)
public Response first() throws Exception {
parseQueryParams();
TranscriptDBAdaptor transcriptDBAdaptor = dbAdaptorFactory.getTranscriptDBAdaptor(this.species, this.assembly);
return createOkResponse(transcriptDBAdaptor.first(queryOptions));
Expand All @@ -88,7 +88,7 @@ public Response first() {
@Path("/count")
@Deprecated
@ApiOperation(httpMethod = "GET", value = "Get the number of transcripts in the database", response = Integer.class,
responseContainer = "QueryResponse")
responseContainer = "QueryResponse", hidden = true)
public Response count(@DefaultValue("")
@QueryParam("region")
@ApiParam(name = "region",
Expand Down Expand Up @@ -315,7 +315,7 @@ public Response getProtein(@PathParam("transcriptId")
}

@GET
@Path("/{transcriptId}/function_prediction")
@Path("/{transcriptId}/functionPrediction")
@ApiOperation(httpMethod = "GET", value = "Get the gene corresponding substitution scores for the protein of a"
+ " certain transcript",
notes = "Schema of returned objects will vary depending on provided query parameters. If the amino acid "
Expand Down
Loading

0 comments on commit c15fc75

Please sign in to comment.