Changeset 7014


Ignore:
Timestamp:
2004-03-11T11:03:28+13:00 (20 years ago)
Author:
mdewsnip
Message:

Taken out anything collection specific. This is bad.

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

Legend:

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

    r6879 r7014  
    112112    private GShellProgressMonitor import_monitor = null;
    113113
    114     private int special_case = -1;
    115114    /** Holds a reference to the thread responsible for closing the collection. If non-null then only calls from the given thread will see the collection is non-ready. All other threads will have to wait until closing thread, and all of it consequential calls, are completely finished. */
    116115    private Thread closing_thread = null;
     
    118117    /** The name of the standard lock file. */
    119118    static final public String LOCK_FILE = "gli.lck";
    120     static final public int NO_SPECIAL_CASE = -1;
    121     static final public int SPECIAL_DLS = 0;
    122119
    123120    /** Used to indicate the source of the message is the file collection methods. */
     
    248245    public void createCollection(String description, String email, String name, String title, File base_collection_directory, ArrayList metadata_sets) {
    249246    boolean cancelled = false;
    250     special_case = NO_SPECIAL_CASE;
     247
    251248    try {
    252249        // Create a progress monitor.
     
    303300            Gatherer.println("This base collection has no metadata directory.");
    304301        }
    305         // If no sets were imported, then create a new metadata with this new collections name. Note that if this is one of the 'big five' collections then I already know the importing mappings as well.
     302        // If no sets were imported, then create a new metadata with this new collections name.
    306303        if(collection.msm.getSets().size() == 0) {
    307             Gatherer.println("As there are no metadata sets loaded yet, we'll make special checks for the collections available on the GS2.39CD.");
    308             BasicCollectionConfiguration col_con = new BasicCollectionConfiguration(new File(base_collection_directory, Utility.CONFIG_DIR));
    309             // If the source collection is one of the 'big five' then we know what the metadata set is.
    310             String collection_name = col_con.getName();
    311             // Demo collection - part of the DLS
    312             if(collection_name.equals(Utility.COLLECTION_DEMO) || collection_name.equals(Utility.COLLECTION_DLS)) {
    313             Gatherer.println("+ This is a DLS.mds collection.");
    314             special_case = SPECIAL_DLS;
    315             String demo_directory = (new File(base_collection_directory.getParentFile(), Utility.COLLECTION_DEMO_DIRECTORY)).getAbsolutePath();
    316             String dls_directory = (new File(base_collection_directory.getParentFile(), Utility.COLLECTION_DLS_DIRECTORY)).getAbsolutePath();
    317             // Add the dls.mds
    318             collection.msm.importMDS(new File(Utility.METADATA_DIR + Utility.DLS_MDS), false);
    319             // Add the mappings for the dls (even if its not present).
    320             collection.msm.profiler.addAction(dls_directory, "AZList", "dls.AZList");
    321             collection.msm.profiler.addAction(dls_directory, "Keyword", "dls.Keyword");
    322             collection.msm.profiler.addAction(dls_directory, "Language", "dls.Language");
    323             collection.msm.profiler.addAction(dls_directory, "Organization", "dls.Organization");
    324             collection.msm.profiler.addAction(dls_directory, "Subject", "dls.Subject");
    325             collection.msm.profiler.addAction(dls_directory, "Title", "dls.Title");
    326             // Add the mappings for the demo dls (even if its not present).
    327             collection.msm.profiler.addAction(demo_directory, "AZList", "dls.AZList");
    328             collection.msm.profiler.addAction(demo_directory, "Keyword", "dls.Keyword");
    329             collection.msm.profiler.addAction(demo_directory, "Language", "dls.Language");
    330             collection.msm.profiler.addAction(demo_directory, "Organization", "dls.Organization");
    331             collection.msm.profiler.addAction(demo_directory, "Subject", "dls.Subject");
    332             collection.msm.profiler.addAction(demo_directory, "Title", "dls.Title");
    333             // Skip the import phase
    334             skip_import_phase = true;
     304            // Prompt the user so that they can choose at least one initial metadata set. We're sneaky here and just create a ncm_prompt
     305            Gatherer.println("This collection has no metadata sets. Present the user with the metadata set selection prompt.");
     306            NewCollectionMetadataPrompt ncm_prompt = new NewCollectionMetadataPrompt();
     307            // If cancelled then they really do mean to start a collection with no metadata sets.
     308            if(!ncm_prompt.isCancelled()) {
     309            ArrayList initial_sets = ncm_prompt.getSets();
     310            for(int i = 0; initial_sets != null && i < initial_sets.size(); i++) {
     311                MetadataSet metadata_set = (MetadataSet) initial_sets.get(i);
     312                collection.msm.importMDS(metadata_set.getFile(), false);
     313                metadata_set = null;
     314            }
     315            initial_sets = null;
    335316            }
    336             // Prompt the user so that they can choose at least one initial metadata set. We're sneaky here and just create a ncm_prompt
    337             else {
    338             Gatherer.println("This collection has no metadata sets, nor is it one of our special collections, thus we cannot import any metadata sets automatically. Present the user with the metadata set selection prompt.");
    339             NewCollectionMetadataPrompt ncm_prompt = new NewCollectionMetadataPrompt();
    340             // If cancelled then they really do mean to start a collection with no metadata sets.
    341             if(!ncm_prompt.isCancelled()) {
    342                 ArrayList initial_sets = ncm_prompt.getSets();
    343                 for(int i = 0; initial_sets != null && i < initial_sets.size(); i++) {
    344                 MetadataSet metadata_set = (MetadataSet) initial_sets.get(i);
    345                 collection.msm.importMDS(metadata_set.getFile(), false);
    346                 metadata_set = null;
    347                 }
    348                 initial_sets = null;
    349             }
    350             ncm_prompt.dispose();
    351             ncm_prompt = null;
    352             }
     317            ncm_prompt.dispose();
     318            ncm_prompt = null;
    353319        }
    354320        // Do a dry metadata import run over the entire base collection, recording profile mappings. We do this by finding the archive files, and then iterating over them using the GreenstoneArchiveParser to retrieve metadata from them. We then process the importing of new metadata elements using the selectElement prompt used in a file action metadata import. However the big change is that we don't actually import any metadata, just create importing profiles.
     
    13751341        // Now read in base_cfg line by line, parsing important onces and/or replacing them with information pertinent to our collection. Each line is then written back out to the new collect.cfg file.
    13761342        try {
    1377             BufferedReader in = new BufferedReader(new FileReader(base_cfg));
    1378             BufferedWriter out = new BufferedWriter(new FileWriter(new_cfg, false)); // Overwrite whats there.
    1379             String command = null;
    1380             while((command = in.readLine()) != null) {
     1343            BufferedReader in = new BufferedReader(new FileReader(base_cfg));
     1344            BufferedWriter out = new BufferedWriter(new FileWriter(new_cfg, false)); // Overwrite whats there.
     1345            String command = null;
     1346            while((command = in.readLine()) != null) {
    13811347            // We have to test the end of command for the special character '\'. If found, remove it and append the next line, then repeat.
    13821348            while(command.trim().endsWith("\\")) {
    1383                 command = command.substring(0, command.lastIndexOf("\\"));
    1384                 String next_line = in.readLine();
    1385                 if(next_line != null) {
    1386                     command = command + next_line;
    1387                 }
     1349                command = command.substring(0, command.lastIndexOf("\\"));
     1350                String next_line = in.readLine();
     1351                if(next_line != null) {
     1352                command = command + next_line;
     1353                }
    13881354            }
    13891355            ///ystem.err.println("Read: " + command);
     
    14161382            }
    14171383            */
    1418         // Just before we try more general parsing there are the special cases to check. These are explicit changes required by some collections to produce sensible results.
    1419             if(special_case == SPECIAL_DLS && command_lc.equals("classify      hierarchy -hfile azlist.txt -metadata azlist -sort title -buttonname title -hlist_at_top")) {
    1420                 write(out, "classify AZList -metadata dls.Title -buttonname Title");
    1421             }
    1422             else if(command_lc.startsWith(Utility.CFG_CLASSIFY)) {
     1384            // Just before we try more general parsing there are the special cases to check. These are explicit changes required by some collections to produce sensible results.
     1385            if(command_lc.startsWith(Utility.CFG_CLASSIFY)) {
    14231386            StringTokenizer tokenizer = new StringTokenizer(command);
    14241387            StringBuffer text = new StringBuffer(tokenizer.nextToken());
  • trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java

    r6638 r7014  
    102102    Dictionary.setText(this, "NewCollectionPrompt.Title");
    103103
    104     // Model building. Build a model of all of the collections in the gsdl collect directory with the appropriate directories and hardcode the big five.
     104    // Model building. Build a model of all of the collections in the gsdl collect directory with the appropriate directories.
    105105    Vector base_collection_model = new Vector();
    106     // Dummy item
    107106    File gsdl_collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path));
    108107    File[] possible_collections = gsdl_collection_directory.listFiles();
    109     for(int i = 0; possible_collections != null && i < possible_collections.length; i++) {
    110         // The simpliest case is if the directory etc/collect.cfg file and a metadata/ in it. Thus it can easily be built upon.
     108    for (int i = 0; possible_collections != null && i < possible_collections.length; i++) {
     109        // If the directory has a etc/collect.cfg file then it looks like a collection
    111110        File collect_cfg_file = new File(possible_collections[i], Utility.CONFIG_DIR);
    112         File metadata_directory = new File(possible_collections[i], Utility.META_DIR);
    113         if(collect_cfg_file.exists()) {
    114         BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(collect_cfg_file);
    115         String collection_name = collect_cfg.getName();
    116         // Even if there is no metadata directory we add it if its one of the 'big five + 1' that we know how to handle.
    117         if(metadata_directory.exists() || collection_name.equals(Utility.COLLECTION_DLS) || collection_name.equals(Utility.COLLECTION_DEMO)) {
    118             // Add to model.
     111        if (collect_cfg_file.exists()) {
     112        // If the directory has a metadata/ then the collection can be used as a base
     113        File metadata_directory = new File(possible_collections[i], Utility.META_DIR);
     114        if (metadata_directory.exists()) {
     115            // Add to model
     116            BasicCollectionConfiguration collect_cfg = new BasicCollectionConfiguration(collect_cfg_file);
    119117            Item item = new Item(possible_collections[i], collect_cfg);
    120             if(!base_collection_model.contains(item)) {
     118            if (!base_collection_model.contains(item)) {
    121119            base_collection_model.add(item);
    122120            }
    123121        }
    124         collection_name = null;
    125         collect_cfg = null;
    126         // Else not a collection we know how to retrieve the metadata set for.
    127         }
    128         // Else not a collection at all. Someones pulling a fast one.
     122        }
    129123    }
    130124
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r6972 r7014  
    8787    /** Definition of an important directory name, in this case the parent directory of all the collections in the gsdl. */
    8888    static final public String COL_DIR = "collect" + File.separator;
    89     static final public String COLLECTION_DEMO = "greenstone demo";
    90     static final public String COLLECTION_DEMO_DIRECTORY = "demo" + File.separator;
    91     static final public String COLLECTION_DLS = "Development Library Subset";
    92     static final public String COLLECTION_DLS_DIRECTORY = "dls" + File.separator;
    9389    static final public String COLLECTION_TREE = "Collection";
    9490    /** Definition of an important directory name, in this case the file the collection configuration is expect to be in. */
     
    10197    /** The default dictionary to load. */
    10298    static final public String DICTIONARY = "dictionary";
    103     static final public String DLS_MDS = "dls.mds";
    10499    static final public String ENCODING = "UTF-8";
    105100    static final public String ENGLISH_VALUE = "en";
Note: See TracChangeset for help on using the changeset viewer.