use of org.nextprot.api.web.service.impl.writer.JSONObjectsWriter 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.nextprot.api.web.service.impl.writer.JSONObjectsWriter in project nextprot-api by calipho-sib.
the class EntryAccessionController method writeEntries.
private void writeEntries(Collection<String> entries, NextprotMediaType mediaType, HttpServletResponse response) throws IOException {
if (mediaType == NextprotMediaType.JSON) {
JSONObjectsWriter<String> writer = new JSONObjectsWriter<>(response.getOutputStream());
writer.write(entries);
} else if (mediaType == NextprotMediaType.TXT) {
PrintWriter writer = new PrintWriter(response.getOutputStream());
entries.forEach(entryAccession -> {
writer.write(entryAccession);
writer.write("\n");
});
writer.close();
}
}
Aggregations