Changeset 25805 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
- Timestamp:
- 2012-06-21T17:42:41+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note:
See TracChangeset
for help on using the changeset viewer.