Changeset 34283


Ignore:
Timestamp:
2020-07-23T13:41:08+12:00 (4 years ago)
Author:
ak19
Message:

Incorporating Kathy & Dr Bainbridge's improvements to the recently added export to meta CSV features: 1. Move meta to CSV now called Convert meta to CSV launch. 2. Launch Export Meta JChooser dialog in collection dir not import dir, but Convert Meta still launched in importDir as before. Also upload any metadata.csv created in collection dir to remote server if client-GLI, not just if meta.csv was created in importDir. 3. Labels of JChooser confirm button and dialog title corrected. 4. Updates to dictionary string names and values.

Location:
main/trunk/gli
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/classes/dictionary.properties

    r34266 r34283  
    532532ExportAsPrompt.MappingXML_Tooltip:Use a mapping file for converting the exported files.
    533533#
    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 *****
     535MetaToCSV.Choose:Choose
     536MetaToCSV.ExportAction:Export
     537MetaToCSV.ConvertAction:Convert
     538MetaToCSV.ChooseMetaCSVFile:{0} metadata from GLI to a new CSV file or add to existing
     539MetaToCSV.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?
     540MetaToCSV.ConvertMetaXMLToCSV_Failed_Message:Failed to export contents of collection metadata.xml files to CSV properly. Will not remove metadata.xml files.
    538541#
    539542#***** Inherited Metadata *****
     
    787790Menu.File_ExportAs:Export...
    788791Menu.File_ExportMeta:Export metadata to CSV...
    789 Menu.File_MoveMetaToCSV:Move metadata to CSV...
     792Menu.File_ConvertMetaToCSV:Convert metadata to CSV...
    790793Menu.File_New:New...
    791794Menu.File_Open:Open...
  • main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r34264 r34283  
    199199        eap = null;
    200200    }
    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) {
    202202        String currCollName = Gatherer.c_man.getCollection().getName();
    203203        String collection_directory_path = CollectionManager.getCollectionDirectoryPath(currCollName);
    204204       
    205205        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);
    207215        if(csvFile != null) {
    208216        MetadataToCSV toCSV = new MetadataToCSV(collection_directory_path, csvFile);
    209217       
    210218        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);
    213221        } else {
    214222            success = toCSV.exportMetaXMLToCSV(csvFile);
     
    216224
    217225        // 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)) {
    220229            if(Gatherer.isGsdlRemote) {
    221230            Gatherer.remoteGreenstoneServer.uploadFilesIntoCollection(currCollName, new File[] {csvFile}, csvFile.getParentFile());
  • main/trunk/gli/src/org/greenstone/gatherer/gui/MenuBar.java

    r34280 r34283  
    7070    public JMenuItem file_exportas   = null;
    7171    public JMenuItem file_exportmeta = null;
    72     public JMenuItem file_movemeta   = null;
     72    public JMenuItem file_convertmeta   = null;
    7373    public JMenuItem file_new        = null;
    7474    public JMenuItem file_open       = null;
     
    130130    file_exportmeta.setComponentOrientation(Dictionary.getOrientation());
    131131
    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());
    136136   
    137137    file_new = new JMenuItem(Dictionary.get("Menu.File_New"));
     
    161161    file.add(file_exportas);
    162162    file.add(file_exportmeta);
    163     file.add(file_movemeta);
     163    file.add(file_convertmeta);
    164164    // these currently don't work. better to just disable them?
    165165    if (!Gatherer.GS3) {
     
    300300    file_save.setEnabled(ready);
    301301    file_exportmeta.setEnabled(ready);
    302     file_movemeta.setEnabled(ready);
     302    file_convertmeta.setEnabled(ready);
    303303    }
    304304
  • main/trunk/gli/src/org/greenstone/gatherer/metadata/MetadataToCSV.java

    r34265 r34283  
    108108
    109109    /** Remove import path prefix from given file. Returned is the path of file relative to import. */
    110     public String fileToRelativeString(File f) {
     110    private String fileToRelativeString(File f) {
    111111    String fullPath = f.getAbsolutePath();
    112112    //System.err.println("@@@ fullpath:            " + fullPath);
     
    174174    // Get all meta in any metadata.csv file
    175175    // and add to it all meta assigned for docs in this collection
    176     public void amalgamateAllMeta() {
     176    private void amalgamateAllMeta() {
    177177    TreeMap<File, TreeMap<String,TreeSet<String>>> assignedMeta = getAllAssignedMetadataForAllFiles();
    178178    TreeMap<File, TreeMap<String,TreeSet<String>>> csvFileMeta = loadMetaFromCSVFile(this.metadataCSVFile);
     
    195195    }
    196196
    197     public TreeSet<String> getAllCollHeadings(TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap) {
     197    private TreeSet<String> getAllCollHeadings(TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap) {
    198198    TreeSet<String> collHeadings = new TreeSet<String>();
    199199
     
    221221     * A simple map.putALL()  will not do the trick as collMetaMap is a complicated data structure.
    222222     */
    223     public void 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) {
    224224
    225225    if(metaMap == null || metaMap.size() == 0) {
     
    279279     * and removes all the child elements from meta xml files' DirectoryMetadata root elements
    280280     */
    281     public boolean moveMetaXMLToCSV(File csvFile, JFrame parent) {
     281    public boolean convertMetaXMLToCSV(File csvFile, JFrame parent) {
    282282
    283283    // Warn the user about the operation being destructive
    284284    int result = JOptionPane.showConfirmDialog(parent,
    285                Dictionary.get("ExportMeta.MoveMetaXMLToCSV_Warning_Message"),
     285               Dictionary.get("MetaToCSV.ConvertMetaXMLToCSV_Warning_Message"),
    286286               Dictionary.get("General.Warning"),
    287287               JOptionPane.OK_CANCEL_OPTION,
     
    300300    } else {
    301301        JOptionPane.showMessageDialog(parent,
    302                       Dictionary.get("ExportMeta.MoveMetaXMLToCSV_Failed_Message"),
     302                      Dictionary.get("MetaToCSV.ConvertMetaXMLToCSV_Failed_Message"),
    303303                      Dictionary.get("General.Error"),
    304304                      JOptionPane.ERROR_MESSAGE);
     
    391391
    392392
    393     public TreeMap<File, TreeMap<String,TreeSet<String>>> loadMetaFromCSVFile(File csvFile) {
     393    private TreeMap<File, TreeMap<String,TreeSet<String>>> loadMetaFromCSVFile(File csvFile) {
    394394    TreeMap<File, TreeMap<String,TreeSet<String>>> csvFileMeta = new TreeMap<File, TreeMap<String,TreeSet<String>>>();
    395395   
     
    475475
    476476    /** For debugging */
    477     public void print(TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap ) {
     477    private void print(TreeMap<File, TreeMap<String,TreeSet<String>>> metaMap ) {
    478478    Iterator<File> iFiles = metaMap.keySet().iterator();
    479479    while(iFiles.hasNext()) {
     
    502502   
    503503    /** For debugging */
    504     public void printOrderedCollectionMeta() {
     504    private void printOrderedCollectionMeta() {
    505505    //TreeMap<File, TreeMap<String,TreeSet<String>>> collMetaMap = getAllAssignedMetadataForAllFiles();
    506506
     
    524524    }
    525525
    526     public void getAllFiles(ArrayList<File> files, File path, FileFilter filter) {
     526    private void getAllFiles(ArrayList<File> files, File path, FileFilter filter) {
    527527    File[] fileList = path.listFiles(filter);   
    528528    for(int i = 0; i < fileList.length; i++) {
     
    563563    //}
    564564
    565     public static File chooseMetaCSVFile(String defaultSearchPath, JFrame parent) {
     565    public static File chooseMetaCSVFile(String defaultSearchPath, boolean convertNotExport, JFrame parent) {
    566566    JFileChooser chooser = new JFileChooser(defaultSearchPath);
    567567    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);
    569574    FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV spreadsheet file", "csv");
    570575    chooser.setFileFilter(filter);//.addChoosableFileFilter(filter);
Note: See TracChangeset for help on using the changeset viewer.