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

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/ndgCommon/trunk/ndg/common/src/clients/xmldb/interfacexmldbatomclient.py@4918
Revision 4918, 3.6 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 Interface for clients to implement for providing functionality to support Atom
3 document usage
4 
5 @author: C Byrom - Tessella, Feb 09
6'''
7import os, sys, logging
8from ndg.common.src.clients.interfacesearchclient import InterfaceSearchClient
9
10class InterfaceXMLDBAtomClient(InterfaceSearchClient):
11       
12    # location of the base moles atom schema in the XML DB
13    # - this should be defined if schema compliance needs to be checked
14    atomSchema = None
15
16    def checkAtomSchemaCompliance(self, atomPath, atom = None, isDebug = False):
17        '''
18        Validate the specified atom in the XML DB with the atom schemas contained in
19        this DB
20        @param atomPath: path to the atom in the XML DB
21        @keyword atom: if set to an atom, this will be created temporarily in the
22        XML DB - since it may not already exist there.  Once validation is completed, the
23        file will be removed from the DB.
24        @keyword isDebug: if True, return full error details, otherwise only return
25        a summary
26        @raise SystemError: if errors encountered whilst running the schema validation
27        @return array: containing any errors found - NB, if an empty array is returned,
28        this indicates successful validation
29        '''
30        raise NotImplementedError("This is an interface class and this method has not " + \
31                                  "been implemented yet")
32
33
34
35    def getAtomPublicationState(self, atomID, providerID):
36        '''
37        Retrieve the publication state of the specified atom - by
38        checking the collection it is in
39        @param atom: atom id to look up
40        @param providerID: provider ID for the atom data
41        @return: AtomState for the atom.  NB, if the ID is not found, assume
42        we're dealing with a new atom and set the state as the working state
43        '''
44        raise NotImplementedError("This is an interface class and this method has not " + \
45                                  "been implemented yet")
46
47
48    def changeAtomPublicationState(self, atom, newState):
49        '''
50        Adjust the publication state of an atom in the XML DB
51        @param atom: the Atom data model of the atom whose publication state
52        needs to change
53        @param newState: an AtomState object representing the new publication
54        state of the atom
55        @return atom: atom data model with updated state
56        '''
57        raise NotImplementedError("This is an interface class and this method has not " + \
58                                  "been implemented yet")
59
60           
61    def createAtom(self, atom, replaceAtom = True, runAsynch = True):
62        '''
63        Create an atom in the XML DB - using the atom contents to work out
64        the location + data set ID
65        @param atom: atom object to create in the DB
66        @keyword replaceAtom: if False and the atom is already available in the
67        XML DB, a DuplicateError will be raised, otherwise the atom is replaced
68        @param runAsynch: if True, if a backup of an existing file, do this
69        asynchronously in a separate thread
70        '''
71        raise NotImplementedError("This is an interface class and this method has not " + \
72                                  "been implemented yet")
73
74
75    def deleteAtom(self, atom):
76        '''
77        Delete the given atom from the XML DB - using the atom
78        details to work out the required path to delete
79        @param atom: an Atom instance to delete
80        @return True if atom deleted successfully, false otherwise
81        '''
82        raise NotImplementedError("This is an interface class and this method has not " + \
83                                  "been implemented yet")
Note: See TracBrowser for help on using the repository browser.