Changeset 7526


Ignore:
Timestamp:
2004-06-02T10:09:57+12:00 (20 years ago)
Author:
kjdon
Message:

fixed up some indenting. also, when you base a collection on an existing one, we now copy over the macros and images directories.

File:
1 edited

Legend:

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

    r7486 r7526  
    5454import org.greenstone.gatherer.collection.SaveCollectionTask;
    5555import org.greenstone.gatherer.file.FileNode;
     56import org.greenstone.gatherer.file.FileQueue;
    5657import org.greenstone.gatherer.file.FileSystemModel;
    5758import org.greenstone.gatherer.gui.LockFileDialog;
     
    280281    }
    281282
     283    /** When basing a new collection on an existing one, we need to copy
     284     *  over some extra directories: images and macros 
     285     */
     286    private boolean copyExtraBaseCollStuff(File new_coll_dir, File base_coll_dir) {
     287    if (!new_coll_dir.isDirectory() || !base_coll_dir.isDirectory()) {
     288        return false;
     289    }
     290    Gatherer.println("Copying images and macros dirs from the base collection");
     291    FileQueue fq = Gatherer.f_man.getQueue();
     292    try {
     293        // do the images dir
     294        File base_coll_images = new File(base_coll_dir, Utility.IMAGES_DIR);
     295        if (base_coll_images.isDirectory()) {
     296        // copy all the images over
     297        File new_coll_images = new File(new_coll_dir, Utility.IMAGES_DIR);
     298        new_coll_images.mkdirs();
     299       
     300        // copy the contents over
     301        fq.copyDirectoryContents(base_coll_images, new_coll_images, null);
     302        }
     303    } catch (Exception e) {
     304        Gatherer.println("Couldn't copy over the images dir from the base collection: "+e.toString());
     305    }
     306    try {
     307        // do the macros dir
     308        File base_coll_macros = new File(base_coll_dir, Utility.MACROS_DIR);
     309        if (base_coll_macros.isDirectory()) {
     310        // copy all the macros over
     311        File new_coll_macros = new File(new_coll_dir, Utility.MACROS_DIR);
     312        new_coll_macros.mkdirs();
     313       
     314        // copy the contents over
     315        fq.copyDirectoryContents(base_coll_macros, new_coll_macros, null);
     316        }
     317    } catch (Exception e) {
     318        Gatherer.println("Couldn't copy over the macros dir from the base collection: "+e.toString());
     319    }
     320    return true;
     321    }
     322
    282323    /** Used to set the current collection to the given collection. Note that this call should -always- be proceeded by a ready call, and if the colection is ready and the saved flag is unset then the user should be prompted to save. Also note that this method creates yet another GShell to run buildcol.pl.
    283324     * @param description a description of the collection as a String
     
    338379           Gatherer.println("Basing new collection on existing one: " + base_collection_directory);
    339380           collection.setBaseCollection(base_collection_directory.getAbsolutePath());
     381           // copy over other needed directories
     382           copyExtraBaseCollStuff(new File(a_dir), base_collection_directory);
    340383        // Try to import any existing metadata sets for this collection. Look in base_collection_directory/metadata and import any metadata sets found.
    341384        File base_metadata = new File(base_collection_directory, Utility.META_DIR);
     
    416459
    417460        collection.cdm = new CollectionDesignManager(new File(getCollectionConfig()));
    418 
     461       
    419462        // Now that we have a CDM, update several settings, such as if we created this collection by basing it on another, set it as public automatically
    420         if(base_collection_directory != null) {
    421             // Update the creator and maintainer
    422             CollectionMeta creator_collectionmeta = new CollectionMeta(collection.cdm.collect_config.getCreator());
    423             creator_collectionmeta.setValue(email);
    424             creator_collectionmeta = null;
    425             CollectionMeta maintainer_collectionmeta = new CollectionMeta(collection.cdm.collect_config.getMaintainer());
    426             maintainer_collectionmeta.setValue(email);
    427             maintainer_collectionmeta = null;
    428             // Update the collection title
    429             CollectionMeta collection_name_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
    430             collection_name_collectionmeta.setValue(title);
    431             collection_name_collectionmeta = null;
    432             // And now the description
    433             CollectionMeta collection_extra_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONEXTRA_STR);
    434             collection_extra_collectionmeta.setValue(description);
    435             collection_extra_collectionmeta = null;
    436             // All collections based on others are automatically public
    437             CollectionMeta public_collectionmeta = new CollectionMeta(collection.cdm.collect_config.getPublic());
    438             public_collectionmeta.setValue(StaticStrings.TRUE_STR);
    439             public_collectionmeta = null;
    440             // Finally reset the icons
    441             CollectionMeta icon_collection_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_ICONCOLLECTION_STR);
    442             icon_collection_collectionmeta.setValue(StaticStrings.EMPTY_STR);
    443             icon_collection_collectionmeta = null;
    444             CollectionMeta icon_collection_small_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_ICONCOLLECTIONSMALL_STR);
    445             icon_collection_small_collectionmeta.setValue(StaticStrings.EMPTY_STR);
    446             icon_collection_small_collectionmeta = null;
    447         }
    448 
     463        if(base_collection_directory != null) {
     464        // Update the creator and maintainer
     465        CollectionMeta creator_collectionmeta = new CollectionMeta(collection.cdm.collect_config.getCreator());
     466        creator_collectionmeta.setValue(email);
     467        creator_collectionmeta = null;
     468        CollectionMeta maintainer_collectionmeta = new CollectionMeta(collection.cdm.collect_config.getMaintainer());
     469        maintainer_collectionmeta.setValue(email);
     470        maintainer_collectionmeta = null;
     471        // Update the collection title
     472        CollectionMeta collection_name_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONNAME_STR);
     473        collection_name_collectionmeta.setValue(title);
     474        collection_name_collectionmeta = null;
     475        // And now the description
     476        CollectionMeta collection_extra_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_COLLECTIONEXTRA_STR);
     477        collection_extra_collectionmeta.setValue(description);
     478        collection_extra_collectionmeta = null;
     479        // All collections based on others are automatically public
     480        CollectionMeta public_collectionmeta = new CollectionMeta(collection.cdm.collect_config.getPublic());
     481        public_collectionmeta.setValue(StaticStrings.TRUE_STR);
     482        public_collectionmeta = null;
     483        // Finally reset the icons
     484        CollectionMeta icon_collection_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_ICONCOLLECTION_STR);
     485        icon_collection_collectionmeta.setValue(StaticStrings.EMPTY_STR);
     486        icon_collection_collectionmeta = null;
     487        CollectionMeta icon_collection_small_collectionmeta = collection.cdm.collectionmeta_manager.getMetadatum(StaticStrings.COLLECTIONMETADATA_ICONCOLLECTIONSMALL_STR);
     488        icon_collection_small_collectionmeta.setValue(StaticStrings.EMPTY_STR);
     489        icon_collection_small_collectionmeta = null;
     490        }
     491       
    449492        collection.gdm = new MetadataXMLFileManager();
    450493
Note: See TracChangeset for help on using the changeset viewer.