Search in sources :

Example 66 with NextProtException

use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.

the class ExportController method exportAllEntryProteinExistencess.

@RequestMapping(value = "/export/entry/all/protein-existences", method = { RequestMethod.GET }, produces = { NextprotMediaType.TSV_MEDIATYPE_VALUE })
public void exportAllEntryProteinExistencess(HttpServletResponse response) {
    try {
        EntryProteinExistenceReportWriter writer = new EntryProteinExistenceReportTSVWriter(response.getOutputStream());
        masterIdentifierService.findUniqueNames().forEach(entryAccession -> writer.write(entryAccession, overviewService.findOverviewByEntry(entryAccession).getProteinExistences()));
        writer.close();
    } catch (IOException e) {
        throw new NextProtException("cannot export all entries in TSV format", e);
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) EntryProteinExistenceReportTSVWriter(org.nextprot.api.core.service.export.io.EntryProteinExistenceReportTSVWriter) EntryProteinExistenceReportWriter(org.nextprot.api.core.service.export.EntryProteinExistenceReportWriter) IOException(java.io.IOException)

Example 67 with NextProtException

use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.

the class GitHubServiceImpl method getTree.

@Override
@Cacheable(value = "github-tree")
public GHTree getTree() {
    try {
        GitHub github = getGitHubConnection();
        GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
        return repo.getTreeRecursive(githubDocBranch, 1);
    } catch (IOException e) {
        e.printStackTrace();
        throw new NextProtException("Documentation not available, sorry for the inconvenience");
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) GHRepository(org.kohsuke.github.GHRepository) GitHub(org.kohsuke.github.GitHub) IOException(java.io.IOException) Cacheable(org.springframework.cache.annotation.Cacheable)

Example 68 with NextProtException

use of org.nextprot.api.commons.exception.NextProtException in project nextprot-api by calipho-sib.

the class GitHubServiceImpl method getPage.

@Override
@Cacheable(value = "github-pages")
public String getPage(String folder, String page) {
    String finalPage = page;
    if ("news".equalsIgnoreCase(folder)) {
        finalPage = getCorrespondingPageForNews(page);
    }
    try {
        GitHub github = getGitHubConnection();
        GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
        GHContent content = null;
        String extension = ".md";
        if (folder.contains("json")) {
            // if folder contains json
            extension = ".json";
        }
        content = repo.getFileContent(folder + "/" + finalPage + extension, githubDocBranch);
        return content.getContent();
    } catch (IOException e) {
        e.printStackTrace();
        throw new NextProtException("Documentation not available, sorry for the inconvenience");
    }
}
Also used : NextProtException(org.nextprot.api.commons.exception.NextProtException) GHRepository(org.kohsuke.github.GHRepository) GitHub(org.kohsuke.github.GitHub) GHContent(org.kohsuke.github.GHContent) IOException(java.io.IOException) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

NextProtException (org.nextprot.api.commons.exception.NextProtException)68 IOException (java.io.IOException)30 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 ApiMethod (org.jsondoc.core.annotation.ApiMethod)8 OutputStream (java.io.OutputStream)7 NamedParameterJdbcTemplate (org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate)7 Cacheable (org.springframework.cache.annotation.Cacheable)6 Isoform (org.nextprot.api.core.domain.Isoform)5 SolrServerException (org.apache.solr.client.solrj.SolrServerException)4 Annotation (org.nextprot.api.core.domain.annotation.Annotation)4 NextprotMediaType (org.nextprot.api.core.service.export.format.NextprotMediaType)4 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)4 java.util (java.util)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 CvTerm (org.nextprot.api.core.domain.CvTerm)3 AnnotationVariant (org.nextprot.api.core.domain.annotation.AnnotationVariant)3 Query (org.nextprot.api.solr.Query)3 SearchResult (org.nextprot.api.solr.SearchResult)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2