source: ndgCommon/trunk/ndg/common/src/clients/interfacesearchclient.py @ 4918

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/ndgCommon/trunk/ndg/common/src/clients/interfacesearchclient.py@4918
Revision 4918, 2.0 KB checked in by cbyrom, 11 years ago (diff)

Define interfaces for the following clients - to improve implementation
and extensibility:

  • search client
  • xml db crud client
  • xml db low level ops client (e.g. to be implemented with XML-RPC/REST interface)
  • atom client for xml db
Line 
1'''
2 Basic interface for clients to implement for the searching
3 of metadata documents
4 
5 @author: C Byrom - Tessella, Jan 09
6'''
7import os, sys, logging
8
9class InterfaceSearchClient(object):
10
11    # target to use when specifying atom searches
12    ATOM_TARGET = 'Atom'
13   
14    # value used when specifying '*' in searches
15    DEFAULT_ALL_VAL = 'All' 
16   
17    def search(self, term, start=1, howmany=20, target='All',
18               scope=None, bbox=None, dateRange=None, geoSearchType='overlaps'):
19        '''
20        Get a list of documents, with basic summary info for each doc, for a
21        specific term using a free text search
22        @param term: term to search on
23        @keyword start:  first record to return
24        @keyword howmany: number of records to return
25        @keyword target: target of search
26        @keyword scope: scope of search
27        @keyword bbox: bounding box for search data - NB, this should be an array with
28        content, [N, W, E, S]
29        @keyword dateRange: range of dates to use in search - an array with content,
30        [startDate, endDate]
31        @keyword geoSearchType: type of geospatial search to use - NB, currently only
32        'overlaps' accepted
33        @return: array of search results; if no results are found this array should be empty
34        '''
35        raise NotImplementedError("This is an interface class and this method has not " + \
36                                  "been implemented yet")
37
38
39    def getDocs(self, documents, format='original'):
40        '''
41        Return one or more complete document
42        @param documents: array of documents to retrieve
43        @keyword format: format the retrieved document should be in.  Default, 'original'
44        returns documents in their original format 
45        @raise ValueError if the requested document(s) cannot be found
46        @return: dictionary with format, {docName: docContents}
47        '''
48        raise NotImplementedError("This is an interface class and this method has not " + \
49                                  "been implemented yet")
50
Note: See TracBrowser for help on using the repository browser.