From 90d7e508abaf1010078fce1fec804b70179caad5 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 5 Dec 2011 08:57:37 +0000 Subject: [PATCH] change over source attribute datamodel --- src/jalview/gui/DasSourceBrowser.java | 96 +++++++++++++++++---------------- 1 file changed, 51 insertions(+), 45 deletions(-) diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java index 6e77a6b..2f257af 100755 --- a/src/jalview/gui/DasSourceBrowser.java +++ b/src/jalview/gui/DasSourceBrowser.java @@ -142,9 +142,9 @@ public class DasSourceBrowser extends GDasSourceBrowser implements Object[][] data = new Object[dSize][2]; for (int i = 0; i < dSize; i++) { - data[i][0] = dasSources[i]. // what's equivalent of nickname + data[i][0] = dasSources[i].getTitle(); // what's equivalent of nickname data[i][1] = new Boolean(selectedSources.contains(dasSources[i] - .getNickname())); + .getTitle())); } refreshTableData(data); @@ -189,33 +189,34 @@ public class DasSourceBrowser extends GDasSourceBrowser implements int dSize = dasSources.length; for (int i = 0; i < dSize; i++) { - if (!dasSources[i].getNickname().equals(nickName)) + if (!dasSources[i].getTitle().equals(nickName)) { continue; } - DasSource ds = dasSources[i]; - + SOURCE ds = dasSources[i]; + VERSION latest = getVersionFor(ds); text.append("Id: " - + dasSources[i].getId() + "
"); + + dasSources[i].getUri() + "
"); text.append("Nickname: " - + dasSources[i].getNickname() + "
"); + + dasSources[i].getTitle() + "
"); text.append("URL: " - + dasSources[i].getUrl() + "
"); + + latest.getUri() + "
"); text.append("Admin Email: " - + dasSources[i].getAdminemail() + "" + "
"); + + ds.getMAINTAINER().getEmail() + "" + "
"); text.append("Registered at: " - + dasSources[i].getRegisterDate() + "
"); + + latest.getCreated() + "
"); - text.append("Last successful test: " - + dasSources[i].getLeaseDate() + "
"); + // TODO: Identify last successful test date +// text.append("Last successful test: " +// + latest.dasSources[i].getLeaseDate() + "
"); text.append("Labels: "); - for (int s = 0; s < dasSources[i].getLabels().length; s++) + for (int s = 0; s < latest.getPROP().length; s++) { text.append(dasSources[i].getLabels()[s]); if (s < dasSources[i].getLabels().length - 1) @@ -227,7 +228,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements text.append("
"); text.append("Capabilities: "); - String[] scap = dasSources[i].getCapabilities(); + CAPABILITY[] scap = latest.getCAPABILITY().toArray(new CAPABILITY[0]); for (int j = 0; j < scap.length; j++) { text.append(scap[j]); @@ -345,7 +346,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements { for (int i = 0; i < dasSources.length; i++) { - if (dasSources[i].getNickname() + if (dasSources[i].getTitle() .equals(selectedSources.elementAt(r))) { selected.addElement(dasSources[i]); @@ -362,7 +363,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements * * @return */ - public DasSource[] getDASSource() + public SOURCE[] getDASSource() { if (dasSources == null) { @@ -413,6 +414,18 @@ public class DasSourceBrowser extends GDasSourceBrowser implements // assume first instance of source is newest in list. - TODO: check if natural ordering of source versions is newest first or oldest first return false; } + private VERSION getVersionFor(SOURCE ds) + { + VERSION latest=null; + for (VERSION v:ds.getVERSION()) { + if (latest==null || isLaterThan(latest.getCreated(),v.getCreated())) + { + // 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 + latest=v; + } + } + return latest; + } private void setCapabilities(SOURCE[] sources) { Vector authority = new Vector(); @@ -427,14 +440,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements for (int i = 0; i < sources.length; i++) { SOURCE ds = sources[i]; - VERSION latest=null; - for (VERSION v:ds.getVERSION()) { - if (latest==null || isLaterThan(latest.getCreated(),v.getCreated())) - { - // 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 - latest=v; - } - } + VERSION latest=getVersionFor(ds); for (COORDINATES cs: latest.getCOORDINATES()) { @@ -555,7 +561,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements localSources = new Hashtable(); } - localSources.put(local.getNickname(), local); + localSources.put(local.getTitle(), local); if (!newSource && !nickname.equals(nametf.getText())) { @@ -568,26 +574,26 @@ public class DasSourceBrowser extends GDasSourceBrowser implements Object[][] data = new Object[size + adjust][2]; for (int i = 0; i < size; i++) { - if (!newSource && dasSources[i].getNickname().equals(nickname)) + if (!newSource && dasSources[i].getTitle().equals(nickname)) { - ((DasSource) dasSources[i]).setNickname(local.getNickname()); + ((DasSource) dasSources[i]).setNickname(local.getTitle()); ((DasSource) dasSources[i]).setUrl(local.getUrl()); - data[i][0] = local.getNickname(); + data[i][0] = local.getTitle(); data[i][1] = new Boolean(true); } else { - data[i][0] = dasSources[i].getNickname(); + data[i][0] = dasSources[i].getTitle(); data[i][1] = new Boolean(selectedSources.contains(dasSources[i] - .getNickname())); + .getTitle())); } } if (newSource) { - data[size][0] = local.getNickname(); + data[size][0] = local.getTitle(); data[size][1] = new Boolean(true); - selectedSources.add(local.getNickname()); + selectedSources.add(local.getTitle()); } DasSource[] tmp = new DasSource[size + adjust]; @@ -612,7 +618,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements } }); - displayFullDetails(local.getNickname()); + displayFullDetails(local.getTitle()); } public void editRemoveLocalSource(MouseEvent evt) @@ -655,16 +661,16 @@ public class DasSourceBrowser extends GDasSourceBrowser implements int index = 0; for (int i = 0; i < dasSources.length; i++) { - if (dasSources[i].getNickname().equals(nickname)) + if (dasSources[i].getTitle().equals(nickname)) { continue; } else { tmp[index] = dasSources[i]; - data[index][0] = dasSources[i].getNickname(); + data[index][0] = dasSources[i].getTitle(); data[index][1] = new Boolean( - selectedSources.contains(dasSources[i].getNickname())); + selectedSources.contains(dasSources[i].getTitle())); index++; } } @@ -697,9 +703,9 @@ public class DasSourceBrowser extends GDasSourceBrowser implements Object[][] data = new Object[size + lsize][2]; for (int i = 0; i < size; i++) { - data[i][0] = dasSources[i].getNickname(); + data[i][0] = dasSources[i].getTitle(); data[i][1] = new Boolean(selectedSources.contains(dasSources[i] - .getNickname())); + .getTitle())); } DasSource[] tmp = new DasSource[size + lsize]; @@ -763,8 +769,8 @@ public class DasSourceBrowser extends GDasSourceBrowser implements // THIS IS A FIX FOR LOCAL SOURCES WHICH DO NOT // HAVE COORDINATE SYSTEMS, INFO WHICH AT PRESENT // IS ADDED FROM THE REGISTRY - names.add(ds.getNickname()); - selected.add(new Boolean(selectedSources.contains(ds.getNickname()))); + names.add(ds.getTitle()); + selected.add(new Boolean(selectedSources.contains(ds.getTitle()))); continue; } @@ -782,9 +788,9 @@ public class DasSourceBrowser extends GDasSourceBrowser implements && selectedInList(filter2.getSelectedValues(), new String[] { dcs[j].getCategory() })) { - names.add(ds.getNickname()); + names.add(ds.getTitle()); selected.add(new Boolean(selectedSources.contains(ds - .getNickname()))); + .getTitle()))); break; } } @@ -844,7 +850,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements while (sources.hasMoreElements()) { Das1Source source = (Das1Source) sources.nextElement(); - localSources.put(source.getNickname(), source); + localSources.put(source.getTitle(), source); } } } @@ -1012,7 +1018,7 @@ public class DasSourceBrowser extends GDasSourceBrowser implements { for (int i = 0; i < dasSources.length; i++) { - if (sources.contains(dasSources[i].getNickname())) + if (sources.contains(dasSources[i].getTitle())) { if (!resolved.contains(dasSources[i])) { -- 1.7.10.2