Changeset 6288


Ignore:
Timestamp:
2003-12-17T13:15:07+13:00 (20 years ago)
Author:
cs025
Message:

Various changes

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/AbstractHierarchyNode.java

    r6104 r6288  
    1515public abstract class AbstractHierarchyNode
    1616{
     17  String prefix;        // a basic prefix used in this hierarchy
    1718  String descriptor;    // the textual descriptor used on screen or long-hand
    1819  String name;          // the index number, letter assignment or other item
     
    3536    this.name       = null;
    3637    this.id         = null;
     38    this.prefix     = null;
    3739    this.childNodes = new ArrayList();
    3840    this.childDocs  = new ArrayList();
     
    4143  }
    4244   
    43   public AbstractHierarchyNode(String name, String id, String descriptor)
     45  public AbstractHierarchyNode(String prefix, String name, String id, String descriptor)
    4446  { this.descriptor = descriptor;
    4547    this.name       = name;
    4648    this.id         = id;
     49    this.prefix     = prefix;
    4750    this.childNodes = new ArrayList();
    4851    this.childDocs  = new ArrayList();
     
    9699
    97100  public String getParentId()
    98   { int dotAt = this.id.lastIndexOf('.');
     101  {
     102    if (this.id == null) {
     103      return "";
     104    }
     105
     106    int dotAt = this.id.lastIndexOf('.');
    99107    if (dotAt < 0) {
    100108      return "";
     
    188196    select = new GS3SQLSelect("classifiers");
    189197    select.addField("ClassifyRef");
    190     GS3SQLWhereItem whereItem = new GS3SQLWhereItem("ClassifyID", "=", this.id);
     198    GS3SQLWhereItem whereItem = new GS3SQLWhereItem("ClassifyID", "=", this.prefix+"."+this.id);
    191199    GS3SQLWhere where = new GS3SQLWhere(whereItem);
    192200    select.setWhere(where);
     
    206214      else {
    207215    insert = new GS3SQLInsert("classifiers");
    208     if (this.parent != null) {
    209       insert.addValue("ParentID", this.getParentId());
     216
     217    String parentId = this.getParentId();
     218
     219    if (parentId.length() > 0) {
     220      insert.addValue("ParentID", this.prefix+"."+this.getParentId());
    210221    }
     222    else {
     223      insert.addValue("ParentID", this.prefix);
     224    }
    211225
    212226    action = insert;
    213227      }
    214       action.addValue("ClassifyID", this.id);
     228      action.addValue("ClassifyID", this.prefix+"."+this.id);
    215229      action.addValue("Name", this.name);
    216230      action.addValue("Description", this.descriptor);
     
    246260
    247261      // delete child documents
    248       GS3SQLDelete delete = new GS3SQLDelete("classifydocuments");
     262      GS3SQLDelete delete = new GS3SQLDelete("classdocuments");
    249263      delete.setWhere(where);
    250264
     
    266280    while (iterator.hasNext()) {
    267281      DocumentID docId = (DocumentID) iterator.next();
    268       insert = new GS3SQLInsert("classifydocuments");
     282      insert = new GS3SQLInsert("classdocuments");
    269283      insert.addValue("ClassifyRef", Integer.toString(classifyRef), GS3SQLField.INTEGER_TYPE);
    270284      insert.addValue("DocID", docId.toString());
     285
     286      connection.execute(insert.toString());
    271287    }
    272288    return true;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/classifier/GS2HierarchyClassifier.java

    r6104 r6288  
    4949    }
    5050   
    51     public GS2HierarchyNode(String name, String id, String descriptor)
    52     { super(name, id, descriptor);
     51    public GS2HierarchyNode(String prefix, String name, String id, String descriptor)
     52    { super(prefix, name, id, descriptor);
    5353    }
    5454   
     
    9797 
    9898      this.rootNode = new GS2HierarchyNode();
     99      String prefix = "CL"+hierarchyName;
    99100
    100101      while (this.hasMoreLines()) {
     
    120121   
    121122    // Initialise the tree
    122     GS2HierarchyNode node = new GS2HierarchyNode(name, "CL"+hierarchyName+"."+id, description);
     123    GS2HierarchyNode node = new GS2HierarchyNode(prefix, name, id, description);
    123124
    124125    this.rootNode.add(node);
     
    224225   */
    225226  public boolean classifyDocument(DocumentID documentID, DocumentInterface document)
    226   { // the observer records the assignment of documents to classifications
     227  { if (this.hierarchy == null) {
     228      return true;
     229    }
     230   
     231    // the observer records the assignment of documents to classifications
    227232    GS2HierarchyClassifierObserver classifyObserver = new GS2HierarchyClassifierObserver(document);
    228233       
     
    241246      }
    242247
     248      System.out.println("Matching " + values.get(0).toString());
     249
     250      if (documentID == null) {
     251    System.out.println("Bad documentID");
     252    continue;
     253      }
     254
    243255      // ...and send them to the classifier
    244256      this.hierarchy.getClassifications(documentID, values, classifyObserver);
Note: See TracChangeset for help on using the changeset viewer.