Changeset 2840 for TI01-discovery
- Timestamp:
- 22/08/07 16:18:47 (14 years ago)
- Location:
- TI01-discovery/trunk/ws-Discovery2/src/ndg/services/discovery
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TI01-discovery/trunk/ws-Discovery2/src/ndg/services/discovery/DiscoveryServiceSkeleton.java
r2462 r2840 254 254 list.addListMember("DIF"); 255 255 list.addListMember("MDIP"); 256 //list.addListMember("iso19115");256 list.addListMember("ISO19115"); 257 257 //list.addListMember("moles"); 258 258 } -
TI01-discovery/trunk/ws-Discovery2/src/ndg/services/discovery/PresentAgent.java
r2839 r2840 338 338 } 339 339 } 340 341 else if ( this.format.equals("ISO19115") ) 342 { 343 //1. Check to see if a dc-format document exists for this name 344 Vector queryParams = new Vector(); 345 // Implements revision #2372 of TI07-MOLES/trunk/MDIP/XQueries/NDG-MDIP.xquery 346 String xqueryStr = "import module namespace voclib='http://ndg.nerc.ac.uk/xquery/lib/vocab' at 'xmldb:exist:///db/xqueryLib/Vocabs/vocab_xquery_lib.xquery'; import module namespace utillib='http://ndg.nerc.ac.uk/xquery/lib/utilities' at 'xmldb:exist:///db/xqueryLib/Utilities/utility_xquery_lib.xquery'; declare default element namespace 'http://www.isotc211.org/2005/gmd'; declare namespace moles='http://ndg.nerc.ac.uk/moles'; declare namespace gco='http://www.isotc211.org/2005/gco'; declare namespace gmd='http://www.isotc211.org/2005/gmd'; declare namespace gml='http://www.opengis.net/gml'; declare namespace xlink='http://www.w3.org/1999/xlink'; declare namespace xsi='http://www.w3.org/2001/XMLSchema-instance'; declare namespace dummy='http://ndg.nerc.ac.uk/dummy'; declare variable $targetCollection as xs:string {'/db/discovery/moles'}; declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; declare variable $localIdentifier as xs:string {'LocalID'}; declare function local:docExists($coll as xs:string, $doc as xs:string) as item()* { let $testset := collection($coll)//root() let $matches := for $i in $testset where util:document-name($i) = $doc return document-uri($i) return $matches }; declare variable $ISO_639-2_ns as xs:string{$voclib:ISO_639-2_ns}; declare variable $ISO_3166_ns as xs:string{$voclib:ISO_3166_ns}; let $i := local:docExists('/db/discovery/original/"+this.format+"', '"+thisdoc+"') return if ( fn:empty($i) ) then ( for $DE in collection($targetCollection)/moles:dgMetadata/moles:dgMetadataRecord[ exists('moles:dgDataEntity') and moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' ] where util:document-name($DE)='"+thisdoc+"' return element dummy:container { element MD_Metadata { attribute xsi:schemaLocation {'http://www.isotc211.org/2005/gmd http://www.isotc211.org/2005/gmd/metadataEntity.xsd'}, element fileIdentifier {element gco:CharacterString {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, $utillib:moles_id_separator, 'ISO19115', $utillib:moles_id_separator, $DE/moles:dgMetadataID/moles:localIdentifier)}}, element language { element gmd:LanguageCode { attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#LanguageCode'}, attribute codeListValue {'eng'}, 'English'} } (: </language> :), element hierarchyLevel { element MD_ScopeCode { attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode_dataset'}, 'dataset'} } (: </hierarchyLevel> :), for $parent in $DE/moles:dgRelatedDataEntity[moles:RelationID/moles:dgValidTerm='is-part-of'] return element parentIdentifier {element gco:CharacterString {concat($DE/moles:dgMetadataID/moles:repositoryIdentifier, ':', $DE/moles:dgMetadataID/moles:localIdentifier, ':', $DE/moles:dgMetadataID/moles:localIdentifier)}}, for $DataCuratorRole in $DE/moles:dgDataEntity/moles:dgDataRoles/moles:dgDataCurator/moles:dgRoleHolder[not(exists(moles:endDate)) or moles:endDate=''] return for $DataCuratorRoleHolder in collection($targetCollection)/moles:dgMetadata/(moles:dgPerson | moles:dgOrganisation)[ moles:dgMetadataID/moles:schemeIdentifier='NDG-B0' and moles:dgMetadataID/moles:repositoryIdentifier=$DataCuratorRole/(moles:dgPersonID | moles:dgOrganisationID)/moles:repositoryIdentifier and moles:dgMetadataID/moles:localIdentifier=$DataCuratorRole/(moles:dgPersonID | moles:dgOrganisationID)/moles:localIdentifier] return element contact { element CI_ResponsibleParty { if (string(local-name($DataCuratorRoleHolder))='dgOrganisation') then element organisationName {element gco:CharacterString {string($DataCuratorRoleHolder/moles:name)}} else if (string(local-name($DataCuratorRoleHolder))='dgPerson') then element individualName {element gco:CharacterString {string(concat(string($DataCuratorRoleHolder/moles:name/moles:initials), ' ', string($DataCuratorRoleHolder/moles:name/moles:familyName)))}} else ('empty content') , element positionName { if (exists($DataCuratorRoleHolder/moles:localName)) then element gco:CharacterString {$DataCuratorRoleHolder/moles:localName} else if (exists($DataCuratorRole/moles:roleName)) then element gco:CharacterString {$DataCuratorRole/moles:roleName} else element gco:CharacterString {'Curator'} } (: </positionName>:), element contactInfo { element gmd:CI_Contact { if (exists($DataCuratorRole/moles:contactDetails/moles:telephone or $DataCuratorRole/moles:contactDetails/moles:fax or $DataCuratorRoleHolder/moles:contactDetails/moles:telephone or $DataCuratorRoleHolder/moles:contactDetails/moles:fax)) then element phone { element gmd:CI_Telephone { if (exists($DataCuratorRole/moles:contactDetails/moles:telephone)) then element voice { element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:telephone)} } (:</voice>:) else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then element voice { element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)} } (:</voice>:) else (), if (exists($DataCuratorRole/moles:contactDetails/moles:fax)) then element facsimile { element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:fax)} } (: </facsimile> :) else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:telephone)) then element facsimile { element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:fax)} } (: </facsimile> :) else () } (: </gmd:CI_Telephone> :) } (: </phone> :) else (), element address { element gmd:CI_Address { if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:addressline)) then for $addressline in $DataCuratorRole/moles:contactDetails/moles:address/moles:addressline return element deliveryPoint {element gco:CharacterString {data($addressline)}} else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline)) then for $addressline in $DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:addressline return element deliveryPoint {element gco:CharacterString {data($addressline)}} else (), if (exists($DataCuratorRole/moles:contactDetails/moles:address/moles:city)) then element city {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:address/moles:city)}} else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)) then element city {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:city)}} else (), if (exists($DataCuratorRole/moles:contactDetails/moles:eMail)) then element electronicMailAddress {element gco:CharacterString {data($DataCuratorRole/moles:contactDetails/moles:eMail)}} else if (exists($DataCuratorRoleHolder/moles:contactDetails/moles:address/moles:postcode)) then element electronicMailAddress {element gco:CharacterString {data($DataCuratorRoleHolder/moles:contactDetails/moles:eMail)}} else () } (: </gmd:CI_Address> :) } (: </address> :) } (: </gmd:CI_Contact> :) } (: </contactInfo> :), element role { element CI_RoleCode { attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode_custodian'}, if (exists($DataCuratorRole/moles:localName)) then data($DataCuratorRole/moles:localName) else if (exists($DataCuratorRoleHolder/moles:localName)) then data($DataCuratorRoleHolder/moles:localName) else 'Curator' } (: </CI_RoleCode> :) } (: </role> :) } (: </CI_ResponsibleParty> :) } (: </contact> :), element dateStamp {element gco:Date {adjust-date-to-timezone(current-date())}}, element metadataStandardName {element gco:CharacterString {'ISO 19115:2003'}}, element metadataStandardVersion {element gco:CharacterString {'2003'}}, element identificationInfo { element gmd:MD_DataIdentification { element citation { element gmd:CI_Citation { element title {element gco:CharacterString {data($DE/moles:name)}}, if (exists($DE/moles:abbreviation) and not(empty($DE/moles:abbreviation))) then element alternateTitle {element gco:CharacterString {data($DE/moles:abbreviation)}} else (), element date { if (exists($DE/(moles:DataProvenance | moles:dgMetadataProvenance)/moles:RecordCreation/moles:CreatedDate)) then element gmd:CI_Date { element date {element gco:Date {adjust-date-to-timezone(data($DE/(moles:DataProvenance | moles:dgMetadataProvenance)/moles:RecordCreation/moles:CreatedDate))}}, element dateType { element CI_DateTypeCode { attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode'}, attribute codeListValue {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode_creation' }, 'Creation'} } (: </dataType> :) } (: </gmd:CI_Date> :) else attribute gco:nilReason {'unknown'} } (: </date> :) } (: </gmd:CI_Citation> :) } (: </citation> :), element abstract {element gco:CharacterString {data($DE/moles:dgMetadataDescription/moles:abstract/moles:abstractText)}}, element language { element gmd:LanguageCode { attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#LanguageCode'}, attribute codeListValue {'eng'}, 'English' } } (: </language> :), for $ISOTopicCategory in ($DE/moles:dgStructuredKeyword[dgValidTermID/moles:ParentListID='http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode']) return element topicCategory { element gmd:MD_TopicCategoryCode { attribute codeList {'http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopicCategoryCode'}, attribute codeListValue {string($ISOTopicCategory/moles:dgValidTerm)}, string($ISOTopicCategory/moles:dgValidTerm)} } (: </topicCategory> :), if (exists($DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage)) then element extent { element gmd:EX_Extent { (: add bounding boxes:) for $geoBBox in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:BoundingBox return element geographicElement { element EX_GeographicBoundingBox { element westBoundLongitude {element gco:Decimal {data($geoBBox/moles:LimitWest)}}, element eastBoundLongitude {element gco:Decimal {data($geoBBox/moles:LimitEast)}}, element southBoundLatitude {element gco:Decimal {data($geoBBox/moles:LimitSouth)}}, element northBoundLatitude {element gco:Decimal {data($geoBBox/moles:LimitNorth)}} } (: </EX_GeographicBoundingBox> :) } (: </geographicElement> :), (: add location terms:) for $geoArea in $DE/moles:dgDataEntity/moles:dgDataSummary/moles:dgDataCoverage//moles:dgArea return element geographicElement { element EX_GeographicDescription { element geographicIdentifier { element gmd:RS_Identifier { element gco:CharacterString {element code {data($geoArea/moles:dgValidTerm)}}, element gco:CharacterString {element codeSpace {data($geoArea/moles:dgValidTermID/moles:ParentListID)}} } } } (: </EX_GeographicDescription> :) } (: </geographicElement> :) } (: </gmd:EX_Extent> :) } (: </extent> :) else() } (:</gmd:MD_DataIdentification> :) } (: </identificationInfo> :) } (: </MD_Metadata> :) } ) else ( element dummy:container { doc(fn:item-at($i, 1)) } ) "; 347 System.out.println( "xquery was:\n" + xqueryStr ); 348 queryParams.addElement( xqueryStr.getBytes("UTF-8") ); 349 queryParams.addElement( 1 ); 350 queryParams.addElement( 1 ); 351 352 Hashtable docSearchOptions = new Hashtable(); 353 docSearchOptions.put("indent", "yes"); 354 docSearchOptions.put("encoding", "UTF-8"); 355 docSearchOptions.put("process-xsl-pi", "no"); 356 queryParams.addElement( docSearchOptions ); 357 try 358 { 359 360 byte[] resultByteArray = (byte[])xmlrpc.execute( "query", queryParams ); 361 362 ByteArrayInputStream resultStream = new ByteArrayInputStream( resultByteArray ); 363 System.out.println( new String(resultByteArray) ); 364 // Use XMLOutputter 365 XMLOutputter out = new XMLOutputter (); 366 out.setFormat( Format.getCompactFormat() ); // UTF-8 & trimming of whitespace 367 368 SAXBuilder builder = new SAXBuilder(); 369 org.jdom.Document doc = builder.build( resultStream ); 370 org.jdom.Element root = doc.getRootElement(); 371 org.jdom.Element container = root.getChild("container", Namespace.getNamespace("dummy","http://ndg.nerc.ac.uk/dummy")); 372 org.jdom.Element elem = container.getChild(properties.getProperty("rootElement.ISO19115"), Namespace.getNamespace(properties.getProperty("namespace.ISO19115"))); 373 // If this doesn't work, try & fetch it as if it belongs to no namespace 374 if ( elem == null ) 375 { 376 elem = container.getChild(properties.getProperty("rootElement.ISO19115"),Namespace.getNamespace("")); 377 } 378 379 380 returnDoc = out.outputString( elem ); 381 if (returnDoc != null) 382 { 383 returnDocs.add( returnDoc ); 384 } 385 } 386 catch ( java.lang.NullPointerException e) 387 { 388 // Catch failure for this individual document 389 returnDocs.add( "" ); 390 failedDocs.add(thisdoc); 391 } 392 } 393 340 394 else 341 395 { -
TI01-discovery/trunk/ws-Discovery2/src/ndg/services/discovery/ServiceProperties.java
r2257 r2840 23 23 properties.setProperty("namespace.MDIP", "http://www.oceannet.org/mdip/xml"); 24 24 properties.setProperty("namespace.moles", "http://ndg.nerc.ac.uk/moles"); 25 properties.setProperty("namespace.ISO19115", "http://www.isotc211.org/2005/gmd"); 25 26 26 27 properties.setProperty("rootElement.DIF", "DIF"); … … 28 29 properties.setProperty("rootElement.MDIP", "Metadata"); 29 30 properties.setProperty("rootElement.moles", "dgMetadata"); 31 properties.setProperty("rootElement.moles", "MD_Metadata"); 30 32 31 33 properties.setProperty("namespacePrefix.DIF", ""); … … 33 35 properties.setProperty("namespacePrefix.MDIP", ""); 34 36 properties.setProperty("namespacePrefix.moles", "moles"); 37 properties.setProperty("namespacePrefix.ISO19115", ""); 35 38 36 39 }
Note: See TracChangeset
for help on using the changeset viewer.