use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class DbXrefController method findAllXrefs.
@ApiMethod(path = "/rdf/xrefs", verb = ApiVerb.GET, description = "Exports list of xrefs", produces = { "text/turtle" })
@RequestMapping("/rdf/xrefs")
public void findAllXrefs(Model model, HttpServletResponse response, HttpServletRequest request) throws Exception {
// too many data, memory errors... should stream rather than list...
List<Long> ids = this.xrService.getAllDbXrefsIds();
// for (Long id : ids) System.out.println("fulllist - id: " + id);
int idx = 0;
int bunchSize = 100000;
int bunchCount = 0;
NextprotMediaType format = getRequestedFormat(request);
String fileName = "nextprot-xrefs" + "." + format.getExtension();
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
View v = viewResolver.resolveViewName("prefix", Locale.ENGLISH);
v.render(model.asMap(), request, response);
while (true) {
bunchCount++;
int idx2 = idx + bunchSize;
if (idx2 > ids.size())
idx2 = ids.size();
System.out.println("bunch: " + bunchCount + " - indices: " + idx + " - " + idx2);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// do the job
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
List<Long> someIds = ids.subList(idx, idx2);
List<DbXref> refs = this.xrService.findDbXRefByIds(someIds);
model.addAttribute("bunch", bunchCount);
model.addAttribute("xrefIds", refs);
model.addAttribute("StringUtils", StringUtils.class);
v = viewResolver.resolveViewName("xref-all", Locale.ENGLISH);
v.render(model.asMap(), request, response);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - -
idx = idx2;
if (idx == ids.size())
break;
}
}
use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class RdfPublicationController method findOnePublicationByMd5.
@ApiMethod(path = "/rdf/publication/{md5}", verb = ApiVerb.GET, description = "Exports one neXtProt publication.", produces = { "text/turtle" })
@RequestMapping("/rdf/publication/{md5}")
public String findOnePublicationByMd5(@ApiPathParam(name = "md5", description = "The md5 of the publication", allowedvalues = { "b240aea6411ebd3cc49099009359df1f" }) @PathVariable("md5") String md5, Model model) {
Publication publication = publicationService.findPublicationByMD5(md5);
model.addAttribute("publication", publication);
model.addAttribute("prefix", true);
model.addAttribute("StringUtils", StringUtils.class);
model.addAttribute("isLargeScale", publicationService.getPublicationStatistics(publication.getPublicationId()).isLargeScale());
return "publication";
}
use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class ChromosomeReportController method exportChromosomeEntryCountByProteinEvidenceFile.
@ApiMethod(path = "/chromosome-report/export/hpp/entry-count-by-pe", verb = ApiVerb.GET, description = "Export number of entries grouped by protein existence for all chromosomes", produces = { NextprotMediaType.TSV_MEDIATYPE_VALUE })
@RequestMapping(value = "/chromosome-report/export/hpp/entry-count-by-pe", method = { RequestMethod.GET })
public void exportChromosomeEntryCountByProteinEvidenceFile(HttpServletResponse response) {
try (OutputStream os = response.getOutputStream()) {
response.setHeader("Content-Disposition", "attachment; filename=\"count-of-pe12345-by-chromosome.tsv\"");
chromosomeReportExportService.exportHPPChromosomeEntryReportCountByProteinExistence(os);
} catch (IOException e) {
throw new NextProtException(e.getMessage() + ": cannot export entry count by protein existence for all chromosomes");
}
}
use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class ChromosomeReportController method exportHPPChromosomeEntriesReportFile.
@ApiMethod(path = "/chromosome-report/export/hpp/{chromosome}", verb = ApiVerb.GET, description = "Export informations of neXtProt entries located on a given chromosome by accession", produces = { MediaType.TEXT_PLAIN_VALUE, NextprotMediaType.TSV_MEDIATYPE_VALUE })
@RequestMapping(value = "/chromosome-report/export/hpp/{chromosome}", method = { RequestMethod.GET })
public void exportHPPChromosomeEntriesReportFile(@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 = "HPP_chromosome_" + chromosome + "." + mediaType.getExtension();
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
chromosomeReportExportService.exportHPPChromosomeEntryReport(chromosome, NextprotMediaType.valueOf(request), os);
} catch (IOException e) {
throw new NextProtException(e.getMessage() + ": cannot export HPP chromosome " + chromosome + " as " + mediaType);
}
}
use of org.jsondoc.core.annotation.ApiMethod in project nextprot-api by calipho-sib.
the class TermController method getAncestorGraph.
@ApiMethod(path = "/term/{term}/ancestor-graph", verb = ApiVerb.GET, description = "Get the ancestor graph of the given term", produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/term/{term}/ancestor-graph", method = { RequestMethod.GET }, produces = MediaType.APPLICATION_JSON_VALUE)
public Map<String, CvTermGraph.View> getAncestorGraph(@ApiPathParam(name = "term", description = "The accession of the cv term", allowedvalues = { "TS-0079" }) @PathVariable("term") String term) {
CvTerm cvTerm = terminologyService.findCvTermByAccession(term);
CvTermGraph graph = cvTermGraphService.findCvTermGraph(TerminologyCv.getTerminologyOf(cvTerm.getOntology()));
return Collections.singletonMap("ancestor-graph", graph.calcAncestorSubgraph(cvTerm.getId().intValue()).toView());
}
Aggregations