Search in sources :

Example 6 with ApiMethod

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);
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) SlimIsoformTSVWriter(org.nextprot.api.core.service.export.io.SlimIsoformTSVWriter) NextprotMediaType(org.nextprot.api.core.service.export.format.NextprotMediaType) IOException(java.io.IOException) JSONObjectsWriter(org.nextprot.api.web.service.impl.writer.JSONObjectsWriter) ApiMethod(org.jsondoc.core.annotation.ApiMethod)

Example 7 with ApiMethod

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;
}
Also used : SearchQueryException(org.nextprot.api.commons.exception.SearchQueryException) NextProtException(org.nextprot.api.commons.exception.NextProtException) QueryRequest(org.nextprot.api.solr.QueryRequest) Query(org.nextprot.api.solr.Query) SearchResult(org.nextprot.api.solr.SearchResult) ApiMethod(org.jsondoc.core.annotation.ApiMethod)

Example 8 with ApiMethod

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);
}
Also used : UserProteinList(org.nextprot.api.user.domain.UserProteinList) ApiMethod(org.jsondoc.core.annotation.ApiMethod)

Example 9 with ApiMethod

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);
}
Also used : UserProteinList(org.nextprot.api.user.domain.UserProteinList) ApiMethod(org.jsondoc.core.annotation.ApiMethod)

Example 10 with ApiMethod

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);
}
Also used : UserQuery(org.nextprot.api.user.domain.UserQuery) ApiMethod(org.jsondoc.core.annotation.ApiMethod)

Aggregations

ApiMethod (org.jsondoc.core.annotation.ApiMethod)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 NextProtException (org.nextprot.api.commons.exception.NextProtException)8 IOException (java.io.IOException)7 OutputStream (java.io.OutputStream)6 NextprotMediaType (org.nextprot.api.core.service.export.format.NextprotMediaType)4 CvTerm (org.nextprot.api.core.domain.CvTerm)2 CvTermGraph (org.nextprot.api.core.domain.CvTermGraph)2 UserProteinList (org.nextprot.api.user.domain.UserProteinList)2 UserQuery (org.nextprot.api.user.domain.UserQuery)2 SearchQueryException (org.nextprot.api.commons.exception.SearchQueryException)1 DbXref (org.nextprot.api.core.domain.DbXref)1 Publication (org.nextprot.api.core.domain.Publication)1 SlimIsoformTSVWriter (org.nextprot.api.core.service.export.io.SlimIsoformTSVWriter)1 Query (org.nextprot.api.solr.Query)1 QueryRequest (org.nextprot.api.solr.QueryRequest)1 SearchResult (org.nextprot.api.solr.SearchResult)1 JSONObjectsWriter (org.nextprot.api.web.service.impl.writer.JSONObjectsWriter)1 View (org.springframework.web.servlet.View)1