Changeset 8990
- Timestamp:
- 2005-02-09T17:22:09+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/metadata/ProfileXMLFile.java
r8164 r8990 38 38 extends File 39 39 { 40 private HashMap metadata_mapping = null; 41 42 40 43 public ProfileXMLFile(String profile_xml_file_path) 41 44 { … … 44 47 45 48 46 public String getMetadataElementFor(String source_metadata_element_name_full)49 public String getMetadataElementFor(String metadata_element_name_full) 47 50 { 48 // Parse the profile.xml file 49 Document document = XMLTools.parseXMLFile(this); 50 if (document == null) { 51 System.err.println("Error: Could not parse profile.xml file " + getAbsolutePath()); 51 if (getMetadataMapping() == null) { 52 52 return null; 53 53 } 54 54 55 // Read all the Action elements in the file 56 NodeList action_elements_nodelist = document.getElementsByTagName("Action"); 57 for (int i = 0; i < action_elements_nodelist.getLength(); i++) { 58 Element current_action_element = (Element) action_elements_nodelist.item(i); 59 60 // Does this action map the desired element? 61 if (current_action_element.getAttribute("source").equals(source_metadata_element_name_full)) { 62 return current_action_element.getAttribute("target"); 63 } 64 } 65 66 // No import mapping for this element 67 return null; 55 return (String) metadata_mapping.get(metadata_element_name_full); 68 56 } 69 57 … … 71 59 public HashMap getMetadataMapping() 72 60 { 73 HashMap metadata_import_mapping = new HashMap(); 61 // If we have already loaded the metadata mapping, use it 62 if (metadata_mapping != null) { 63 return metadata_mapping; 64 } 65 66 // Build the metadata mapping from the profile.xml file 67 metadata_mapping = new HashMap(); 74 68 75 69 // Parse the profile.xml file … … 86 80 String source_metadata_element_name_full = current_action_element.getAttribute("source"); 87 81 String target_metadata_element_name_full = current_action_element.getAttribute("target"); 88 metadata_ import_mapping.put(source_metadata_element_name_full, target_metadata_element_name_full);82 metadata_mapping.put(source_metadata_element_name_full, target_metadata_element_name_full); 89 83 } 90 84 91 return metadata_ import_mapping;85 return metadata_mapping; 92 86 } 93 87 … … 110 104 // Rewrite the profile.xml file 111 105 XMLTools.writeXMLFile(this, document); 106 107 // Invalidate the metadata mapping 108 metadata_mapping = null; 112 109 } 113 110 }
Note:
See TracChangeset
for help on using the changeset viewer.