Changeset 24254 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
- Timestamp:
- 2011-07-14T21:39:43+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
r23792 r24254 41 41 import java.util.Iterator; 42 42 import java.util.ArrayList; 43 import java.util.regex.Matcher; 44 import java.util.regex.Pattern; 43 45 44 46 import org.apache.log4j.*; … … 196 198 197 199 } 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 198 203 for (int i=0; i<metadata_names.size(); i++) { 199 204 String meta_name = (String) metadata_names.get(i); 200 205 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 match 209 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 input 212 201 213 GSXML.addMetadata(this.doc, metadata_list, meta_name, value); 202 214 } … … 317 329 protected String getMetadata(String node_id, DBInfo info, 318 330 String metadata, String lang) { 319 boolean multiple = false;331 String multiple = "false"; // multiple can now be "true", "false" or "offset<number>". It's no longer a boolean 320 332 String relation = ""; 321 333 String separator = ", "; … … 346 358 metadata = metadata.substring(pos+1); 347 359 // check for all on the front 348 if (temp.equals("all") ) {349 multiple =true;360 if (temp.equals("all") || temp.startsWith("offset")) { // multiple can now be "true", "false" or "offset" 361 multiple = temp; // multiple=true; 350 362 pos = metadata.indexOf(GSConstants.META_RELATION_SEP); 351 363 if (pos ==-1) { … … 399 411 StringBuffer result = new StringBuffer(); 400 412 401 if ( !multiple) {413 if (multiple.equals("false")) { 402 414 result.append(this.macro_resolver.resolve(relation_info.getInfo(metadata), lang, MacroResolver.SCOPE_META, relation_id)); 403 } else { 404 // we have multiple meta 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 405 425 Vector values = relation_info.getMultiInfo(metadata); 406 426 if (values != null) { 407 427 boolean first = true; 408 428 for (int i=0; i<values.size(); i++) { … … 415 435 } 416 436 } 417 logger.info(result); 437 logger.info(result); 418 438 } 419 439 // if not ancestors, then this is all we do … … 428 448 relation_info = this.coll_db.getInfo(relation_id); 429 449 if (relation_info == null) return result.toString(); 430 if ( !multiple) {450 if (multiple.equals("false")) { //if (!multiple) 431 451 result.insert(0, separator); 432 452 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.