Changeset 7014
- Timestamp:
- 2004-03-11T11:03:28+13:00 (20 years ago)
- 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 112 112 private GShellProgressMonitor import_monitor = null; 113 113 114 private int special_case = -1;115 114 /** 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. */ 116 115 private Thread closing_thread = null; … … 118 117 /** The name of the standard lock file. */ 119 118 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;122 119 123 120 /** Used to indicate the source of the message is the file collection methods. */ … … 248 245 public void createCollection(String description, String email, String name, String title, File base_collection_directory, ArrayList metadata_sets) { 249 246 boolean cancelled = false; 250 special_case = NO_SPECIAL_CASE; 247 251 248 try { 252 249 // Create a progress monitor. … … 303 300 Gatherer.println("This base collection has no metadata directory."); 304 301 } 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. 306 303 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; 335 316 } 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; 353 319 } 354 320 // 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. … … 1375 1341 // 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. 1376 1342 try { 1377 1378 1379 1380 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) { 1381 1347 // We have to test the end of command for the special character '\'. If found, remove it and append the next line, then repeat. 1382 1348 while(command.trim().endsWith("\\")) { 1383 1384 1385 1386 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 } 1388 1354 } 1389 1355 ///ystem.err.println("Read: " + command); … … 1416 1382 } 1417 1383 */ 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)) { 1423 1386 StringTokenizer tokenizer = new StringTokenizer(command); 1424 1387 StringBuffer text = new StringBuffer(tokenizer.nextToken()); -
trunk/gli/src/org/greenstone/gatherer/gui/NewCollectionDetailsPrompt.java
r6638 r7014 102 102 Dictionary.setText(this, "NewCollectionPrompt.Title"); 103 103 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. 105 105 Vector base_collection_model = new Vector(); 106 // Dummy item107 106 File gsdl_collection_directory = new File(Utility.getCollectionDir(Gatherer.config.gsdl_path)); 108 107 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 111 110 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); 119 117 Item item = new Item(possible_collections[i], collect_cfg); 120 if (!base_collection_model.contains(item)) {118 if (!base_collection_model.contains(item)) { 121 119 base_collection_model.add(item); 122 120 } 123 121 } 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 } 129 123 } 130 124 -
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r6972 r7014 87 87 /** Definition of an important directory name, in this case the parent directory of all the collections in the gsdl. */ 88 88 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;93 89 static final public String COLLECTION_TREE = "Collection"; 94 90 /** Definition of an important directory name, in this case the file the collection configuration is expect to be in. */ … … 101 97 /** The default dictionary to load. */ 102 98 static final public String DICTIONARY = "dictionary"; 103 static final public String DLS_MDS = "dls.mds";104 99 static final public String ENCODING = "UTF-8"; 105 100 static final public String ENGLISH_VALUE = "en";
Note:
See TracChangeset
for help on using the changeset viewer.