Changeset 4967


Ignore:
Timestamp:
12/02/09 17:38:40 (11 years ago)
Author:
cbyrom
Message:

Fix search client and associated xqueries to return all search results
in a single data set.

Location:
ndgCommon/trunk/ndg/common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/xmldb/eXist/searchclient.py

    r4923 r4967  
    55''' 
    66from ndg.common.src.clients.xmldb.abstractsearchxmldbclient import AbstractSearchXMLDBClient 
    7 from ndg.common.src.lib.utilities import loadConfigDetails 
     7from ndg.common.src.lib.utilities import loadConfigDetails, edict 
    88from xml.etree import cElementTree as ET 
    99import dbconstants as dc 
     
    102102 
    103103        results = self.client.runQuery(xquery, offset=start - 1, noResults = howmany,  
    104                                        useChunked = useChunked) 
     104                                       useChunked = False) 
    105105        logging.info("Search complete - processing results") 
    106106 
     
    117117            return self.results 
    118118         
    119         self.hits = len(results) 
    120119        self.error = None 
    121120        self.start = start 
    122121        self.howmany = howmany 
    123122         
    124         for result in results: 
    125             s = ET.fromstring(result) 
    126             t = {'id': s.find('id').text, 
    127                  'name': s.find('name').text, 
    128                  'type': s.find('type').text} 
     123        docET = ET.fromstring(results[0]) 
     124        summaries = docET.getchildren() 
     125        self.hits = len(summaries) 
     126        for summary in summaries: 
     127            t = edict(id=summary.findtext('id'), 
     128                      name=summary.findtext('name'), 
     129                      type=summary.findtext('type')) 
    129130 
    130131            # add extra stuff for atom search (NB, this could be added to all 
     
    132133            if target == self.ATOM_TARGET: 
    133134                for key in ['providerID', 'created', 'href', 'subtype']: 
    134                     t[key] = s.find(key).text 
     135                    t[key] = summary.findtext(key) 
    135136 
    136137                    # adjust href to point to atom editor instead of atom view 
     
    154155        xquery = "declare namespace moles='http://ndg.nerc.ac.uk/schema/moles2beta';\n" + \ 
    155156            "declare namespace atom='http://www.w3.org/2005/Atom';\n" + \ 
     157            "<results>\n{\n" + \ 
    156158            "for $DE in collection('/db/atoms')/atom:entry[" 
    157159 
     
    184186<providerID>{$DE/moles:entity/moles:molesISO/moles:providerID/text()}</providerID> \ 
    185187<created>{$DE/moles:entity/moles:molesISO/moles:created/text()}</created> \ 
    186 </summary>" 
     188</summary>\ 
     189}\ 
     190</results>" 
    187191 
    188192        logging.debug("Created xquery: '%s'" %xquery) 
  • ndgCommon/trunk/ndg/common/xmldb/xquery/molesSummary.xq

    r4793 r4967  
    22    browse. SEARCHSTRING should be overwritten with target query :) 
    33declare namespace m='http://ndg.nerc.ac.uk/moles'; 
     4<results> 
     5{ 
    46for $dd in collection('/db/ndg_B_metadata')//root()[. &= 'SEARCHSTRING'] 
    57return <summary> 
     
    810<type>{if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgDataEntity)) then 'DataEntity' else (if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgObservationStation)) then 'ObservationStation' else (if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgDataProductionTool)) then 'DataProductionTool' else (if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgActivity)) then 'Activity' else ('unknown'))))}</type> 
    911</summary> 
     12} 
     13</results> 
  • ndgCommon/trunk/ndg/common/xmldb/xquery/numsimSummary.xq

    r4793 r4967  
    22declare namespace m='http://ndg.nerc.ac.uk/moles'; 
    33declare namespace n='http://ndg.nerc.ac.uk/numsim'; 
     4<results> 
     5{ 
    46for $dd in collection('/db/NumSim')//root()[. &= 'SEARCHSTRING'] 
    57return <summary> 
     
    810<type>numsim:{local-name($dd/n:simulationMetadata/*[1])}</type> 
    911</summary> 
     12} 
     13</results> 
Note: See TracChangeset for help on using the changeset viewer.