-/**
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
*
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
*/
package jalview.ws.dbsources.das.datamodel;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
private Hashtable<String, jalviewSourceI> localSources = null;
- public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das1/sources/";
+ public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das/";
/**
* true if thread is running and we are talking to DAS registry service
DEFAULT_REGISTRY);
registry = DEFAULT_REGISTRY;
}
+ if (registry.lastIndexOf("sources.xml") == registry.length() - 11)
+ {
+ // no trailing sources.xml document for registry in JDAS
+ jalview.bin.Cache.setProperty(
+ jalview.bin.Cache.DAS_REGISTRY_URL,
+ registry = registry.substring(0,
+ registry.lastIndexOf("sources.xml")));
+ }
return registry;
}
private List<jalviewSourceI> getDASSources()
{
- return getDASSources(getDasRegistryURL());
+ return getDASSources(getDasRegistryURL(), this);
}
/**
* @param registryURL
* return sources from registryURL
*/
- private static List<jalviewSourceI> getDASSources(String registryURL)
+ private static List<jalviewSourceI> getDASSources(String registryURL,
+ MultipleConnectionPropertyProviderI registry)
{
try
{
URL url = new URL(registryURL);
org.biodas.jdas.client.SourcesClientInterface client = new SourcesClient();
- SOURCES sources = client.fetchDataRegistry(registryURL, null, null, null, null, null, null);
+ SOURCES sources = client.fetchDataRegistry(registryURL, null, null,
+ null, null, null, null);
List<SOURCE> dassources = sources.getSOURCE();
ArrayList<jalviewSourceI> dsrc = new ArrayList<jalviewSourceI>();
+ HashMap<String, Integer> latests = new HashMap<String, Integer>();
+ Integer latest;
for (SOURCE src : dassources)
{
- dsrc.add(new JalviewSource(src, false));
+ JalviewSource jsrc = new JalviewSource(src, registry, false);
+ latest = latests.get(jsrc.getSourceURL());
+ if (latest != null)
+ {
+ if (jsrc.isNewerThan(dsrc.get(latest.intValue())))
+ {
+ dsrc.set(latest.intValue(), jsrc);
+ }
+ else
+ {
+ System.out.println("Debug: Ignored older source "
+ + jsrc.getTitle());
+ }
+ }
+ else
+ {
+ latests.put(jsrc.getSourceURL(), Integer.valueOf(dsrc.size()));
+ dsrc.add(jsrc);
+ }
}
return dsrc;
} catch (Exception ex)
}
}
-
public void run()
{
getSources();
*/
private void addLocalDasSources()
{
- String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE");
- if (local != null)
+ if (localSources == null)
{
- StringTokenizer st = new StringTokenizer(local, "\t");
- while (st.hasMoreTokens())
+ // get local sources from properties and initialise the local source list
+ String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE");
+ if (local != null)
{
- String token = st.nextToken();
- int bar = token.indexOf("|");
- String url = token.substring(bar + 1);
- boolean features = true, sequence = false;
- if (url.startsWith("sequence:"))
+ StringTokenizer st = new StringTokenizer(local, "\t");
+ while (st.hasMoreTokens())
{
- url = url.substring(9);
- // this source also serves sequences as well as features
- sequence = true;
+ String token = st.nextToken();
+ int bar = token.indexOf("|");
+ String url = token.substring(bar + 1);
+ boolean features = true, sequence = false;
+ if (url.startsWith("sequence:"))
+ {
+ url = url.substring(9);
+ // this source also serves sequences as well as features
+ sequence = true;
+ }
+ createLocalSource(url, token.substring(0, bar), sequence,
+ features);
}
- createLocalSource(url, token.substring(0, bar), sequence, features);
}
}
}
private List<jalviewSourceI> appendLocalSources()
{
- List<jalviewSourceI> srclist=new ArrayList<jalviewSourceI>();
+ List<jalviewSourceI> srclist = new ArrayList<jalviewSourceI>();
addLocalDasSources();
sourceNames = new Hashtable<String, jalviewSourceI>();
if (dasSources != null)
{
localSources = new Hashtable<String, jalviewSourceI>();
}
- jalviewSourceI src=new JalviewSource(local, true);
+ jalviewSourceI src = new JalviewSource(local, this, true);
localSources.put(local.getTitle(), src);
return src;
}
*/
CAPABILITY cap = new CAPABILITY();
cap.setType("das1:" + Capabilities.SEQUENCE.getName());
- cap.setQueryUri(url+"/sequence");
+ cap.setQueryUri(url + "/sequence");
cp.add(cap);
}
if (features)
{
CAPABILITY cap = new CAPABILITY();
cap.setType("das1:" + Capabilities.FEATURES.getName());
- cap.setQueryUri(url+"/features");
+ cap.setQueryUri(url + "/features");
cp.add(cap);
}
localSources.remove(source.getTitle());
sourceNames.remove(source.getTitle());
dasSources.remove(source);
+ jalview.bin.Cache.setProperty("DAS_LOCAL_SOURCE",
+ getLocalSourceString());
+
return true;
}
return false;