source: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSModel.java@ 2184

Last change on this file since 2184 was 2184, checked in by daven, 23 years ago

preferences dialog added

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/*
2 * SimpleGraphicalClient.java
3 * Copyright (C) 2001 New Zealand Digital Library Project
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19package org.nzdl.gsdl.SimpleGraphicalClient;
20
21import java.util.Set;
22import java.util.TreeSet;
23import java.util.Iterator;
24import java.util.Vector;
25
26// local libraries
27
28import org.nzdl.gsdl.service.NzdlService;
29import org.nzdl.gsdl.service.NzdlCollectionInfo;
30/**
31 * Class
32 *
33 * A class to
34 *
35 * @author Dave Nichols ([email protected])
36 * @author stuart yeates ([email protected])
37 * @version $Revision: 2184 $
38 * @see org.nzdl.gsdl.service.SimpleGraphicalClient.SimpleGraphicalClient
39 */
40
41class CSModel extends Object
42{
43
44 Vector collectionList;
45 String currentCollection;
46 ResultModel results;
47 NzdlService nzdl;
48
49
50 public CSModel(NzdlService newNzdl)
51 {
52 nzdl = newNzdl;
53 results = new ResultModel();
54 collectionList = new Vector();
55 currentCollection = "";
56 initialiseCollection();
57 }
58
59
60 public NzdlService getNzdlService()
61 {
62 return nzdl;
63 }
64
65
66
67
68 /* Result methods */
69
70 public ResultModel getResultsModel()
71 {
72 return results;
73 }
74
75 public void addResult(Result result)
76 {
77 results.add(result);
78 }
79
80 public void clearResults()
81 {
82 //System.out.println("Clearing resultModel");
83 results.clear();
84 }
85
86 /* collectionList methods */
87
88 public Vector getCollectionList()
89 {
90 return collectionList;
91 }
92
93 public int getCollectionListSize()
94 {
95 return collectionList.size();
96 }
97
98 public void addCollection(String collection)
99 {
100 collectionList.add(collection);
101 }
102
103 public void setCurrentCollection(String collection )
104 {
105 currentCollection = collection;
106 }
107
108 public String getCurrentCollection()
109 {
110 return currentCollection;
111 }
112
113 public String getFirstCollection()
114 {
115 if (collectionList.size() > 0)
116 return (String)collectionList.get(0);
117 else
118 return "no collections";
119 }
120 /**
121 *
122 */
123 public void initialiseCollection()
124 {
125 Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles
126 TreeSet orderedCollectionSet = new TreeSet(collectionSet);
127 // TreeSet automatically puts strings in alphabetical order
128 System.out.println("Number of collections on the server: " +
129 orderedCollectionSet.size());
130 Iterator collectionSetIterator = orderedCollectionSet.iterator();
131 while (collectionSetIterator.hasNext() ) {
132 // object -> String
133 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 if
141 else {
142 System.err.println("Collection " + collectionName + " getBuildDate() returned 0");
143 } // end else
144 } // end while
145
146
147
148 setCurrentCollection(getFirstCollection()); //assume at least one collection
149
150 }
151
152
153}
Note: See TracBrowser for help on using the repository browser.