use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class EntryController method getListOfIsoformAcMd5Sequence.
@ApiMethod(path = "/isoforms", verb = ApiVerb.GET, description = "Retrieves all isoforms", produces = { MediaType.APPLICATION_JSON_VALUE, NextprotMediaType.TSV_MEDIATYPE_VALUE })
@RequestMapping(value = "/isoforms", method = { RequestMethod.GET }, produces = { MediaType.APPLICATION_JSON_VALUE, NextprotMediaType.TSV_MEDIATYPE_VALUE })
public void getListOfIsoformAcMd5Sequence(HttpServletRequest request, HttpServletResponse response) {
NextprotMediaType mediaType = NextprotMediaType.valueOf(request);
try {
List<SlimIsoform> isoforms = isoformService.findListOfIsoformAcMd5Sequence();
if (mediaType == NextprotMediaType.JSON) {
JSONObjectsWriter<SlimIsoform> writer = new JSONObjectsWriter<>(response.getOutputStream());
writer.write(isoforms);
} else if (mediaType == NextprotMediaType.TSV) {
SlimIsoformTSVWriter writer = new SlimIsoformTSVWriter(response.getOutputStream());
writer.write(isoforms);
writer.close();
}
} catch (IOException e) {
throw new NextProtException("cannot get isoforms in " + mediaType.getExtension() + " format", e);
}
}
use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class EntryPublicationController method getEntryPublicationsByPubId.
@ApiMethod(path = "/entry-publications/pubid/{pubid}", verb = ApiVerb.GET, description = "Exports identified publication associated with neXtProt entries", produces = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/entry-publications/pubid/{pubid}", method = { RequestMethod.GET })
@ResponseBody
public PublicationView getEntryPublicationsByPubId(@ApiPathParam(name = "pubid", description = "A publication id", allowedvalues = { "630194" }) @PathVariable("pubid") long publicationId, @ApiQueryParam(name = "limit", description = "The maximum number of returned results", allowedvalues = { "500" }) @RequestParam(value = "limit", required = false) String limit) {
List<EntryPublication> eps = publicationService.getEntryPublications(publicationId);
QueryRequest qr = new QueryRequest();
qr.setQuality("gold");
qr.setRows((limit != null) ? limit : "500");
PublicationView view = new PublicationView();
view.setPublication(publicationService.findPublicationById(publicationId));
// return the n first results
view.addEntryPublicationList(eps.stream().limit(Integer.parseInt(qr.getRows())).collect(Collectors.toList()));
qr.setEntryAccessionSet(view.getEntryPublicationMap().keySet());
Query q = queryBuilderService.buildQueryForSearch(qr, "entry");
try {
SearchResult searchResult = solrService.executeQuery(q);
view.setRelatedEntryCount(eps.size());
searchResult.getResults().forEach(result -> view.putEntrySolrResult(result));
} catch (SearchQueryException e) {
throw new NextProtException(e.getMessage());
}
return view;
}
use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class UserProteinListController method deleteUserProteinList.
// Delete a list
@ApiMethod(verb = ApiVerb.DELETE, description = "Deletes a user protein list for the current logged user", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/user/me/lists/{listid}", method = { RequestMethod.DELETE })
public void deleteUserProteinList(@PathVariable("listid") String id) {
UserProteinList userProteinList = proteinListService.getUserProteinListById(Long.parseLong(id));
this.proteinListService.deleteUserProteinList(userProteinList);
}
use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class UserProteinListController method uploadProteinList.
@ApiMethod(path = "/user/me/lists/{listid}/upload", verb = ApiVerb.POST, description = "Uploads a user protein list for the current logged user", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/user/me/lists/{listid}/upload", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
public void uploadProteinList(@RequestParam("file") MultipartFile file, @PathVariable(value = "listid") long listId, @RequestParam(value = "ignoreNotFoundEntries", defaultValue = "false") boolean ignoreNotFoundEntries) throws IOException {
UserProteinList pl = proteinListService.getUserProteinListById(listId);
Set<String> acs = UserProteinListUtils.parseAccessionNumbers(file, masterIdentifierService.findUniqueNames(), ignoreNotFoundEntries);
pl.addAccessions(acs);
this.proteinListService.updateUserProteinList(pl);
}
use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class UserQueryController method deleteUserQuery.
// DELETE
@ApiMethod(verb = ApiVerb.DELETE, description = "Deletes an advanced query for the current logged user", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaType.APPLICATION_JSON_VALUE })
@RequestMapping(value = "/user/me/queries/{id}", method = { RequestMethod.DELETE })
public void deleteUserQuery(@PathVariable("id") String id, Model model) {
// Never trust what the users sends to you! Send the query with the correct username, so it will be verified by the service,
// TODO Is this done on the aspect
UserQuery q = userQueryService.getUserQueryById(Long.parseLong(id));
userQueryService.deleteUserQuery(q);
}
Aggregations