Changeset 5668 for trunk/gli/src/org/greenstone/gatherer/msm
- Timestamp:
- 2003-10-17T04:45:05+13:00 (21 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/msm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/msm/GDMDocument.java
r5589 r5668 32 32 import org.greenstone.gatherer.msm.GDMManager; 33 33 import org.greenstone.gatherer.msm.MSMUtils; 34 import org.greenstone.gatherer.util.Codec; 34 35 import org.greenstone.gatherer.util.HashMap3D; 35 36 import org.greenstone.gatherer.util.StaticStrings; … … 164 165 if(sibling_metadata_element.getAttribute(NAME_ATTRIBUTE).equals(metadata_element.getAttribute(NAME_ATTRIBUTE))) { 165 166 // Check the values and return if they are the same. 166 //if(metadata_element.getAttribute(NAME_ATTRIBUTE).equalsIgnoreCase("dls.Title")) { 167 // Gatherer.println("Comparing:"); 168 // Gatherer.println("'" + metadata.getAbsoluteValue() + "'"); 169 // Gatherer.println(" with:"); 170 // Gatherer.println("'" + MSMUtils.getValue(sibling_metadata_element) + "'"); 171 //} 172 if(metadata.getAbsoluteValue().equals(MSMUtils.getValue(sibling_metadata_element))) { 173 // Gatherer.println("Value already exists: " + metadata); 174 return; 175 } 176 will_accumulate = true; 177 } 167 if(metadata.getAbsoluteValue().equals(MSMUtils.getValue(sibling_metadata_element))) { 168 return; 169 } 170 will_accumulate = true; 171 } 178 172 sibling_metadata_element = null; 179 173 } … … 191 185 } 192 186 String node_value = metadata.getAbsoluteValue(); 187 ///ystem.err.println("Creating node in GDMDocument: '" + node_value + "'"); 193 188 metadata_element.appendChild(base_document.createTextNode(node_value)); 194 189 // Retrieve the first description element for this fileset (there should only be one, but I'll play it safe). … … 279 274 String raw_value = metadata_element.getAttribute(HVALUE_ATTRIBUTE); 280 275 if(raw_value == null || raw_value.length() == 0) { 281 raw_value = MSMUtils.getValue(metadata_element); 276 raw_value = MSMUtils.getValue(metadata_element); 277 // Raw value is in GREENSTONE form, convert to DOM 278 raw_value = Codec.transform(raw_value, Codec.GREENSTONE_TO_DOM); 282 279 } 283 280 // ***** LEGACY SUPPORT ***** … … 498 495 this.up_to_date = up_to_date; 499 496 } 500 501 /** Decode a string that was previously made Perl safe. */502 private String decode(String safe) {503 return safe.replaceAll("\\\\.",".");504 }505 506 /** Encodes unsafe filename characters (such as the . before the file extension) into Perl safe ones. */507 private String encode(String dangerous) {508 return dangerous.replaceAll("\\.", "\\\\.");509 }510 497 } -
trunk/gli/src/org/greenstone/gatherer/msm/Metadata.java
r5589 r5668 120 120 } 121 121 /** Determine the absolute path value of this metadata, taking into account whether this value is hierarchical. */ 122 public String getAbsoluteValue() { 123 String abs_value = getValue(); 122 public String getAbsoluteValue() { 123 String abs_result = ""; 124 if(value != null) { 125 abs_result = value.toString(GValueNode.GREENSTONE); 126 } 127 return abs_result; 128 129 //String abs_value = getValue(); 124 130 // What actually gets written as the value depends on whether this is a hierarchy based element. 125 GValueModel model = Gatherer.c_man.getCollection().msm.getValueTree(element); 126 /*if(model != null && model.isHierarchy()) { 127 if(value != null) { 128 abs_value = value.getFullPath(false); 129 } 130 abs_value = model.getHIndex(abs_value); 131 } 132 else {*/ 133 abs_value = abs_value.replaceAll(StaticStrings.LBRACKET_PATTERN, StaticStrings.ESCAPE_PATTERN + StaticStrings.LBRACKET_PATTERN); 134 abs_value = abs_value.replaceAll(StaticStrings.RBRACKET_PATTERN, StaticStrings.ESCAPE_PATTERN + StaticStrings.RBRACKET_PATTERN); 135 //} 131 //GValueModel model = Gatherer.c_man.getCollection().msm.getValueTree(element); 136 132 // Return the result 137 return abs_value;133 //return abs_value; 138 134 } 139 135 /** Retrieve the reference count. … … 207 203 return element.toString() + "=" + getValue(); 208 204 } 205 209 206 /** Retrieve the value node associated with a certain value string. */ 210 207 static final public GValueNode getDefaultValueNode(ElementWrapper element, String value) { -
trunk/gli/src/org/greenstone/gatherer/msm/MetadataSetManager.java
r5593 r5668 104 104 * @param value The value to assign to the metadata as a String. 105 105 */ 106 public void addMetadata(long id, FileNode records[], ElementWrapper element, String value_str) { 107 if (records.length == 1) { 108 addMetadata(id, records, element, value_str, MetaEditPrompt.ACCUMULATE_ALL); 109 } 110 else { 111 addMetadata(id, records, element, value_str, MetaEditPrompt.CONFIRM); 112 } 113 } 114 public void addMetadata(long id, FileNode records[], ElementWrapper element, String value_str, int action) { 106 public Metadata addMetadata(long id, FileNode records[], ElementWrapper element, String value_str) { 107 Metadata metadata = null; 108 if (records.length == 1) { 109 metadata = addMetadata(id, records, element, value_str, MetaEditPrompt.ACCUMULATE_ALL); 110 } 111 else { 112 metadata = addMetadata(id, records, element, value_str, MetaEditPrompt.CONFIRM); 113 } 114 return metadata; 115 } 116 public Metadata addMetadata(long id, FileNode records[], ElementWrapper element, String value_str, int action) { 115 117 // Retrieve the appropriate value node from the value tree for this element, creating it if necessary. 116 118 GValueModel model = getValueTree(element); … … 138 140 } 139 141 } 142 return metadata; 140 143 } 141 144 … … 1072 1075 } 1073 1076 else { 1074 1077 // Recover the metadata from this file. 1075 1078 ArrayList metadata = Gatherer.c_man.getCollection().gdm.getMetadata(record.getFile()); 1076 1079 // Most important test, we don't have to add the metadata if its already there! 1077 1080 if(!metadata.contains(data)) { 1078 1081 // Record undo information for this file node.
Note:
See TracChangeset
for help on using the changeset viewer.