Changeset 6069
- Timestamp:
- 2003-12-01T19:52:02+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java
r6051 r6069 231 231 private String value = null; 232 232 233 private AppendMetadataTask(ElementWrapper element, String value) {233 private AppendMetadataTask(ElementWrapper element, String raw_value) { 234 234 this.element = element; 235 this.value = raw_value; 235 236 // Transform the raw text to be GREENSTONE and DOM compatible - as that will be its next destination immediately after being added to the value model 236 this.value = Codec.transform(value, Codec.ENCODE_PATH);237 this.value = Codec.transform(this.value, Codec.REMOVE_SQUARE_BRACKET);238 this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM);237 //this.value = /odec.transform(value, /odec.ENCODE_PATH); 238 //this.value = /odec.transform(this.value, /odec.REMOVE_SQUARE_BRACKET); 239 //this.value = /odec.transform(this.value, /odec.TEXT_TO_DOM); 239 240 } 240 241 … … 267 268 private String value; 268 269 269 private UpdateMetadataTask(ElementWrapper element, String value) {270 private UpdateMetadataTask(ElementWrapper element, String raw_value) { 270 271 this.element = element; 272 this.value = raw_value; 271 273 // Transform the raw text to be DOM compatible - as that will be its next destination immediately after being added to the value model 272 this.value = Codec.transform(value, Codec.REMOVE_SQUARE_BRACKET);273 this.value = Codec.transform(this.value, Codec.TEXT_TO_DOM);274 //this.value = /odec.transform(value, /odec.REMOVE_SQUARE_BRACKET); 275 //this.value = /odec.transform(this.value, /odec.TEXT_TO_DOM); 274 276 } 275 277 … … 1103 1105 JPanel value_field_pane = new JPanel(); 1104 1106 TransformCharacterTextField value_init = new TransformCharacterTextField(); 1105 value_init.replaceCharacter(StaticStrings.PIPE_CHAR, StaticStrings.FORWARDSLASH_CHAR);1107 //value_init.replaceCharacter(StaticStrings.PIPE_CHAR, StaticStrings.FORWARDSLASH_CHAR); 1106 1108 value = value_init; 1107 1109 value_init = null; … … 1189 1191 1190 1192 public String getSelectedValue() { 1191 return Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_GREENSTONE); 1193 //return /odec.transform(/odec.transformUnicode(value.getText()), /odec.TEXT_TO_GREENSTONE); 1194 String raw_value = value.getText(); 1195 raw_value = Codec.transformUnicode(raw_value); 1196 raw_value = Codec.transform(raw_value, Codec.ENCODE_PATH); 1197 raw_value = Codec.transform(raw_value, Codec.ENCODE_SQUARE_BRACKETS); 1198 return raw_value; 1192 1199 } 1193 1200 … … 1256 1263 // Setting the text of the field causes the DocumentListener to be notified, and 1257 1264 // updating the tree is handled there (DocumentListenerImpl::validate()) 1258 ///ystem.err.println("Setting selected value to: " + val);1259 1265 if (!card_showing.equals(NONE)) { 1266 // Decode val 1267 //System.err.println("Before transforms: " + val); 1268 //val = Codec.transform(val, Codec.DECODE_SQUARE_BRACKETS); 1269 //val = Codec.transform(val, Codec.DECODE_PATH); 1270 //System.err.println("Setting selected value to: " + val); 1260 1271 manual_text_edit_event = val.equals(""); // Set to false unless val == "" 1261 value.setText( Codec.transform(val, Codec.GREENSTONE_TO_TEXT));1272 value.setText(val); ///odec.transform(val, /odec.GREENSTONE_TO_TEXT)); 1262 1273 value.setCaretPosition(0); 1263 1274 manual_text_edit_event = true; … … 1269 1280 private TreePath getClosestPath(String val) 1270 1281 { 1282 System.err.println("Select closest path to: " + val); 1271 1283 // Start at the root of the tree 1272 1284 GValueNode tree_node = (GValueNode) tree.getModel().getRoot(); 1273 1285 1274 // Hierarchical values are separated using ' \'1275 PatternTokenizer tokenizer = new PatternTokenizer(val, "\\"); //StaticStrings.PIPE_STR);1286 // Hierarchical values are separated using '|' 1287 PatternTokenizer tokenizer = new PatternTokenizer(val, StaticStrings.PIPE_STR); 1276 1288 while (tokenizer.hasMoreTokens()) { 1277 1289 String token = tokenizer.nextToken(); … … 1336 1348 TreePath path = tree.getSelectionPath(); 1337 1349 GValueNode node = (GValueNode) path.getLastPathComponent(); 1338 value.setText(node.getFullPath(true)); 1350 String val = node.getFullPath(true); 1351 System.err.println("Setting value to: " + val); 1352 value.setText(val); 1353 val = null; 1339 1354 } 1340 1355 } … … 1374 1389 private void validate() 1375 1390 { 1376 String value_text = Codec.transform(getSelectedValue(), Codec.TEXT_TO_DOM);1391 String value_text = getSelectedValue(); ///odec.transform(getSelectedValue(), /odec.TEXT_TO_DOM); 1377 1392 ///ystem.err.println("\n(Validate) Value text: " + value_text); 1378 1393 -
trunk/gli/src/org/greenstone/gatherer/msm/GDMDocument.java
r6051 r6069 190 190 String node_value = null; 191 191 if(model != null && model.isHierarchy()) { 192 node_value = Codec.transform(metadata.getValueNode().getFullPath(false), Codec.TEXT_TO_DOM); 192 //node_value = /odec.transform(metadata.getValueNode().getFullPath(false), /odec.TEXT_TO_DOM); 193 node_value = metadata.getValueNode().getFullPath(false); 193 194 } 194 195 else { 195 196 } 197 ///ystem.err.println("Creating node in GDMDocument: '" + node_value + "'");196 node_value = metadata.getAbsoluteValue(); 197 } 198 System.err.println("Creating node in GDMDocument: '" + node_value + "'"); 198 199 metadata_element.appendChild(base_document.createTextNode(node_value)); 199 200 // Retrieve the first description element for this fileset (there should only be one, but I'll play it safe). … … 253 254 return getMetadata(filename, remove, metadatum_so_far, file, append_folder_level, false); 254 255 } 255 256 256 /** Retrieve the metadata associated with the given filename. Keep track of what metadata should be overwritten and what should be accumulated. Also make note of the source file, and remove the metadata if required. Finally if purge is set retrieve every piece of metadata in this file. */ 257 public ArrayList getMetadata(String filename, boolean remove, ArrayList metadatum_so_far, File file, boolean append_folder_level, boolean purge) { 257 258 Gatherer.println("Get metadata for " + filename); 258 259 ArrayList metadatum = null; 259 260 if(metadatum_so_far == null) { 260 261 metadatum = new ArrayList(); 261 262 } 262 263 else { 263 264 metadatum = metadatum_so_far; 264 265 } 265 266 try { 266 267 268 269 270 267 // Retrieve the document element. 268 Element directorymetadata_element = base_document.getDocumentElement(); 269 // Iterate through the filesets, checking the FileName child element against the target file's name using regular expression matching. 270 NodeList fileset_elements = directorymetadata_element.getElementsByTagName(FILESET_ELEMENT); 271 for(int i = 0; i < fileset_elements.getLength(); i++) { 271 272 Element fileset_element = (Element) fileset_elements.item(i); 272 273 NodeList filename_elements = fileset_element.getElementsByTagName(FILENAME_ELEMENT); 273 274 for(int j = 0; j < filename_elements.getLength(); j++) { 274 275 276 275 Element filename_element = (Element) filename_elements.item(j); 276 String filename_text = MSMUtils.getValue(filename_element); 277 if((filename != null && (filename.matches(filename_text) || (append_folder_level && filename.indexOf(File.separator) != -1 && filename_text.equals(filename.substring(0, filename.indexOf(File.separator)))))) || ((filename == null || append_folder_level) && filename_text.equals(DIRECTORY_FILENAME)) || purge) { 277 278 // If they match add all of the metadata found in the Description child element, remembering to abide by desired mode (accumulate vs. overwrite). 278 279 // Normal metadata 279 280 NodeList description_elements = fileset_element.getElementsByTagName(DESCRIPTION_ELEMENT); 280 281 for(int k = 0; k < description_elements.getLength(); k++) { 281 Element description_element = (Element) description_elements.item(k); 282 // We have to do this for each type of metadata 283 for(int z = 0; z < ALL_METADATA_TYPES.length; z++) { 284 NodeList metadata_elements = description_element.getElementsByTagName(ALL_METADATA_TYPES[z]); 285 for(int l = 0; l < metadata_elements.getLength(); l++) { 286 Element metadata_element = (Element) metadata_elements.item(l); 287 String raw_element = metadata_element.getAttribute(StaticStrings.NAME_ATTRIBUTE); 288 //String language = metadata_element.getAttribute("language"); 289 String mode = metadata_element.getAttribute(MODE_ATTRIBUTE); 290 String raw_value = MSMUtils.getValue(metadata_element); 291 // Raw value is in GREENSTONE form, convert to DOM 292 raw_value = Codec.transform(raw_value, Codec.GREENSTONE_TO_DOM); 293 // ***** LEGACY SUPPORT ***** 294 // If this raw_value contains a '\' character, but no '\\', '[' or ']' characters, then replace the '\' with a '\\' 295 if(raw_value.indexOf(StaticStrings.ESCAPE_STR) != -1) { 296 Gatherer.println("Detected Legacy Path: " + raw_value); 297 raw_value = raw_value.replaceAll(StaticStrings.ESCAPE_PATTERN, StaticStrings.PIPE_STR); 298 Gatherer.println("Updated Path To: " + raw_value); 299 MSMUtils.setValue(metadata_element, raw_value); 300 } 301 // ************************** 302 // Using the element string and value, retrieve a matching Metadata object from the cache 303 Metadata metadata = null; 304 // If this element has hierarchy values then we must ensure the raw value is a full path, not an index. 305 // Try to retrieve an already comstructed piece of metadata from file - but not if we are purging, as this will stuff up anything that is still using that metadata - such as the GTable 306 if(GDMManager.metadata_cache.contains(raw_element, raw_value) && !purge) { 307 ///ystem.err.println("HIT! Retrieve metadata from cache: " + raw_element + " -> " + raw_value + "\n"); 308 metadata = (Metadata) GDMManager.metadata_cache.get(raw_element, raw_value); 309 } 310 else { 311 ElementWrapper element = Gatherer.c_man.getCollection().msm.getElement(raw_element); 312 if (element != null) { 313 GValueNode value = Metadata.getDefaultValueNode(element, raw_value); 314 ///ystem.err.println("Miss. Create new metadata: " + raw_element + " -> " + raw_value + "\n"); 315 metadata = new Metadata(element, value); 316 if(!purge) { 317 GDMManager.metadata_cache.put(raw_element, raw_value, metadata); 318 } 319 ///ystem.err.println("Added metadata to cache: " + raw_element + " -> " + raw_value + "\n"); 320 value = null; 321 element = null; 322 } 323 } 324 // check whether the metadata is null 325 if (metadata != null) { 326 // We determine whether this metadata is file or folder level 327 if(filename != null) { 328 ///ystem.err.println("Filename = " + filename); 329 ///ystem.err.println("filename_text = " + filename_text); 330 // If can only be file level if there is no folder path details in filename and if the filename matched the filename text node (it may have matched .* instead)! 331 if(filename.indexOf(File.separator) == -1 && filename.equals(filename_text)) { 332 metadata.setFileLevel(true); 333 ///ystem.err.println("File level!!!"); 334 } 335 else { 336 metadata.setFileLevel(false); 337 ///ystem.err.println("Inherited!!!"); 338 } 339 } 340 else { 341 ///ystem.err.println("Filename is null therefore this is file level metadata."); 342 metadata.setFileLevel(true); 343 } 344 metadata.setFile(file); 345 // If mode is overwrite, then remove any previous values for this metadata element. 346 if(mode.equals("accumulate")) { 347 metadata.setAccumulate(true); 348 } 349 else { 350 metadata.setAccumulate(false); 351 ///ystem.err.println("Metadata overwrites: " + metadata); 352 for(int m = metadatum.size() - 1; m >= 0; m--) { 353 Metadata old_metadata = (Metadata) metadatum.get(m); 354 if(old_metadata.getElement().equals(metadata.getElement())) { 355 metadatum.remove(m); 356 ///ystem.err.println("Removing overridden metadata: " + old_metadata); 357 } 358 old_metadata = null; 359 } 360 } 361 mode = null; 362 // Add the completed metadata and clean up 363 ///ystem.err.println("Adding metadata: " + metadata); 364 metadatum.add(metadata); 365 // Having found our metadata check if the value from the xml matches the one from the gvaluenode. If not update it. This happens whenever hierarchy information is involved (indexes rapidly become obsolete). 366 // If remove was set, remove it. We can only remove pure file level metadata, or folder level iff we were asked for folder level. 367 if(remove && ((filename != null && filename.matches(filename_text) && !filename_text.equals(DIRECTORY_FILENAME)) || (filename == null && filename_text.equals(DIRECTORY_FILENAME)))) { 368 ///ystem.err.println("Removing " + metadata + " from " + file); 369 description_element.removeChild(metadata_element); 370 // Remove the description element if empty. 371 if(!description_element.hasChildNodes()) { 372 fileset_element.removeChild(description_element); 373 } 374 } 375 else { 376 //String current_value = metadata.getAbsoluteValue(); 377 String current_value = Codec.transform(metadata.getValueNode().getFullPath(false), Codec.TEXT_TO_DOM); 378 ///ystem.err.println("Checking the current hfile: " + current_value); 379 ///ystem.err.println("Against whats in the hfile: " + current_value); 380 if(!raw_value.equals(current_value)) { 381 // Remove old text 382 while(metadata_element.hasChildNodes()) { 383 metadata_element.removeChild(metadata_element.getFirstChild()); 384 } 385 // Add new. 386 metadata_element.appendChild(base_document.createTextNode(current_value)); 387 } 388 } 389 } 390 metadata = null; 391 raw_value = null; 392 raw_element = null; 393 metadata_element = null; 394 } 395 metadata_elements = null; 282 Element description_element = (Element) description_elements.item(k); 283 // We have to do this for each type of metadata 284 for(int z = 0; z < ALL_METADATA_TYPES.length; z++) { 285 NodeList metadata_elements = description_element.getElementsByTagName(ALL_METADATA_TYPES[z]); 286 for(int l = 0; l < metadata_elements.getLength(); l++) { 287 Element metadata_element = (Element) metadata_elements.item(l); 288 String raw_element = metadata_element.getAttribute(StaticStrings.NAME_ATTRIBUTE); 289 //String language = metadata_element.getAttribute("language"); 290 String mode = metadata_element.getAttribute(MODE_ATTRIBUTE); 291 String raw_value = MSMUtils.getValue(metadata_element); 292 // 293 //raw_value = Codec.transform(raw_value, Codec.DOM_TO_); 294 ///ystem.err.println("Retrieved raw value: " + raw_value); 295 // ***** LEGACY SUPPORT ***** 296 // If this raw_value contains a '\' character, but no '\\', '[' or ']' characters, then replace the '\' with a '\\' 297 if(raw_value.indexOf(StaticStrings.ESCAPE_STR) != -1) { 298 ///ystem.err.println("Blarg"); 299 Gatherer.println("Detected Legacy Path: " + raw_value); 300 raw_value = raw_value.replaceAll(StaticStrings.ESCAPE_PATTERN, StaticStrings.PIPE_STR); 301 Gatherer.println("Updated Path To: " + raw_value); 302 MSMUtils.setValue(metadata_element, raw_value); 303 } 304 // ************************** 305 // Using the element string and value, retrieve a matching Metadata object from the cache 306 Metadata metadata = null; 307 // If this element has hierarchy values then we must ensure the raw value is a full path, not an index. 308 // Try to retrieve an already comstructed piece of metadata from file - but not if we are purging, as this will stuff up anything that is still using that metadata - such as the GTable 309 if(GDMManager.metadata_cache.contains(raw_element, raw_value) && !purge) { 310 ///ystem.err.println("HIT! Retrieve metadata from cache: " + raw_element + " -> " + raw_value + "\n"); 311 metadata = (Metadata) GDMManager.metadata_cache.get(raw_element, raw_value); 312 } 313 else { 314 ElementWrapper element = Gatherer.c_man.getCollection().msm.getElement(raw_element); 315 if (element != null) { 316 GValueNode value = Metadata.getDefaultValueNode(element, raw_value); 317 ///ystem.err.println("Miss. Create new metadata: " + raw_element + " -> " + raw_value + "\n"); 318 metadata = new Metadata(element, value); 319 if(!purge) { 320 GDMManager.metadata_cache.put(raw_element, raw_value, metadata); 321 } 322 ///ystem.err.println("Added metadata to cache: " + raw_element + " -> " + raw_value + "\n"); 323 value = null; 324 element = null; 325 } 326 } 327 // check whether the metadata is null 328 if (metadata != null) { 329 // We determine whether this metadata is file or folder level 330 if(filename != null) { 331 ///ystem.err.println("Filename = " + filename); 332 ///ystem.err.println("filename_text = " + filename_text); 333 // If can only be file level if there is no folder path details in filename and if the filename matched the filename text node (it may have matched .* instead)! 334 if(filename.indexOf(File.separator) == -1 && filename.equals(filename_text)) { 335 metadata.setFileLevel(true); 336 ///ystem.err.println("File level!!!"); 337 } 338 else { 339 metadata.setFileLevel(false); 340 ///ystem.err.println("Inherited!!!"); 341 } 342 } 343 else { 344 ///ystem.err.println("Filename is null therefore this is file level metadata."); 345 metadata.setFileLevel(true); 346 } 347 metadata.setFile(file); 348 // If mode is overwrite, then remove any previous values for this metadata element. 349 if(mode.equals("accumulate")) { 350 metadata.setAccumulate(true); 351 } 352 else { 353 metadata.setAccumulate(false); 354 ///ystem.err.println("Metadata overwrites: " + metadata); 355 for(int m = metadatum.size() - 1; m >= 0; m--) { 356 Metadata old_metadata = (Metadata) metadatum.get(m); 357 if(old_metadata.getElement().equals(metadata.getElement())) { 358 metadatum.remove(m); 359 ///ystem.err.println("Removing overridden metadata: " + old_metadata); 360 } 361 old_metadata = null; 362 } 363 } 364 mode = null; 365 // Add the completed metadata and clean up 366 ///ystem.err.println("Adding metadata: " + metadata); 367 metadatum.add(metadata); 368 // Having found our metadata check if the value from the xml matches the one from the gvaluenode. If not update it. This happens whenever hierarchy information is involved (indexes rapidly become obsolete). 369 // If remove was set, remove it. We can only remove pure file level metadata, or folder level iff we were asked for folder level. 370 if(remove && ((filename != null && filename.matches(filename_text) && !filename_text.equals(DIRECTORY_FILENAME)) || (filename == null && filename_text.equals(DIRECTORY_FILENAME)))) { 371 ///ystem.err.println("Removing " + metadata + " from " + file); 372 description_element.removeChild(metadata_element); 373 // Remove the description element if empty. 374 if(!description_element.hasChildNodes()) { 375 fileset_element.removeChild(description_element); 376 } 377 } 378 else { 379 //String current_value = metadata.getAbsoluteValue(); 380 //String current_value = Codec.transform(metadata.getValueNode().getFullPath(false), Codec.TEXT_TO_DOM); 381 String current_value = metadata.getValueNode().getFullPath(false); 382 //System.err.println("Checking the current mdv path: " + current_value); 383 //System.err.println("Against whats in the metadata file: " + raw_value); 384 if(!raw_value.equals(current_value)) { 385 // Remove old text 386 while(metadata_element.hasChildNodes()) { 387 metadata_element.removeChild(metadata_element.getFirstChild()); 388 } 389 // Add new. 390 metadata_element.appendChild(base_document.createTextNode(current_value)); 391 } 392 } 393 } 394 metadata = null; 395 raw_value = null; 396 raw_element = null; 397 metadata_element = null; 396 398 } 397 description_element = null; 399 metadata_elements = null; 400 } 401 description_element = null; 398 402 } 399 403 description_elements = null; 400 401 402 404 } 405 filename_text = null; 406 filename_element = null; 403 407 } 404 408 // If the file set no longer has any description entries, remove it entirely 405 409 NodeList description_elements = fileset_element.getElementsByTagName(DESCRIPTION_ELEMENT); 406 410 if(description_elements.getLength() == 0) { 407 411 directorymetadata_element.removeChild(fileset_element); 408 412 } 409 413 description_elements = null; 410 414 filename_elements = null; 411 415 fileset_element = null; 412 413 414 416 } 417 fileset_elements = null; 418 directorymetadata_element = null; 415 419 } 416 420 catch (Exception error) { 417 421 Gatherer.self.printStackTrace(error); 418 422 } 419 423 ///ystem.err.println("Found " + metadatum.size() + " pieces of metadata."); 420 424 return metadatum; 421 422 425 } 426 423 427 /** Determine if this document has been saved recently, and thus xml file version is up to date. */ 424 428 public boolean isUpToDate() { -
trunk/gli/src/org/greenstone/gatherer/util/Codec.java
r6051 r6069 37 37 */ 38 38 public class Codec { 39 39 40 40 static final public String DECODE_PATH = "DECODE_PATH"; 41 static final public String DOM_TO_GREENSTONE = "DOM_TO_GREENSTONE"; 42 static final public String DOM_TO_TEXT = "DOM_TO_TEXT"; 41 static final public String DECODE_SQUARE_BRACKETS = "DECODE_SQUARE_BRACKETS"; 42 static final public String DOM_TO_GREENSTONE = "DOM_TO_GREENSTONE"; 43 static final public String DOM_TO_TEXT = "DOM_TO_TEXT"; 43 44 static final public String ENCODE_PATH = "ENCODE_PATH"; 44 static final public String GREENSTONE_TO_DOM = "GREENSTONE_TO_DOM";45 static final public String GREENSTONE_TO_TEXT = "GREENSTONE_TO_TEXT";46 static final public String REMOVE_SQUARE_BRACKET = "REMOVE_SQUARE_BRACKET";47 static final public String TEXT_TO_DOM = "TEXT_TO_DOM";48 static final public String TEXT_TO_GREENSTONE = "TEXT_TO_GREENSTONE";49 static final public String TEXT_TO_SHELL_UNIX = "TEXT_TO_SHELL_UNIX";50 static final public String TEXT_TO_SHELL_WINDOWS = "TEXT_TO_SHELL_WINDOWS";51 45 static final public String ENCODE_SQUARE_BRACKETS = "ENCODE_SQUARE_BRACKETS"; 46 static final public String GREENSTONE_TO_DOM = "GREENSTONE_TO_DOM"; 47 static final public String GREENSTONE_TO_TEXT = "GREENSTONE_TO_TEXT"; 48 static final public String TEXT_TO_DOM = "TEXT_TO_DOM"; 49 static final public String TEXT_TO_GREENSTONE = "TEXT_TO_GREENSTONE"; 50 static final public String TEXT_TO_SHELL_UNIX = "TEXT_TO_SHELL_UNIX"; 51 static final public String TEXT_TO_SHELL_WINDOWS = "TEXT_TO_SHELL_WINDOWS"; 52 52 53 static final private int MAX_CACHE_SIZE = 100; 53 54 54 55 static private HashMap TRANSFORMS; 55 56 static private HashMap3D CACHE; 56 57 57 58 58 /** Static function called to construct TRANSFORMS mappings */ 59 59 static { … … 61 61 62 62 String[] decode_path = { 63 "\\|", "\\\\" 63 "\\|", "\\\\", 64 "|", "\\|" 64 65 }; 65 66 TRANSFORMS.put(DECODE_PATH, decode_path); 66 67 decode_path = null; 68 69 // Transform text into text, but without [ and ] 70 String[] decode_square_brackets = { 71 "[", "\\[", 72 "]", "\\]" 73 }; 74 TRANSFORMS.put(DECODE_SQUARE_BRACKETS, decode_square_brackets); 75 decode_square_brackets = null; 67 76 68 77 // Translate DOM encoded text into Greenstone encoding … … 94 103 95 104 String[] encode_path = { 105 "\\|", "|", 96 106 "\\\\", "\\|" 97 107 }; 98 108 TRANSFORMS.put(ENCODE_PATH, encode_path); 99 109 encode_path = null; 110 111 // Transform text into text, but without [ and ] 112 String[] encode_square_brackets = { 113 "\\[", "[", 114 "\\]", "]" 115 }; 116 TRANSFORMS.put(ENCODE_SQUARE_BRACKETS, encode_square_brackets); 117 encode_square_brackets = null; 100 118 101 119 // Transform Greenstone encoded text to DOM encoding … … 125 143 TRANSFORMS.put(GREENSTONE_TO_TEXT, greenstone_to_text); 126 144 greenstone_to_text = null; 127 128 // Transform text into text, but without [ and ]129 String[] remove_square_bracket = {130 "\\[", "&#091;",131 "\\]", "&#093;"132 };133 TRANSFORMS.put(REMOVE_SQUARE_BRACKET, remove_square_bracket);134 remove_square_bracket = null;135 145 136 146 // Transform plain html text into something that can be placed in a DOM -
trunk/gli/src/org/greenstone/gatherer/util/MetadataXML.java
r5875 r6069 59 59 String index = model.getHIndex(full_value); 60 60 61 write(bw, "\"" + Utility.stripNL(full_value) + "\"\t" + index + "\t\"" + Utility.stripNL(node.toString( )) + "\"");61 write(bw, "\"" + Utility.stripNL(full_value) + "\"\t" + index + "\t\"" + Utility.stripNL(node.toString(GValueNode.GREENSTONE)) + "\""); 62 62 } 63 63 // Very important we do this, or else buffer may not have -
trunk/gli/src/org/greenstone/gatherer/valuetree/GValueModel.java
r6037 r6069 251 251 252 252 private String getHIndex(GValueNode node, String value, String index) { 253 253 ///ystem.err.println("Get the HIndex for: " + value); 254 254 for(int i = node.size(); i != 0; i--) { 255 255 GValueNode next = (GValueNode)node.get(i - 1); 256 String next_str = next.toString( );256 String next_str = next.toString(GValueNode.DOM); 257 257 ///ystem.err.println("Does " + value + " start with " + next_str + "?"); 258 258 if(value.startsWith(next_str)) { -
trunk/gli/src/org/greenstone/gatherer/valuetree/GValueNode.java
r6044 r6069 162 162 return default_value; 163 163 } 164 StringBuffer path = new StringBuffer(toString( ));164 StringBuffer path = new StringBuffer(toString(DOM)); 165 165 GValueNode node = (GValueNode) getParent(); 166 166 while(node != null && !node.getElement().getNodeName().equalsIgnoreCase("AssignedValues")) { 167 167 path.insert(0, StaticStrings.PIPE_STR); 168 path.insert(0, node.toString( ));168 path.insert(0, node.toString(DOM)); 169 169 node = (GValueNode) node.getParent(); 170 170 } 171 171 if(as_text) { 172 String temp = Codec.transform(path.toString(), Codec.GREENSTONE_TO_TEXT); 173 return Codec.transform(temp, Codec.DECODE_PATH); 172 String temp = path.toString(); ///odec.transform(path.toString(), codec.GREENSTONE_TO_TEXT); 173 System.err.println("Raw: " + temp); 174 temp = Codec.transform(temp, Codec.DECODE_PATH); 175 temp = Codec.transform(temp, Codec.DECODE_SQUARE_BRACKETS); 176 System.err.println("Decoded: " + temp); 177 return temp; 174 178 } 175 179 else { … … 313 317 String result = null; 314 318 if(name.equals("Subject")) { 315 result = MSMUtils.getValue(element); 316 result = Codec.transform(result, Codec.DECODE_PATH); 317 switch(decode_type) { 318 case GValueNode.GREENSTONE: 319 // We want this as greenstone format 320 ///ystem.err.print(result); 321 result = Codec.transform(result, Codec.DOM_TO_GREENSTONE); 322 ///ystem.err.println(" -> D2G decode -> " + result); 323 break; 324 case GValueNode.TEXT: 325 ///ystem.err.print(result); 326 result = Codec.transform(result, Codec.DOM_TO_TEXT); 327 ///ystem.err.println(" -> D2T decode -> " + result); 328 break; 329 default: 330 ///ystem.err.println(result + " -> nothing to do."); 331 } 319 result = MSMUtils.getValue(element); 320 ///ystem.err.print(result); 321 switch(decode_type) { 322 case GValueNode.GREENSTONE: 323 // We want this as greenstone format 324 ///ystem.err.print(result); 325 //result = /odec.transform(result, /odec.DOM_TO_GREENSTONE); 326 ///ystem.err.println(" -> D2G decode -> " + result); 327 break; 328 case GValueNode.TEXT: 329 //result = /odec.transform(result, /odec.DOM_TO_TEXT); 330 result = Codec.transform(result, Codec.DECODE_PATH); 331 result = Codec.transform(result, Codec.DECODE_SQUARE_BRACKETS); 332 ///ystem.err.println(" -> D2T decode -> " + result); 333 break; 334 default: 335 ///ystem.err.println(result + " -> nothing to do."); 336 } 332 337 } 333 338 else if(name.equals("AssignedValues")) {
Note:
See TracChangeset
for help on using the changeset viewer.