Changeset 34283
- Timestamp:
- 2020-07-23T13:41:08+12:00 (4 years ago)
- Location:
- main/trunk/gli
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/classes/dictionary.properties
r34266 r34283 532 532 ExportAsPrompt.MappingXML_Tooltip:Use a mapping file for converting the exported files. 533 533 # 534 #***** Export Metadata to CSV ***** 535 ExportMeta.ChooseMetaCSVFile: Export metadata from GLI to a new CSV file or add to existing 536 ExportMeta.MoveMetaXMLToCSV_Warning_Message: Warning, this will remove all metadata from GLI after exporting to CSV. Proceed? 537 ExportMeta.MoveMetaXMLToCSV_Failed_Message: Failed to export contents of collection metadata.xml files to CSV properly. Will not remove metadata.xml files. 534 #***** Export/Convert Metadata to CSV ***** 535 MetaToCSV.Choose:Choose 536 MetaToCSV.ExportAction:Export 537 MetaToCSV.ConvertAction:Convert 538 MetaToCSV.ChooseMetaCSVFile:{0} metadata from GLI to a new CSV file or add to existing 539 MetaToCSV.ConvertMetaXMLToCSV_Warning_Message:Warning, this will remove all metadata from GLI (metadata.xml files) after exporting to CSV.\nThis means you will no longer be able to edit this metadata from within GLI.\nProceed? 540 MetaToCSV.ConvertMetaXMLToCSV_Failed_Message:Failed to export contents of collection metadata.xml files to CSV properly. Will not remove metadata.xml files. 538 541 # 539 542 #***** Inherited Metadata ***** … … 787 790 Menu.File_ExportAs:Export... 788 791 Menu.File_ExportMeta:Export metadata to CSV... 789 Menu.File_ MoveMetaToCSV:Movemetadata to CSV...792 Menu.File_ConvertMetaToCSV:Convert metadata to CSV... 790 793 Menu.File_New:New... 791 794 Menu.File_Open:Open... -
main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r34264 r34283 199 199 eap = null; 200 200 } 201 else if (esrc == menu_bar.file_exportmeta || esrc == menu_bar.file_ movemeta) {201 else if (esrc == menu_bar.file_exportmeta || esrc == menu_bar.file_convertmeta) { 202 202 String currCollName = Gatherer.c_man.getCollection().getName(); 203 203 String collection_directory_path = CollectionManager.getCollectionDirectoryPath(currCollName); 204 204 205 205 String importDir = collection_directory_path + "import"; 206 File csvFile = MetadataToCSV.chooseMetaCSVFile(importDir, this); 206 207 boolean convertMode = false; 208 String startDir = collection_directory_path; 209 if(esrc == menu_bar.file_convertmeta) { 210 startDir = importDir; 211 convertMode = true; 212 } 213 214 File csvFile = MetadataToCSV.chooseMetaCSVFile(startDir, convertMode, this); 207 215 if(csvFile != null) { 208 216 MetadataToCSV toCSV = new MetadataToCSV(collection_directory_path, csvFile); 209 217 210 218 boolean success = false; 211 if(esrc == menu_bar.file_ movemeta) {212 success = toCSV. moveMetaXMLToCSV(csvFile, this);219 if(esrc == menu_bar.file_convertmeta) { 220 success = toCSV.convertMetaXMLToCSV(csvFile, this); 213 221 } else { 214 222 success = toCSV.exportMetaXMLToCSV(csvFile); … … 216 224 217 225 // refresh coll view if meta.csv was created somewhere inside this coll's import folder 218 // And for remote case, also upload any new file that's inside import dir to server 219 if(success && csvFile.exists() && csvFile.getAbsolutePath().startsWith(importDir)) { 226 // And for remote case, also upload any new file that's inside collection dir 227 // (especially import dir) to server 228 if(success && csvFile.exists() && csvFile.getAbsolutePath().startsWith(collection_directory_path)) { 220 229 if(Gatherer.isGsdlRemote) { 221 230 Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(currCollName, new File[] {csvFile}, csvFile.getParentFile()); -
main/trunk/gli/src/org/greenstone/gatherer/gui/MenuBar.java
r34280 r34283 70 70 public JMenuItem file_exportas = null; 71 71 public JMenuItem file_exportmeta = null; 72 public JMenuItem file_ movemeta = null;72 public JMenuItem file_convertmeta = null; 73 73 public JMenuItem file_new = null; 74 74 public JMenuItem file_open = null; … … 130 130 file_exportmeta.setComponentOrientation(Dictionary.getOrientation()); 131 131 132 file_ movemeta = new JMenuItem(Dictionary.get("Menu.File_MoveMetaToCSV"));133 file_ movemeta.addActionListener(Gatherer.g_man);134 file_ movemeta.setEnabled(false);135 file_ movemeta.setComponentOrientation(Dictionary.getOrientation());132 file_convertmeta = new JMenuItem(Dictionary.get("Menu.File_ConvertMetaToCSV")); 133 file_convertmeta.addActionListener(Gatherer.g_man); 134 file_convertmeta.setEnabled(false); 135 file_convertmeta.setComponentOrientation(Dictionary.getOrientation()); 136 136 137 137 file_new = new JMenuItem(Dictionary.get("Menu.File_New")); … … 161 161 file.add(file_exportas); 162 162 file.add(file_exportmeta); 163 file.add(file_ movemeta);163 file.add(file_convertmeta); 164 164 // these currently don't work. better to just disable them? 165 165 if (!Gatherer.GS3) { … … 300 300 file_save.setEnabled(ready); 301 301 file_exportmeta.setEnabled(ready); 302 file_ movemeta.setEnabled(ready);302 file_convertmeta.setEnabled(ready); 303 303 } 304 304 -
main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataToCSV.java
r34265 r34283 108 108 109 109 /** Remove import path prefix from given file. Returned is the path of file relative to import. */ 110 p ublicString fileToRelativeString(File f) {110 private String fileToRelativeString(File f) { 111 111 String fullPath = f.getAbsolutePath(); 112 112 //System.err.println("@@@ fullpath: " + fullPath); … … 174 174 // Get all meta in any metadata.csv file 175 175 // and add to it all meta assigned for docs in this collection 176 p ublicvoid amalgamateAllMeta() {176 private void amalgamateAllMeta() { 177 177 TreeMap<File, TreeMap<String,TreeSet<String>>> assignedMeta = getAllAssignedMetadataForAllFiles(); 178 178 TreeMap<File, TreeMap<String,TreeSet<String>>> csvFileMeta = loadMetaFromCSVFile(this.metadataCSVFile); … … 195 195 } 196 196 197 p ublicTreeSet<String> getAllCollHeadings(TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap) {197 private TreeSet<String> getAllCollHeadings(TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap) { 198 198 TreeSet<String> collHeadings = new TreeSet<String>(); 199 199 … … 221 221 * A simple map.putALL() will not do the trick as collMetaMap is a complicated data structure. 222 222 */ 223 p ublicvoid merge(TreeMap<File, TreeMap<String,TreeSet<String>>> baseMetaMap, TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap) {223 private void merge(TreeMap<File, TreeMap<String,TreeSet<String>>> baseMetaMap, TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap) { 224 224 225 225 if(metaMap == null || metaMap.size() == 0) { … … 279 279 * and removes all the child elements from meta xml files' DirectoryMetadata root elements 280 280 */ 281 public boolean moveMetaXMLToCSV(File csvFile, JFrame parent) {281 public boolean convertMetaXMLToCSV(File csvFile, JFrame parent) { 282 282 283 283 // Warn the user about the operation being destructive 284 284 int result = JOptionPane.showConfirmDialog(parent, 285 Dictionary.get(" ExportMeta.MoveMetaXMLToCSV_Warning_Message"),285 Dictionary.get("MetaToCSV.ConvertMetaXMLToCSV_Warning_Message"), 286 286 Dictionary.get("General.Warning"), 287 287 JOptionPane.OK_CANCEL_OPTION, … … 300 300 } else { 301 301 JOptionPane.showMessageDialog(parent, 302 Dictionary.get(" ExportMeta.MoveMetaXMLToCSV_Failed_Message"),302 Dictionary.get("MetaToCSV.ConvertMetaXMLToCSV_Failed_Message"), 303 303 Dictionary.get("General.Error"), 304 304 JOptionPane.ERROR_MESSAGE); … … 391 391 392 392 393 p ublicTreeMap<File, TreeMap<String,TreeSet<String>>> loadMetaFromCSVFile(File csvFile) {393 private TreeMap<File, TreeMap<String,TreeSet<String>>> loadMetaFromCSVFile(File csvFile) { 394 394 TreeMap<File, TreeMap<String,TreeSet<String>>> csvFileMeta = new TreeMap<File, TreeMap<String,TreeSet<String>>>(); 395 395 … … 475 475 476 476 /** For debugging */ 477 p ublicvoid print(TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap ) {477 private void print(TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap ) { 478 478 Iterator<File> iFiles = metaMap.keySet().iterator(); 479 479 while(iFiles.hasNext()) { … … 502 502 503 503 /** For debugging */ 504 p ublicvoid printOrderedCollectionMeta() {504 private void printOrderedCollectionMeta() { 505 505 //TreeMap<File, TreeMap<String,TreeSet<String>>> collMetaMap = getAllAssignedMetadataForAllFiles(); 506 506 … … 524 524 } 525 525 526 p ublicvoid getAllFiles(ArrayList<File> files, File path, FileFilter filter) {526 private void getAllFiles(ArrayList<File> files, File path, FileFilter filter) { 527 527 File[] fileList = path.listFiles(filter); 528 528 for(int i = 0; i < fileList.length; i++) { … … 563 563 //} 564 564 565 public static File chooseMetaCSVFile(String defaultSearchPath, JFrame parent) {565 public static File chooseMetaCSVFile(String defaultSearchPath, boolean convertNotExport, JFrame parent) { 566 566 JFileChooser chooser = new JFileChooser(defaultSearchPath); 567 567 chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); 568 chooser.setDialogTitle(Dictionary.get("ExportMeta.ChooseMetaCSVFile")); 568 String actionName = Dictionary.get("MetaToCSV.ExportAction"); // Export or Convert 569 if(convertNotExport) { 570 actionName = Dictionary.get("MetaToCSV.ConvertAction"); 571 } 572 chooser.setDialogTitle(Dictionary.get("MetaToCSV.ChooseMetaCSVFile", actionName)); 573 chooser.setApproveButtonText(Dictionary.get("MetaToCSV.Choose"));//actionName); 569 574 FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV spreadsheet file", "csv"); 570 575 chooser.setFileFilter(filter);//.addChoosableFileFilter(filter);
Note:
See TracChangeset
for help on using the changeset viewer.