Changeset 34246


Ignore:
Timestamp:
2020-07-04T06:34:20+12:00 (4 years ago)
Author:
ak19
Message:

Still part of commit 34241 and now also 34245.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r34235 r34246  
    6868import org.greenstone.gatherer.metadata.MetadataSetManager;
    6969import org.greenstone.gatherer.metadata.MetadataXMLFileManager;
     70import org.greenstone.gatherer.metadata.MetadataElement;
     71import org.greenstone.gatherer.metadata.MetadataValue;
    7072import org.greenstone.gatherer.metadata.ProfileXMLFileManager;
    7173import org.greenstone.gatherer.remote.RemoteGreenstoneServer;
     
    153155    }
    154156    }
    155 
    156 
     157   
     158    /** helper methods to export metadata for collection files to csv */
     159    public TreeMap<File, ArrayList> getAllAssignedMetadataForAllFiles() {
     160    TreeMap<File, ArrayList> files_with_meta = new TreeMap<File, ArrayList>();
     161   
     162    ArrayList<File> files = listFilesInCollection();
     163    Iterator<File> i = files.iterator();
     164   
     165    while(i.hasNext()) {
     166        File f = i.next();
     167        ArrayList file_meta = MetadataXMLFileManager.getMetadataAssignedToFile(f);
     168        files_with_meta.put(f, file_meta);
     169       
     170        // debugging display
     171        System.err.println("Meta for file: " + f.getAbsolutePath());
     172        Iterator it = file_meta.iterator();
     173        while(it.hasNext()) {
     174        MetadataValue meta = (MetadataValue)it.next();
     175        String metaVal = meta.getValue();
     176        MetadataElement metaEl = meta.getMetadataElement();
     177        String metaName = metaEl.getFullName();
     178        System.err.println("   field: " + metaName);
     179        System.err.println("   value: " + metaVal);
     180        }
     181
     182    }
     183
     184    return files_with_meta;
     185    }
     186   
     187    public ArrayList<File> listFilesInCollection() {
     188    ArrayList<File> files = new ArrayList<File>();
     189    if(collection_tree_model != null) {
     190        collection_tree_model.getFileListing(files);
     191    }
     192    return files;
     193    }
     194   
    157195    static public void addCollectionContentsChangedListener(CollectionContentsChangedListener listener)
    158196    {
     
    13071345        File external_metadata_set_file = external_metadata_set.getMetadataSetFile();
    13081346        File metadata_set_file = new File(getLoadedCollectionMetadataDirectoryPath(), external_metadata_set_file.getName());
     1347
    13091348        // If we're using a remote Greenstone server, upload the metadata file
    13101349        if (Gatherer.isGsdlRemote) {
    13111350            Gatherer.remoteGreenstoneServer.uploadCollectionFile(collection.getGroupQualifiedName(false), metadata_set_file);
    13121351        }
    1313         }
    1314         catch (Exception exception) {
    1315         DebugStream.printStackTrace(exception);
    1316         }   
     1352       
     1353        // It's not enough that the local collection's mds file in gli user location
     1354        // (e.g. AppData/Roaming/Greenstone/GLI/collect/<collname>/metadata gets updated,
     1355        // Need to also update local GS3's installation's gli/metadatacopy of the .mds file
     1356        if (metadata_set_file.exists()) {
     1357            System.err.println("@@@ Replacing: " + metadata_set_file);
     1358            System.err.println("@@@ With: " + external_metadata_set_file);
     1359           
     1360            // delete GLI's copy and replace
     1361            //if(metadata_set_file.delete()) { // only if deletion was sucessful, try to replace
     1362            //Gatherer.f_man.getQueue().copyFile(external_metadata_set_file, metadata_set_file, true);// true for overwrite
     1363            //}
     1364           
     1365        }
     1366    } catch (Exception exception) {
     1367        DebugStream.printStackTrace(exception);
     1368    }   
    13171369    }
    13181370   
  • main/trunk/gli/src/org/greenstone/gatherer/file/FileNode.java

    r23433 r34246  
    378378    /** Tests if this enumeration contains more elements. */
    379379    public boolean hasMoreElements() {
     380        if(child_nodes == null) { // special case needed handling
     381        return false;
     382        }
    380383        return (index < child_nodes.size());
    381384    }
  • main/trunk/gli/src/org/greenstone/gatherer/file/FileSystemModel.java

    r13466 r34246  
    3131    }
    3232
     33    /** helper methods to export metadata for collection files to csv */
     34    public void getFileListing(ArrayList<File> files) {
     35    getFileListing(root, files);
     36    return;
     37    }
     38   
     39    private void getFileListing(TreeNode node, ArrayList<File> files) {
     40    if(node == null) return;
     41   
     42    if(!(node instanceof FileNode)) {
     43        return;
     44    } else {
     45        FileNode current = (FileNode)node;
     46        files.add(current.getFile());
     47        if(current.isLeaf()) {
     48        return;
     49        }
     50       
     51        Enumeration children = current.children();     
     52        while(children.hasMoreElements()) {
     53        FileNode child = (FileNode)children.nextElement();
     54        getFileListing(child, files);
     55        }
     56    }
     57    }
     58   
    3359    public FileFilter[] getFilters() {
    3460    if(filters == null) {
  • main/trunk/gli/src/org/greenstone/gatherer/gui/ConfigFileEditor.java

    r34205 r34246  
    204204        }       
    205205    }
     206   
    206207
    207208    // Final dialog setup & positioning.
    208     setDefaultCloseOperation(DISPOSE_ON_CLOSE); // get rid of this dialog when it's closed (on dispose())
     209    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); // get rid of this dialog when it's closed (on dispose())
    209210    this.addWindowListener(new WindowAdapter() { // called on dispose. Return focus to any curr GLI Pane
    210         public void windowClose(WindowEvent we) {
     211        @Override
     212        public void windowClosed(WindowEvent we) {
     213            super.windowClosed(we);         
    211214            Gatherer.g_man.doRegainFocus();
     215            //Gatherer.g_man.refresh(Gatherer.COLLECTION_OPENED, true);
     216            Gatherer.g_man.updateUI();
    212217        }
    213218        });
     
    228233    editor.requestFocusInWindow();
    229234    }
     235
    230236
    231237    public void actionPerformed(ActionEvent e) {
  • main/trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r34205 r34246  
    8787    public FileOpenActionListener foa_listener = new FileOpenActionListener();
    8888
    89 
    9089    /** A reference to the currently instantiated help window, if any. */
    9190    private HelpFrame help = null;
     
    305304        }
    306305        //Gatherer.c_man.saveCollection(); //shouldn't have to do this, in theory. See above comment
     306
     307        Gatherer.c_man.getAllAssignedMetadataForAllFiles();
    307308       
    308309        ConfigFileEditor configEditor = new ConfigFileEditor();
     
    10831084    // remember to click other panes whenever they want to edit the collConfig.xml.   
    10841085    private void doLoseFocus() {
    1085    
    10861086    if (previous_pane != null) {
    10871087        if (previous_pane == gather_pane) {
     
    11031103    }
    11041104    public void doRegainFocus() {
    1105    
    11061105    if (previous_pane != null) {
    11071106        if (previous_pane == gather_pane) {
  • main/trunk/gli/src/org/greenstone/gatherer/util/Codec.java

    r34241 r34246  
    4242    static final public String ENCODE_SQUARE_BRACKETS = "ENCODE_SQUARE_BRACKETS";
    4343    static final public String ESCAPEDHTML_TO_UNESCAPED = "ESCAPEDHTML_TO_UNESCAPED";
     44    static final public String REINSTATE_HTML_TAGS = "REINSTATE_HTML_TAGS";
    4445    static final public String GREENSTONE_TO_DOM = "GREENSTONE_TO_DOM";
    4546    static final public String GREENSTONE_TO_TEXT = "GREENSTONE_TO_TEXT";
     
    175176        "&", "&amp;",
    176177        "\"", "&quot;",
    177         "\'", "&apos;"
     178        //"\'", "&apos;"
    178179    };
    179180    TRANSFORMS.put(TEXT_TO_DOM_PRESERVE_TAGS, text_to_dom_preserve_tags);
     
    190191    TRANSFORMS.put(ESCAPEDHTML_TO_UNESCAPED, escapedhtml_to_unescaped);
    191192    escapedhtml_to_unescaped = null;
     193   
     194    // Reinstate tag markers <>
     195    String[] reinstate_html_tags = {
     196        "&lt;", "<",
     197        "&gt;", ">",
     198    };
     199    TRANSFORMS.put(REINSTATE_HTML_TAGS, reinstate_html_tags);
     200    reinstate_html_tags = null;
     201   
    192202
    193203    // Transform plain html text into greenstone encoding
Note: See TracChangeset for help on using the changeset viewer.