Ignore:
Timestamp:
31/08/12 16:32:18 (7 years ago)
Author:
mnagni
Message:

Incomplete - # 22551: List resources / display single file
 http://team.ceda.ac.uk/trac/ceda/ticket/22551

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/HPFos/trunk/hpfos/HPFos/moles3epb.py

    r8548 r8549  
    3232''' 
    3333from hpfos.libs.epb import EPB 
    34 from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection import CEDA_ObservationCollection 
    35 from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation import CEDA_Observation 
    36 from ea_model.moles3_4.observationcollection.mo_observationcollection import MO_ObservationCollection 
     34from ea_model.ceda_metadatamodel.ceda_observationcollection.ceda_observationcollection \ 
     35    import CEDA_ObservationCollection 
     36from ea_model.ceda_metadatamodel.ceda_observation.ceda_observation \ 
     37    import CEDA_Observation 
     38from ea_model.moles3_4.observationcollection.mo_observationcollection \ 
     39    import MO_ObservationCollection 
    3740from ea_model.moles3_4.observation.mo_observation import MO_Observation 
    3841from sqlalchemy import Table, Column, ForeignKey, Integer, String 
     
    4043from hpfos.HPFos.ceda_guid import CedaGUID 
    4144from sqlalchemy.orm.util import identity_key 
    42 from ea_model.iso_19115_2006_metadata_corrigendum.extent_information.ex_geographicboundingbox import EX_GeographicBoundingBox 
     45from ea_model.iso_19115_2006_metadata_corrigendum.extent_information.\ 
     46ex_geographicboundingbox import EX_GeographicBoundingBox 
    4347 
    4448import logging 
     
    6266        guid_table = Table('ceda_guid', self._db_manager.metadata, \ 
    6367                           Column('id', String, primary_key=True), \ 
    64                            Column('ceda_observationcollection', Integer, ForeignKey('ceda_observationcollection.id')),  
    65                            Column('ceda_observation', Integer, ForeignKey('ceda_observation.id'))) 
     68                           Column('ceda_observationcollection', Integer,  
     69                                  ForeignKey('ceda_observationcollection.id')),  
     70                           Column('ceda_observation', Integer,  
     71                                  ForeignKey('ceda_observation.id'))) 
    6672        mapper(CedaGUID, guid_table) 
    6773        self._db_manager.metadata.create_all() 
    6874 
    69     def _getSession(self): 
     75    def _get_session(self): 
    7076        if self._db_manager is not None: 
    7177            return self._db_manager.createDbSession()                 
     
    7379         
    7480    def createEPB(self): 
    75         return Moles3EPB(self._getSession()) 
     81        return Moles3EPB(self._get_session()) 
    7682 
    7783class Moles3EPB(object): 
     
    8995                                  start = None, end = None): 
    9096        """ 
    91             Returns the stored CEDA_ObservationCollection eventually filtering them against a postgis goemetry 
     97            Returns the stored CEDA_ObservationCollection  
     98            eventually filtering them against a postgis goemetry 
    9299            @param bbox: a postgis geometry 
    93100            @return: a list of CEDA_ObservationCollections or None if empty   
     
    155162        """ 
    156163            Returns the CedaGUID object associated with the given instance. 
    157             @param instance: an instance of CEDA_Observation os CEDA_ObservationCollection   
     164            @param instance: instance of CEDA_Observation or CEDA_ObservationCollection   
    158165        """ 
    159166        if instance is None: 
    160167            return None 
    161168        if type(instance) == CEDA_ObservationCollection: 
    162             return self._session.query(CedaGUID).filter(CedaGUID.ceda_observationcollection==instance.id).first() 
     169            return self._session.query(CedaGUID).\ 
     170                filter(CedaGUID.ceda_observationcollection==instance.id).first() 
    163171        elif type(instance) == CEDA_Observation: 
    164             return self._session.query(CedaGUID).filter(CedaGUID.ceda_observation==instance.id).first()             
     172            return self._session.query(CedaGUID).\ 
     173                filter(CedaGUID.ceda_observation==instance.id).first()             
    165174 
    166175    def getInstanceFromGUID(self, guid): 
     
    175184                return self.search(CEDA_Observation, ceda_guid.ceda_observation) 
    176185            elif ceda_guid.ceda_observationcollection: 
    177                 return self.search(CEDA_ObservationCollection, ceda_guid.ceda_observationcollection) 
     186                return self.search(CEDA_ObservationCollection,  
     187                                   ceda_guid.ceda_observationcollection) 
    178188        return None 
    179189 
     
    182192            Searches a required instance by id 
    183193            @param clazz: the class type to search for 
    184             @param inst_key: the instance id for which the search is done. If None return all the instances of the type 
     194            @param inst_key: the instance id for which the search is done.  
     195                                If None return all the instances of the type 
    185196            @return the required instance(s) 
    186197        """         
     
    203214        """ 
    204215            Searches a required instance by id loading selectively \ 
    205             the specified fields. The parameter "attributes" is a single string or a list of attributes  
     216            the specified fields. The parameter "attributes" is a single string or  
     217            a list of attributes  
    206218            owned by the instance of "clazz". Furthermore such list may contain  
    207219            also the children of the main attributes. For example "attrs" may look  
    208220            like 
    209             ['resultAccumulation', 'identifier.authority', 'resultTime.position.dateTime8601.month', \ 
     221            ['resultAccumulation', 'identifier.authority',  
     222            'resultTime.position.dateTime8601.month', \ 
    210223                      'relatedParty.party', 'result.source.function', 'permission', \ 
    211224                      'geographicExtent', 'phenomenonTime', 'keywords', 'description', \ 
     
    219232            @param inst_id: the instance id for which the search is done 
    220233            @param attributes: a single string or a list of attributes to load  
    221             @param session: a session to use for the query. By default a new one is created automatically at start and closed at the end 
     234            @param session: a session to use for the query. By default a new one  
     235                        is created automatically at start and closed at the end 
    222236            @return the required instance               
    223237        """                
     
    227241    def loadAttributes(self, instance, attributes): 
    228242        """ 
    229             Returns the attribute of an instance. The parameter "attributes" is a single string or a list of attributes  
     243            Returns the attribute of an instance. The parameter "attributes"  
     244            is a single string or a list of attributes  
    230245            owned by the instance of "clazz". Furthermore such list may contain  
    231246            also the children of the main attributes. For example "attrs" may look  
    232247            like 
    233             ['resultAccumulation', 'identifier.authority', 'resultTime.position.dateTime8601.month', \ 
     248            ['resultAccumulation', 'identifier.authority',  
     249            'resultTime.position.dateTime8601.month', \ 
    234250                      'relatedParty.party', 'result.source.function', 'permission', \ 
    235251                      'geographicExtent', 'phenomenonTime', 'keywords', 'description', \ 
Note: See TracChangeset for help on using the changeset viewer.