source: mauRepo/MolesManager/trunk/src/MolesManager/moles3epb.py @ 8143

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/MolesManager/moles3epb.py@8143
Revision 8143, 1.5 KB checked in by mnagni, 8 years ago (diff)

Implementation of tickets #22386, #22387

Line 
1'''
2Created on 10 Jan 2012
3
4@author: mnagni
5'''
6from MolesManager.settings import MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT
7from libs.commons_db import DbManager
8from libs.epb import EPB
9
10molesDB = DbManager(MOLES3_DB_CONNECTION, MOLES3_DB_SCRIPT)
11
12class Moles3EPB(EPB):
13
14    @classmethod       
15    def search(self, clazz, inst_id, session = None):
16        intSession = Moles3EPB._getSession(session)
17        return EPB.search(clazz, inst_id, intSession)
18
19    @classmethod       
20    def searchEager(self, clazz, inst_id, session = None):
21        intSession = Moles3EPB._getSession(session)
22        return EPB.searchEager(clazz, inst_id, intSession)
23
24    @classmethod       
25    def addCedaObject(self, ceda_observation, session = None, commit = False):
26        """
27            Adds and eventually commit a CEDA Object in MOLES3 db
28            @param ceda_observation: the CEDA object to persist
29            @param session: the external session to use. If None a new session will be open to add and commit the object and then closed at the exit. The object is committed
30            @param commit: defines if the object has to be committed immediately or not.
31        """
32        intSession = Moles3EPB._getSession(session)
33        intSession.add(ceda_observation)
34        if commit:
35            intSession.commit()
36        Moles3EPB._closeSession(session) 
37
38    @classmethod       
39    def getNewMolesSession(self):
40            return Moles3EPB._getSession()
41
42    @classmethod
43    def _getSession(self, session = None):
44        return EPB._getSession(molesDB, session)
Note: See TracBrowser for help on using the repository browser.