Changeset 2145 for trunk/java-client


Ignore:
Timestamp:
2001-03-09T14:33:06+13:00 (23 years ago)
Author:
say1
Message:

Added Model initialisation to CSModel. Fixed the bug where empty collections appear. Fixed the exception thrown on an empty doc set

Location:
trunk/java-client/org/nzdl/gsdl
Files:
4 edited

Legend:

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

    r2143 r2145  
    2222import javax.swing.*;
    2323
    24 
    2524// local libraries
    2625
    2726import org.nzdl.gsdl.service.NzdlService;
    28 
     27import org.nzdl.gsdl.service.NzdlCollectionInfo;
    2928/**
    3029 * Class
     
    4140{
    4241
    43     Vector collectionList;
    44     String currentCollection;
    45     ResultModel results;
    46     NzdlService nzdl;
     42  Vector collectionList;
     43  String currentCollection;
     44  ResultModel results;
     45  NzdlService nzdl;
    4746   
    4847
    49     public CSModel(NzdlService newNzdl)
    50     {
    51         nzdl = newNzdl;
    52         results = new ResultModel();
    53         collectionList = new Vector();
    54         currentCollection = "";
    55     }
    56 
    57 
    58     public NzdlService getNzdlService()
    59     {
    60     return nzdl;
    61     }
     48  public CSModel(NzdlService newNzdl)
     49  {
     50    nzdl = newNzdl;
     51    results = new ResultModel();
     52    collectionList = new Vector();
     53    currentCollection = "";
     54    initialiseCollection();
     55  }
     56 
     57 
     58  public NzdlService getNzdlService()
     59  {
     60    return nzdl;
     61  }
    6262
    6363   
    6464   
    6565
    66 /* Result methods */
     66  /* Result methods */
    6767
    68      public ResultModel getResultsModel()
    69     {
    70     return results;
    71     }
     68  public ResultModel getResultsModel()
     69  {
     70    return results;
     71  }
    7272   
    73     public void addResult(Result result)
    74     {
    75     results.add(result);
    76     }
     73  public void addResult(Result result)
     74  {
     75    results.add(result);
     76  }
    7777   
    78     public void clearResults()
    79     {
    80     System.out.println("Clearing resultModel");
    81     results.clear();
    82     }
     78  public void clearResults()
     79  {
     80    System.out.println("Clearing resultModel");
     81    results.clear();
     82  }
    8383
    84 /* collectionList methods */
     84  /* collectionList methods */
    8585
    86     public Vector getCollectionList()
    87     {
    88        return collectionList;
    89     }
     86  public Vector getCollectionList()
     87  {
     88    return collectionList;
     89  }
    9090
    91     public int getCollectionListSize()
    92     {
    93     return collectionList.size();
    94     }
     91  public int getCollectionListSize()
     92  {
     93    return collectionList.size();
     94  }
    9595   
    96     public void addCollection(String collection)
    97     {
    98     collectionList.add(collection);
    99     }
     96  public void addCollection(String collection)
     97  {
     98    collectionList.add(collection);
     99  }
    100100
    101     public void setCurrentCollection(String collection )
    102     {
    103     currentCollection = collection;
    104     }
     101  public void setCurrentCollection(String collection )
     102  {
     103    currentCollection = collection;
     104  }
    105105
    106     public String getCurrentCollection()
    107     {
    108     return currentCollection;
    109     }
     106  public String getCurrentCollection()
     107  {
     108    return currentCollection;
     109  }
    110110
    111     public String getFirstCollection()
    112     {
    113     return (String)collectionList.get(0);
    114     }
     111  public String getFirstCollection()
     112  {
     113    return (String)collectionList.get(0);
     114  }
     115  /**
     116   *
     117   */
     118  public void initialiseCollection()
     119  {
     120    Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles
     121    TreeSet orderedCollectionSet = new TreeSet(collectionSet);
     122    // TreeSet automatically puts strings in alphabetical order
     123    System.out.println("Number of collections on the server: " +
     124               orderedCollectionSet.size());
     125    Iterator collectionSetIterator = orderedCollectionSet.iterator();
     126    while (collectionSetIterator.hasNext() ) {
     127      // object -> String
     128      String collectionName = (String)collectionSetIterator.next();
     129      NzdlCollectionInfo info = nzdl.getCollectionInfo(collectionName);
     130      //System.err.println(info);
     131      if (info != null &&
     132      info.getBuildDate() != 0) {
     133    addCollection(collectionName);
     134    System.err.println("Adding " + collectionName + " to collection list...");
     135      } // end if
     136      else {
     137    System.err.println("Collection " + collectionName + " getBuildDate() returned 0");
     138      } // end else
     139    } // end while 
     140    setCurrentCollection(getFirstCollection()); //assume at least one collection
     141   
     142  }
    115143   
    116144   
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java

    r2143 r2145  
    228228      } //end while
    229229      // default to showing the top ranked document
    230       resultsList.setSelectedIndex(0);
     230      if (docIDs.size() > 0)
     231    resultsList.setSelectedIndex(0);
    231232    } // end if
    232233    else {
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SimpleGraphicalClient.java

    r2143 r2145  
    111111    csModel = new CSModel(nzdl);
    112112   
    113     Set collectionSet = nzdl.getCollectionSet(); // set of strings of collection titles
    114     TreeSet orderedCollectionSet = new TreeSet(collectionSet);
    115     // TreeSet automatically puts strings in alphabetical order
    116     System.out.println("Number of collections on the server: " + orderedCollectionSet.size());
    117     Iterator collectionSetIterator = orderedCollectionSet.iterator();
    118     while (collectionSetIterator.hasNext() ) {
    119         String collectionName = (String)collectionSetIterator.next(); // object -> String
    120         if (nzdl.hasCollection(collectionName) && nzdl.pingCollection(collectionName) ) {
    121         csModel.addCollection(collectionName);
    122         System.out.println("Adding " + collectionName + " to collection list...");
    123         } // end if
    124         else {
    125         System.err.println("Collection " + collectionName + " wasn't added ");
    126         System.err.println("\t either pingCollection() or hasCollection() returned false");
    127         } // end else
    128     } // end while 
    129     csModel.setCurrentCollection(csModel.getFirstCollection()); //assume at least one collection
    130113    window = new CSFrame("Search via Corba", csModel);   
    131114    Toolkit theKit = window.getToolkit();        // Get the window toolkit
  • trunk/java-client/org/nzdl/gsdl/service/NzdlCollectionInfo.java

    r2098 r2145  
    4848  }
    4949
     50  public String toString() {
     51    StringBuffer buf = new  StringBuffer(1000);
     52    buf.append("coll name=\"").append(getName());
     53    buf.append("\" isPublic=").append(isPublic());
     54    buf.append(" isBeta=").append(isBeta());
     55    buf.append(" buildDate=").append(getBuildDate());
     56    buf.append(" numOfDocs=").append(getNumOfDocs());
     57    buf.append(" numOfWords=").append(getNumOfWords());
     58    buf.append(" numOfBytes=").append(getNumOfBytes());
     59    return buf.toString();
     60  }
     61
    5062  /** */
    5163  public void print() {
     
    5870
    5971}
     72
     73
     74
     75
     76
     77
     78
     79
Note: See TracChangeset for help on using the changeset viewer.