Changeset 8586 for trunk/gli/src/org/greenstone/gatherer/collection
- Timestamp:
- 2004-11-17T13:20:30+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/collection
- Files:
-
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/collection/Collection.java
r8313 r8586 188 188 public void save() { 189 189 Utility.export(document, file); 190 saved = true; 190 191 } 191 192 -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r8576 r8586 753 753 public void importCollection() { 754 754 importing = true; 755 if(!saved()) { 755 756 if (!saved()) { 756 757 DebugStream.println("CollectionManager.importCollection().forcesave"); 757 758 import_monitor.saving(); 758 // Force save. 759 try { 760 SaveCollectionTask save_task = new SaveCollectionTask(collection); 761 save_task.setImportAfter(true); 762 save_task.start(); 763 } 764 catch(Exception error) { 765 DebugStream.printStackTrace(error); 766 } 759 saveCollection(); 760 } 761 762 DebugStream.println("CollectionManager.importCollection()"); 763 //check that we can remove the old index before starting import 764 File index_dir = new File(getCollectionIndex(), "temp.txt"); 765 index_dir = index_dir.getParentFile(); 766 if(index_dir.exists()) { 767 DebugStream.println("Old Index = " + index_dir.getAbsolutePath()+", testing for deletability"); 768 if (!canDelete(index_dir)) { 769 // tell the user 770 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Delete_Index"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 771 // tell the gui manager 772 // a message for the building log 773 GShellEvent event = new GShellEvent(this, 0, GShell.IMPORT, Dictionary.get("CollectionManager.Cannot_Delete_Index_Log"), GShell.ERROR); 774 Gatherer.g_man.create_pane.message(event); 775 event = new GShellEvent(this, 0, GShell.IMPORT, "", GShell.ERROR); 776 Gatherer.g_man.create_pane.processComplete(event); 777 importing = false; 778 return; 779 } 780 } 781 782 String collect_dir = getCollectDirectory(); 783 784 String args[]; 785 String lang = Configuration.getLanguage(); 786 if((Utility.isWindows()) && (!Gatherer.isGsdlRemote)) { 787 args = new String[8]; 788 args[0] = Configuration.perl_path; 789 args[1] = "-S"; 790 args[2] = Configuration.getScriptPath() + "import.pl"; 791 args[3] = "-gli"; 792 args[4] = "-language"; 793 args[5] = lang; 794 args[6] = "-collectdir"; 795 args[7] = collect_dir; 767 796 } 768 797 else { 769 DebugStream.println("CollectionManager.importCollection()"); 770 //check that we can remove the old index before starting import 771 File index_dir = new File(getCollectionIndex(), "temp.txt"); 772 index_dir = index_dir.getParentFile(); 773 if(index_dir.exists()) { 774 DebugStream.println("Old Index = " + index_dir.getAbsolutePath()+", testing for deletability"); 775 if (!canDelete(index_dir)) { 776 // tell the user 777 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Delete_Index"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE); 778 // tell the gui manager 779 // a message for the building log 780 GShellEvent event = new GShellEvent(this, 0, GShell.IMPORT, Dictionary.get("CollectionManager.Cannot_Delete_Index_Log"), GShell.ERROR); 781 Gatherer.g_man.create_pane.message(event); 782 event = new GShellEvent(this, 0, GShell.IMPORT, "", GShell.ERROR); 783 Gatherer.g_man.create_pane.processComplete(event); 784 importing = false; 785 return; 786 } 787 } 788 789 String collect_dir = getCollectDirectory(); 790 791 String args[]; 792 String lang = Configuration.getLanguage(); 793 if((Utility.isWindows()) && (!Gatherer.isGsdlRemote)) { 794 args = new String[8]; 795 args[0] = Configuration.perl_path; 796 args[1] = "-S"; 797 args[2] = Configuration.getScriptPath() + "import.pl"; 798 args[3] = "-gli"; 799 args[4] = "-language"; 800 args[5] = lang; 801 args[6] = "-collectdir"; 802 args[7] = collect_dir; 803 } 804 else { 805 args = new String[6]; 806 args[0] = Configuration.getScriptPath() + "import.pl"; 807 args[1] = "-gli"; 808 args[2] = "-language"; 809 args[3] = lang; 810 args[4] = "-collectdir"; 811 args[5] = collect_dir; 812 } 813 collect_dir = null; 814 args = ArrayTools.add(args, collection.build_options.getImportValues()); 815 args = ArrayTools.add(args, collection.getName()); 816 817 GShell shell = new GShell(args, GShell.IMPORT, BUILDING, this, import_monitor, GShell.GSHELL_IMPORT); 818 shell.addGShellListener(Gatherer.g_man.create_pane); 819 shell.start(); 820 DebugStream.println("CollectionManager.importCollection().return"); 821 } 798 args = new String[6]; 799 args[0] = Configuration.getScriptPath() + "import.pl"; 800 args[1] = "-gli"; 801 args[2] = "-language"; 802 args[3] = lang; 803 args[4] = "-collectdir"; 804 args[5] = collect_dir; 805 } 806 collect_dir = null; 807 args = ArrayTools.add(args, collection.build_options.getImportValues()); 808 args = ArrayTools.add(args, collection.getName()); 809 810 GShell shell = new GShell(args, GShell.IMPORT, BUILDING, this, import_monitor, GShell.GSHELL_IMPORT); 811 shell.addGShellListener(Gatherer.g_man.create_pane); 812 shell.start(); 813 DebugStream.println("CollectionManager.importCollection().return"); 814 822 815 importing = false; 823 816 } … … 1280 1273 return result; 1281 1274 } 1282 /** Saves a collection by serializing it to file. 1283 * @param close_after <i>true</i> to cause the Gatherer to close the collection once save is complete, <i>false</i> otherwise. 1284 * @param exit_after <i>true</i> to cause the Gatherer to exit once save is complete, <i>false</i> otherwise. 1285 * @see org.greenstone.gatherer.Gatherer 1286 * @see org.greenstone.gatherer.gui.GUIManager 1287 * @see org.greenstone.gatherer.collection.Collection 1288 */ 1289 public void saveCollection(boolean close_after, boolean exit_after) { 1290 DebugStream.println("Save collection: " + collection.getName()); 1291 try { 1292 SaveCollectionTask save_task = new SaveCollectionTask(collection, close_after, exit_after); 1293 save_task.start(); 1294 // Run this in the same thread 1295 //save_task.run(); 1296 } 1297 catch(Exception error) { 1298 DebugStream.printStackTrace(error); 1299 } 1300 } 1275 1276 1277 /** Saves the currently loaded collection. */ 1278 public void saveCollection() 1279 { 1280 DebugStream.println("Saving collection " + collection.getName() + "..."); 1281 1282 // Change cursor to hourglass 1283 Gatherer.g_man.wait(true); 1284 1285 // Create a backup of the collection file, just in case anything goes wrong 1286 File collection_file = new File(Gatherer.c_man.getCollectionFilename()); 1287 if (collection_file.exists()) { 1288 File collection_file_backup = new File(collection_file.getAbsolutePath() + "~"); 1289 if (!collection_file.renameTo(collection_file_backup)) { 1290 DebugStream.println("Error in CollectionManager.saveCollection(): could not create backup file."); 1291 } 1292 collection_file_backup.deleteOnExit(); 1293 } 1294 1295 // Write out the collection file 1296 collection.save(); 1297 1298 // Write out the collection configuration file 1299 Gatherer.g_man.design_pane.saveConfiguration(); 1300 1301 // Write hfiles for the loaded metadata elements into the collection "etc" directory 1302 MetadataSetManager.writeHierarchyFiles(new File(Gatherer.c_man.getCollectionEtc())); 1303 1304 // Change cursor back to normal 1305 Gatherer.g_man.wait(false); 1306 } 1307 1301 1308 1302 1309 public void setClosingThread(boolean set) {
Note:
See TracChangeset
for help on using the changeset viewer.