Ignore:
Timestamp:
2001-04-04T22:44:38+12:00 (23 years ago)
Author:
daven
Message:

turned on the BerryBasket. Try right-clicking on a result in the results List
to add one - no delete yet. Re-sizing maybe improved as well - no
guarantees yet though.

File:
1 edited

Legend:

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

    r2278 r2281  
    4141 */
    4242
    43 class CSModel extends Object
    44 {
     43class CSModel extends Object {
    4544
    46   Vector collectionList;
    47   TreeMap collectionInfoMap;
     45    Vector collectionList;
     46    TreeMap collectionInfoMap;
    4847    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;
    5353   
    5454
    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    }
    6667 
    6768 
    68   public NzdlService getNzdlService()
    69   {
    70     return nzdl;
    71   }
     69    public NzdlService getNzdlService()
     70    {
     71    return nzdl;
     72    }
    7273
    7374    public QueryHistoryModel getQueryHistoryModel() {
    7475    return queryHistoryModel;
    7576    }
     77
     78    public BerryBasketModel getBerryBasketModel() {
     79    return berryBasketModel;
     80    }
    7681   
     82    /* Result methods */
    7783
    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    }
    7999
    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 */
    97101
    98102    public Vector getCollectionList() {
     
    127131
    128132
    129     public void setCurrentCollection(String collection )
    130         {
    131         currentCollection = collection;
    132         }
     133    public void setCurrentCollection(String collection )
     134    {
     135    currentCollection = collection;
     136    }
    133137
    134     public String getCurrentCollection()
    135         {
    136         return currentCollection;
    137         }
     138    public String getCurrentCollection()
     139    {
     140    return currentCollection;
     141    }
    138142
    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);
     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);
    161165
    162           if (info != null &&
    163               info.getBuildDate() != 0 &&
    164               nzdl.pingCollection(collectionName)) {
    165             collectionInfoMap.put(collectionName, info);
    166             String longCollectionName = "";
    167             Set n = nzdl.getMetaData(collectionName, "collection", "collectionname");
    168             if (n != null) {
    169               if (n.size() == 1)
     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)
    170174            longCollectionName = (String) n.toArray()[0];
    171               else
     175            else
    172176            longCollectionName = collectionName + " has more than 1 collectionname";
    173               collectionNameMap.put(collectionName,longCollectionName );
    174               System.err.println("Adding " + collectionName + " to collection list...");
    175             }
    176           } // end if
    177           else {
    178             System.err.println("Collection " + collectionName + " getBuildDate() returned 0");
    179           } // end else
    180         } // end while 
    181         setCurrentCollection(getFirstCollection()); //assume at least one collection
     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
    182186   
    183         }
     187    }
    184188   
    185189   
    186     }
     190}
Note: See TracChangeset for help on using the changeset viewer.