Search in sources :

Example 1 with SlimIsoformTSVWriter

use of org.nextprot.api.core.service.export.io.SlimIsoformTSVWriter 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)

Aggregations

IOException (java.io.IOException)1 ApiMethod (org.jsondoc.core.annotation.ApiMethod)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 NextprotMediaType (org.nextprot.api.core.service.export.format.NextprotMediaType)1 SlimIsoformTSVWriter (org.nextprot.api.core.service.export.io.SlimIsoformTSVWriter)1 JSONObjectsWriter (org.nextprot.api.web.service.impl.writer.JSONObjectsWriter)1