Changeset 1812 for TI01-discovery/trunk/ws-Discovery2
- Timestamp:
- 05/12/06 09:58:03 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TI01-discovery/trunk/ws-Discovery2/src/ndg/services/discovery/SearchAgent.java
r1801 r1812 15 15 import java.text.DecimalFormat; 16 16 import java.text.SimpleDateFormat; 17 17 import java.util.regex.Matcher; 18 18 import javax.xml.namespace.*; 19 19 import javax.xml.xpath.*; … … 50 50 String term = ""; 51 51 String orderBy; // representation used in WSDL e.g. "date", "dataCentre" 52 String orderByField = " "; // xquery / xpath expression representing orderBy field52 String orderByField = "document($name)/dgMetadata/dgMetadataRecord/dgDataEntity/dgDataSummary/dgDataCoverage/dgTemporalCoverage/DateRange/DateRangeStart"; // xquery / xpath expression representing orderBy field 53 53 String orderByDirection = "ascending"; //default orderBy direction 54 54 // TODO ...add orderByDirection (and to WSDL) … … 120 120 if ( s.equals("date") ) 121 121 { 122 this.orderByField = " {document($name)/dgMetadata/dgMetadataRecord/dgDataEntity/dgDataSummary/dgDataCoverage/dgTemporalCoverage/DateRange/DateRangeStart}";122 this.orderByField = "document($name)/dgMetadata/dgMetadataRecord/dgDataEntity/dgDataSummary/dgDataCoverage/dgTemporalCoverage/DateRange/DateRangeStart"; 123 123 } 124 124 … … 126 126 { 127 127 // TODO ...not correct yet (should look up Organisation moles record) 128 this.orderByField = " {document($name)/dgMetadata/dgMetadataRecord/dgDataEntity/dgDataRoles/dgDataCurator/dgRoleHolder/dgOrganisationID/repositoryIdentifier}";128 this.orderByField = "document($name)/dgMetadata/dgMetadataRecord/dgDataEntity/dgDataRoles/dgDataCurator/dgRoleHolder/dgOrganisationID/repositoryIdentifier"; 129 129 } 130 130 } … … 419 419 xqueryStr = xqueryStr.replaceFirst("__subst_doTerm__", this.doTerm ? "fn:true()" : "fn:false()"); 420 420 xqueryStr = xqueryStr.replaceFirst("__subst_doSpatioTemp__", (this.doSpatio | this.doTemporal) ? "fn:true()" : "fn:false()"); 421 xqueryStr = xqueryStr.replaceFirst("__subst_doOrderBy__", this.doOrderBy ? "fn:true()" : "fn:false()"); 421 xqueryStr = xqueryStr.replaceFirst("__subst_doOrderBy__", this.doOrderBy ? "fn:true()" : "fn:false()"); //NB replaceAll cos more than 1! 422 422 xqueryStr = xqueryStr.replaceFirst("__subst_doScope__", this.doScope ? "fn:true()" : "fn:false()"); 423 424 // orderByField contains $ chars etc so needs special treatment to avoid "java.lang.IllegalArgumentException: Illegal group reference" when replacing 425 String orderByFieldReplace = Matcher.quoteReplacement(this.orderByField); 426 xqueryStr = xqueryStr.replaceAll("__subst_orderByField__", orderByFieldReplace); //NB replaceAll cos more than 1! 423 427 424 428 System.out.println("Xquery was \n" + xqueryStr); … … 531 535 " \"__subst_scope__\" \n"+ 532 536 "}; \n"+ 533 "declare function local:getOrderByField() as xs:string { \n"+534 " \"__subst_orderByField__\" \n"+535 "}; \n"+536 537 "declare function local:getSpatioTempWhereClause() as xs:string { \n"+ 537 538 " \"__subst_spatioTempWhereClause__\" \n"+ … … 575 576 " for $i in $arg1 \n"+ 576 577 " let $coll := '/db/discovery/moles' \n"+ 577 " let $thisdoc := util:document-name($i) \n"+578 " let $thisdoc := $i/text() \n"+ 578 579 " let $name := string-join( ($coll , $thisdoc), '/' ) \n"+ 579 580 " let $molesdoc := document( $name ) \n"+ … … 587 588 " if ( local:getOrderByDirection() = \"descending\" ) then ( \n"+ 588 589 " for $i in $arg1 \n"+ 589 " order by local:getOrderByField() descending \n"+ 590 " let $coll := '/db/discovery/moles' \n"+ 591 " let $thisdoc := $i/text() \n"+ 592 " let $name := string-join( ($coll , $thisdoc), '/' ) \n"+ 593 " order by document($name)/dgMetadata/dgMetadataRecord/dgDataEntity/dgDataSummary/dgDataCoverage/dgTemporalCoverage/DateRange/DateRangeStart descending \n"+ 590 594 " return $i \n"+ 591 595 " ) \n"+ 592 596 " else ( \n"+ 593 597 " for $i in $arg1 \n"+ 594 " order by local:getOrderByField() ascending \n"+ 598 " let $coll := '/db/discovery/moles' \n"+ 599 " let $thisdoc := $i/text() \n"+ 600 " let $name := string-join( ($coll , $thisdoc), '/' ) \n"+ 601 " order by document($name)/dgMetadata/dgMetadataRecord/dgDataEntity/dgDataSummary/dgDataCoverage/dgTemporalCoverage/DateRange/DateRangeStart ascending \n"+ 595 602 " return $i \n"+ 596 603 " ) \n"+
Note: See TracChangeset
for help on using the changeset viewer.