Changeset 5039


Ignore:
Timestamp:
2003-07-25T16:38:55+12:00 (21 years ago)
Author:
jmt12
Message:

Fixed bug where no metadata was being extracted from the archives unless it was already specified in the extracted metadata set. (a test during inserting a new element was comparing to 'ex' and was, not surprisingly, failing).

Location:
trunk/gli/src/org/greenstone/gatherer/msm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/msm/GreenstoneArchiveParser.java

    r4674 r5039  
    3939import java.net.*;
    4040import java.util.*;
     41import org.greenstone.gatherer.Configuration;
    4142import org.greenstone.gatherer.Gatherer;
    4243import org.greenstone.gatherer.collection.Collection;
     
    6263    public GreenstoneArchiveParser(GShellProgressMonitor progress, GShell shell) {
    6364    // We can only extract metadata if an extracted metadata set exists in our collection.
    64     if(Gatherer.c_man.msm.getSet("") != null) {
     65    if(Gatherer.c_man.msm.getSet(Utility.EXTRACTED_METADATA_NAMESPACE) != null) {
    6566        this.shell = shell;
    6667        // Determine the collection archive directory.
     
    7475            // Then extract the metadata from it.
    7576            if(document_file.exists()) {
    76             extractMetadata(document_file);
     77            int count = extractMetadata(document_file);
    7778            // Display a pretty progress message.
    78             shell.fireMessage(GShell.IMPORT, shell.typeAsString(GShell.IMPORT) + "> " + Gatherer.dictionary.get("GShell.Extracted", document_directories[i].getName()), GShell.OK);
     79            String[] args = new String[2];
     80            args[0] = document_directories[i].getName();
     81            args[1] = String.valueOf(count);
     82            shell.message(GShell.IMPORT, shell.typeAsString(GShell.IMPORT) + "> " + Gatherer.dictionary.get("GShell.Extracted", args), GShell.OK);
     83            args = null;
    7984            progress.increment();
    8085            }
     
    115120                ElementWrapper element = Gatherer.c_man.msm.getElement(name);
    116121                if(element == null) {
    117                 MetadataSet extracted_mds = Gatherer.c_man.msm.getSet("ex");
     122                MetadataSet extracted_mds = Gatherer.c_man.msm.getSet(Utility.EXTRACTED_METADATA_NAMESPACE);
    118123                if(extracted_mds != null) {
    119                     element = extracted_mds.addElement(name);
     124                    element = extracted_mds.addElement(name, Gatherer.config.interface_language);
    120125                }
    121126                }
  • trunk/gli/src/org/greenstone/gatherer/msm/MetadataSetManager.java

    r4933 r5039  
    386386    // First we seperate off what set it is in, where we have '<set><namespace_separator><element>'.
    387387    if(name.indexOf(MSMUtils.NS_SEP) != -1) {
    388         String namespace = name.substring(0, name.indexOf(MSMUtils.NS_SEP));
    389                 // Retrieve the correct set if possible.
    390         set = (MetadataSet)mds_hashtable.get(namespace);
    391         namespace = null;
    392                 // Now retrieve the element name.
    393         element = name.substring(name.indexOf(MSMUtils.NS_SEP) + 1);
     388        if(name.startsWith(Utility.EXTRACTED_METADATA_NAMESPACE)) {
     389        // Retrieve the correct set if possible.
     390        set = (MetadataSet)mds_hashtable.get("");
     391        // Now retrieve the element name.
     392        element = name.substring(name.indexOf(MSMUtils.NS_SEP) + 1);
     393        }
     394        else {
     395        String namespace = name.substring(0, name.indexOf(MSMUtils.NS_SEP));
     396        // Retrieve the correct set if possible.
     397        set = (MetadataSet)mds_hashtable.get(namespace);
     398        namespace = null;
     399        // Now retrieve the element name.
     400        element = name.substring(name.indexOf(MSMUtils.NS_SEP) + 1);
     401        }
    394402    }
    395403    else {
    396                 // No namespace so assume ns = "".
     404        // No namespace so assume ns = "".
    397405        set = (MetadataSet)mds_hashtable.get("");
    398406        element = name;
    399407    }
    400408    if(set != null) {
    401                 ///ystem.err.print("Trying to match element " + element +"?");
     409        ///ystem.err.print("Trying to match element " + element +"?");
    402410        Element temp = set.getElement(element);
    403411        if(temp != null) {
     
    457465        return (MetadataSet) mds_hashtable.get(name);
    458466    }
     467    else if(name.equals(Utility.EXTRACTED_METADATA_NAMESPACE)) {
     468        return (MetadataSet) mds_hashtable.get("");
     469    }
    459470    else {
    460                 ///ystem.err.println("Couldn't find metadata set.");
     471        ///ystem.err.println("Couldn't find metadata set.");
    461472        if(name.equals(HIDDEN)) {
    462473        return createHidden();
Note: See TracChangeset for help on using the changeset viewer.