Changeset 9131
- Timestamp:
- 2005-02-22T13:51:48+13:00 (19 years ago)
- 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 1175 1175 // Write out the collection configuration file 1176 1176 Gatherer.g_man.design_pane.saveConfiguration(); 1177 1178 // Write hfiles for the loaded metadata elements into the collection "etc" directory1179 MetadataSetManager.writeHierarchyFiles(new File(getCollectionEtcDirectoryPath()));1180 1177 1181 1178 // Change cursor back to normal -
trunk/gli/src/org/greenstone/gatherer/metadata/MetadataElement.java
r9023 r9131 172 172 return getDisplayName(); 173 173 } 174 175 176 public void writeHierarchyFile(File hierarchy_file)177 {178 metadata_value_tree_model.writeHierarchyFile(hierarchy_file);179 }180 174 } -
trunk/gli/src/org/greenstone/gatherer/metadata/MetadataSetManager.java
r9102 r9131 205 205 } 206 206 } 207 208 209 static public void writeHierarchyFiles(File directory)210 {211 // Make sure the directory (etc) exists212 if (directory.exists() == false) {213 return;214 }215 216 // Write a hierarchy file for each loaded metadata element, except extracted metadata217 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 }226 207 } -
trunk/gli/src/org/greenstone/gatherer/metadata/MetadataValueTreeModel.java
r8164 r9131 135 135 return metadata_value_tree_node; 136 136 } 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 classifier143 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 Exception160 {161 // Perform a depth-first traversal of the value tree, writing the metadata values out to the hfile162 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 recursively171 writeHierarchyFileInternal(child_metadata_value_tree_node, index_string, buffered_writer);172 }173 }174 137 }
Note:
See TracChangeset
for help on using the changeset viewer.