Changeset 24393 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
- Timestamp:
- 2011-08-12T09:57:26+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
r24254 r24393 41 41 import java.util.Iterator; 42 42 import java.util.ArrayList; 43 import java.util.regex.Matcher;44 import java.util.regex.Pattern;45 43 46 44 import org.apache.log4j.*; … … 198 196 199 197 } else { 200 // prepare regex to work with mdoffset: looking for <offset\d*_>201 Pattern pattern = Pattern.compile("offset[0-9]*" + GSConstants.META_RELATION_SEP);202 203 198 for (int i=0; i<metadata_names.size(); i++) { 204 199 String meta_name = (String) metadata_names.get(i); 205 200 String value = getMetadata(node_id, info, meta_name, lang); 206 207 // Remove the occurrence (if any) in this metaname of the mdoffset number in the pattern <offset\d*_>208 // Leaving string "offset" in at this point: it will be handled in config_format.xsl's gsf:metadata template match209 Matcher matcher = pattern.matcher(meta_name);210 meta_name = matcher.replaceFirst("offset" + GSConstants.META_RELATION_SEP);211 //replaceFirst(""); // if removing the occurrence (if any) of entire pattern <offset\d*_> in input212 213 201 GSXML.addMetadata(this.doc, metadata_list, meta_name, value); 214 202 } … … 329 317 protected String getMetadata(String node_id, DBInfo info, 330 318 String metadata, String lang) { 331 String multiple = "false"; // multiple can now be "true", "false" or "offset<number>". It's no longer a boolean319 boolean multiple = false; 332 320 String relation = ""; 333 321 String separator = ", "; … … 358 346 metadata = metadata.substring(pos+1); 359 347 // check for all on the front 360 if (temp.equals("all") || temp.startsWith("offset")) { // multiple can now be "true", "false" or "offset"361 multiple = temp; // multiple=true;348 if (temp.equals("all")) { 349 multiple=true; 362 350 pos = metadata.indexOf(GSConstants.META_RELATION_SEP); 363 351 if (pos ==-1) { … … 411 399 StringBuffer result = new StringBuffer(); 412 400 413 if ( multiple.equals("false")) {401 if (!multiple) { 414 402 result.append(this.macro_resolver.resolve(relation_info.getInfo(metadata), lang, MacroResolver.SCOPE_META, relation_id)); 415 } else if(multiple.startsWith("offset")) { // multiple = offset 416 String offset = multiple.substring("offset".length(), multiple.length()); 417 int offsetVal = offset.equals("") ? 0 : Integer.parseInt(offset); 418 String value = relation_info.getInfoOffset(metadata, offsetVal); // what if this metadata is not the one we need to get the offset for? MDTYPE! 419 // at the moment, do we assume the user will specify retrieving the offset only for such metadata as has an offset? 420 // At least, getInfoOffset will return the firstelement if the offset exceeds the bounds of the values for this metadata key 421 422 result.append(this.macro_resolver.resolve(value, lang, MacroResolver.SCOPE_META, relation_id)); 423 424 } else { // multiple = true, we have multiple meta 403 } else { 404 // we have multiple meta 425 405 Vector values = relation_info.getMultiInfo(metadata); 426 if (values != null) {406 if (values != null) { 427 407 boolean first = true; 428 408 for (int i=0; i<values.size(); i++) { … … 435 415 } 436 416 } 437 logger.info(result); 417 logger.info(result); 438 418 } 439 419 // if not ancestors, then this is all we do … … 448 428 relation_info = this.coll_db.getInfo(relation_id); 449 429 if (relation_info == null) return result.toString(); 450 if ( multiple.equals("false")) { //if (!multiple)430 if (!multiple) { 451 431 result.insert(0, separator); 452 432 result.insert(0, this.macro_resolver.resolve(relation_info.getInfo(metadata), lang, MacroResolver.SCOPE_META, relation_id));
Note:
See TracChangeset
for help on using the changeset viewer.