Changeset 7341 for trunk


Ignore:
Timestamp:
2004-05-17T13:34:32+12:00 (20 years ago)
Author:
kjdon
Message:

in gs3 can now base a coll on one in another site

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java

    r7326 r7341  
    103103    Vector base_collection_model = new Vector();
    104104    // need to modify this to base a coll on any collection from any site
    105     File gsdl_collection_directory;
    106105    if (Gatherer.GS3) {
    107         gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, Gatherer.config.site_name));
     106        File sites_dir = new File(Utility.getSitesDir(Gatherer.config.gsdl3_path));
     107        File [] sites = sites_dir.listFiles();
     108        for (int i=0; i<sites.length; i++) {
     109        File collect_dir = new File(Utility.getCollectDir(Gatherer.config.gsdl3_path, sites[i].getName()));
     110        if (collect_dir.exists()) {
     111            addCollectionsToModel(base_collection_model, collect_dir, sites[i].getName());
     112        }
     113        }
    108114    } else {
    109        gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
    110     }
    111     File[] possible_collections = gsdl_collection_directory.listFiles();
    112     for (int i = 0; possible_collections != null && i < possible_collections.length; i++) {
    113         // If the directory has a etc/collect.cfg file then it looks like a collection
    114         File collect_cfg_file = new File(possible_collections[i], Utility.CONFIG_FILE);
    115         if (collect_cfg_file.exists()) {
    116         // If the directory has a metadata/ then the collection can be used as a base
    117         File metadata_directory = new File(possible_collections[i], Utility.META_DIR);
    118         if (metadata_directory.exists()) {
    119             // Add to model
    120             BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(collect_cfg_file);
    121             Item item = new Item(possible_collections[i], collect_cfg);
    122             if (!base_collection_model.contains(item)) {
    123             base_collection_model.add(item);
    124             }
    125         }
    126         }
     115       File gsdl_collection_directory = new File(Utility.getCollectDir(Gatherer.config.gsdl_path));
     116       addCollectionsToModel(base_collection_model, gsdl_collection_directory, null);
    127117    }
    128118
     
    289279    }
    290280
     281    private void addCollectionsToModel(Vector base_collection_model, File collect_directory, String site) {
     282    File[] possible_collections = collect_directory.listFiles();
     283    for (int i = 0; possible_collections != null && i < possible_collections.length; i++) {
     284        // If the directory has a etc/collect.cfg file then it looks like a collection
     285        File collect_cfg_file = new File(possible_collections[i], Utility.CONFIG_FILE);
     286        if (collect_cfg_file.exists()) {
     287        // If the directory has a metadata/ then the collection can be used as a base
     288        File metadata_directory = new File(possible_collections[i], Utility.META_DIR);
     289        if (metadata_directory.exists()) {
     290            // Add to model
     291            BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(collect_cfg_file);
     292            if (Gatherer.GS3 && site != null) {
     293            collect_cfg.setSite(site);
     294            }
     295            Item item = new Item(possible_collections[i], collect_cfg);
     296            if (!base_collection_model.contains(item)) {
     297            base_collection_model.add(item);
     298            }
     299        }
     300        }
     301    }
     302       
     303    }
     304
    291305    private class CancelListener
    292306    implements ActionListener {
Note: See TracChangeset for help on using the changeset viewer.