Search in sources :

Example 1 with ApiMethod

use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.

the class ChromosomeReportController method exportChromosomeEntryWithUnconfirmedMsData.

@ApiMethod(path = "/chromosome-report/export/hpp/unconfirmed-ms-data-entries", verb = ApiVerb.GET, description = "Export list of unconfirmed MS data protein entries", produces = { MediaType.TEXT_PLAIN_VALUE })
@RequestMapping(value = "/chromosome-report/export/hpp/unconfirmed-ms-data-entries", method = { RequestMethod.GET })
public void exportChromosomeEntryWithUnconfirmedMsData(HttpServletResponse response) {
    try (OutputStream os = response.getOutputStream()) {
        response.setHeader("Content-Disposition", "attachment; filename=\"HPP_entries_with_unconfirmed_MS_data.txt\"");
        chromosomeReportExportService.exportUnconfirmedMsEntries(os);
    } catch (IOException e) {
        throw new NextProtException(e.getMessage() + ": cannot export unconfirmed MS data protein entries");
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) OutputStream(java.io.OutputStream) IOException(java.io.IOException) ApiMethod(org.jsondoc.core.annotation.ApiMethod) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ApiMethod

use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.

the class ChromosomeReportController method exportChromosomeEntryWithNAcetyl.

@ApiMethod(path = "/chromosome-report/export/hpp/nacetylated-entries", verb = ApiVerb.GET, description = "Export list of N-acetylated protein entries", produces = { NextprotMediaType.TSV_MEDIATYPE_VALUE })
@RequestMapping(value = "/chromosome-report/export/hpp/nacetylated-entries", method = { RequestMethod.GET })
public void exportChromosomeEntryWithNAcetyl(HttpServletResponse response) {
    try (OutputStream os = response.getOutputStream()) {
        response.setHeader("Content-Disposition", "attachment; filename=\"HPP_entries_with_nacetyl_by_chromosome.tsv\"");
        chromosomeReportExportService.exportNAcetylatedEntries(os);
    } catch (IOException e) {
        throw new NextProtException(e.getMessage() + ": cannot export N-acetylated protein entries");
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) OutputStream(java.io.OutputStream) IOException(java.io.IOException) ApiMethod(org.jsondoc.core.annotation.ApiMethod) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ApiMethod

use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.

the class ChromosomeReportController method exportChromosomeEntryWithPhospho.

@ApiMethod(path = "/chromosome-report/export/hpp/phosphorylated-entries", verb = ApiVerb.GET, description = "Export list of phosphorylated protein entries", produces = { NextprotMediaType.TSV_MEDIATYPE_VALUE })
@RequestMapping(value = "/chromosome-report/export/hpp/phosphorylated-entries", method = { RequestMethod.GET })
public void exportChromosomeEntryWithPhospho(HttpServletResponse response) {
    try (OutputStream os = response.getOutputStream()) {
        response.setHeader("Content-Disposition", "attachment; filename=\"HPP_entries_with_phospho_by_chromosome.tsv\"");
        chromosomeReportExportService.exportPhosphorylatedEntries(os);
    } catch (IOException e) {
        throw new NextProtException(e.getMessage() + ": cannot export phosphorylated protein entries");
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) OutputStream(java.io.OutputStream) IOException(java.io.IOException) ApiMethod(org.jsondoc.core.annotation.ApiMethod) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with ApiMethod

use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.

the class ChromosomeReportController method exportChromosomeEntriesReportFile.

@ApiMethod(path = "/chromosome-report/export/{chromosome}", verb = ApiVerb.GET, description = "Export informations of neXtProt entries located on a given chromosome", produces = { MediaType.TEXT_PLAIN_VALUE, NextprotMediaType.TSV_MEDIATYPE_VALUE })
@RequestMapping(value = "/chromosome-report/export/{chromosome}", method = { RequestMethod.GET })
public void exportChromosomeEntriesReportFile(@ApiPathParam(name = "chromosome", description = "The chromosome number or name (X,Y..)", allowedvalues = { "Y" }) @PathVariable("chromosome") String chromosome, HttpServletRequest request, HttpServletResponse response) {
    NextprotMediaType mediaType = NextprotMediaType.valueOf(request);
    try (OutputStream os = response.getOutputStream()) {
        String filename = "nextprot_chromosome_" + chromosome + "." + mediaType.getExtension();
        response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
        chromosomeReportExportService.exportChromosomeEntryReport(chromosome, NextprotMediaType.valueOf(request), os);
    } catch (IOException e) {
        throw new NextProtException(e.getMessage() + ": cannot export chromosome " + chromosome + " as " + mediaType);
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) OutputStream(java.io.OutputStream) NextprotMediaType(org.nextprot.api.core.service.export.format.NextprotMediaType) IOException(java.io.IOException) ApiMethod(org.jsondoc.core.annotation.ApiMethod) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with ApiMethod

use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.

the class UserQueryController method updateAdvancedQuery.

// UPDATE
@ApiMethod(path = "/user/me/queries/{id}", verb = ApiVerb.PUT, description = "Updates 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.PUT })
@ResponseBody
public UserQuery updateAdvancedQuery(@PathVariable("id") String id, @RequestBody UserQuery advancedUserQuery, Model model) {
    // Never trust what the users sends to you! Set the correct username, so it will be verified by the service,
    // TODO Is this done on the aspect
    UserQuery q = userQueryService.getUserQueryById(advancedUserQuery.getUserQueryId());
    advancedUserQuery.setOwner(q.getOwner());
    advancedUserQuery.setOwnerId(q.getOwnerId());
    return userQueryService.updateUserQuery(advancedUserQuery);
}
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