Search in sources :

Example 1 with EnsemblReleaseJson

use of uk.ac.ebi.spot.goci.model.EnsemblReleaseJson in project goci by EBISPOT.

the class EnsemblRelease method getReleaseVersion.

/**
     * Getter for the release version
     *
     * @return the numeric release version
     */
public int getReleaseVersion() throws EnsemblRestIOException {
    RestTemplate restTemplate = new RestTemplate();
    String url = getServer() + getEndpoint();
    int currentEnsemblRelease = 0;
    try {
        EnsemblReleaseJson ensemblReleaseJson = restTemplate.getForObject(url, EnsemblReleaseJson.class);
        getLog().info("Querying " + url);
        int[] releases = ensemblReleaseJson.getReleases();
        if (releases != null) {
            if (releases.length == 1) {
                currentEnsemblRelease = releases[0];
            } else {
                throw new EnsemblRestIOException("Unable to determine Ensembl release");
            }
        } else {
            throw new EnsemblRestIOException("No Ensembl release information returned from API");
        }
    } catch (Exception e) {
        throw new EnsemblRestIOException("Problem querying Ensembl API for release");
    }
    return currentEnsemblRelease;
}
Also used : RestTemplate(org.springframework.web.client.RestTemplate) EnsemblRestIOException(uk.ac.ebi.spot.goci.exception.EnsemblRestIOException) EnsemblRestIOException(uk.ac.ebi.spot.goci.exception.EnsemblRestIOException) EnsemblReleaseJson(uk.ac.ebi.spot.goci.model.EnsemblReleaseJson)

Aggregations

RestTemplate (org.springframework.web.client.RestTemplate)1 EnsemblRestIOException (uk.ac.ebi.spot.goci.exception.EnsemblRestIOException)1 EnsemblReleaseJson (uk.ac.ebi.spot.goci.model.EnsemblReleaseJson)1