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

Various changes

File:
1 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;
Note: See TracChangeset for help on using the changeset viewer.