X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fensembl%2FEnsemblInfo.java;h=97ad242e0795ee66d0a5d65ae6f287d36d7817f8;hb=564c47bdd60cf84046269e45d2f85f39408e4441;hp=31081944b8d94394d50253a65224b3ceda35b3ab;hpb=604cbee405a837565ba1a74aa9bddd62aed685ab;p=jalview.git
diff --git a/src/jalview/ext/ensembl/EnsemblInfo.java b/src/jalview/ext/ensembl/EnsemblInfo.java
index 3108194..97ad242 100644
--- a/src/jalview/ext/ensembl/EnsemblInfo.java
+++ b/src/jalview/ext/ensembl/EnsemblInfo.java
@@ -20,72 +20,136 @@
*/
package jalview.ext.ensembl;
-/**
- * A data class to model the data and rest version of one Ensembl domain,
- * currently for rest.ensembl.org and rest.ensemblgenomes.org
- *
- * @author gmcarstairs
- */
-class EnsemblInfo
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefSource;
+import jalview.util.JSONUtils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.json.simple.parser.ParseException;
+
+public class EnsemblInfo extends EnsemblRestClient
{
- /*
- * The http domain this object is holding data values for
- */
- String domain;
/*
- * The latest version Jalview has tested for, e.g. "4.5"; a minor version change should be
- * ok, a major version change may break stuff
+ * cached results of REST /info/divisions service, currently
+ *
+ * The values for EnsemblGenomes are retrieved by a REST call, that for
+ * Ensembl is added programmatically for convenience of lookup
*/
- String expectedRestVersion;
+ private static Map divisions;
- /*
- * Major / minor / point version e.g. "4.5.1"
- * @see http://rest.ensembl.org/info/rest/?content-type=application/json
- */
- String restVersion;
+ @Override
+ public String getDbName()
+ {
+ return "ENSEMBL";
+ }
- /*
- * data version
- * @see http://rest.ensembl.org/info/data/?content-type=application/json
- */
- String dataVersion;
+ @Override
+ public AlignmentI getSequenceRecords(String queries) throws Exception
+ {
+ return null;
+ }
- /*
- * true when http://rest.ensembl.org/info/ping/?content-type=application/json
- * returns response code 200 and not {"error":"Database is unavailable"}
- */
- boolean restAvailable;
+ @Override
+ protected URL getUrl(List ids) throws MalformedURLException
+ {
+ return null;
+ }
- /*
- * absolute time when availability was last checked
- */
- long lastAvailableCheckTime;
+ @Override
+ protected boolean useGetRequest()
+ {
+ return true;
+ }
- /*
- * absolute time when version numbers were last checked
+ /**
+ * Answers the domain (http://rest.ensembl.org or
+ * http://rest.ensemblgenomes.org) for the given division, or null if not
+ * recognised by Ensembl.
+ *
+ * @param division
+ * @return
*/
- long lastVersionCheckTime;
-
- // flag set to true if REST major version is not the one expected
- boolean restMajorVersionMismatch;
+ public String getDomain(String division)
+ {
+ if (divisions == null)
+ {
+ fetchDivisions();
+ }
+ return divisions.get(division.toUpperCase());
+ }
- /*
- * absolute time to wait till if we overloaded the REST service
+ /**
+ * On first request only, populate the lookup map by fetching the list of
+ * divisions known to EnsemblGenomes.
*/
- long retryAfter;
+ void fetchDivisions()
+ {
+ divisions = new HashMap<>();
+
+ /*
+ * for convenience, pre-fill ensembl.org as the domain for "ENSEMBL"
+ */
+ divisions.put(DBRefSource.ENSEMBL.toUpperCase(), ensemblDomain);
+ try
+ {
+ @SuppressWarnings("unchecked")
+ Iterator