Changeset 7526
- Timestamp:
- 2004-06-02T10:09:57+12:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r7486 r7526 54 54 import org.greenstone.gatherer.collection.SaveCollectionTask; 55 55 import org.greenstone.gatherer.file.FileNode; 56 import org.greenstone.gatherer.file.FileQueue; 56 57 import org.greenstone.gatherer.file.FileSystemModel; 57 58 import org.greenstone.gatherer.gui.LockFileDialog; … … 280 281 } 281 282 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 282 323 /** 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. 283 324 * @param description a description of the collection as a String … … 338 379 Gatherer.println("Basing new collection on existing one: " + base_collection_directory); 339 380 collection.setBaseCollection(base_collection_directory.getAbsolutePath()); 381 // copy over other needed directories 382 copyExtraBaseCollStuff(new File(a_dir), base_collection_directory); 340 383 // Try to import any existing metadata sets for this collection. Look in base_collection_directory/metadata and import any metadata sets found. 341 384 File base_metadata = new File(base_collection_directory, Utility.META_DIR); … … 416 459 417 460 collection.cdm = new CollectionDesignManager(new File(getCollectionConfig())); 418 461 419 462 // 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 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 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 449 492 collection.gdm = new MetadataXMLFileManager(); 450 493
Note:
See TracChangeset
for help on using the changeset viewer.