- Timestamp:
- 2020-07-12T02:51:45+12:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataToCSV.java
r34263 r34264 39 39 import java.io.*; 40 40 import java.util.*; 41 import javax.swing.filechooser.FileNameExtensionFilter; 41 42 import javax.swing.JFileChooser; 42 import javax.swing.filechooser.FileNameExtensionFilter;43 43 import javax.swing.JFrame; 44 import javax.swing.JOptionPane; 44 45 45 46 import org.apache.commons.csv.*; 46 47 47 48 import org.greenstone.gatherer.util.SafeProcess; 48 //import org.greenstone.gatherer.Configuration;49 49 import org.greenstone.gatherer.DebugStream; 50 50 import org.greenstone.gatherer.Dictionary; 51 import org.greenstone.gatherer.Gatherer; 52 //import org.greenstone.gatherer.gui.WarningDialog; 53 import org.greenstone.gatherer.collection.Collection; 54 import org.greenstone.gatherer.metadata.MetadataChangedListener; 55 import org.greenstone.gatherer.metadata.MetadataElement; // 56 import org.greenstone.gatherer.metadata.MetadataSet; 57 import org.greenstone.gatherer.metadata.MetadataSetManager; 51 import org.greenstone.gatherer.metadata.MetadataElement; 52 import org.greenstone.gatherer.metadata.MetadataValue; 58 53 import org.greenstone.gatherer.metadata.MetadataXMLFileManager; 59 import org.greenstone.gatherer.metadata.MetadataValue;// 54 60 55 61 56 … … 81 76 private File metadataCSVFile; 82 77 83 /** Is this useful?78 /** TODO: Is this useful? 84 79 * Not yet implemented: if this flag is true, then if a file mentioned in metadata.csv does not exist, 85 80 * its entry is dropped and won't appear again when the metadata.csv is written out again. … … 274 269 * then will need to remove all meta from GLI (metadata.xml files). 275 270 * Just del or rename those files to .bak? 271 * This dangerous method goes through all the metadata.xml files that were in use so far 272 * and removes all the child elements from meta xml files' DirectoryMetadata root elements 276 273 */ 277 public void moveGLIMetaToCSV(File csvFile) { 278 boolean success = exportGLIMetaToCSV(csvFile); 279 // TODO 280 if(success) { 274 public boolean moveMetaXMLToCSV(File csvFile, JFrame parent) { 275 276 // Warn the user about the operation being destructive 277 int result = JOptionPane.showConfirmDialog(parent, 278 Dictionary.get("ExportMeta.MoveMetaXMLToCSV_Warning_Message"), 279 Dictionary.get("General.Warning"), 280 JOptionPane.OK_CANCEL_OPTION, 281 JOptionPane.WARNING_MESSAGE); 282 if(result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { 283 // NO_OPTION shouldn't happen 284 return false; 285 } 286 287 boolean success = exportMetaXMLToCSV(csvFile); 288 289 if(success) { // now it's backed up to a metadatacsv file, can clear all metadata from metaXML files 290 291 System.err.println("About to clear all metadata in collection..."); 292 MetadataXMLFileManager.clearAllMetadataInCollection(); 281 293 } else { 282 System.err.println("Failed to export GLI metadata for this collection to CSV properly. Will not remove metadata.xml files"); 283 } 294 JOptionPane.showMessageDialog(parent, 295 Dictionary.get("ExportMeta.MoveMetaXMLToCSV_Failed_Message"), 296 Dictionary.get("General.Error"), 297 JOptionPane.ERROR_MESSAGE); 298 //System.err.println("@@@ Failed to properly export metadata.xml files' contents for this collection to CSV. Will not remove metadata.xml files"); 299 } 300 301 return success; 284 302 } 285 303 286 304 /** If given a new file to create, creates the specified meta csv file from GLI's meta for the current collection. 287 305 * If the file exists, this will append the GLI metadata without checking if the file already contains the same entries. */ 288 public boolean export GLIMetaToCSV(File csvFile) {306 public boolean exportMetaXMLToCSV(File csvFile) { 289 307 boolean appendSetting = false; 290 308 boolean success = false; 291 292 // if(csvFile.exists()) {293 // appendSetting = true; // TODO: better to call the other version of this method in this case?294 // }295 // TreeMap<File, TreeMap<String,TreeSet<String>>> assignedMeta = getAllAssignedMetadataForAllFiles();296 // writeMetaToCSV(assignedMeta, csvFile, appendSetting);297 309 298 310 if(csvFile.exists()) { … … 510 522 } 511 523 512 /** Filter to only a llowGathered GS documents524 /** Filter to only accept Gathered GS documents 513 525 * to produce the list of files for which we need to export GLI metadata info to CSV. 514 526 */
Note:
See TracChangeset
for help on using the changeset viewer.