Changeset 13399 for trunk/gli


Ignore:
Timestamp:
2006-12-01T14:23:45+13:00 (17 years ago)
Author:
mdewsnip
Message:

Tidied up default metadata sets and added a "addRequiredMetadataSets" function so the extracted metadata set is always loaded when creating or loading a collection.

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

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r13398 r13399  
    414414
    415415        // Import default metadata sets, if any
    416         for (int i = 0; metadata_sets != null && i < metadata_sets.size(); i++) {
    417         importMetadataSet((MetadataSet) metadata_sets.get(i));
    418         }
     416        // for (int i = 0; metadata_sets != null && i < metadata_sets.size(); i++) {
     417        // importMetadataSet((MetadataSet) metadata_sets.get(i));
     418        // }
    419419
    420420        ProfileXMLFileManager.loadProfileXMLFile(new File(collection_directory_path + "metadata"));
     
    452452        }
    453453
    454         // Always import the extracted metadata set if we didn't already
    455         if (MetadataSetManager.getMetadataSet(MetadataSetManager.EXTRACTED_METADATA_NAMESPACE) == null) {
    456         File extracted_metadata_set_file = new File(Gatherer.getGLIMetadataDirectoryPath() + MetadataSetManager.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION);
    457         importMetadataSet(new MetadataSet(extracted_metadata_set_file));
    458         }
     454        // Load the default metadata sets
     455        addDefaultMetadataSets();
     456
     457        // Make sure we always have the extracted metadata set
     458        addRequiredMetadataSets();
    459459
    460460        collection.cdm = new CollectionDesignManager(new File(getCollectionConfigFilePath()));
     
    793793        }
    794794        }
    795         catch (Exception ex) {
    796         ex.printStackTrace();
     795        catch (Exception exception) {
     796        DebugStream.printStackTrace(exception);
    797797        }
    798798
     
    860860    }
    861861
    862     boolean non_gli_collection = false;
    863 
    864862    // Check we have actually been given a .col file.
    865863    if (!location.endsWith(".col")) {
     
    895893
    896894    // Special case of a user trying to open an old greenstone collection.
     895    boolean non_gli_collection = false;
    897896    File collection_metadata_directory = new File(collection_directory, "metadata");
    898897    if (!collection_metadata_directory.exists()) {
     
    960959        MetadataSetManager.loadMetadataSets(collection_metadata_directory);
    961960
     961        // Make sure we always have the extracted metadata set
     962        addRequiredMetadataSets();
     963
    962964        ProfileXMLFileManager.loadProfileXMLFile(collection_metadata_directory);
    963965 
    964         // If this is a non-GLI (legacy) collection, load the
    965         // default metadata
     966        // If this is a non-GLI (legacy) collection, load the default metadata sets
    966967        if (non_gli_collection) {
    967         addDefaultMetadataSets(collection_directory);
    968        
     968        addDefaultMetadataSets();
     969
    969970        // Recurse the import folder tree, backing up the metadata.xml files before they are edited
    970971        LegacyCollectionImporter.backupMetadataXMLFiles(collection_directory);
     
    12611262
    12621263    /** I started giving the user the choice of using an existing meta set or creating a new one. The second option being so that they didn't have to add/merge/ignore each element, they could all be added automatically. However, I am not sure where the merge prompt gets called from, and it is not essential, so I am leaving it for now - it should be added back in and finished. [kjdon] */
    1263     private boolean addDefaultMetadataSets(File collection_dir) {
    1264 
    1265 
     1264    private void addDefaultMetadataSets()
     1265    {
    12661266    // Add dublin core which is the default metadata set. The user
    12671267    // can change this later
     
    12701270        importMetadataSet(new MetadataSet(dc_file));
    12711271    }
    1272 
     1272    }
     1273
     1274
     1275    private void addRequiredMetadataSets()
     1276    {
    12731277    // Always import the extracted metadata set
    12741278    File extracted_metadata_set_file = new File(Gatherer.getGLIMetadataDirectoryPath() + MetadataSetManager.EXTRACTED_METADATA_NAMESPACE + StaticStrings.METADATA_SET_EXTENSION);
    12751279    importMetadataSet(new MetadataSet(extracted_metadata_set_file));
    1276 
    1277     return true;
    12781280    }
    12791281
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r13393 r13399  
    745745        // Create the collection details prompt from new collection prompt
    746746        NewCollectionDetailsPrompt ncd_prompt = new NewCollectionDetailsPrompt();
    747         // dc metadata set is the default
    748         ArrayList metadata_sets  = new ArrayList();
    749         File dc_file = new File(Gatherer.getGLIMetadataDirectoryPath()+"dublin.mds");
    750         if (dc_file.exists()) {
    751         metadata_sets.add(new MetadataSet(dc_file));
    752         }
     747
    753748        // Create the new collection (if not cancelled) in a new thread.
    754749        if (!ncd_prompt.isCancelled()) {
     
    759754       
    760755        // Create new collection.
    761         Gatherer.c_man.createCollection(ncd_prompt.getDescription(), Configuration.getEmail(), ncd_prompt.getName(), ncd_prompt.getTitle(), ncd_prompt.getBase(), metadata_sets);
     756        Gatherer.c_man.createCollection(ncd_prompt.getDescription(), Configuration.getEmail(), ncd_prompt.getName(), ncd_prompt.getTitle(), ncd_prompt.getBase(), new ArrayList());
    762757        ncd_prompt.dispose();
    763758        }
Note: See TracChangeset for help on using the changeset viewer.