- Timestamp:
- 2001-04-04T22:44:38+12:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSModel.java
r2278 r2281 41 41 */ 42 42 43 class CSModel extends Object 44 { 43 class CSModel extends Object { 45 44 46 Vector collectionList;47 TreeMap collectionInfoMap;45 Vector collectionList; 46 TreeMap collectionInfoMap; 48 47 HashMap collectionNameMap; 49 String currentCollection; 50 ResultModel results; 51 NzdlService nzdl; 52 QueryHistoryModel queryHistoryModel; 48 String currentCollection; 49 ResultModel results; 50 NzdlService nzdl; 51 QueryHistoryModel queryHistoryModel; 52 BerryBasketModel berryBasketModel; 53 53 54 54 55 public CSModel(NzdlService newNzdl) 56 { 57 nzdl = newNzdl; 58 results = new ResultModel(); 59 collectionList = new Vector(); 60 collectionInfoMap = new TreeMap(); 61 collectionNameMap = new HashMap(); 62 queryHistoryModel = new QueryHistoryModel(); 63 currentCollection = ""; 64 initialiseCollection(); 65 } 55 public CSModel(NzdlService newNzdl) 56 { 57 nzdl = newNzdl; 58 results = new ResultModel(); 59 collectionList = new Vector(); 60 collectionInfoMap = new TreeMap(); 61 collectionNameMap = new HashMap(); 62 queryHistoryModel = new QueryHistoryModel(); 63 berryBasketModel = new BerryBasketModel(); 64 currentCollection = ""; 65 initialiseCollection(); 66 } 66 67 67 68 68 public NzdlService getNzdlService()69 {70 71 }69 public NzdlService getNzdlService() 70 { 71 return nzdl; 72 } 72 73 73 74 public QueryHistoryModel getQueryHistoryModel() { 74 75 return queryHistoryModel; 75 76 } 77 78 public BerryBasketModel getBerryBasketModel() { 79 return berryBasketModel; 80 } 76 81 82 /* Result methods */ 77 83 78 /* Result methods */ 84 public ResultModel getResultsModel() 85 { 86 return results; 87 } 88 89 public void addResult(Result result) 90 { 91 results.add(result); 92 } 93 94 public void clearResults() 95 { 96 //System.out.println("Clearing resultModel"); 97 results.clear(); 98 } 79 99 80 public ResultModel getResultsModel() 81 { 82 return results; 83 } 84 85 public void addResult(Result result) 86 { 87 results.add(result); 88 } 89 90 public void clearResults() 91 { 92 //System.out.println("Clearing resultModel"); 93 results.clear(); 94 } 95 96 /* collectionList methods */ 100 /* collectionList methods */ 97 101 98 102 public Vector getCollectionList() { … … 127 131 128 132 129 130 131 132 133 public void setCurrentCollection(String collection ) 134 { 135 currentCollection = collection; 136 } 133 137 134 135 136 137 138 public String getCurrentCollection() 139 { 140 return currentCollection; 141 } 138 142 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 143 public String getFirstCollection() 144 { 145 if (getCollectionListSize() > 0) 146 return (String)collectionInfoMap.firstKey(); 147 else 148 return "no collections"; 149 } 150 /** 151 * 152 */ 153 public void initialiseCollection() 154 { 155 Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles 156 TreeSet orderedCollectionSet = new TreeSet(collectionSet); 157 // TreeSet automatically puts strings in alphabetical order 158 System.out.println("Number of collections on the server: " + 159 orderedCollectionSet.size()); 160 Iterator collectionSetIterator = orderedCollectionSet.iterator(); 161 while (collectionSetIterator.hasNext() ) { 162 // object -> String 163 String collectionName = (String)collectionSetIterator.next(); 164 NzdlCollectionInfo info = nzdl.getCollectionInfo(collectionName); 161 165 162 163 164 165 166 167 168 169 166 if (info != null && 167 info.getBuildDate() != 0 && 168 nzdl.pingCollection(collectionName)) { 169 collectionInfoMap.put(collectionName, info); 170 String longCollectionName = ""; 171 Set n = nzdl.getMetaData(collectionName, "collection", "collectionname"); 172 if (n != null) { 173 if (n.size() == 1) 170 174 longCollectionName = (String) n.toArray()[0]; 171 175 else 172 176 longCollectionName = collectionName + " has more than 1 collectionname"; 173 174 175 176 177 178 179 180 181 177 collectionNameMap.put(collectionName,longCollectionName ); 178 System.err.println("Adding " + collectionName + " to collection list..."); 179 } 180 } // end if 181 else { 182 System.err.println("Collection " + collectionName + " getBuildDate() returned 0"); 183 } // end else 184 } // end while 185 setCurrentCollection(getFirstCollection()); //assume at least one collection 182 186 183 187 } 184 188 185 189 186 190 }
Note:
See TracChangeset
for help on using the changeset viewer.