Changeset 25805
- Timestamp:
- 2012-06-21T17:42:41+12:00 (12 years ago)
- Location:
- main/trunk/greenstone3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/Action.java
r25635 r25805 106 106 Element elem = (Element) metadata_nodes.item(i); 107 107 StringBuffer metadata = new StringBuffer(); 108 String all = elem.getAttribute("multiple");108 String pos = elem.getAttribute("pos"); 109 109 String name = elem.getAttribute("name"); 110 110 String select = elem.getAttribute("select"); 111 111 String sep = elem.getAttribute("separator"); 112 if ( all.equals("true"))113 { 114 metadata.append("all");112 if (!pos.equals("")) 113 { 114 metadata.append("pos"+pos); // first, last or indexing number 115 115 metadata.append(GSConstants.META_RELATION_SEP); 116 116 } -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
r25635 r25805 369 369 protected String getMetadata(String node_id, DBInfo info, String metadata, String lang) 370 370 { 371 boolean multiple = false;371 String pos = ""; 372 372 String relation = ""; 373 373 String separator = ", "; 374 int pos= metadata.indexOf(GSConstants.META_RELATION_SEP);375 if ( pos== -1)374 int index = metadata.indexOf(GSConstants.META_RELATION_SEP); 375 if (index == -1) 376 376 { 377 377 Vector<String> values = info.getMultiInfo(metadata); … … 402 402 } 403 403 404 String temp = metadata.substring(0, pos); 405 metadata = metadata.substring(pos + 1); 406 // check for all on the front 407 if (temp.equals("all")) 408 { 409 multiple = true; 410 pos = metadata.indexOf(GSConstants.META_RELATION_SEP); 411 if (pos == -1) 404 String temp = metadata.substring(0, index); 405 metadata = metadata.substring(index + 1); 406 // check for pos on the front, indicating which piece of meta the user wants 407 // pos can be "first", "last" or the position value of the requested piece of metadata 408 if (temp.startsWith(GSConstants.META_POS)) 409 { 410 temp = temp.substring(GSConstants.META_POS.length()); 411 pos = temp; 412 413 index = metadata.indexOf(GSConstants.META_RELATION_SEP); 414 if (index == -1) 412 415 { 413 416 temp = ""; … … 415 418 else 416 419 { 417 temp = metadata.substring(0, pos);418 metadata = metadata.substring( pos+ 1);420 temp = metadata.substring(0, index); 421 metadata = metadata.substring(index + 1); 419 422 } 420 423 } 421 424 422 425 // now check for relational info 423 if (temp.equals("parent") || temp.equals("root") || temp.equals("ancestors")) 426 if (temp.equals("parent") || temp.equals("root") || temp.equals("ancestors") 427 || temp.equals("siblings") || temp.equals("children") || temp.equals("descendants")) 424 428 { // "current" "siblings" "children" "descendants" 429 // gets all siblings by default 425 430 relation = temp; 426 pos= metadata.indexOf(GSConstants.META_RELATION_SEP);427 if ( pos== -1)431 index = metadata.indexOf(GSConstants.META_RELATION_SEP); 432 if (index == -1) 428 433 { 429 434 temp = ""; … … 431 436 else 432 437 { 433 temp = metadata.substring(0, pos);434 metadata = metadata.substring( pos+ 1);438 temp = metadata.substring(0, index); 439 metadata = metadata.substring(index + 1); 435 440 } 436 441 } … … 474 479 475 480 StringBuffer result = new StringBuffer(); 476 477 if (!multiple) 478 { 479 result.append(this.macro_resolver.resolve(relation_info.getInfo(metadata), lang, MacroResolver.SCOPE_META, relation_id)); 481 482 Vector<String> values = relation_info.getMultiInfo(metadata); 483 484 if (!pos.equals("")) // if a particular position was specified, so not multiple values for the metadata 485 { 486 String meta = ""; 487 if (values != null) { 488 if(pos.equals(GSConstants.META_FIRST)) { 489 meta = values.firstElement(); 490 } else if(pos.equals(GSConstants.META_LAST)) { 491 meta = values.lastElement(); 492 } else { 493 int position = Integer.parseInt(pos); 494 if(position < values.size()) { 495 meta = values.elementAt(position); 496 } 497 } 498 } // else "" 499 500 result.append(this.macro_resolver.resolve(meta, lang, MacroResolver.SCOPE_META, relation_id)); 480 501 } 481 502 else 482 503 { 483 // we have multiple meta484 Vector<String> values = relation_info.getMultiInfo(metadata);485 504 if (values != null) 486 505 { … … 515 534 if (relation_info == null) 516 535 return result.toString(); 517 if (!multiple) 518 { 536 537 values = relation_info.getMultiInfo(metadata); 538 if (!pos.equals("")) // if a particular position was specified, so not multiple values for the metadata 539 { 540 String meta = ""; 541 if (values != null) { 542 if(pos.equals(GSConstants.META_FIRST)) { 543 meta = values.firstElement(); 544 } else if(pos.equals(GSConstants.META_LAST)) { 545 meta = values.lastElement(); 546 } else { 547 int position = Integer.parseInt(pos); 548 if(position < values.size()) { 549 meta = values.elementAt(position); 550 } 551 } 552 } // else "" 553 519 554 result.insert(0, separator); 520 result.insert(0, this.macro_resolver.resolve( relation_info.getInfo(metadata), lang, MacroResolver.SCOPE_META, relation_id));555 result.insert(0, this.macro_resolver.resolve(meta, lang, MacroResolver.SCOPE_META, relation_id)); 521 556 } 522 557 else 523 558 { 524 Vector<String> values = relation_info.getMultiInfo(metadata);525 559 if (values != null) 526 560 { -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSConstants.java
r24719 r25805 32 32 public static final String META_RELATION_SEP = "_"; 33 33 public static final String META_SEPARATOR_SEP = "*"; 34 public static final String META_FIRST = "first"; 35 public static final String META_LAST = "last"; 36 public static final String META_POS = "pos"; 34 37 } -
main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl
r25752 r25805 183 183 184 184 <xsl:template match="gsf:metadata" mode="get-metadata-name"> 185 <xsl:if test="@multiple='true'"> 186 <xsl:text>all_</xsl:text> 185 <xsl:if test="@pos"> 186 <xsl:text>pos</xsl:text> 187 <xsl:value-of select='@pos'/> 188 <xsl:text>_</xsl:text> 187 189 </xsl:if> 188 190 <xsl:if test='@select'> … … 191 193 </xsl:if> 192 194 <xsl:if test="@separator"> 193 <xsl:text>*</xsl:text>195 <xsl:text>*</xsl:text> 194 196 <xsl:value-of select='@separator'/> 195 197 <xsl:text>*_</xsl:text> … … 197 199 <xsl:value-of select="@name"/> 198 200 </xsl:template> 199 200 <xsl:template match="gsf:metadata-old"> 201 202 <xsl:template match="gsf:metadata-old" mode="get-metadata-name"> 203 <xsl:if test="@multiple='true'"> 204 <xsl:text>all_</xsl:text> 205 </xsl:if> 206 <xsl:if test='@select'> 207 <xsl:value-of select='@select'/> 208 <xsl:text>_</xsl:text> 209 </xsl:if> 210 <xsl:if test="@separator"> 211 <xsl:text>*</xsl:text> 212 <xsl:value-of select='@separator'/> 213 <xsl:text>*_</xsl:text> 214 </xsl:if> 215 <xsl:value-of select="@name"/> 216 </xsl:template> 217 218 <xsl:template match="gsf:metadata-older"> 201 219 <xslt:value-of disable-output-escaping="yes"> 202 220 <xsl:attribute name="select">
Note:
See TracChangeset
for help on using the changeset viewer.