*/\r
package jalview.gui;\r
\r
-import java.security.interfaces.DSAKey;\r
import java.text.ParseException;\r
import java.util.*;\r
import java.util.List;\r
import javax.swing.table.*;\r
\r
import org.biodas.jdas.dassources.Capabilities;\r
+import org.biodas.jdas.dassources.utils.DasCoordinateSystemCollector;\r
import org.biodas.jdas.dassources.utils.DasTimeFormat;\r
+import org.biodas.jdas.schema.registrycoordinates.DASCOORDINATESYSTEM;\r
import org.biodas.jdas.schema.sources.CAPABILITY;\r
import org.biodas.jdas.schema.sources.COORDINATES;\r
import org.biodas.jdas.schema.sources.MAINTAINER;\r
{\r
static org.biodas.jdas.schema.sources.SOURCE[] dasSources = null;\r
\r
- Hashtable localSources = null;\r
+ Hashtable<String, SOURCE> localSources = null;\r
\r
Vector selectedSources;\r
\r
+ dasSources[i].getUri() + "<br>");\r
text.append("<font color=\"#0000FF\">Nickname:</font> "\r
+ dasSources[i].getTitle() + "<br>");\r
- text.append("<font color=\"#0000FF\">URL:</font> "\r
- + latest.getUri() + "<br>");\r
+ text.append("<font color=\"#0000FF\">URL:</font> " + latest.getUri()\r
+ + "<br>");\r
\r
text.append("<font color=\"#0000FF\">Admin Email:</font> <a href=\"mailto:"\r
+ ds.getMAINTAINER().getEmail()\r
+ latest.getCreated() + "<br>");\r
\r
// TODO: Identify last successful test date\r
-// text.append("<font color=\"#0000FF\">Last successful test:</font> "\r
-// + latest.dasSources[i].getLeaseDate() + "<br>");\r
+ // text.append("<font color=\"#0000FF\">Last successful test:</font> "\r
+ // + latest.dasSources[i].getLeaseDate() + "<br>");\r
\r
text.append("<font color=\"#0000FF\">Labels:</font> ");\r
- for (int s = 0; s < latest.getPROP().length; s++)\r
+ boolean b = false;\r
+ for (PROP labl : latest.getPROP())\r
{\r
- text.append(dasSources[i].getLabels()[s]);\r
- if (s < dasSources[i].getLabels().length - 1)\r
+ if (labl.getName().equalsIgnoreCase("LABEL"))\r
{\r
- text.append(",");\r
+ if (!b)\r
+ {\r
+ text.append(",");\r
+ }\r
+ text.append(" ");\r
+\r
+ text.append(labl.getValue());\r
+ b = true;\r
}\r
- text.append(" ");\r
+ ;\r
}\r
text.append("<br>");\r
\r
text.append("<br>");\r
\r
text.append("<font color=\"#0000FF\">Coordinates:</font> ");\r
- DasCoordinateSystem[] dcs = ds.getCoordinateSystem();\r
- for (int j = 0; j < dcs.length; j++)\r
+ for (COORDINATES dcs : latest.getCOORDINATES())\r
{\r
- text.append("(" + dcs[j].getUniqueId() + ") "\r
- + dcs[j].getCategory() + ", " + dcs[j].getName());\r
- if (dcs[j].getNCBITaxId() != 0)\r
+ text.append("(" + dcs.getUri() + ") "\r
+\r
+ + dcs.getSource() + ", " + dcs.getAuthority());\r
+ if (dcs.getTaxid() != null && dcs.getTaxid().trim().length() > 0)\r
{\r
- text.append(", " + dcs[j].getNCBITaxId());\r
+ text.append(", " + dcs.getTaxid());\r
}\r
- if (dcs[j].getOrganismName().length() > 0)\r
+ if (dcs.getVersion().trim().length() > 0)\r
{\r
- text.append(", " + dcs[j].getOrganismName());\r
- }\r
+ {\r
+ text.append(", " + dcs.getVersion());\r
+ }\r
\r
- text.append("<br>");\r
- }\r
+ text.append("<br>");\r
+ }\r
\r
- text.append("<font color=\"#0000FF\">Description:</font> "\r
- + dasSources[i].getDescription() + "<br>");\r
+ text.append("<font color=\"#0000FF\">Description:</font> "\r
+ + dasSources[i].getDescription() + "<br>");\r
\r
- if (dasSources[i].getHelperurl() != null\r
- && dasSources[i].getHelperurl().length() > 0)\r
- {\r
- text.append("<font color=\"#0000FF\"><a href=\""\r
- + dasSources[i].getHelperurl()\r
- + "\">Go to site</a></font<br>");\r
- }\r
+ if (dasSources[i].getDocHref() != null\r
+ && dasSources[i].getDocHref().length() > 0)\r
+ {\r
+ text.append("<font color=\"#0000FF\"><a href=\""\r
+ + dasSources[i].getDocHref()\r
+ + "\">Go to site</a></font<br>");\r
+ }\r
\r
- text.append("</font></html>");\r
+ text.append("</font></html>");\r
\r
- break;\r
+ break;\r
+ }\r
}\r
-\r
fullDetails.setText(text.toString());\r
javax.swing.SwingUtilities.invokeLater(new Runnable()\r
{\r
{\r
for (int i = 0; i < dasSources.length; i++)\r
{\r
- if (dasSources[i].getTitle()\r
- .equals(selectedSources.elementAt(r)))\r
+ if (dasSources[i].getTitle().equals(selectedSources.elementAt(r)))\r
{\r
selected.addElement(dasSources[i]);\r
break;\r
\r
private boolean isLaterThan(String ref, String newer)\r
{\r
- Date refdate=null,newdate=null;\r
- try {\r
- refdate=DasTimeFormat.fromDASString(ref);\r
- \r
- }\r
- catch (ParseException x)\r
+ Date refdate = null, newdate = null;\r
+ try\r
+ {\r
+ refdate = DasTimeFormat.fromDASString(ref);\r
+\r
+ } catch (ParseException x)\r
{\r
return false;\r
}\r
- try {\r
+ try\r
+ {\r
newdate = DasTimeFormat.fromDASString(newer);\r
- }\r
- catch (ParseException e) {\r
+ } catch (ParseException e)\r
+ {\r
// TODO: handle exception\r
}\r
- if (refdate!=null)\r
+ if (refdate != null)\r
{\r
- if (newdate!=null)\r
+ if (newdate != null)\r
{\r
return refdate.before(newdate);\r
}\r
return false;\r
}\r
- if (newdate!=null)\r
+ if (newdate != null)\r
{\r
return true;\r
}\r
- // assume first instance of source is newest in list. - TODO: check if natural ordering of source versions is newest first or oldest first\r
+ // assume first instance of source is newest in list. - TODO: check if\r
+ // natural ordering of source versions is newest first or oldest first\r
return false;\r
}\r
+\r
private VERSION getVersionFor(SOURCE ds)\r
{\r
- VERSION latest=null;\r
- for (VERSION v:ds.getVERSION()) {\r
- if (latest==null || isLaterThan(latest.getCreated(),v.getCreated()))\r
+ VERSION latest = null;\r
+ for (VERSION v : ds.getVERSION())\r
+ {\r
+ if (latest == null\r
+ || isLaterThan(latest.getCreated(), v.getCreated()))\r
{\r
- // TODO: das 1.6 - should just get the first version - ignore other versions since not specified how to construct URL from version's URI + source URI\r
- latest=v;\r
+ // TODO: das 1.6 - should just get the first version - ignore other\r
+ // versions since not specified how to construct URL from version's URI\r
+ // + source URI\r
+ latest = v;\r
}\r
}\r
return latest;\r
}\r
+\r
private void setCapabilities(SOURCE[] sources)\r
{\r
Vector<String> authority = new Vector<String>();\r
Vector<String> type = new Vector<String>();\r
Vector<String> label = new Vector<String>();\r
- Vector<String> taxIds=new Vector<String>();\r
+ Vector<String> taxIds = new Vector<String>();\r
authority.add("Any");\r
type.add("Any");\r
label.add("Any");\r
- \r
\r
for (int i = 0; i < sources.length; i++)\r
{\r
SOURCE ds = sources[i];\r
- VERSION latest=getVersionFor(ds);\r
- \r
- for (COORDINATES cs: latest.getCOORDINATES())\r
+ VERSION latest = getVersionFor(ds);\r
+\r
+ for (COORDINATES cs : latest.getCOORDINATES())\r
{\r
if (!type.contains(cs.getSource()))\r
{\r
}\r
}\r
\r
- for (PROP slabel:latest.getPROP())\r
+ for (PROP slabel : latest.getPROP())\r
{\r
- if (slabel.getName().equalsIgnoreCase("LABEL") && !label.contains(slabel.getValue()))\r
+ if (slabel.getName().equalsIgnoreCase("LABEL")\r
+ && !label.contains(slabel.getValue()))\r
{\r
label.add(slabel.getValue());\r
}\r
int selectedRow = table.getSelectionModel().getMinSelectionIndex();\r
nickname = table.getValueAt(selectedRow, 0).toString();\r
url = ((SOURCE) localSources.get(nickname)).getUri();\r
- seqsrc = ((SOURCE) localSources.get(nickname)).getVERSION().get(0).getCAPABILITY().contains(Capabilities.SEQUENCE);\r
+ seqsrc = ((SOURCE) localSources.get(nickname)).getVERSION().get(0)\r
+ .getCAPABILITY().contains(Capabilities.SEQUENCE);\r
}\r
\r
JTextField nametf = new JTextField(nickname, 40);\r
urltf.setText(urltf.getText() + "/");\r
}\r
\r
- // build using pattern from test: sourcesclientImplTest\r
- {\r
- SOURCE source = new SOURCE();\r
- String uri = "http://das.sanger.ac.uk/das/dummysource";\r
- source.setUri("http://das.sanger.ac.uk/das/dummysource");\r
- source.setDescription("Dummy Test Source, should not be in a working registry sources doc");\r
- VERSION version = new VERSION();\r
- version.setUri(uri);\r
- COORDINATES coord = new COORDINATES();\r
- coord.setAuthority("NCBI");\r
- coord.setSource("Chromosome");\r
- coord.setTaxid("9606");\r
- coord.setVersion("35");\r
- version.getCOORDINATES().add(coord);\r
- CAPABILITY cap = new CAPABILITY();\r
- cap.setQueryUri(uri + "features");\r
- cap.setType("das1:" + Capabilities.FEATURES.getName());\r
- version.getCAPABILITY().add(cap);\r
- source.getVERSION().add(version);\r
- MAINTAINER m = new MAINTAINER();\r
- m.setEmail("jw12@sanger.ac.uk");\r
- source.setMAINTAINER(m);\r
- source.setTitle("dummy title");\r
-\r
- }\r
- SOURCE local = new Das1Source();\r
-\r
- local.setUrl(urltf.getText());\r
- local.setNickname(nametf.getText());\r
- if (seqs.isSelected())\r
- {\r
- local.setCapabilities(new String[]\r
- { "features", "sequence" });\r
- }\r
+ SOURCE local = createLocalSource(urltf.getText(), nametf.getText(), seqs.isSelected(), true);\r
+ \r
if (localSources == null)\r
{\r
localSources = new Hashtable();\r
{\r
if (!newSource && dasSources[i].getTitle().equals(nickname))\r
{\r
- ((DasSource) dasSources[i]).setNickname(local.getTitle());\r
- ((DasSource) dasSources[i]).setUrl(local.getUrl());\r
+ dasSources[i] = local;\r
data[i][0] = local.getTitle();\r
data[i][1] = new Boolean(true);\r
}\r
selectedSources.add(local.getTitle());\r
}\r
\r
- DasSource[] tmp = new DasSource[size + adjust];\r
+ SOURCE[] tmp = new SOURCE[size + adjust];\r
\r
System.arraycopy(dasSources, 0, tmp, 0, size);\r
\r
displayFullDetails(local.getTitle());\r
}\r
\r
+ private SOURCE createLocalSource(String url, String name,\r
+ boolean sequence, boolean features)\r
+ {\r
+ SOURCE local = new SOURCE();\r
+\r
+ local.setUri(url);\r
+ local.setTitle(name);\r
+ local.setVERSION(new ArrayList<VERSION>());\r
+ VERSION v = new VERSION();\r
+ List<CAPABILITY> cp = new ArrayList<CAPABILITY>();\r
+ if (sequence)\r
+ {\r
+/* Could try and synthesize a coordinate system for the source if needbe\r
+ * COORDINATES coord = new COORDINATES();\r
+ coord.setAuthority("NCBI");\r
+ coord.setSource("Chromosome");\r
+ coord.setTaxid("9606");\r
+ coord.setVersion("35");\r
+ version.getCOORDINATES().add(coord);*/\r
+ CAPABILITY cap=new CAPABILITY();\r
+ cap.setType("das1:"+Capabilities.SEQUENCE.getName());\r
+ cp.add(cap);\r
+ }\r
+ if (features)\r
+ {\r
+ CAPABILITY cap = new CAPABILITY();\r
+ cap.setType("das1:"+Capabilities.FEATURES.getName());\r
+ cp.add(cap);\r
+ }\r
+ \r
+ v.getCAPABILITY().addAll(cp);\r
+ local.getVERSION().add(v);\r
+\r
+ return local;\r
+ }\r
+\r
public void editRemoveLocalSource(MouseEvent evt)\r
{\r
int selectedRow = table.getSelectionModel().getMinSelectionIndex();\r
localSources.remove(nickname);\r
selectedSources.remove(nickname);\r
Object[][] data = new Object[dasSources.length - 1][2];\r
- DasSource[] tmp = new DasSource[dasSources.length - 1];\r
+ SOURCE[] tmp = new SOURCE[dasSources.length - 1];\r
int index = 0;\r
for (int i = 0; i < dasSources.length; i++)\r
{\r
.getTitle()));\r
}\r
\r
- DasSource[] tmp = new DasSource[size + lsize];\r
+ SOURCE[] tmp = new SOURCE[size + lsize];\r
if (dasSources != null)\r
{\r
System.arraycopy(dasSources, 0, tmp, 0, size);\r
String key = en.nextElement().toString();\r
data[index][0] = key;\r
data[index][1] = new Boolean(false);\r
- tmp[index] = new Das1Source();\r
- tmp[index].setNickname(key);\r
- tmp[index].setUrl(((DasSource) localSources.get(key)).getUrl());\r
+ tmp[index] = createLocalSource(localSources.get(key).getUri(), key, false, true);\r
\r
index++;\r
}\r
\r
ArrayList names = new ArrayList();\r
ArrayList selected = new ArrayList();\r
- DasSource ds;\r
+ SOURCE ds;\r
\r
// The features filter is not visible, but we must still\r
// filter the das source list here.\r
for (int i = 0; i < dSize; i++)\r
{\r
ds = dasSources[i];\r
- DasCoordinateSystem[] dcs = ds.getCoordinateSystem();\r
-\r
- if (dcs.length == 0 && ds.getCapabilities().length == 0\r
+ VERSION v=getVersionFor(ds);\r
+ List<COORDINATES> coords = v.getCOORDINATES();\r
+ if ((coords==null || coords.size()==0)\r
&& filter1.getSelectedIndex() == 0\r
&& filter2.getSelectedIndex() == 0\r
&& filter3.getSelectedIndex() == 0)\r
continue;\r
}\r
\r
- if (!selectedInList(dummyFeatureList, ds.getCapabilities())\r
+ if (!selectedInList(dummyFeatureList, getCapabilityKeys(v))\r
|| !selectedInList(filter3.getSelectedValues(),\r
- ds.getLabels()))\r
+ getLabelsFor(v)))\r
{\r
continue;\r
}\r
\r
- for (int j = 0; j < dcs.length; j++)\r
+ for (int j = 0; j <coords.size(); j++)\r
{\r
if (selectedInList(filter1.getSelectedValues(), new String[]\r
- { dcs[j].getName() })\r
+ { coords.get(j).getAuthority() })\r
&& selectedInList(filter2.getSelectedValues(), new String[]\r
- { dcs[j].getCategory() }))\r
+ { coords.get(j).getSource()}))\r
{\r
names.add(ds.getTitle());\r
- selected.add(new Boolean(selectedSources.contains(ds\r
- .getTitle())));\r
+ selected.add(new Boolean(selectedSources.contains(ds.getTitle())));\r
break;\r
}\r
}\r
refreshTableData(data);\r
}\r
\r
+ private String[] getLabelsFor(VERSION v)\r
+ {\r
+ ArrayList<String> labels=new ArrayList<String>();\r
+ for (PROP p: v.getPROP())\r
+ {\r
+ if (p.getName().equalsIgnoreCase("LABEL"))\r
+ {\r
+ labels.add(p.getValue());\r
+ }\r
+ }\r
+ return labels.toArray(new String[0]);\r
+ }\r
+\r
+ private String[] getCapabilityKeys(VERSION v)\r
+ {\r
+\r
+ ArrayList<String> labels=new ArrayList<String>();\r
+ for (CAPABILITY p: v.getCAPABILITY())\r
+ {\r
+ // TODO: work out what to do with namespace prefix \r
+ // does SEQUENCE == das1:SEQUENCE and das2:SEQUENCE ?\r
+ // for moment, just show all capabilities...\r
+ if (p.getType().startsWith("das1:"))\r
+ {\r
+ labels.add(p.getType());\r
+ }\r
+ }\r
+ return labels.toArray(new String[0]);\r
+ }\r
+\r
boolean selectedInList(Object[] selection, String[] items)\r
{\r
for (int i = 0; i < selection.length; i++)\r
{\r
if (localSources == null)\r
{\r
- localSources = new Hashtable();\r
+ localSources = new Hashtable<String, SOURCE>();\r
}\r
Enumeration sources = _localSources.elements();\r
while (sources.hasMoreElements())\r
{\r
- Das1Source source = (Das1Source) sources.nextElement();\r
+ SOURCE source = (SOURCE) sources.nextElement();\r
localSources.put(source.getTitle(), source);\r
}\r
}\r
String token = en.nextElement().toString();\r
sb.append(token\r
+ "|"\r
- + (((DasSource) localSources.get(token))\r
- .hasCapability("sequence") ? "sequence:" : "")\r
- + ((DasSource) localSources.get(token)).getUrl() + "\t");\r
+ + (selectedInList(getCapabilityKeys(getVersionFor(localSources.get(token))),\r
+ new String[] { "das1:"+Capabilities.SEQUENCE.getName()}) ? "sequence:" : "")\r
+ + getVersionFor(localSources.get(token)).getUri() + "\t");\r
}\r
\r
properties.setProperty(jalview.bin.Cache.DAS_LOCAL_SOURCE,\r