Changeset 8708


Ignore:
Timestamp:
2004-11-30T14:39:46+13:00 (19 years ago)
Author:
chi
Message:

add indentation for METS output file

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

Legend:

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

    r8702 r8708  
    245245     *  @param <code>Element</code> the XML element which represents the dmdSec itself
    246246     */
    247    
    248     //public static METSDescriptive parseXML(Element element, METSDescriptive thisDescriptive)
    249247    public static METSDescriptive parseXML(Element element)
    250248    {
     
    283281    return thisDescriptive;
    284282    }
    285    
    286    
    287     /**
    288      *  Parse an XML Element as a METS Descriptive Metadata section
    289      *
    290      *  @param <code>Element</code> the XML element which represents the dmdSec itself
    291      */
    292     /*  public static METSDescriptive parseXML(Element element)
    293     { // Note: no parsing of attributes required, we just move onto the metadata
    294     //       namespaces/sections themselves
    295     String ID = element.getAttribute("ID");
    296     String label = element.getAttribute("GROUPID");
    297     METSDescriptive thisDescriptive = new METSDescriptive(ID, label);
    298    
    299     NodeList children = element.getChildNodes();
    300    
    301     for (int c = 0; c < children.getLength(); c ++)
    302     { if (children.item(c).getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
    303         continue;
    304     }
    305    
    306     Element childElement = (Element) children.item(c);
    307     if (childElement.getNodeName().equals("mets:mdRef"))
    308     {   METSNamespace namespace = NamespaceFactory.parseXML(element);
    309     }
    310     else if (childElement.getNodeName().equals("mets:mdWrap"))
    311     {   METSNamespace namespace = NamespaceFactory.parseXML(element);
    312     }
    313     else
    314     {   // TODO: raise an error!
    315     }
    316     }
    317     return thisDescriptive;
    318     }
    319     */
    320 
    321283    /**
    322284     *  Write the document metadata to a <code>PrintWriter</code> in METS
     
    349311        while (namespaces.hasNext()){
    350312        METSNamespace namespace = (METSNamespace) namespaces.next();
    351        
     313   
    352314        namespace.write(output);
    353315        }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDescriptiveSet.java

    r8701 r8708  
    197197    return true;
    198198    }
    199 
    200     /*    public static METSDescriptiveSet parseXML(NodeList dmdSecs)
    201     {
    202     METSDescriptiveSet set = new METSDescriptiveSet();
    203     METSDescriptive thisDescriptive = null;
    204 
    205     for (int g = 0; g < dmdSecs.getLength(); g ++) {
    206         Element dmdNode = (Element) dmdSecs.item(g);
    207         String ID = dmdNode.getAttribute("ID");
    208         String label = dmdNode.getAttribute("GROUPID");
    209        
    210         if (label.equals("1")) {
    211         thisDescriptive = set.getDescriptive("default");
    212         } else {
    213         thisDescriptive = new METSDescriptive(ID, label);
    214         }
    215        
    216         METSDescriptive metadata = METSDescriptive.parseXML((Element) dmdSecs.item(g), thisDescriptive);
    217        
    218         set.addDescriptive(metadata);
    219         }
    220         return set;
    221         }*/
    222199
    223200    public static METSDescriptiveSet parseXML(NodeList dmdSecs)
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSDivision.java

    r8703 r8708  
    391391   
    392392    // write the central tag
     393    writer.print("   ");  //indentation
    393394    writer.println(tag);
    394395
     
    396397    if (this.fileRefs.size() > 0) {
    397398        String fileList = this.writeTagList("mets", "fptr", "FILEID", this.fileRefs);
     399        writer.print("      ");  //indentation
    398400        writer.println(fileList);
    399401    }
     
    411413   
    412414    // close the div element
     415    writer.print("   ");  //indentation
    413416    writer.println(XMLTools.getCloseTag("mets", DIVISION_TAG));
    414417
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFile.java

    r8703 r8708  
    173173    tag = XMLTools.addAttribute(tag, "MIMETYPE", this.MIMEType);
    174174    tag = XMLTools.addAttribute(tag, "ID", this.id.toString());
     175    writer.print("      ");   //indentation
    175176    writer.println(tag);
    176177   
     
    180181   
    181182    tag = XMLTools.makeSingleton(tag);
     183    writer.print("         ");  //indentation
    182184    writer.println(tag);
    183185   
     186    writer.print("      ");   //indentation
    184187    writer.println(XMLTools.getCloseTag("mets", "file"));
    185188    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSFileGroup.java

    r8703 r8708  
    256256    String tag = XMLTools.getOpenTag("mets","fileGrp");
    257257    tag = XMLTools.addAttribute(tag, "ID", this.id);
     258    writer.print("   ");   //indentation
    258259    writer.println(tag);
    259260   
     
    263264        file.write(writer);
    264265    }
     266    writer.print("   ");   //indentation
    265267    writer.println(XMLTools.getCloseTag("mets","fileGrp"));
    266268    }
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSNamespace.java

    r8461 r8708  
    1717public abstract class METSNamespace
    1818{
    19   protected String       type;        // the type of the metadata
    20   protected String       otherType;   // if a non-standard type, then...
    21   protected String       name;        // e.g. "DC" for Dublin Core
    22   protected METSLocation location;    // the location of the corresponding file
    23   protected String       group;       // the group of metadata namespaces to which
    24   // this namespace belongs
    25   protected String       id;          // the ID for this namespace
    26 
    27   public METSNamespace(String name)
    28   { this.name        = name;
    29     this.location    = null;
    30     this.group       = null;
    31     this.id          = null;
    32   }
    33 
    34   public METSNamespace(String name, METSLocation location)
    35   { this.location = location;
    36     this.name = name;
    37     this.group       = null;
    38     this.id          = null;
    39   }
    40 
    41   /**
    42    *  Get the name of the namespace...
    43    *
    44    *  @return <code>String</code> the name of the namespace
    45    */
    46   public String getName()
    47   { return this.name;
    48   }
    49 
    50   /**
    51    *  Get the group of namespaces to which this namespace belongs.
    52    *
    53    *  @return <code>String</code> the name of the namespace group
    54    */
    55   public String getGroup()
    56   { return this.group;
    57   }
     19    protected String       type;        // the type of the metadata
     20    protected String       otherType;   // if a non-standard type, then...
     21    protected String       name;        // e.g. "DC" for Dublin Core
     22    protected METSLocation location;    // the location of the corresponding file
     23    protected String       group;       // the group of metadata namespaces to which
     24    // this namespace belongs
     25    protected String       id;          // the ID for this namespace
     26
     27    public METSNamespace(String name)
     28    {
     29    this.name        = name;
     30    this.location    = null;
     31    this.group       = null;
     32    this.id          = null;
     33    }
     34   
     35    public METSNamespace(String name, METSLocation location)
     36    {
     37    this.location    = location;
     38    this.name        = name;
     39    this.group       = null;
     40    this.id          = null;
     41    }
     42   
     43    /**
     44     *  Get the name of the namespace...
     45     *
     46     *  @return <code>String</code> the name of the namespace
     47     */
     48    public String getName()
     49    {
     50    return this.name;
     51    }
     52   
     53    /**
     54     *  Get the group of namespaces to which this namespace belongs.
     55     *
     56     *  @return <code>String</code> the name of the namespace group
     57     */
     58    public String getGroup()
     59    {
     60    return this.group;
     61    }
     62   
     63    /**
     64     *  Set the group of namespaces to which this namespace belongs.
     65     *
     66     *  @param <code>String</code> the name of the namespace group
     67     */
     68    public void setGroup(String group)
     69    {
     70    this.group = group;
     71    }
     72   
     73    /**
     74     *  Get the ID for this namespace.
     75     *
     76     *  @return <code>String</code> the id of the namespace
     77     */
     78    public String getID()
     79    {
     80    return this.id;
     81    }
     82   
     83    /**
     84     *  Set the id of this namespace.
     85     *
     86     *  @param <code>String</code> the name of the namespace group
     87     */
     88    public void setID(String id)
     89    {
     90    this.id = id;
     91    }
     92
     93    /**
     94     *  <p>Indicate whether this namespace is open to being changed or not.</p>
     95     *  <p>Metadata which is created from a distinct file cannot be changed,
     96     *  only those which have no associated file can be modified.
     97     *
     98     *  @return <code>boolean</code> whether this namespace can be altered.
     99     */
     100    public boolean isEditable()
     101    {
     102    return (this.location == null);
     103    }
     104   
     105    public abstract boolean addMetadata(String label, String value);
     106    public abstract boolean setMetadata(String label, String value);
     107    public abstract boolean removeMetadata(String label);
     108    public abstract boolean removeMetadata(String label, String value);
     109    public abstract List    getMetadata(String label);
     110    public abstract Iterator getMetadataNames();
     111    public abstract boolean write(PrintWriter writer);
     112    //  public abstract boolean writeSQL(GS3SQLConnection connection);
     113
     114    /**
     115     *  Write out the metadata to an SQL database through a <code>GS3SQLConnection</code>.
     116     *
     117     *  @param <code>int</code> the sql identifier of the parent object (in "metadata") table.
     118     *  @param <code>GS3SQLConnection</code> the SQL database to use.
     119     */
     120    public boolean writeSQL(int parentId, GS3SQLConnection connection)
     121    {
     122    GS3SQLAction action;
     123
     124    // If the namespace is not null, then set it...
     125    if (this.id != null) {
     126        // use an update action in this case...
     127        GS3SQLUpdate update = new GS3SQLUpdate("namespaces");
     128        update.addValue("NamespaceID", this.id);
     129
     130        // set up the where clause
     131        GS3SQLWhere where =
     132        new GS3SQLWhere(new GS3SQLWhereItem("NamespaceRef", "=", this.id,
     133                            GS3SQLField.INTEGER_TYPE));
     134        update.setWhere(where);
     135        action = update;
     136    }
     137    else {
     138        GS3SQLInsert insert = new GS3SQLInsert("namespaces");
     139        action = insert;
     140    }
     141
     142    if (this.location != null) {
     143        action.addValue("FileLoc", this.location.getLocation().toString());
     144        action.addValue("FileType", "URL");
     145    }
     146    else {
     147        // no location stuff
     148    }
     149    action.addValue("MetadataRef", Integer.toString(parentId), GS3SQLField.INTEGER_TYPE);
     150    action.addValue("NamespaceType", this.name);
     151
     152    // Execute the action
     153    connection.execute(action.toString());
     154
     155    // then get the namespace reference number if needsbe...
     156    if (this.id == null) {
     157        GS3SQLSelect select = new GS3SQLSelect("namespaces");
     158        select.addField("NamespaceRef");
     159        GS3SQLWhereItem whereItem = new GS3SQLWhereItem("MetadataRef", "=", Integer.toString(parentId), GS3SQLField.INTEGER_TYPE);
     160        GS3SQLWhere where = new GS3SQLWhere(whereItem);
     161        whereItem = new GS3SQLWhereItem("NamespaceType", "=", this.name);
     162        where.add(where);
     163        try {
     164        connection.execute(select.toString());
     165     
     166        ResultSet result = connection.getResultSet();
     167        result.last();
     168        this.id = Integer.toString(result.getInt("NamespaceRef"));
     169        }
     170        catch (SQLException sqlex){
     171        this.id = null;
     172        System.err.println(sqlex);
     173        return false;
     174        }
     175    }
    58176   
    59   /**
    60    *  Set the group of namespaces to which this namespace belongs.
    61    *
    62    *  @param <code>String</code> the name of the namespace group
    63    */
    64   public void setGroup(String group)
    65   { this.group = group;
    66   }
    67 
    68   /**
    69    *  Get the ID for this namespace.
    70    *
    71    *  @return <code>String</code> the id of the namespace
    72    */
    73   public String getID()
    74   { return this.id;
    75   }
    76 
    77   /**
    78    *  Set the id of this namespace.
    79    *
    80    *  @param <code>String</code> the name of the namespace group
    81    */
    82   public void setID(String id)
    83   { this.id = id;
    84   }
    85 
    86   /**
    87    *  <p>Indicate whether this namespace is open to being changed or not.</p>
    88    *  <p>Metadata which is created from a distinct file cannot be changed,
    89    *  only those which have no associated file can be modified.
    90    *
    91    *    @return <code>boolean</code> whether this namespace can be altered.
    92    */
    93   public boolean isEditable()
    94   { return (this.location == null);
    95   }
    96 
    97   public abstract boolean addMetadata(String label, String value);
    98   public abstract boolean setMetadata(String label, String value);
    99   public abstract boolean removeMetadata(String label);
    100   public abstract boolean removeMetadata(String label, String value);
    101   public abstract List    getMetadata(String label);
    102   public abstract Iterator getMetadataNames();
    103   public abstract boolean write(PrintWriter writer);
    104   //  public abstract boolean writeSQL(GS3SQLConnection connection);
    105 
    106   /**
    107    *  Write out the metadata to an SQL database through a <code>GS3SQLConnection</code>.
    108    *
    109    *  @param <code>int</code> the sql identifier of the parent object (in "metadata") table.
    110    *  @param <code>GS3SQLConnection</code> the SQL database to use.
    111    */
    112   public boolean writeSQL(int parentId, GS3SQLConnection connection)
    113   {
    114     GS3SQLAction action;
    115 
    116     // If the namespace is not null, then set it...
    117     if (this.id != null) {
    118       // use an update action in this case...
    119       GS3SQLUpdate update = new GS3SQLUpdate("namespaces");
    120       update.addValue("NamespaceID", this.id);
    121 
    122       // set up the where clause
    123       GS3SQLWhere where =
    124     new GS3SQLWhere(new GS3SQLWhereItem("NamespaceRef", "=", this.id,
    125                         GS3SQLField.INTEGER_TYPE));
    126       update.setWhere(where);
    127       action = update;
    128     }
    129     else {
    130       GS3SQLInsert insert = new GS3SQLInsert("namespaces");
    131       action = insert;
    132     }
    133 
    134     if (this.location != null) {
    135       action.addValue("FileLoc", this.location.getLocation().toString());
    136       action.addValue("FileType", "URL");
    137     }
    138     else {
    139       // no location stuff
    140     }
    141     action.addValue("MetadataRef", Integer.toString(parentId), GS3SQLField.INTEGER_TYPE);
    142     action.addValue("NamespaceType", this.name);
    143 
    144     // Execute the action
    145     connection.execute(action.toString());
    146 
    147     // then get the namespace reference number if needsbe...
    148     if (this.id == null) {
    149       GS3SQLSelect select = new GS3SQLSelect("namespaces");
    150       select.addField("NamespaceRef");
    151       GS3SQLWhereItem whereItem = new GS3SQLWhereItem("MetadataRef", "=", Integer.toString(parentId), GS3SQLField.INTEGER_TYPE);
    152       GS3SQLWhere where = new GS3SQLWhere(whereItem);
    153       whereItem = new GS3SQLWhereItem("NamespaceType", "=", this.name);
    154       where.add(where);
    155       try {
    156     connection.execute(select.toString());
     177    return true;
     178    }
     179   
     180    public static METSNamespace readSQL(GS3SQLConnection connection, ResultSet resultSet)
     181    {
     182    METSLocation metsLocation = null;
     183   
     184    try {
     185        String name = resultSet.getString("NamespaceType");
     186        String id = resultSet.getString("NamespaceRef");
     187        String location = resultSet.getString("FileLoc");
     188        String type = resultSet.getString("FileType");
     189        if (location != null && type != null) {
     190        metsLocation = new METSLocation(type, location);
     191        }
     192       
     193        METSNamespace namespace = NamespaceFactory.initNamespace(name, metsLocation);
     194        namespace.id = id;
     195
     196        int namespaceRef = resultSet.getInt("NamespaceRef");
    157197     
    158     ResultSet result = connection.getResultSet();
    159     result.last();
    160     this.id = Integer.toString(result.getInt("NamespaceRef"));
    161       }
    162       catch (SQLException sqlex)
    163       { this.id = null;
    164         System.err.println(sqlex);
    165     return false;
    166       }
    167     }
    168 
    169     return true;
    170   }
    171 
    172   public static METSNamespace readSQL(GS3SQLConnection connection, ResultSet resultSet)
    173   {
    174     METSLocation metsLocation = null;
    175    
    176     try {
    177       String name = resultSet.getString("NamespaceType");
    178       String id = resultSet.getString("NamespaceRef");
    179       String location = resultSet.getString("FileLoc");
    180       String type = resultSet.getString("FileType");
    181       if (location != null && type != null) {
    182     metsLocation = new METSLocation(type, location);
    183       }
    184 
    185       METSNamespace namespace = NamespaceFactory.initNamespace(name, metsLocation);
    186       namespace.id = id;
    187 
    188       int namespaceRef = resultSet.getInt("NamespaceRef");
     198        GS3SQLSelect select = new GS3SQLSelect("mdvalues");
     199        select.addField("*");
     200        GS3SQLWhere where = new GS3SQLWhere(new GS3SQLWhereItem("NamespaceRef", "=", Integer.toString(namespaceRef),
     201                                    GS3SQLField.INTEGER_TYPE));
     202        select.setWhere(where);
     203
     204        connection.execute(select.toString());
    189205     
    190       GS3SQLSelect select = new GS3SQLSelect("mdvalues");
    191       select.addField("*");
    192       GS3SQLWhere where = new GS3SQLWhere(new GS3SQLWhereItem("NamespaceRef", "=", Integer.toString(namespaceRef),
    193                                   GS3SQLField.INTEGER_TYPE));
    194       select.setWhere(where);
    195 
    196       connection.execute(select.toString());
    197      
    198       ResultSet valuesSet = connection.getResultSet();
    199       if (valuesSet != null && valuesSet.first()) {
    200     do {
    201       String label = valuesSet.getString("Label");
    202       String value = valuesSet.getString("Value");
    203 
    204       namespace.addMetadata(label, value);
    205     }
    206     while (valuesSet.next());
    207       }
    208 
    209       return namespace;
    210     }
    211     catch (java.net.MalformedURLException urlEx)
    212     { System.out.println(urlEx);
    213     }
    214     catch (SQLException sqlEx)
    215     { System.out.println(sqlEx);
    216     }   
    217     return null;
    218   }
     206        ResultSet valuesSet = connection.getResultSet();
     207        if (valuesSet != null && valuesSet.first()) {
     208        do {
     209            String label = valuesSet.getString("Label");
     210            String value = valuesSet.getString("Value");
     211
     212            namespace.addMetadata(label, value);
     213        }
     214        while (valuesSet.next());
     215        }
     216
     217        return namespace;
     218    }
     219    catch (java.net.MalformedURLException urlEx){
     220        System.out.println(urlEx);
     221    }
     222    catch (SQLException sqlEx){
     223        System.out.println(sqlEx);
     224    }   
     225    return null;
     226    }
    219227}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/METSStructureSet.java

    r8461 r8708  
    2323
    2424public class METSStructureSet
    25 { Map children;
     25{
     26    Map children;
    2627
    27   public static final String GSDL3_SECTION_STRUCTURE = "Section";
     28    public static final String GSDL3_SECTION_STRUCTURE = "Section";
    2829
    29   public METSStructureSet()
    30   { this.children = new HashMap();
    31   }
     30    public METSStructureSet()
     31    {
     32    this.children = new HashMap();
     33    }
    3234
    33   public void addStructure(METSStructure structure)
    34   { this.children.put(structure.getID(), structure);
    35   }
     35    public void addStructure(METSStructure structure)
     36    {
     37    this.children.put(structure.getID(), structure);
     38    }
    3639
    37   public METSStructure getStructure(String name)
    38   { return (METSStructure) this.children.get(name);
    39   }
     40    public METSStructure getStructure(String name)
     41    {
     42    return (METSStructure) this.children.get(name);
     43    }
    4044
    41   /**
    42    *  Find the divisions that contain a list of given files
    43    *
    44    *  @param <code>List</code> the list of files to find...
    45    *  @return <code>List</code> the matching divisions.
    46    */
    47   public List findDivisionsForFiles(List listOfFileIdentifiers)
    48   { List reply = new ArrayList();
     45    /**
     46     *  Find the divisions that contain a list of given files
     47     *
     48     *  @param <code>List</code> the list of files to find...
     49     *  @return <code>List</code> the matching divisions.
     50     */
     51    public List findDivisionsForFiles(List listOfFileIdentifiers)
     52    {
     53    List reply = new ArrayList();
    4954
    50     // iterate across all the children...
    51     Iterator structures = this.children.values().iterator();
     55    // iterate across all the children...
     56    Iterator structures = this.children.values().iterator();
     57   
     58    while (structures.hasNext()){
     59        METSStructure structure = (METSStructure) structures.next();
     60       
     61        structure.findDivisionsForFiles(listOfFileIdentifiers, reply);     
     62    }   
     63    return reply;
     64    }
    5265   
    53     while (structures.hasNext())
    54     { METSStructure structure = (METSStructure) structures.next();
     66    /**
     67     *  Add a division to an indicated structure.
     68     *
     69     *  @param <code>String</code> the structure identifier
     70     *  @param <code>METSDivision</code> the division to be added.
     71     */
     72    public void addDivision(String structureId, METSDivision division)
     73    {
     74    METSStructure structure = (METSStructure) this.children.get(structureId);
     75   
     76    if (structure != null){
     77        structure.addDivision(division);
     78    }
     79    }
    5580
    56       structure.findDivisionsForFiles(listOfFileIdentifiers, reply);     
    57     }   
    58     return reply;
    59   }
     81    /**
     82     *  Add a division to an indicated division within structure.
     83     *
     84     *  @param <code>String</code> the structure identifier
     85     *  @param <code>String</code> the division identifer, within which the division
     86     *         is to be placed.
     87     *  @param <code>METSDivision</code> the division to be added.
     88     */
     89    public void addSubDivision(String structureId, String divisionID, METSDivision division)
     90    {
     91    METSStructure structure = (METSStructure) this.children.get(structureId);
    6092
    61   /**
    62    *  Add a division to an indicated structure.
    63    *
    64    *  @param <code>String</code> the structure identifier
    65    *  @param <code>METSDivision</code> the division to be added.
    66    */
    67   public void addDivision(String structureId, METSDivision division)
    68   { METSStructure structure = (METSStructure) this.children.get(structureId);
     93    if (structure != null){
     94        structure.addSubDivision(divisionID, division);
     95    }
     96    }
    6997
    70     if (structure != null)
    71     { structure.addDivision(division);
     98    /**
     99     *  Get a division from within a given structure
     100     *
     101     *  @param <code>String</code> the structure identifier
     102     *  @param <code>String</code> the division identifer
     103     *
     104     *  @return <code>METSDivision</code> the division
     105     */
     106    public METSDivision getDivision(String structureId, String divisionId)
     107    {
     108    METSStructure structure = (METSStructure) this.children.get(structureId);
     109
     110    if (structure != null){
     111        return structure.getDivision(divisionId);
     112    }
     113    return null;
    72114    }
    73   }
    74 
    75   /**
    76    *  Add a division to an indicated division within structure.
    77    *
    78    *  @param <code>String</code> the structure identifier
    79    *  @param <code>String</code> the division identifer, within which the division
    80    *         is to be placed.
    81    *  @param <code>METSDivision</code> the division to be added.
    82    */
    83   public void addSubDivision(String structureId, String divisionID, METSDivision division)
    84   { METSStructure structure = (METSStructure) this.children.get(structureId);
    85 
    86     if (structure != null)
    87     { structure.addSubDivision(divisionID, division);
    88     }
    89   }
    90 
    91   /**
    92    *  Get a division from within a given structure
    93    *
    94    *  @param <code>String</code> the structure identifier
    95    *  @param <code>String</code> the division identifer
    96    *
    97    *  @return <code>METSDivision</code> the division
    98    */
    99   public METSDivision getDivision(String structureId, String divisionId)
    100   { METSStructure structure = (METSStructure) this.children.get(structureId);
    101 
    102     if (structure != null)
    103     { return structure.getDivision(divisionId);
    104     }
    105     return null;
    106   }
    107115    public static METSStructureSet parseXML(NodeList structMapSecs)
    108      {
     116    {
    109117    METSStructureSet set = new METSStructureSet();
    110118 
     
    114122    }
    115123    return set;
    116      }
     124    }
    117125       
    118126
    119   public void write(PrintWriter writer)
    120   { Iterator structures = this.children.values().iterator();
     127    public void write(PrintWriter writer)
     128    {
     129    Iterator structures = this.children.values().iterator();
    121130
    122     while (structures.hasNext())
    123     { METSStructure group = (METSStructure) structures.next();
     131    while (structures.hasNext()){
     132        METSStructure group = (METSStructure) structures.next();
     133       
     134        group.write(writer);
     135    }
     136    }
     137   
     138    public boolean writeSQL(DocumentInterface document, GS3SQLConnection connection)
     139    {
     140    Iterator structures = this.children.values().iterator();
     141   
     142    while (structures.hasNext()){
     143        METSStructure group = (METSStructure) structures.next();
    124144
    125       group.write(writer);
    126     }
    127   }
    128 
    129   public boolean writeSQL(DocumentInterface document, GS3SQLConnection connection)
    130   { Iterator structures = this.children.values().iterator();
    131    
    132     while (structures.hasNext())
    133     { METSStructure group = (METSStructure) structures.next();
    134 
    135       if (!group.writeSQL(document, connection))
    136       { return false;
    137       }
    138     }
    139     return true;
    140   }
    141 
    142   public static METSStructureSet readSQL(DocumentInterface document, GS3SQLConnection connection)
    143   {
    144     METSStructureSet set = new METSStructureSet();
    145 
    146     GS3SQLSelect select = new GS3SQLSelect("structure");
    147     select.addField("*");
    148     GS3SQLWhereItem whereItem = new GS3SQLWhereItem("DocID", "=", document.getID().toString());
    149     select.setWhere(new GS3SQLWhere(whereItem));
    150     connection.execute(select.toString());
    151 
    152     // start going through the matching metadata blocks
    153     try {
    154       ResultSet resultSet = connection.getResultSet();
    155       resultSet.first();
    156       do {
    157     METSStructure structure = METSStructure.readSQL(document, connection, resultSet);
    158     if (structure != null) {
    159       set.addStructure(structure);
     145        if (!group.writeSQL(document, connection)){
     146        return false;
     147        }
    160148    }
    161       } while (resultSet.next());
    162     }
    163     catch (SQLException sqlEx) {
    164       System.out.println(sqlEx);
    165       System.exit(1);
     149    return true;
    166150    }
    167151
    168     return set;
    169   }
     152    public static METSStructureSet readSQL(DocumentInterface document, GS3SQLConnection connection)
     153    {
     154    METSStructureSet set = new METSStructureSet();
    170155
     156    GS3SQLSelect select = new GS3SQLSelect("structure");
     157    select.addField("*");
     158    GS3SQLWhereItem whereItem = new GS3SQLWhereItem("DocID", "=", document.getID().toString());
     159    select.setWhere(new GS3SQLWhere(whereItem));
     160    connection.execute(select.toString());
     161
     162    // start going through the matching metadata blocks
     163    try {
     164        ResultSet resultSet = connection.getResultSet();
     165        resultSet.first();
     166        do {
     167        METSStructure structure = METSStructure.readSQL(document, connection, resultSet);
     168        if (structure != null) {
     169            set.addStructure(structure);
     170        }
     171        } while (resultSet.next());
     172    }
     173    catch (SQLException sqlEx) {
     174        System.out.println(sqlEx);
     175        System.exit(1);
     176    }
     177    return set;
     178    }
    171179}
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/OrderedNamespace.java

    r8700 r8708  
    197197        tag = XMLTools.addAttribute(tag, "OTHERMDTYPE", this.name);
    198198        if (this.id != null) {
    199         //System.err.println("###ID" +this.id);
    200199        this.id = "gsdl"+this.id;
    201200        tag = XMLTools.addAttribute(tag, "ID", this.id);
    202201        }
     202        writer.print("   ");  //indentation
    203203        writer.println(tag);
    204204       
     
    209209        this.writeItem(writer, item);
    210210        }
     211        writer.print("   ");  //indentation
    211212        writer.println("</mets:mdWrap>");
    212213    }
     
    236237    {
    237238    // Do some default sillinesses
    238     //writer.write("         ");
     239    //writer.write("         "); 
    239240    writer.write(XMLTools.getOpenTag(this.name, item.getLabel()));
    240241   
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/metadata/SimpleNamespace.java

    r8700 r8708  
    193193        if (this.id != null) {
    194194        this.id = "gsdl"+this.id;
    195         //System.err.println("###Simple ID=" +this.id);
    196195        tag = XMLTools.addAttribute(tag, "ID", this.id);
    197196        }
     197        writer.print("   ");  //indentation
    198198        writer.println(tag);
    199199       
    200200        tag = XMLTools.getOpenTag("mets", "xmlData");
     201        writer.print("      ");  //indentation
    201202        writer.println(tag);
    202203       
     
    204205        while (keys.hasNext()){
    205206        String thisKey = keys.next().toString();
     207        writer.print("         "); //indentation
    206208        this.writeItem(writer, thisKey);
    207209        }
    208210       
     211        writer.print("      ");  //indentation
    209212        writer.println(XMLTools.getCloseTag("mets", "xmlData"));
    210213       
     214        writer.print("   ");  //indentation
    211215        writer.println(XMLTools.getCloseTag("mets", "mdWrap"));
    212216    }
     
    225229        }
    226230        writer.println(tag);
    227        
     231        writer.print("   ");  //indentation
    228232        writer.println("</mets:mdRef>");
    229233        }
     
    245249        String metaTagName = "Metadata name=" +'"'+ label +'"';
    246250        //writer.write(XMLTools.getOpenTag(this.name, label));
    247         writer.write("         ");
    248251        writer.write(XMLTools.getOpenTag(this.name, metaTagName));
    249252        writer.write(value);
     
    259262        tag = XMLTools.addAttribute(tag, "MDTYPE", this.getName());
    260263        tag = XMLTools.makeSingleton(tag);
     264        writer.print("      "); //indentation
    261265        writer.println(tag);
    262266    }
Note: See TracChangeset for help on using the changeset viewer.