Changeset 8549 for mauRepo


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

Location:
mauRepo/HPFos/trunk
Files:
4 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', \ 
  • mauRepo/HPFos/trunk/hpfos/HPFos/osImpl/myimpl.py

    r8548 r8549  
    3434from hpfos.libs.postgisutil import create_st_setSRID 
    3535from ceda_markup.opensearch.osquery import OSQuery 
    36 from ceda_markup.atom.atom import createID, createUpdated,\ 
     36from ceda_markup.atom.atom import createID, createUpdated, \ 
    3737    createPublished, createEntry 
    3838from ceda_markup.atom.info import createTitle, HTML_TYPE, createContent 
     
    4040from ceda_markup.gml.gml import createBeginPosition, createEndPosition, \ 
    4141    createTimePeriod, createValidTime, createEnvelope, createLowerCorner, \ 
    42     createUpperCorner, createPosList, createLinearRing, createExterior, createPolygon,\ 
     42    createUpperCorner, createPosList, createLinearRing, createExterior, createPolygon, \ 
    4343    GML_NAMESPACE 
    4444from ceda_markup.georss.georss import createWhere 
    4545from ceda_markup.atom.link import REL_SEARCH, REL_ALTERNATE, createLink 
    46 from ceda_markup.opensearch import filter_results, COUNT_DEFAULT,\ 
     46from ceda_markup.opensearch import filter_results, COUNT_DEFAULT, \ 
    4747    START_INDEX_DEFAULT, START_PAGE_DEFAULT, create_autodiscovery_link 
    4848from ceda_markup.opensearch.template.osresponse import Result, Subresult 
     
    5959from ceda_markup.atom.atom import ATOM_NAMESPACE 
    6060from hpfos.HPFos.osImpl.commons import get_document, get_xml_document, \ 
    61     from_pt_to_string, isoDateStringToDatetime, tm_InstantToDatetime 
     61    from_pt_to_string, tm_InstantToDatetime 
    6262from ceda_markup.opensearch.os_request import OS_NAMESPACE 
    6363from xml.etree.ElementTree import _ElementInterface 
     
    311311            beginPosition = None 
    312312            endPosition = None 
    313             if hasattr(subresult, 'beginPosition') and subresult.beginPosition is not None: 
     313            if hasattr(subresult, 'beginPosition') \ 
     314                    and subresult.beginPosition is not None: 
    314315                beginPosition = subresult.beginPosition 
    315316            if hasattr(subresult, 'endPosition') and subresult.endPosition is not None:                 
     
    359360        entry.append(where) 
    360361 
    361     def _append_valid_time(self, subresult, entry, atomroot, beginPosition, endPosition): 
     362    def _append_valid_time(self, subresult, entry, atomroot,  
     363                           beginPosition, endPosition): 
    362364        #xmlentry = entry.buildElement() 
    363365        if beginPosition is not None: 
    364             beginPosition = createBeginPosition(root = atomroot, body = subresult.beginPosition) 
     366            beginPosition = createBeginPosition(root = atomroot,  
     367                                                body = subresult.beginPosition) 
    365368        if endPosition is not None:                 
    366             endPosition = createEndPosition(root = atomroot, body = subresult.endPosition)                 
    367         timePeriod = createTimePeriod(root = atomroot, begin = beginPosition, end = endPosition)        
     369            endPosition = createEndPosition(root = atomroot,  
     370                                            body = subresult.endPosition)                 
     371        timePeriod = createTimePeriod(root = atomroot,  
     372                                      begin = beginPosition, end = endPosition)        
    368373        validTime = createValidTime(root = atomroot, body = timePeriod) 
    369374        if beginPosition is not None or endPosition is not None: 
     
    420425        ''' 
    421426            Constructor 
    422         ''' 
    423         #param_1 = OSParam("q", "searchTerms", namespace = "http://example.com/opensearchextensions/1.0/")        
     427        '''        
    424428        param_1 = OSParam("count", "count") 
    425429        param_2 = OSParam("startPage", "startPage") 
    426430        param_3 = OSParam("startIndex", "startIndex")                 
    427431        param_4 = OSParam("q", "searchTerms")            
    428         param_5 = OSParam("uid", "uid", namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
    429         param_6 = OSParam(BBOX, BBOX, namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
    430         param_7 = OSParam("start", "start", namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
    431         param_8 = OSParam("stop", "stop", namespace = "http://a9.com/-/opensearch/extensions/time/1.0/")         
     432        param_5 = OSParam("uid", "uid",  
     433                          namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
     434        param_6 = OSParam(BBOX, BBOX,  
     435                          namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
     436        param_7 = OSParam("start", "start",  
     437                          namespace = "http://a9.com/-/opensearch/extensions/geo/1.0/")         
     438        param_8 = OSParam("stop", "stop",  
     439                          namespace = "http://a9.com/-/opensearch/extensions/time/1.0/")         
    432440        params = [param_1, param_2, param_3, param_4, param_5, param_6, param_7, param_8]  
    433441        super(MyOSQuery, self).__init__(params) 
  • mauRepo/HPFos/trunk/hpfos/libs/epb.py

    r8355 r8549  
    175175 
    176176    @classmethod 
    177     def _getSession(self, dbManager, session = None): 
     177    def _get_session(self, dbManager, session = None): 
    178178        if session: 
    179179            return session         
  • mauRepo/HPFos/trunk/resources/requirements.txt

    r8542 r8549  
    77# --extra-index-url http://ciprod1.cems.rl.ac.uk/pip 
    88# to your pip install  
    9 ceda-markup==0.0.9 
     9ceda-markup==0.0.10 
    1010ceda-moles-model==0.1.5 
    1111 
Note: See TracChangeset for help on using the changeset viewer.