Ignore:
Timestamp:
2001-03-26T19:07:55+12:00 (23 years ago)
Author:
daven
Message:

added QueryHistory, tooltips on collectionInfoButton. Altered
CSModel to retain CollectionInfo objects and longCollectionNames
for performance. Added files for a BerryBasket - to be turned on
soon. Added sorting of the QueryHistory via the TableMap and TableSorter
files - from the Java Swing tutorial - not sure about GPL status
of these 2.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSModel.java

    r2184 r2225  
    1919package org.nzdl.gsdl.SimpleGraphicalClient;
    2020
     21import java.util.*;
    2122import java.util.Set;
    2223import java.util.TreeSet;
     
    2829import org.nzdl.gsdl.service.NzdlService;
    2930import org.nzdl.gsdl.service.NzdlCollectionInfo;
     31
    3032/**
    3133 * Class
     
    4345
    4446  Vector collectionList;
     47  TreeMap collectionInfoMap;
     48    HashMap collectionNameMap;
    4549  String currentCollection;
    4650  ResultModel results;
    4751  NzdlService nzdl;
     52  QueryHistoryModel queryHistoryModel;
    4853   
    4954
     
    5358    results = new ResultModel();
    5459    collectionList = new Vector();
     60    collectionInfoMap = new TreeMap();
     61    collectionNameMap = new HashMap();
     62    queryHistoryModel = new QueryHistoryModel();
    5563    currentCollection = "";
    5664    initialiseCollection();
     
    6371  }
    6472
    65    
     73    public QueryHistoryModel getQueryHistoryModel() {
     74    return queryHistoryModel;
     75    }
    6676   
    6777
     
    8696  /* collectionList methods */
    8797
    88   public Vector getCollectionList()
    89   {
    90     return collectionList;
    91   }
     98    public Vector getCollectionList() {
     99    return new Vector(collectionInfoMap.keySet());
     100    }
    92101
    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    }
    102105
    103   public void setCurrentCollection(String collection )
    104   {
    105     currentCollection = collection;
    106   }
     106    public int getCollectionListSize() {
     107    return collectionInfoMap.size();
     108    }
    107109
    108   public String getCurrentCollection()
    109   {
    110     return currentCollection;
    111   }
     110    public NzdlCollectionInfo getCollectionInfo(String collectionName) {
     111    return (NzdlCollectionInfo) collectionInfoMap.get(collectionName);
     112    }
    112113
    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 
    145114
     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
    146178   
    147 
    148     setCurrentCollection(getFirstCollection()); //assume at least one collection
    149    
    150   }
     179        }
    151180   
    152181   
    153 }
     182    }
Note: See TracChangeset for help on using the changeset viewer.