Ignore:
Timestamp:
2003-12-17T13:14:49+13:00 (21 years ago)
Author:
cs025
Message:

Various changes to the METS structures and identifier factories to
move towards updateable structures and to add section support.

Location:
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata
Files:
4 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/FileIdentifierFactory.java

    r5800 r6287  
    77import org.greenstone.gsdl3.gs3build.doctypes.DocumentID;
    88
    9 public class FileIdentifierFactory
     9public class FileIdentifierFactory extends AbstractIdentifierFactory
    1010{
    11     public static Object makeFileIdentifier(DocumentID document)
    12     {
    13     return null;
    14     }
     11  public static final String FILE_IDENTIFIER_PRELUDE = "FILE";
     12
     13  public FileIdentifierFactory()
     14  { super(FILE_IDENTIFIER_PRELUDE);
     15  }
    1516}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptive.java

    r5945 r6287  
    123123  }
    124124
    125     /**
    126     *  Fetch a <code>List</code> of the values matching the given label in
    127     *  the requisite namespace.
    128     *
    129     *  @param <code>String</code> namespace
    130     *  @param <code>String</code> label of metadata to match
    131     *
    132     *  @return <code>List</code> the corresponding values found.
    133     */
    134     public List getMetadata(String namespace, String label)
    135     {
    136         // Simple case - no metadata
    137         if (!this.map.containsKey(namespace))
    138         { return null;
    139         }
    140 
    141         // if there's just one instance of the requisite namespace,
    142         // then again it is a simple case
    143         if (this.map.getAll(namespace).size() == 1)
    144         {   return this.getNamespace(namespace).getMetadata(label);
    145         }
    146 
    147         // otherwise, step through and accumulate
    148         List accumulatedValues = new ArrayList();
    149         Iterator namespaceIterator = this.map.getAll(namespace).iterator();
    150         while (namespaceIterator.hasNext())
    151         {   METSNamespace localNamespace = (METSNamespace) namespaceIterator.next();
    152 
    153             List localList = localNamespace.getMetadata(label);
    154             if (localList != null && localList.size() > 0)
    155             {   accumulatedValues.addAll(localList);
    156             }
    157         }
    158 
    159         // if the result of the accumulation is empty, return a null item
    160         if (accumulatedValues.size() == 0)
    161         { return null;
    162         }
    163 
    164         return accumulatedValues;
    165     }
     125  /**
     126  *  Fetch a <code>List</code> of the values matching the given label in
     127  *  the requisite namespace.
     128  *
     129  *  @param <code>String</code> namespace
     130  *  @param <code>String</code> label of metadata to match
     131  *
     132  *  @return <code>List</code> the corresponding values found.
     133  */
     134  public List getMetadata(String namespace, String label)
     135  {
     136    // Simple case - no metadata
     137    if (!this.map.containsKey(namespace))
     138    { return null;
     139    }
     140
     141    // if there's just one instance of the requisite namespace,
     142    // then again it is a simple case
     143    if (this.map.getAll(namespace).size() == 1)
     144    {   return this.getNamespace(namespace).getMetadata(label);
     145    }
     146
     147    // otherwise, step through and accumulate
     148    List accumulatedValues = new ArrayList();
     149    Iterator namespaceIterator = this.map.getAll(namespace).iterator();
     150    while (namespaceIterator.hasNext())
     151    { METSNamespace localNamespace = (METSNamespace) namespaceIterator.next();
     152
     153      List localList = localNamespace.getMetadata(label);
     154      if (localList != null && localList.size() > 0)
     155      { accumulatedValues.addAll(localList);
     156      }
     157    }
     158
     159    // if the result of the accumulation is empty, return a null item
     160    if (accumulatedValues.size() == 0)
     161    { return null;
     162    }
     163
     164    return accumulatedValues;
     165  }
    166166
    167167    /**
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptiveSet.java

    r5945 r6287  
    2929{ Map children;
    3030  Map childrenById;
     31  DescriptiveIdentifierFactory identifierFactory;
     32
     33  class DescriptiveIdentifierFactory extends AbstractIdentifierFactory
     34  { public DescriptiveIdentifierFactory()
     35    { super("DM");
     36    }
     37  }
    3138
    3239  public METSDescriptiveSet()
     
    3441    this.childrenById = new HashMap();
    3542
    36     METSDescriptive descriptive = new METSDescriptive("DM1", "default");
    37     this.addDescriptive(descriptive);
    38   }
    39 
     43    this.identifierFactory = new DescriptiveIdentifierFactory();
     44
     45    this.createDescriptive("default");
     46  }
     47
     48  /**
     49   *  Create a new descriptive child, adding it automatically to this descriptive set.
     50   *
     51   *  @param <code>String</code> a name to describe the descriptive set.
     52   */
     53  public METSDescriptive createDescriptive(String name)
     54  { METSDescriptive descriptive = new METSDescriptive(this.identifierFactory.getNextIdentifier(), name);
     55
     56    this.children.put(name, descriptive);
     57    this.childrenById.put(descriptive.getID(), descriptive);
     58    return descriptive;
     59  }
     60
     61  /**
     62   *  Add a descriptive item to this set.
     63   *
     64   *  @param <code>METSDescriptive</code> the descriptive set
     65   */
    4066  public void addDescriptive(METSDescriptive metadata)
    41   { this.children.put(metadata.getName(), metadata);
     67  { // insert the item into both maps...
     68    this.children.put(metadata.getName(), metadata);
    4269    this.childrenById.put(metadata.getID(), metadata);
    43   }
    44 
     70   
     71    // when a descriptive block is added, check that it hasn't been used before...
     72    this.identifierFactory.noteIdentifier(metadata.getID());
     73  }
     74
     75  /**
     76   *  Get a descriptive item by its name
     77   */
    4578  public METSDescriptive getDescriptive(String name)
    4679  { return (METSDescriptive) this.children.get(name);
    4780  }
    4881
     82  /**
     83   *  Get a descriptive item by its identifier
     84   */
    4985  public METSDescriptive getDescriptiveById(String id)
    5086  { return (METSDescriptive) this.childrenById.get(id);
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDivision.java

    r6017 r6287  
    77import java.util.ArrayList;
    88import java.util.Map;
    9 import java.util.HashMap;
     9import java.util.LinkedHashMap;
    1010
    1111import java.sql.SQLException;
     
    1717import org.greenstone.gsdl3.gs3build.database.*;
    1818
    19 
    20 public class METSDivision
     19public class METSDivision extends AbstractStructure
    2120{
    22   String       ID;          // the unique identifier for this division (unique within the
    23                             // document, not necessarily unique within the collection).
    2421  String       order;       // see the METS documentation for the meaning of the different
    2522  String       orderLabel;  // label types.
     
    2926  List         adminRefs;
    3027  List         fileRefs;
    31   Map          children;
    3228 
    33   public static final String STRUCTURE_PARENT = "Structure";
    34   public static final String DIVISION_PARENT  = "Division";
     29  public static final String DIVISION_TYPE  = "Division";
    3530
    3631  public METSDivision(String ID, String order, String orderLabel, String userLabel, String type)
    37   { this.ID = ID;
     32  { super(ID);
     33
    3834    this.order = order;
    3935    this.orderLabel = orderLabel;
     
    4238    this.fileRefs = new ArrayList();
    4339    this.metadataRefs = new ArrayList();
    44     this.children = new HashMap();
    45   }
    46 
    47   public String getID()
    48   { return this.ID;
     40  }
     41
     42  public String getStructureType()
     43  { return DIVISION_TYPE;
     44  }
     45
     46  public String getLabel()
     47  { return this.orderLabel;
    4948  }
    5049
     
    141140   *  Add a new file reference to the structure
    142141   *
    143    *  @param <code>METSFileRef</code> the file to be referenced.
     142   *  @param <code>METSFileID</code> the file to be referenced.
    144143   */
    145144  public void addFileReference(METSFileID fileRef)
     145  { this.addFileReference(fileRef.toString());
     146  }
     147
     148  public void addFileReference(String fileRef)
    146149  { this.fileRefs.add(fileRef);
    147150  }
     
    156159
    157160  /**
    158    *  Add a child division, or sub-division to the document.  For example,
    159    *  sections within a chapter.
    160    *
    161    *  @param <code>METSDivision</code> the child division.
    162    */
    163   public void addSubDivision(METSDivision child)
    164   { this.children.put(child.getID(), child);
    165   }
    166 
    167   /**
    168    *  Add a child division to a descendent of this division.
    169    *
    170    *  @param <code>String</code> the path to the division into which the
    171    *         subdivision will be added.
    172    *  @param <code>METSDivision</code> the division to be added
    173    */
    174   public void addSubDivision(String divisionID, METSDivision division)
    175   { String topDivision = METSDivision.getTopDivisionName(divisionID);
    176 
    177     METSDivision child = (METSDivision) this.children.get(topDivision);
     161   *  Get all the metadata references
     162   *
     163   *  @return <code>List</code> containing all the references
     164   */
     165  public List getMetadataReferences()
     166  { return this.metadataRefs;
     167  }
     168
     169  /**
     170   *  Get all the default (first) metadata reference...
     171   *
     172   *  @return <code>List</code> containing all the references
     173   */
     174  //TODO: check for this first *open* metadata item...
     175  public String getDefaultMetadataReference()
     176  { if (this.metadataRefs.size() == 0) {
     177      return null;
     178    }
     179    return this.metadataRefs.get(0).toString();
     180  }
     181
     182  /**
     183   *  Get all the default (first) first filegroup reference...
     184   *
     185   *  @return <code>List</code> containing all the references
     186   */
     187  public String getDefaultFileReference()
     188  { if (this.fileRefs.size() == 0) {
     189      return null;
     190    }
     191    return this.fileRefs.get(0).toString();
     192  }
     193
     194  /**
     195   *  Get a child or descendant division
     196   *
     197   *  @param <code>String</code> the path to the child division
     198   *  @return <code>METSDivision</code> the division found.
     199   */
     200  public METSDivision getDivision(String divisionLabel)
     201  { // if the division ID equals this, then process it
     202    if (divisionLabel.equals(this.orderLabel)) {
     203      return this;
     204    }
     205
     206    // if we just shouldn't be here, then error...
     207    if (!divisionLabel.startsWith(this.orderLabel + ".")) {
     208      return null;
     209    }
     210
     211    // get the next division in the division path...
     212    String subdivisionPath = divisionLabel.substring(this.orderLabel.length() + 1);
     213    String nextDivision = getTopDivisionName(subdivisionPath);
     214    String nextLabel;
     215
     216    // first try the current division name with an appended '.' and the next child id...
     217    METSDivision child = (METSDivision) this.children.get(this.orderLabel + "." + nextDivision);
    178218    if (child == null)
    179     { return;
    180     }
    181 
    182     String subDivisionID = METSDivision.getSubDivisionName(divisionID);
    183     if (subDivisionID == null)
    184     { child.addSubDivision(division);
    185     }
    186     else
    187     { child.addSubDivision(subDivisionID, division);
    188     }
    189   }
    190 
    191   public METSDivision getDivision(String divisionID)
    192   { String topDivision = METSDivision.getTopDivisionName(divisionID);
    193 
    194     METSDivision child = (METSDivision) this.children.get(topDivision);
    195     if (child == null)
    196     { return null;
    197     }
    198 
    199     String subDivision = METSDivision.getSubDivisionName(divisionID);
    200     if (subDivision != null)
    201     { child = child.getDivision(subDivision);
    202     }
    203     
    204     return child;
    205   }
    206 
     219    { // if that didn't work, try the next division on its own
     220      child = (METSDivision) this.children.get(nextDivision);
     221
     222      // if neither worked, then abort...
     223      if (child == null) {
     224    return null;
     225      }
     226      else {
     227    // set the next identifier
     228    nextLabel = METSDivision.getSubDivisionName(divisionLabel);
     229      }
     230    }
     231    else {
     232      // set the next identifier...
     233      nextLabel = divisionLabel;
     234    }
     235
     236    return child.getDivision(nextLabel);
     237  }
     238
     239  /**
     240   *  A convenience method for splitting a division name - this gives the name
     241   *  without the leading division label...  To be used when division identifiers
     242   *  are given as '.' separated paths and division names do not contain the
     243   *  full path of their parents.
     244   *
     245   *  @return <code>String</code>
     246   */
    207247  public static String getSubDivisionName(String divisionName)
    208248  { int at = divisionName.indexOf('.');
     
    216256  }
    217257
     258  public static String getParentName(String divisionName)
     259  { int at = divisionName.lastIndexOf('.');
     260
     261    if (at >= 0) {
     262      return divisionName.substring(0, at);
     263    }
     264    return "";
     265  }
     266
    218267  public static String getTopDivisionName(String divisionName)
    219268  { int at = divisionName.indexOf('.');
     
    232281   *  @param <code>PrintWriter</code> the destination of the output
    233282   */
    234   public void write(PrintWriter writer)
     283  public boolean write(PrintWriter writer)
    235284  { String tag = XMLTools.getOpenTag("mets", "div");
    236285    tag = XMLTools.addAttribute(tag, "ID", this.ID.toString());
     
    267316      writer.println(tag);
    268317    }
    269      
     318
     319    // write out any children in turn
     320    Iterator groups = this.children.values().iterator();
     321
     322    while (groups.hasNext())
     323    { METSDivision group = (METSDivision) groups.next();
     324   
     325      if (!group.write(writer)) {
     326    return false;
     327      }
     328    }
     329   
    270330    // close the div element
    271331    writer.println(XMLTools.getCloseTag("mets", "div"));
    272   }
    273 
     332
     333    return true;
     334  }
     335
     336  /**
     337   *  A convenience method for writing a <code>List</code> as a space-separated <code>String</code>.
     338   */
    274339  private String writeList(List list)
    275340  { StringBuffer listString = new StringBuffer();
     
    294359    select.addField("DivisionRef");
    295360    GS3SQLWhereItem whereItem = new GS3SQLWhereItem("ParentRef", "=", Integer.toString(parentRef), GS3SQLField.INTEGER_TYPE);
    296     GS3SQLWhereItem parentItem = new GS3SQLWhereItem("ParentType", "=", parentIsStructure ? "Structure" : "Division");
     361    GS3SQLWhereItem parentItem = new GS3SQLWhereItem("ParentType", "=", parentIsStructure ? METSStructure.STRUCTURE_TYPE : METSDivision.DIVISION_TYPE);
    297362    GS3SQLWhereItem item = new GS3SQLWhereItem("SectionID", "=", this.ID.toString());
    298     GS3SQLWhere where = new GS3SQLWhere(whereItem);   
     363    GS3SQLWhere where = new GS3SQLWhere(whereItem);
    299364    where.add(parentItem);
    300365    where.add(item);
     
    316381    insert.addValue("SectionID", this.ID.toString());
    317382    insert.addValue("ParentRef", Integer.toString(parentRef));
    318     insert.addValue("ParentType", parentIsStructure == true ? STRUCTURE_PARENT : DIVISION_PARENT);
     383    insert.addValue("ParentType", parentIsStructure == true ? METSStructure.STRUCTURE_TYPE : METSDivision.DIVISION_TYPE);
    319384   
    320385    action = insert;
     
    332397    }
    333398    catch (SQLException sql) {
    334       System.err.println(sql);
     399      System.err.println(sql + " " + select.toString());
    335400      return false;
    336401    }
     
    373438      }
    374439      catch (SQLException sql) {
    375     System.err.println(sql);
     440    System.err.println(sql + " " + select.toString());
    376441      }
    377442    }
     
    435500    METSLocation metsLocation = null;
    436501   
     502    GS3SQLSelect select = null;
    437503    try {
    438504      // read the basic information
     
    449515      int divisionRef = resultSet.getInt("DivisionRef");
    450516
    451       GS3SQLSelect select = new GS3SQLSelect("divisions");
     517      select = new GS3SQLSelect("divisions");
    452518      select.addField("*");
    453519      GS3SQLWhereItem whereItem = new GS3SQLWhereItem("ParentRef", "=", Integer.toString(divisionRef),
    454520                              GS3SQLField.INTEGER_TYPE);
    455521      GS3SQLWhere where = new GS3SQLWhere(whereItem);
    456       whereItem = new GS3SQLWhereItem("ParentType", "=", DIVISION_PARENT);
     522      whereItem = new GS3SQLWhereItem("ParentType", "=", METSDivision.DIVISION_TYPE);
    457523      where.add(whereItem);
    458524      select.setWhere(where);
     
    466532    do {
    467533      METSDivision childDivision = METSDivision.readSQL(connection, childSet);
    468       division.addSubDivision(childDivision);
     534      division.addDivision(childDivision);
    469535    }
    470536    while (childSet.next());
     
    508574    }
    509575    catch (SQLException sqlEx)
    510     { System.out.println(sqlEx);
     576    { System.out.println(sqlEx + " " +select.toString());
    511577    }   
    512578    return null;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileGroup.java

    r5945 r6287  
    115115    file.setGroup(this);
    116116    if (!file.getID().isDefined())
    117     { file.setID(new METSFileID(this.id + Integer.toString(this.children.size())));
     117    { file.setID(new METSFileID(this.id + "." + Integer.toString(this.children.size())));
    118118    }
    119119  }
     
    170170   *  @return <code>String</code> the name of this group
    171171   */
    172   public String getName()
     172  public String getId()
    173173  { return this.id;
    174174  }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileSet.java

    r5945 r6287  
    2828{ Map    fileGroups;
    2929  String reference;
     30  FileIdentifierFactory identifierFactory;
     31  FileGroupIdentifierFactory groupIdentifierFactory;
     32
     33  class FileGroupIdentifierFactory extends AbstractIdentifierFactory
     34  { public static final String FILEGROUP_PRELUDE = "FG";
     35
     36    public FileGroupIdentifierFactory()
     37    { super("FILEGROUP_PRELUDE");
     38    }
     39  }
    3040
    3141  public METSFileSet()
     
    3343    this.fileGroups.put("default", new METSFileGroup("default"));
    3444    this.reference = null;
     45    this.identifierFactory = new FileIdentifierFactory();
     46    this.groupIdentifierFactory = new FileGroupIdentifierFactory();
     47  }
     48
     49  /**
     50   *  Get a new FileGroup to lie within this fileset.  The group is not initialised with
     51   *  a parent, etc. - all that is done is the allocation of a unique group identifier.
     52   *
     53   *  @return <code>METSFileGroup</code> the new group.
     54   */
     55  public METSFileGroup createGroup()
     56  { METSFileGroup group = new METSFileGroup(this.groupIdentifierFactory.getNextIdentifier());
     57    return group;
     58  }
     59
     60  public METSFile createFile(METSFilePos filePos, String type)
     61  { METSFile file = new METSFile(new METSFileID(this.identifierFactory.getNextIdentifier()), filePos, type);
     62    return file;
    3563  }
    3664 
     
    80108    if (destGroup == null)
    81109    { destGroup = new METSFileGroup(toGroup);
    82       this.fileGroups.put(destGroup.getName(), destGroup);
     110      this.fileGroups.put(destGroup.getId(), destGroup);
    83111    }
    84112       
     
    97125   */
    98126  public void addGroup(METSFileGroup group)
    99   { this.fileGroups.put(group.getName(), group);
     127  { this.fileGroups.put(group.getId(), group);
    100128  }
    101129
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructure.java

    r6017 r6287  
    66import java.util.ArrayList;
    77import java.util.Map;
    8 import java.util.HashMap;
     8import java.util.LinkedHashMap;
    99import java.util.Iterator;
    1010
     
    1818import org.greenstone.gsdl3.gs3build.database.*;
    1919
    20 public class METSStructure
     20public class METSStructure extends AbstractStructure
    2121{
    22   Map children;
    23   String ID;
    2422  String label;
    2523  String type;
     24
     25  public static final String STRUCTURE_TYPE = "Structure";
    2626 
    2727  public METSStructure(String id, String label, String type)
    28   { this.children = new HashMap();
    29     this.ID       = id;
     28  { super(id);
     29
    3030    this.label    = label;
    3131    this.type     = type;
    3232  }
     33
     34  /**
     35   *  Show what sort of <code>AbstractStructure</code> this structure is...
     36   *
     37   *  @return <code>String The identifying string for a <code>METSStructure</code> type.
     38   */
     39  public String getStructureType()
     40  { return STRUCTURE_TYPE;
     41  }
    3342 
    34   /**
    35    *  Get the identifer of this structure
    36    *
    37    *  @param <code>String</code> the identifier.
    38    */
    39   public String getID()
    40   { return this.ID;
    41   }
    42 
    4343  /**
    4444   *  Find all the divisions that match a given list of file group
     
    5959
    6060  /**
    61    *  Add a division directly underneath this structure.
    62    *
    63    *  @param <code>METSDivision</code> the division to add.
    64    */
    65   public void addDivision(METSDivision division)
    66   { this.children.put(division.getID(), division);
    67   }
    68 
    69   /**
    7061   *  Add a division further into this structure.
    7162   *
    72    *  @param <code>String</code> the identifier for the division
     63   *  @param <code>String</code> the identifier label for the division
    7364   *         within which the division is to be added.
    7465   *  @param <code>METSDivision</code> the division to add.   
    7566   */
    76   public void addSubDivision(String divisionID, METSDivision division)
    77   { String topDivision = METSDivision.getTopDivisionName(divisionID);
     67  public void addSubDivision(String divisionLabel, METSDivision division)
     68  { String topDivision = METSDivision.getTopDivisionName(divisionLabel);
    7869
    7970    METSDivision child = (METSDivision) this.children.get(topDivision);
     
    8273    }
    8374
    84     String subDivisionID = METSDivision.getSubDivisionName(divisionID);
    85     if (subDivisionID == null)
    86     { child.addSubDivision(division);
    87     }
    88     else
    89     { child.addSubDivision(subDivisionID, division);
     75    child = child.getDivision(divisionLabel);
     76
     77    if (child != null) {
     78      child.addDivision(division);
    9079    }
    9180  }
     
    9887   *          <code>null</code> if it is not found.
    9988   */
    100   public METSDivision getDivision(String divisionID)
    101   { String topDivision = METSDivision.getTopDivisionName(divisionID);
    102 
     89  public METSDivision getDivision(String divisionLabel)
     90  { String topDivision = METSDivision.getTopDivisionName(divisionLabel);
     91
     92  if (!topDivision.equals("All"))
     93    System.out.println("Top division is " + topDivision);
    10394    METSDivision child = (METSDivision) this.children.get(topDivision);
    10495    if (child == null)
    105     { return null;
    106     }
    107 
    108     String subDivision = METSDivision.getSubDivisionName(divisionID);
    109     if (subDivision != null)
    110     { child = child.getDivision(subDivision);
    111     }
     96      { System.out.println("No child found");
     97      Iterator groups = this.children.keySet().iterator();
     98      while (groups.hasNext()) {
     99    System.out.println(groups.next().toString());
     100      }
     101      return null;
     102    }
     103
     104
     105    child = child.getDivision(divisionLabel);
    112106
    113107    return child;
    114108  }
    115109
     110  /**
     111   *  Write this structure in XML(METS) format to a <code>PrintWriter</code>
     112   */
    116113  public void write(PrintWriter writer)
    117114  { Iterator groups = this.children.values().iterator();
     
    216213  }
    217214
    218 
     215  /**
     216   *  Read a METSStructure from a database - on entry, the current item in the
     217   *  <code>ResultSet</code> holds the row in the database with the structure's
     218   *  data.
     219   *
     220   *  @param <code>DocumentInterface</code> the document which owns the structure
     221   *  @param <code>GS3SQLConnection</code> the database connection itself, to load
     222   *         child objects through, etc.
     223   *  @param <code>ResultSet</code> pointing to the current row in the database.
     224   */
    219225  public static METSStructure readSQL(DocumentInterface document, GS3SQLConnection connection,
    220226                      ResultSet resultSet)
    221227  {
     228    GS3SQLSelect select = null;
     229
    222230    try {
    223231      String ID    = resultSet.getString("StructureID");
     
    232240
    233241      // query the database for matching division for this structure block
    234       GS3SQLSelect select = new GS3SQLSelect("divisions");
     242      select = new GS3SQLSelect("divisions");
    235243      select.addField("*");
    236244      GS3SQLWhereItem whereItem = new GS3SQLWhereItem("ParentRef", "=", Integer.toString(structureRef),
    237245                              GS3SQLField.INTEGER_TYPE);
    238246      GS3SQLWhere where = new GS3SQLWhere(whereItem);
    239       whereItem = new GS3SQLWhereItem("ParentType", "=", METSDivision.STRUCTURE_PARENT);
     247      whereItem = new GS3SQLWhereItem("ParentType", "=", METSStructure.STRUCTURE_TYPE);
    240248      where.add(whereItem);
    241249      select.setWhere(where);
     
    245253      // parse through the divisions
    246254      ResultSet divisionSet = connection.getResultSet();
    247       divisionSet.first();
    248       do {
    249     METSDivision division = METSDivision.readSQL(connection, divisionSet);
    250     if (division != null) {
    251       structure.addDivision(division);
     255      if (divisionSet != null && divisionSet.first()) {
     256    do {
     257      METSDivision division = METSDivision.readSQL(connection, divisionSet);
     258      if (division != null) {
     259        structure.addDivision(division);
     260      }
    252261    }
    253       }
    254       while (divisionSet.next());
     262    while (divisionSet.next());
     263      }
    255264
    256265      return structure;
    257266    }
    258267    catch (SQLException sqlEx)
    259     { System.out.println(sqlEx);
     268    { System.out.println(sqlEx + " " + select.toString());
    260269      System.exit(1);
    261270    }
     
    263272  }
    264273}
     274
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructureSet.java

    r5945 r6287  
    1919public class METSStructureSet
    2020{ Map children;
     21
     22  public static final String GSDL3_SECTION_STRUCTURE = "Section";
    2123
    2224  public METSStructureSet()
     
    5860   *  @param <code>METSDivision</code> the division to be added.
    5961   */
    60   public void addDivision(String structureName, METSDivision division)
    61   { METSStructure structure = (METSStructure) this.children.get(structureName);
     62  public void addDivision(String structureId, METSDivision division)
     63  { METSStructure structure = (METSStructure) this.children.get(structureId);
    6264
    6365    if (structure != null)
     
    7476   *  @param <code>METSDivision</code> the division to be added.
    7577   */
    76   public void addSubDivision(String structureName, String divisionID, METSDivision division)
    77   { METSStructure structure = (METSStructure) this.children.get(structureName);
     78  public void addSubDivision(String structureId, String divisionID, METSDivision division)
     79  { METSStructure structure = (METSStructure) this.children.get(structureId);
    7880
    7981    if (structure != null)
     
    8284  }
    8385
    84   public METSDivision getDivision(String structureName, String divisionID)
    85   { METSStructure structure = (METSStructure) this.children.get(structureName);
     86  /**
     87   *  Get a division from within a given structure
     88   *
     89   *  @param <code>String</code> the structure identifier
     90   *  @param <code>String</code> the division identifer
     91   *
     92   *  @return <code>METSDivision</code> the division
     93   */
     94  public METSDivision getDivision(String structureId, String divisionId)
     95  { METSStructure structure = (METSStructure) this.children.get(structureId);
    8696
    8797    if (structure != null)
    88     { return structure.getDivision(divisionID);
     98    { return structure.getDivision(divisionId);
    8999    }
    90100    return null;
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/SimpleNamespace.java

    r5945 r6287  
    3636  { super(name);
    3737    this.metadataMap = new MultiMap();
    38     System.out.println("Namespace " + name);
    3938  }
    4039
Note: See TracChangeset for help on using the changeset viewer.