Changeset 5712


Ignore:
Timestamp:
2003-10-23T10:48:34+13:00 (21 years ago)
Author:
jmt12
Message:

Now metadata attached to files whose origin is the base collection, can be automatically assumed to be extracted if no other namespace is specified

File:
1 edited

Legend:

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

    r5589 r5712  
    9393    /** Locate and import any metadata parsed by this metadata parser given the file involved and its previous incarnation. */
    9494    public boolean process(FileNode destination, FileNode origin, boolean folder_level, boolean dummy_run) {
    95     ///atherer.println("GreenstoneMetadataParser: Process " + origin + ": ");
     95    Gatherer.println("GreenstoneMetadataParser: Process " + origin + ": ");
    9696    int counter = 0;
    9797    dialog_cancelled = false;
     
    114114        if(possible_cfg_file.exists() && (possible_gimport_directory.exists() || possible_import_directory.exists())) {
    115115        found = true;
    116         ///ystem.err.println("Found greenstone collection at " + collection_dir.getAbsolutePath());
     116        Gatherer.println("Found greenstone collection at " + collection_dir.getAbsolutePath());
    117117        }
    118118        else {
     
    131131
    132132    // 2. If a collection configuration file was found, attempt to merge in any mdses and make note of those that are successfully imported (by removing reference from collect.cfg).
    133     ///ystem.err.print("2 ");
     133    Gatherer.println("Merging in any metadata sets found.");
    134134    if(collect_cfg != null) {
    135135        ArrayList mdses = collect_cfg.getMetadataSets();
     
    143143
    144144    // 3. Locate all of the metadata.xml files that may have an affect on the origin file. Make sure the metadata.xml closest to the origin files directory is last (to ensure property inheritance regarding accumulate/overwrite).
    145     ///ystem.err.print("3 ");
     145    Gatherer.println("Searching for metadata.xml files");
    146146    ArrayList search_files = new ArrayList();
    147147    File file = origin.getFile();
     
    176176    for(int i = 0; i < search_files.size(); i++) {
    177177        MetadataXMLFileSearch a_search = (MetadataXMLFileSearch) search_files.get(i);
    178         ///ystem.err.println("Search " + a_search.file.getAbsolutePath() + " for " + (a_search.filename != null ? a_search.filename : ".*"));
     178        Gatherer.println("Search " + a_search.file.getAbsolutePath() + " for " + (a_search.filename != null ? a_search.filename : ".*"));
     179        Gatherer.println("Search at the " + (folder_level ? "Folder" : "Filename") + " level");
    179180        // Retrieve the document
    180181        BasicGDMDocument document = getDocument(a_search.file);
     
    193194    search_files = null;
    194195    // Finally assign the metadata
    195     ///ystem.err.println("Found " + metadata.size() + " pieces of metadata for " + destination);
     196    Gatherer.println("Found " + metadata.size() + " pieces of metadata for " + destination);
    196197    if(metadata.size() > 0) {
    197198        addMetadata(origin, destination, metadata, collection_dir, collect_cfg, dummy_run);
     
    281282        ///atherer.println("Assigning metadatum.");
    282283        if(metadatum != null) {
    283             // 6c. Try to add metadata. If there is no matching metadata element:
    284             ElementWrapper element = Gatherer.c_man.getCollection().msm.getElement(metadatum.element, true);
    285             // Arg. The element returned may come from the Greenstone dls, which of course should never be involved during importing. To solve check the namespace isn't "" and if it is nullify the element. Nullify. NULLIFY, Bwuhahahaha...
    286             if(element != null && element.getNamespace().equals("")) {
    287             element = null;
    288             }
     284           ElementWrapper element = null;
     285           // 6c. Try to add metadata.
     286           // If we just happen to be importing files from our base collection, then we can assume that any non-namespaced elements are actually extracted metadata
     287           if(Utility.isParentFolderOf(Gatherer.c_man.getCollection().getBaseCollection(), origin.getFile().getParentFile())) {
     288              element = Gatherer.c_man.getCollection().msm.getElement(metadatum.element);// Perfect Match not required
     289           }
     290           // Typical case
     291           else {
     292              element = Gatherer.c_man.getCollection().msm.getElement(metadatum.element, true); // Perfect match
     293           }
     294           
     295           ///ystem.err.println("Closest match: " + element);
    289296            // 6ci. If no match exists, prompt the user to add/merge with specific metadata element. The user can also choose to ignore this metadata.
    290297            if(element == null) {
Note: See TracChangeset for help on using the changeset viewer.