- Timestamp:
- 2001-03-26T19:07:55+12:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSModel.java
r2184 r2225 19 19 package org.nzdl.gsdl.SimpleGraphicalClient; 20 20 21 import java.util.*; 21 22 import java.util.Set; 22 23 import java.util.TreeSet; … … 28 29 import org.nzdl.gsdl.service.NzdlService; 29 30 import org.nzdl.gsdl.service.NzdlCollectionInfo; 31 30 32 /** 31 33 * Class … … 43 45 44 46 Vector collectionList; 47 TreeMap collectionInfoMap; 48 HashMap collectionNameMap; 45 49 String currentCollection; 46 50 ResultModel results; 47 51 NzdlService nzdl; 52 QueryHistoryModel queryHistoryModel; 48 53 49 54 … … 53 58 results = new ResultModel(); 54 59 collectionList = new Vector(); 60 collectionInfoMap = new TreeMap(); 61 collectionNameMap = new HashMap(); 62 queryHistoryModel = new QueryHistoryModel(); 55 63 currentCollection = ""; 56 64 initialiseCollection(); … … 63 71 } 64 72 65 73 public QueryHistoryModel getQueryHistoryModel() { 74 return queryHistoryModel; 75 } 66 76 67 77 … … 86 96 /* collectionList methods */ 87 97 88 public Vector getCollectionList() 89 { 90 return collectionList; 91 } 98 public Vector getCollectionList() { 99 return new Vector(collectionInfoMap.keySet()); 100 } 92 101 93 public int getCollectionListSize() 94 { 95 return collectionList.size(); 96 } 97 98 public void addCollection(String collection) 99 { 100 collectionList.add(collection); 101 } 102 public Collection getCollectionAsCollection() { 103 return (Collection)collectionInfoMap; 104 } 102 105 103 public void setCurrentCollection(String collection ) 104 { 105 currentCollection = collection; 106 } 106 public int getCollectionListSize() { 107 return collectionInfoMap.size(); 108 } 107 109 108 public String getCurrentCollection() 109 { 110 return currentCollection; 111 } 110 public NzdlCollectionInfo getCollectionInfo(String collectionName) { 111 return (NzdlCollectionInfo) collectionInfoMap.get(collectionName); 112 } 112 113 113 public String getFirstCollection()114 {115 if (collectionList.size() > 0)116 return (String)collectionList.get(0);117 else118 return "no collections";119 }120 /**121 *122 */123 public void initialiseCollection()124 {125 Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles126 TreeSet orderedCollectionSet = new TreeSet(collectionSet);127 // TreeSet automatically puts strings in alphabetical order128 System.out.println("Number of collections on the server: " +129 orderedCollectionSet.size());130 Iterator collectionSetIterator = orderedCollectionSet.iterator();131 while (collectionSetIterator.hasNext() ) {132 // object -> String133 String collectionName = (String)collectionSetIterator.next();134 NzdlCollectionInfo info = nzdl.getCollectionInfo(collectionName);135 //System.err.println(info);136 if (info != null &&137 info.getBuildDate() != 0) {138 addCollection(collectionName);139 System.err.println("Adding " + collectionName + " to collection list...");140 } // end if141 else {142 System.err.println("Collection " + collectionName + " getBuildDate() returned 0");143 } // end else144 } // end while145 114 115 public String getLongCollectionName(String collectionName) { 116 return (String) collectionNameMap.get(collectionName); 117 } 118 119 120 public String getCollectionDescription(String collectionName) { 121 Set descSet = nzdl.getMetaData(collectionName, "collection", "collectionextra"); 122 if (descSet.size() == 1) 123 return (String) descSet.toArray()[0]; 124 else 125 return "collectionName has more than 1 collectionextra entry"; 126 } 127 128 129 public void setCurrentCollection(String collection ) 130 { 131 currentCollection = collection; 132 } 133 134 public String getCurrentCollection() 135 { 136 return currentCollection; 137 } 138 139 public String getFirstCollection() 140 { 141 if (getCollectionListSize() > 0) 142 return (String)collectionInfoMap.firstKey(); 143 else 144 return "no collections"; 145 } 146 /** 147 * 148 */ 149 public void initialiseCollection() 150 { 151 Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles 152 TreeSet orderedCollectionSet = new TreeSet(collectionSet); 153 // TreeSet automatically puts strings in alphabetical order 154 System.out.println("Number of collections on the server: " + 155 orderedCollectionSet.size()); 156 Iterator collectionSetIterator = orderedCollectionSet.iterator(); 157 while (collectionSetIterator.hasNext() ) { 158 // object -> String 159 String collectionName = (String)collectionSetIterator.next(); 160 NzdlCollectionInfo info = nzdl.getCollectionInfo(collectionName); 161 if (info != null && 162 info.getBuildDate() != 0) { 163 collectionInfoMap.put(collectionName, info); 164 String longCollectionName = ""; 165 Set n = nzdl.getMetaData(collectionName, "collection", "collectionname"); 166 if (n.size() == 1) 167 longCollectionName = (String) n.toArray()[0]; 168 else 169 longCollectionName = collectionName + " has more than 1 collectionname"; 170 collectionNameMap.put(collectionName,longCollectionName ); 171 System.err.println("Adding " + collectionName + " to collection list..."); 172 } // end if 173 else { 174 System.err.println("Collection " + collectionName + " getBuildDate() returned 0"); 175 } // end else 176 } // end while 177 setCurrentCollection(getFirstCollection()); //assume at least one collection 146 178 147 148 setCurrentCollection(getFirstCollection()); //assume at least one collection 149 150 } 179 } 151 180 152 181 153 }182 }
Note:
See TracChangeset
for help on using the changeset viewer.