source: mauRepo/MolesManager/trunk/src/libs/migration/InfodbEPB.py @ 8334

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/libs/migration/InfodbEPB.py@8334
Revision 8334, 1.7 KB checked in by mnagni, 7 years ago (diff)

the infodb session was not injected in the migration process

Line 
1'''
2Created on 10 Jan 2012
3
4@author: mnagni
5'''
6from libs.epb import EPB
7from sqlalchemy.sql.expression import text
8
9class InfodbEPBFactory(EPB):
10   
11    def __init__(self, dbManager):
12        self._dbManager = dbManager
13
14    def _getSession(self):
15        if self._dbManager is not None:
16            return self._dbManager.createDbSession()               
17        return None
18       
19    def createEPB(self):
20        return InfodbEPB(self._getSession())
21
22class InfodbEPB(EPB):
23   
24    def __init__(self, session):
25        self._session = session           
26
27    def close(self):
28        return self._session.close()
29
30    def getCedaInfoApp_dataentityByDE_ID(self, de_id):
31        """
32            Returns a dictionary representing the cedainfoapp_dataentity table in the cedainfo DB.
33            The dictionary has the following keys:
34               logical_path, category, name
35            @param de_id: the cedainfoapp_dataentity.dataentity_id to look for             
36        """
37        query_string = text("SELECT cedainfoapp_dataentity.logical_path AS logical_path, \
38            cedainfoapp_curationcategory.category AS category,\
39            cedainfoapp_person.name AS name \
40            FROM cedainfoapp_dataentity \
41                LEFT JOIN cedainfoapp_curationcategory \
42                    ON cedainfoapp_dataentity.curation_category_id=cedainfoapp_curationcategory.id \
43                LEFT JOIN cedainfoapp_person \
44                    ON cedainfoapp_dataentity.responsible_officer_id=cedainfoapp_person.id \
45            WHERE cedainfoapp_dataentity.dataentity_id=:i_id")
46        records = self._session.execute(query_string, params={'i_id':de_id})
47        ret = records.fetchone()
48        records.close()
49        return ret
Note: See TracBrowser for help on using the repository browser.