Changeset 5304


Ignore:
Timestamp:
18/05/09 17:22:02 (10 years ago)
Author:
cbyrom
Message:

Extend the discovery ws client to allow access to the getListNames and
getList methods + add tests to these + extend search method to include
the orderBy and orderDirection parameters. NB, there is a bug in the
getListNames code which means that the getListNameRequest object
cannot be created, so the method cannot be invoked - presumably this
is an error due to the wsdl2python generation.

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

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/ws/discovery/discoveryserviceclient.py

    r5006 r5304  
    5656        self.status=None 
    5757     
    58     def search(self,term,start=1,howmany=20,target='All', 
    59                scope=None,bbox=None,dateRange=None,geoSearchType='overlaps'): 
     58    def search(self, term, start=1, howmany=20, target='All', 
     59               scope=None, bbox=None, dateRange=None, 
     60               geoSearchType='overlaps', orderBy = None, orderDirection = None): 
    6061        '''  
    6162        Get a list of documents, with basic summary info for each doc, for a  
     
    8182        request.Start=start 
    8283        request.HowMany=howmany 
     84        if orderBy: 
     85            request.set_element_orderBy(orderBy) 
     86 
     87        if orderDirection: 
     88            request.set_element_orderByDirection(orderDirection) 
     89 
    8390        request.TermType={'Authors':'author','Params':'parameter','All':'fullText'}[target] 
    8491        if bbox is not None: 
     
    139146        logging.debug("Request object set up") 
    140147        return request 
     148 
     149 
     150    def getListNames(self): 
     151        ''' 
     152        Get the various list names used by the web service 
     153        @return list with all the different listnames in 
     154        ''' 
     155        logging.debug("Getting list names from discovery webservice") 
     156        # TODO: this current doesn't work - must be an error in the wsdl2python 
     157        # code generation.... 
     158        request = getListNamesRequest() 
     159 
     160        names = self.server.getListNames(request) 
     161         
     162        logging.debug("- returning list names") 
     163        return result 
     164 
     165 
     166    def getList(self, listName): 
     167        ''' 
     168        Get the values for the specified list 
     169        @param listName: name of list to retrieve values for 
     170        @return list with the data for the specified list 
     171        ''' 
     172        logging.debug("Getting data for list '%s'" %listName) 
     173        request = getListRequest() 
     174        request.set_element_listName(listName) 
     175 
     176        results = self.server.getList(request) 
     177        listData = results.get_element_list().get_element_listMember() 
     178         
     179        logging.debug("- returning list names") 
     180        return listData 
    141181 
    142182 
  • ndgCommon/trunk/ndg/common/src/clients/xmldb/eXist/searchclient.py

    r5170 r5304  
    8282               dateRange=None,geoSearchType=None, \ 
    8383               providerID=None, atomTypeID=None, 
    84                useChunked = True): 
     84               useChunked = True, orderBy = None, 
     85               orderDirection = None): 
    8586        '''  
    8687        Provides a search interface that mimics the WSDL search interface, except  
    87         that the target used is the exist collection name, and scope, bbox and  
     88        that the target used is the exist collection name, and scope, bbox, orderBy, 
     89        orderDirection and  
    8890        dateRange are ignored, and a python summary object is returned  
    8991        ''' 
  • ndgCommon/trunk/ndg/common/unittests/clients/ws/discovery/testdiscoveryserviceclient.py

    r5006 r5304  
    33from ndg.common.src.models.ndgObject import ndgObject as no 
    44from ndg.common.src.clients.ws.discovery.discoveryserviceclient import DiscoveryServiceClient 
     5from ZSI import FaultException 
    56 
    67class TestCase(unittest.TestCase): 
     
    1415        ''' 
    1516        self.client = DiscoveryServiceClient() 
     17 
     18    def OFFtestGetListNames(self): 
     19        # this method doesn't work owing to a problem with the generated code... 
     20        names = self.client.getListNames() 
     21 
     22    def testValidGetList(self): 
     23        names = self.client.getList('orderByFieldList') 
     24        self.assertTrue(len(names) > 0) 
     25 
     26    def testInvalidGetList(self): 
     27        self.assertRaises(FaultException, self.client.getList, 'orderByFieldListxx') 
    1628     
    1729    def testSearch(self): 
Note: See TracChangeset for help on using the changeset viewer.