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

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

Add getNDGDoc method to the interfacesearchclient - since this is a
universally used method.

RevLine 
[4793]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):
[4918]10
11    # target to use when specifying atom searches
12    ATOM_TARGET = 'Atom'
[4793]13   
[4918]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'):
[4793]19        '''
[4918]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
[4793]34        '''
[4918]35        raise NotImplementedError("This is an interface class and this method has not " + \
36                                  "been implemented yet")
[4793]37
38
[4918]39    def getDocs(self, documents, format='original'):
[4793]40        '''
[4918]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}
[4793]47        '''
[4918]48        raise NotImplementedError("This is an interface class and this method has not " + \
49                                  "been implemented yet")
[4793]50
[4985]51
52    def getNDGDoc(self, providerID, docType, localID, targetCollection = "/"):
53        '''
54        Retrieve the document represented by an ndgURI
55        @param providerID: ID of the provider of the metadata
56        @param docType: document type - see ndgObject for valid types
57        @param localID: local ID of the ndg document to retrieve
58        @keyword targetCollection: collection in XML db to look for doc in.  Default = '/'
59        - i.e. the base collection
60        @return document matching the ndgURI
61        '''
62        raise NotImplementedError("This is an interface class and this method has not " + \
63                                  "been implemented yet")
Note: See TracBrowser for help on using the repository browser.