source: mauRepo/MolesManager/trunk/src/MolesManager/dataaccess.py @ 8015

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/MolesManager/dataaccess.py@8015
Revision 8015, 1018 bytes checked in by mnagni, 9 years ago (diff)

implemented a prototype for the cedaObservation.
Further implementation for the Moles2 migration

Line 
1'''
2Created on 3 Nov 2011
3
4@author: mnagni
5'''
6from MolesManager.settings import MOLES3DB
7from ea_model.iso_19103_2005_schema_language.basic_types.primitive.date_and_time.date import Date
8from ea_model.ceda_moles.ceda_observation.ceda_observation import CEDA_Observation
9
10
11def _buildFilter(key, keyValue):
12    return '%s = \'%s\'' % (key, keyValue)
13
14def _checkSession(session):
15    if session is None:
16        return MOLES3DB.getSession()
17    else:
18        return session
19
20def doInsert(toStoreInstance, session = None): 
21    session = _checkSession(session)
22    session.add(toStoreInstance)
23    session.commit()
24
25def getCEDA_ObservationById(id, session = None):     
26    session = _checkSession(session)
27    res = session.query(CEDA_Observation).filter(*[_buildFilter('ceda_observation_id', id)])
28    print(res)
29    return res.all()
30
31def getDateById(id, session = None):     
32    session = _checkSession(session)
33    res = session.query(Date).filter(*[_buildFilter('date_id', id)])
34    print(res)
35    return res.all()
Note: See TracBrowser for help on using the repository browser.