Changeset 9131


Ignore:
Timestamp:
2005-02-22T13:51:48+13:00 (19 years ago)
Author:
mdewsnip
Message:

Removed all hfile writing from the GLI -- users should now be using AutoHierarchy, which doesn't require hfiles. In the case where the user really needs to a custom hierarchy, they're going to have to create the hfiles themselves anyway (and use Hierarchy).

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
4 edited

Legend:

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

    r9097 r9131  
    11751175    // Write out the collection configuration file
    11761176    Gatherer.g_man.design_pane.saveConfiguration();
    1177 
    1178     // Write hfiles for the loaded metadata elements into the collection "etc" directory
    1179     MetadataSetManager.writeHierarchyFiles(new File(getCollectionEtcDirectoryPath()));
    11801177
    11811178    // Change cursor back to normal
  • trunk/gli/src/org/greenstone/gatherer/metadata/MetadataElement.java

    r9023 r9131  
    172172    return getDisplayName();
    173173    }
    174 
    175 
    176     public void writeHierarchyFile(File hierarchy_file)
    177     {
    178     metadata_value_tree_model.writeHierarchyFile(hierarchy_file);
    179     }
    180174}
  • trunk/gli/src/org/greenstone/gatherer/metadata/MetadataSetManager.java

    r9102 r9131  
    205205    }
    206206    }
    207 
    208 
    209     static public void writeHierarchyFiles(File directory)
    210     {
    211     // Make sure the directory (etc) exists
    212     if (directory.exists() == false) {
    213         return;
    214     }
    215 
    216     // Write a hierarchy file for each loaded metadata element, except extracted metadata
    217     ArrayList every_metadata_set_element = getEveryMetadataSetElement();
    218     for (int i = 0; i < every_metadata_set_element.size(); i++) {
    219         MetadataElement metadata_element = (MetadataElement) every_metadata_set_element.get(i);
    220         if (metadata_element.isExtractedMetadata() == false) {
    221         File hierarchy_file = new File(directory, metadata_element.getFullName() + ".txt");
    222         metadata_element.writeHierarchyFile(hierarchy_file);
    223         }
    224     }
    225     }
    226207}
  • trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValueTreeModel.java

    r8164 r9131  
    135135    return metadata_value_tree_node;
    136136    }
    137 
    138 
    139     public void writeHierarchyFile(File hierarchy_file)
    140     {
    141     try {
    142         // Write the value tree out to a hierarchy file, for the Hierarchy classifier
    143         FileOutputStream file_output_stream = new FileOutputStream(hierarchy_file);
    144         OutputStreamWriter output_stream_writer = new OutputStreamWriter(file_output_stream, "UTF-8");
    145         BufferedWriter buffered_writer = new BufferedWriter(output_stream_writer);
    146 
    147         writeHierarchyFileInternal((MetadataValueTreeNode) root, "", buffered_writer);
    148 
    149         buffered_writer.flush();
    150         buffered_writer.close();
    151     }
    152     catch (Exception ex) {
    153         ex.printStackTrace();
    154     }
    155     }
    156 
    157 
    158     private void writeHierarchyFileInternal(MetadataValueTreeNode parent_metadata_value_tree_node, String index, BufferedWriter buffered_writer)
    159     throws Exception
    160     {
    161     // Perform a depth-first traversal of the value tree, writing the metadata values out to the hfile
    162     for (int i = 0; i < parent_metadata_value_tree_node.getChildCount(); i++) {
    163         MetadataValueTreeNode child_metadata_value_tree_node = (MetadataValueTreeNode) parent_metadata_value_tree_node.getChildAt(i);
    164         String metadata_value_full = child_metadata_value_tree_node.getFullValue();
    165         String index_string = (index.equals("") ? "" + (i + 1) : index + "." + (i + 1));
    166         String metadata_value = child_metadata_value_tree_node.getValue();
    167         String hierarchy_string = "\"" + metadata_value_full + "\"\t" + index_string + "\t\"" + metadata_value + "\"\n";
    168         buffered_writer.write(hierarchy_string, 0, hierarchy_string.length());
    169 
    170         // Apply recursively
    171         writeHierarchyFileInternal(child_metadata_value_tree_node, index_string, buffered_writer);
    172     }
    173     }
    174137}
Note: See TracChangeset for help on using the changeset viewer.