Changeset 2976 for TI05-delivery


Ignore:
Timestamp:
01/11/07 11:59:07 (12 years ago)
Author:
lawrence
Message:

A whole raft of modifications

  • changing to the NERC icons
  • search support within Browse and NumSim
  • NumSim V10 support in viewing
  • older numsim docs will now not be found and displayed properly (which means a lot of updating is needed)
Location:
TI05-delivery/ows_framework/trunk/ows_server
Files:
20 added
13 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ndgDiscovery.config

    r2934 r2976  
    2626# 
    2727layout:         /layout/ 
     28icondir:        /layout/icons/ 
    2829# 
    2930mailserver:       outbox.rl.ac.uk 
     
    5455stfcLink:       http://ceda.stfc.ac.uk/ 
    5556stfcImage:      %(layout)sstfc-circle-sm.gif 
    56 key:            %(layout)skey.gif 
     57key:            %(icondir)spadlock.png 
    5758keyGrey:        %(layout)skeyG.gif 
    5859selectI:        %(layout)stick.png 
    59 Xicon:          %(layout)sX.gif 
    60 printer:        %(layout)sprinter.gif 
    61 helpIcon:       %(layout)shelp_icon.gif 
     60Xicon:          %(icondir)sxml.png 
     61printer:        %(icondir)sprinter.png 
     62helpIcon:       %(icondir)shelp.png 
    6263HdrLeftAlt:     %(layout)sNatural Environment Research Council 
    6364HdrLeftLogo:    %(layout)sNERC_Logo.gif 
     
    7273[NDG_A_SERVICE] 
    7374badc.nerc.ac.uk: http://glue.badc.rl.ac.uk/cgi-bin/dxui 
    74 icon: %(layout)s/A.gif 
     75icon: %(icondir)sdata_aservice.png 
    7576icon_alt: A Service 
    7677service_name: A 
     
    8990grid.bodc.nerc.ac.uk: http://grid.bodc.nerc.ac.uk 
    9091ndg.noc.soton.ac.uk: http://ndg.noc.soton.ac.uk:8001 
    91 icon: %(layout)s/B.gif 
     92icon: %(icondir)sbrowse_bservice.png 
    9293icon_alt: B Service 
    9394icon_title: Links to a METADATA BROWSE view of this dataset 
     
    104105# is the NDG identifier. 
    105106#  
     107local: chinook.badc.rl.ac.uk 
    106108badc.nerc.ac.uk: chinook.badc.rl.ac.uk 
    107109neodc.nerc.ac.uk: chinook.badc.rl.ac.uk 
     
    165167 
    166168[RELATED] 
    167 icon: %(layout)s/R.gif 
     169icon: %(icondir)srelated_link.png 
    168170icon_alt: Related 
    169171service_name: Related 
     
    172174 
    173175[DISCOVERY] 
    174 icon: %(layout)s/D.gif 
     176icon: %(icondir)scatalogue_dservice.png 
    175177icon_alt: Catalogue 
    176178service_name: Catalogue 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/discovery.py

    r2845 r2976  
    44from ows_server.templates import DiscoveryTemplate 
    55from ows_server.models import ndgSearch as NS 
     6from ows_server.models.DocumentRetrieve import DocumentRetrieve as DR 
    67from ows_server.models.DIF import DIF 
    78from ows_server.templates.renderDiscoverySet import renderDiscoverySet 
     
    1011from ows_server.models.Utilities import myConfig 
    1112from ows_server.lib.mailer import mailHandler 
     13from ows_server.models.xmlHandler2 import xmlHandler 
    1214 
    1315 
     
    1820        ''' Common setup for controller methods ''' 
    1921        self.cf=request.environ['ndgConfig'] 
     22        self.exist=self.cf.get('NDG_EXIST','local') 
    2023        self.inputs=dict(parse_querystring(request.environ)) 
    2124        self.message='' 
     
    2629        # parse the query string and hand off to a discovery engine 
    2730        if self.inputs=={} or 'ClearForm' in self.inputs: return self.__advancedPrompt() 
     31         
     32        # see if this is a discovery search or a more complicated search 
     33        if 'searchTarget' not in self.inputs: self.inputs['searchTarget']='Discovery' 
    2834         
    2935        #the following need to be defined 
     
    4349             
    4450        # the next simplest is one that includes texttarget as well ... 
    45         expected=['searchString','textTarget','start','howmany'] 
     51        expected=['searchString','textTarget','start','howmany','searchTarget'] 
    4652        self.__checkform(expected) 
    4753     
     
    5056            return render_response('content') 
    5157         
    52         if len(self.inputs)==4: 
     58        if len(self.inputs)==5: 
    5359             
    5460            # now we add the defaults ... 
     
    6369            expected=['startDateDay','startDateMon','startDateYear', 
    6470                            'endDateDay','endDateMon','endDateYear', 
    65                             'bboxN','bboxE','bboxS','bboxW','searchString','textTarget']  
     71                            'bboxN','bboxE','bboxS','bboxW','searchString','textTarget','searchTarget']  
    6672            self.__checkform(expected) 
    6773            if self.message!='':  
     
    106112        else: 
    107113        # ------------- ok, now go do the search ----------- 
     114         
    108115           response=self.doText(self.inputs['searchString'],self.inputs['textTarget'], 
    109116                self.inputs['start'],self.inputs['howmany'],scope=scope,dateRange=dateRange,bbox=bbox) 
     
    118125        start,howmany=int(start),int(howmany)  # url arguments need conversion ... 
    119126         
    120         ws=NS.ndgSearch(logger=logger) 
     127        if self.inputs['searchTarget']=='Discovery': 
     128            ws=NS.ndgSearch(logger=logger) 
     129        elif self.inputs['searchTarget'] in ['Browse','NumSim']: 
     130            ws=DR(self.exist) 
     131            #overriding text target which is ignored currently ... yuck ... 
     132            textTarget=self.inputs['searchTarget'] 
     133            if textTarget=='Browse':textTarget='ndg_B_metadata' 
     134        else: 
     135            c.xml='Unknown searchTarget %s'%self.inputs['searchTarget'] 
     136            return render_response('error') 
     137             
    121138        documents=ws.search(searchString,start=start,howmany=howmany,target=textTarget, 
    122139                            scope=scope,dateRange=dateRange,bbox=bbox) 
     
    134151         
    135152        if hits<howmany:howmany=hits 
    136         state=DiscoveryState(id,searchString,request.environ,hits,searchConstraints,start,howmany) 
     153        print howmany,hits 
     154        c.state=DiscoveryState(id,searchString,request.environ,hits,searchConstraints,start,howmany) 
     155        print c.state 
    137156         
    138157        if hits==0:  
    139             c.xml='<p>No records found [%s]</p>'%state.constraints 
     158            c.xml='<p>No records found [%s]</p>'%c.state.constraints 
    140159            return render_response('content') 
    141         
     160      
    142161        try: 
    143             results=ws.getLabelledDocs(format='DIF') 
     162            if self.inputs['searchTarget']=='Discovery': 
     163                results=ws.getLabelledDocs(format='DIF') 
     164            else: 
     165                return self.moreSearch(ws) 
    144166            difs=[] 
    145167            errors=[] 
     
    176198                    return render_response('content') 
    177199                 
    178                 c.state=state 
     200                 
    179201                c.difs=difs 
    180202                if 'searchString' in self.inputs: 
     
    196218                c.xml='<p> Error retrieving documents for %s hits is [%s]</p>'%(hits,e) 
    197219                return render_response('content') 
    198                                 
    199         return 
     220        except Exception,e: 
     221                c.xml='Unknown error %s,%s'%(str(Exception),e) 
     222                return render_response('error')                        
     223         
    200224    def __advancedPrompt(self,searchConstraints=None): 
    201225        ''' This provides the advanced search input page ''' 
     
    268292        c.constraints=request.environ['QUERY_STRING'] 
    269293        return render_response('semantic',fragment=True) 
     294     
     295    def moreSearch(self,ws): 
     296        ''' Provides the search on Browse and NumSim content ''' 
     297        c.results=ws.results 
     298        c.searchTarget=self.inputs['searchTarget'] 
     299        for r in c.results: 
     300            n=ndgObject(r.id,config=self.cf) 
     301            r.link={'Browse':n.BURL,'NumSim':n.URL}[c.searchTarget] 
     302         
     303        return render_response('short_results') 
     304             
     305 
     306    
     307         
     308         
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/retrieve.py

    r2895 r2976  
    9494                    c.xmlh=x 
    9595                    c.tbinfo=self.__mytb('') 
    96                     name=x.getText('NS_Model/NS_Name') 
     96                    name=x.getText('NS_Name') 
     97                    c.name=name 
    9798                else: 
    9899                    c.xml=x.tohtml() 
     
    145146            resp=Response(resp,code=code) 
    146147        else: 
     148            #resp=Response(render(r),code=code) 
    147149            try: 
    148150                resp=Response(render(r),code=code) 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/DocumentRetrieve.py

    r2881 r2976  
    3535            xquery=xquery.replace('TargetCollection',targetCollection) 
    3636            xquery=xquery.replace('LocalID',localID) 
     37            print xquery 
    3738            id,summary=self.executeQuery(xquery) 
    3839            if summary['hits']==1: 
     
    9495                      
    9596            xquery=queryReplace(xquery,repository,localID,targetCollection) 
     97            
    9698            try: 
    9799                id,summary=self.executeQuery(xquery) 
     
    115117        self.sessionRelease(id) 
    116118        return r 
    117              
    118119             
    119120class ndgHTTP: 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/eXistInterface.py

    r2626 r2976  
    11# Code inspired by example on eXist website. 
    22import urllib2, base64, urllib, urlparse, httplib, xmlrpclib, types, os 
    3  
    4 class   InstanceObject(object): 
     3from xmlHandler2 import xmlHandler as xmlh 
     4import ndg_xqueries as xq 
     5 
     6class InstanceObject(object): 
    57    def __init__(self, **kw): 
    68        self.dict={} 
     
    810    def __getattr__(self,arg): 
    911        return self.dict[arg] 
     12    def __str__(self): 
     13        return 'InstanceObject: %s '%self.dict 
     14        
     15class edict(dict): 
     16    '''An extended dictionary which allows one to set and get values 
     17    as attributes (kudos Joe Gregorio's 1812)  
     18    The extended part allows you to get and set values as attributes. 
     19    That is,  
     20       d.fred  
     21    is the same as  
     22       d['fred'] 
     23    ''' 
     24    def __init__(self,**kw): 
     25        for a in kw: 
     26            self[a]=kw[a] 
     27    def __getattr__(self, key): 
     28        try: 
     29            return self.__dict__[key] 
     30        except KeyError: 
     31            pass 
     32        try: 
     33            assert not key.startswith('_') 
     34            return self.__getitem__(key) 
     35        except: 
     36            raise AttributeError, "object has no attribute '%s'" % key 
     37    def __setattr__(self, key, value): 
     38        if key.startswith('_'): 
     39            self.__dict__[key] = value 
     40        else: 
     41            return self.__setitem__(key, value) 
     42 
    1043 
    1144class  eXist_Connector(object): 
     
    105138        '''Create an NDG full text query ''' 
    106139        if target is not None: 
    107             s="//%s[. &='%s']"%(target,query) 
     140            s='''let $hits := collection('/db/%s')//root()[. &= '%s']  
     141                 for $i in $hits  
     142                    return <document>{document-uri($i)}</document>'''%(target,query) 
    108143        else: s="/*[. &='%s']"%query 
     144 
    109145        return s#xmlrpclib.Binary(s) 
    110146 
     
    158194        return r 
    159195         
    160     
     196    def search(self,term,start=1,howmany=20,target=None,scope=None,bbox=None,dateRange=None): 
     197        ''' Provides a search interface that mimics the WSDL search interface, except that 
     198        the target used is the exist collection name, and scope, bbox and dateRange are ignored, 
     199        and a python summary object is returned ''' 
     200        xquery={'ndg_B_metadata':xq.molesSearchSummary,'NumSim':xq.numsimSummary}[target] 
     201        xquery=xquery.replace('SEARCHSTRING',term) 
     202        r=self.executeChunkedQuery(xquery,start,howmany) 
     203        print r 
     204        x=xmlh(str(r),string=1) 
     205        h=x.tree.get('hits') 
     206        self.results=[] 
     207        self.serverSessionID='' 
     208        if h is None: 
     209            self.hits=0 
     210            self.start=0 
     211            self.howmany=0 
     212            self.error=['No results for [%s]'%term,] 
     213        else: 
     214            self.hits=int(h) 
     215            self.error=None 
     216            self.start=int(x.tree.get('start')) 
     217            self.howmany=int(x.tree.get('count')) 
     218            slist=x.tree.findall('summary') 
     219            for s in slist: 
     220                t=edict(id=s.find('id').text,name=s.find('name').text,type=s.find('type').text) 
     221                self.results.append(t) 
     222        return self.results 
     223 
    161224import unittest 
    162225 
     
    172235        r=existDB.retrieveNext(id) 
    173236        d=summary['documents'][0][0] 
    174         print d 
    175237        doc=existDB.getDoc('/db/discovery/moles',d) 
    176238         
    177239        ok=existDB.sessionRelease(id) 
    178240        self.assertEqual(1,ok) 
     241         
     242    def testSearch(self): 
     243        existDB=ndg_eXist(db='chinook.badc.rl.ac.uk') 
     244        r=existDB.search('coapec',target='ndg_B_metadata') 
     245        print existDB.hits 
     246        for i in r: print i 
     247        r=existDB.search('HadAM2',target='NumSim') 
     248        print existDB.hits 
     249         
     250    def testedict(self): 
     251        i=edict(a=1,b=2) 
     252        i.c=3 
     253        i['d']=4 
     254        correct={'a':1,'b':2,'c':3,'d':4} 
     255        for j in correct: self.assertEqual(correct[j],i[j]) 
    179256 
    180257if __name__=="__main__": 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/ndgRetrieve.py

    r2881 r2976  
    165165        self.assertEqual(status,1) 
    166166         
     167    def testNumSim(self): 
     168        '''Get a NumSim document ''' 
     169        self.setup() 
     170        doc='badc.nerc.ac.uk__NumSim__HadAM2_CodeBase' 
     171        uri=ndgObject.ndgObject(doc) 
     172        status,xml=ndgRetrieve(uri,self.c) 
     173        print status,xml 
     174         
    167175         
    168176if __name__=="__main__": 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/ndg_xqueries.py

    r2698 r2976  
    44 
    55numsimQuery='''  
    6 declare default element namespace 'http://ndg.nerc.ac.uk/NumSim';  
     6declare namespace n='http://ndg.nerc.ac.uk/numsim'; 
     7declare namespace m='http://ndg.nerc.ac.uk/moles';  
    78for $DE in  
    8 collection('TargetCollection')/NS_Simulated[*/dgMetadataID/schemeIdentifier='NumSim'  
    9 and */dgMetadataID/repositoryIdentifier='RepositoryID' and  
    10 */dgMetadataID/localIdentifier='LocalID']  
     9collection('TargetCollection')/n:simulationMetadata[*/n:id/m:schemeIdentifier='NumSim'  
     10and */n:id/m:repositoryIdentifier='RepositoryID' and */n:id/m:localIdentifier='LocalID']  
    1111return $DE 
     12''' 
     13 
     14molesSearchSummary=''' 
     15declare namespace m='http://ndg.nerc.ac.uk/moles'; 
     16for $dd in collection('/db/ndg_B_metadata')//root()[. &= 'SEARCHSTRING'] 
     17return <summary> 
     18<id>{$dd/m:dgMetadata/m:dgMetadataRecord/m:dgMetadataID/m:repositoryIdentifier/text()}__{$dd/m:dgMetadata/m:dgMetadataRecord/m:dgMetadataID/m:schemeIdentifier/text()}__{$dd/m:dgMetadata/m:dgMetadataRecord/m:dgMetadataID/m:localIdentifier/text()}</id> 
     19<name>{$dd/m:dgMetadata/m:dgMetadataRecord/m:name/text()}</name> 
     20<type>{if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgDataEntity)) then 'DataEntity' else (if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgObservationStation)) then 'ObservationStation' else (if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgDataProductionTool)) then 'DataProductionTool' else (if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgActivity)) then 'Activity' else ('unknown'))))}</type> 
     21</summary> 
     22''' 
     23numsimSummary=''' 
     24declare namespace m='http://ndg.nerc.ac.uk/moles'; 
     25declare namespace n='http://ndg.nerc.ac.uk/numsim'; 
     26for $dd in collection('/db/NumSim')//root()[. &= 'SEARCHSTRING'] 
     27return <summary> 
     28<id>{$dd/n:simulationMetadata/n:model/n:id/m:repositoryIdentifier/text()}__{$dd/n:simulationMetadata/n:model/n:id/m:schemeIdentifier/text()}__{$dd/n:simulationMetadata/n:model/n:id/m:localIdentifier/text()}</id> 
     29<name>{$dd/n:simulationMetadata/n:model/n:name/text()}</name> 
     30<type>Numsim-{$dd/n:simulationMetadata/*[1]/name()}</type> 
     31</summary> 
    1232''' 
    1333 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/ndg_xqueries.py~

    r2672 r2976  
    33# Update DIF/DC queries  
    44 
    5 numsimQuery=''' declare default element namespace 'http://ndg.nerc.ac.uk/NumSim';  
    6 for $DE in collection('TargetCollection')/NS_Simulated/NS_CodeBase[dgMetadataID/schemeIdentifier='NumSim' and dgMetadataID/repositoryIdentifier='RepositoryID' and dgMetadataID/localIdentifier='LocalID'] return <NS_Simulated>$DE</NS_Simulated> 
     5numsimQuery='''  
     6declare namespace n='http://ndg.nerc.ac.uk/numsim'; 
     7declare namespace m='http://ndg.nerc.ac.uk/moles';  
     8for $DE in  
     9collection('TargetCollection')/n:simulationMetadata[n:id/m:schemeIdentifier='NumSim'  
     10and n:id/m:repositoryIdentifier='RepositoryID' and n:id/m:localIdentifier='LocalID']  
     11return $DE 
     12''' 
     13 
     14molesSearchSummary=''' 
     15declare namespace m='http://ndg.nerc.ac.uk/moles'; 
     16for $dd in collection('/db/ndg_B_metadata')//root()[. &= 'SEARCHSTRING'] 
     17return <summary> 
     18<id>{$dd/m:dgMetadata/m:dgMetadataRecord/m:dgMetadataID/m:repositoryIdentifier/text()}__{$dd/m:dgMetadata/m:dgMetadataRecord/m:dgMetadataID/m:schemeIdentifier/text()}__{$dd/m:dgMetadata/m:dgMetadataRecord/m:dgMetadataID/m:localIdentifier/text()}</id> 
     19<name>{$dd/m:dgMetadata/m:dgMetadataRecord/m:name/text()}</name> 
     20<type>{if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgDataEntity)) then 'DataEntity' else (if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgObservationStation)) then 'ObservationStation' else (if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgDataProductionTool)) then 'DataProductionTool' else (if (exists($dd/m:dgMetadata/m:dgMetadataRecord/m:dgActivity)) then 'Activity' else ('unknown'))))}</type> 
     21</summary> 
     22''' 
     23numsimSummary=''' 
     24declare namespace m='http://ndg.nerc.ac.uk/moles'; 
     25declare namespace n='http://ndg.nerc.ac.uk/numsim'; 
     26for $dd in collection('/db/NumSim')//root()[. &= 'SEARCHSTRING'] 
     27return <summary> 
     28<id>{$dd/n:simulationMetadata/n:model/n:id/m:repositoryIdentifier/text()}__{$dd/n:simulationMetadata/n:model/n:id/m:schemeIdentifier/text()}__{$dd/n:simulationMetadata/n:model/n:id/m:localIdentifier/text()}</id> 
     29<name>{$dd/n:simulationMetadata/n:model/n:name/text()}</name> 
     30<type>Numsim-{$dd/n:simulationMetadata/*[1]/name()}</type> 
     31</summary> 
    732''' 
    833 
     
    3459declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
    3560declare variable $localIdentifier as xs:string {'LocalID'}; 
    36 (: replacable parameters 
    37 declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
    38 declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
    39 declare variable $localIdentifier as xs:string {'dataent_chablis'}; 
    40 :) 
    4161 
    4262declare function f:return-stub-activity($out-element-name as xs:string, $repid as xs:string, $locid as xs:string) as element()  
     
    247267element obsStnList { 
    248268for $DepObsStnRepository in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
    249 for $DepObsStnLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     269for $DepObsStnLocal in distinct-values($DE/moles:dgDataEntity/moles:RelatedDeployment/moles:ObservationStationID/moles:localIdentifier) 
    250270let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal)) 
    251271return $DepObsStn  
    252272} 
     273, element rawDeployments {for $rawDeployments in $DE/moles:dgDataEntity/moles:RelatedDeployment return $rawDeployments} 
    253274} (: </DeploymentSummary> :) , 
    254         for $RelatedDataEntity in $DE/moles:dgDataEntity/moles:dgRelatedDataEntity 
     275        for $RelatedDataEntity in $DE/moles:dgActivity/moles:dgRelatedDataEntity 
    255276            return 
    256277                element relateddataentity { 
     
    282303Will return when scope problem sussed... ;( 
    283304import module namespace stubblib='http://ndg.nerc.ac.uk/xquery/lib/stubb' at 'xmldb:exist:///db/xqueryLib/StubB/stubb_xquery_lib.xquery'; 
    284 :) 
    285 (: replacable parameters 
    286 declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
    287 declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
    288 declare variable $localIdentifier as xs:string {'activity_11680365144712080'}; 
    289305:) 
    290306declare variable $targetCollection as xs:string {'TargetCollection'}; 
     
    539555element obsStnList { 
    540556for $DepObsStnRepository in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
    541 for $DepObsStnLocal in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     557for $DepObsStnLocal in distinct-values($Act/moles:dgActivity/moles:ActivityDeployment/moles:ObservationStationID/moles:localIdentifier) 
    542558let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal)) 
    543559return $DepObsStn  
     
    552568return f:return-stub-dataentity('dataentity', $DE) 
    553569} 
     570, element rawDeployments {for $rawDeployments in $Act/moles:dgActivity/moles:ActivityDeployment return $rawDeployments} 
    554571}, (: </DeploymentSummary> :) 
    555572        if (exists($Act/dgActivityCoverage)) then 
     
    578595declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    579596 
    580 (: replacable parameters 
    581 declare variable $targetCollection as xs:string {'/db/ndg_B_metadata'}; 
    582 declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
    583 declare variable $localIdentifier as xs:string {'dpt_116291244849226'}; 
    584 :) 
    585597declare variable $targetCollection as xs:string {'TargetCollection'}; 
    586598declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
     
    727739element obsStnList { 
    728740for $DepObsStnRepository in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ObservationStationID/moles:repositoryIdentifier) 
    729 for $DepObsStnLocal in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:DataProductionToolID/moles:localIdentifier) 
     741for $DepObsStnLocal in distinct-values($DPT/moles:dgDataProductionTool/moles:DPTDeployment/moles:ObservationStationID/moles:localIdentifier) 
    730742let $DepObsStn :=  f:return-stub-obsstn('observationstation', data($DepObsStnRepository), data($DepObsStnLocal)) 
    731743return $DepObsStn  
     
    740752return f:return-stub-dataentity('dataentity', $DE) 
    741753} 
     754, element rawDeployments {for $rawDeployments in $DPT/moles:dgDataProductionTool/moles:DPTDeployment return $rawDeployments} 
    742755} (: </DeploymentSummary> :) 
    743756} (: </dgDataProductionTool> :),  
     
    760773declare namespace moles='http://ndg.nerc.ac.uk/moles'; 
    761774 
    762 (: replacable parameters 
    763 declare variable $targetCollection as xs:string {'/db/ndg_B_metadata_4'}; 
    764 declare variable $repositoryIdentifier as xs:string {'badc.nerc.ac.uk'}; 
    765 declare variable $localIdentifier as xs:string {'obs_1162914661529326'}; 
    766 :) 
    767775declare variable $targetCollection as xs:string {'TargetCollection'}; 
    768776declare variable $repositoryIdentifier as xs:string {'RepositoryID'}; 
     
    942950return f:return-stub-dataentity('dataentity', $DE) 
    943951} 
     952, element rawDeployments {for $rawDeployments in $ObsStn/moles:dgObservationStation/moles:ObsStationDeployment return $rawDeployments} 
    944953} (: </DeploymentSummary> :)  
    945954} (: </dgObservationStation> :),  
     
    948957if (exists($ObsStn/moles:dgMetadataSecurity)) then $ObsStn/moles:dgMetadataSecurity else () 
    949958} (: End </dgMetadataRecord> :) 
    950 ) (: End namespace strip :) 
    951 ''' 
     959) (: End namespace strip :)''' 
    952960 
    953961ISO19139Query = ''' 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/stubB.py

    r2970 r2976  
    145145            c.append(self.helper.getText(t,'DateRangeEnd')) 
    146146        else: 
    147             c=(self.helper.getText(self.elem, 
    148                     'dgDataSummary/dgDataCoverage/dgTemporalCoverage/DateSingle'),) 
     147            c=[self.helper.getText(self.elem, 
     148                    'dgDataSummary/dgDataCoverage/dgTemporalCoverage/DateSingle'),''] 
    149149        c.append(self.helper.getText(self.elem,'dgDataSummary/dgDatasetStatus/dgDatasetClosure')) 
    150150        return c 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/models/xmlHandler2.py

    r2835 r2976  
    2727 
    2828        if string: 
    29             self.xmls=xml 
     29            self.xmls=xml  #we better hope that xml is a unicode or string object otherwise odd things happen 
    3030            xmlf=None 
    3131        else: 
     
    3535        # Unfortunately we never know whether the incoming xml content is 
    3636        # unicode or a string ... 
     37 
    3738        encoding='utf-8' 
    3839        try: 
     
    6364         
    6465 
     66        self.defns=None 
    6567        if self.xmls[0:19]==XMLHDR: 
    6668            self.root=1 
     
    171173        nslist={} 
    172174        for ns in self.realns: nslist[self.realns[ns]]=ns 
    173         r='xmlns="%s"'%nslist['default'] 
     175        if 'default' in nslist: r='xmlns="%s"'%nslist['default'] 
    174176        for ns in nslist: 
    175177            if ns<>'default': r+=' xmlns:%s="%s"'%(ns,nslist[ns]) 
     
    193195    def _distributens(self,xpathExpression): 
    194196        ''' Actually we only support tag finding in this ''' 
     197        if self.defns is None: return xpathExpression 
    195198        tags=xpathExpression.split('/') 
    196199        new='' 
     
    294297            print h 
    295298             
     299        def testExist(self): 
     300            s='''<exist:result xmlns:exist="http://exist.sourceforge.net/NS/exist" hits="4" start="1" count="4"> 
     301<document>/db/ndg_B_metadata/badc.nerc.ac.uk/activity_activity_COAPEC.xml</document><document>/db/ndg_B_metadata/badc.nerc.ac.uk/activity_activity_coapec_1k.xml</document><document>/db/ndg_B_metadata/badc.nerc.ac.uk/activity_activity_cpdn.xml</document><document>/db/ndg_B_metadata/badc.nerc.ac.uk/dataent_COAPEC.xml</document> 
     302</exist:result>''' 
     303            x=xmlHandler(s,string=1) 
     304            d=x.getText('Document',multiple=1) 
     305             
     306             
     307             
    296308    unittest.main() 
    297309             
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/NSfunctions.kid

    r2967 r2976  
    5858            <?python 
    5959            rel=elem.find(nsfix('NS_Relationship')) 
    60             if rel is not None: rel.text+=',' 
     60            if rel is not None and rel.text[-1]!=',': rel.text+=',' 
    6161            href=elem.attrib.get('{http://www.w3.org/1999/xlink}href') 
    6262            title=elem.attrib.get('{http://www.w3.org/1999/xlink}title') 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/ndgPage.kid

    r2929 r2976  
    2727    <!-- One line search box for top of many pages follows --> 
    2828     
    29     <div py:def="searchOneLine()" class="searchBar"> 
     29    <div py:def="searchOneLine(targets=0)" class="searchBar"> 
    3030        <table width="100%"><tr><td align="left"> 
    3131        <form action="$g.discoveryURL"> 
     
    3737            <option value="Params">Parameters</option>  
    3838            </select> 
     39            <span py:if="targets"> in 
     40            <?python 
     41            sel=[['Discovery','Discovery'],['Browse','Browse'],['Simulation','NumSim']] 
     42            ?> 
     43            <select name="searchTarget"> 
     44                ${XML(h.options_for_select(sel,targets))} 
     45            </select> 
     46            </span> 
    3947            <input type="submit" value="Search"/> 
    4048         </form> 
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/templates/numsim.kid

    r2882 r2976  
    1 <html py:extends="'ndgPage.kid',NSfunctions.kid" xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"> 
     1<html py:extends="'ndgPage.kid',NSfunctions10.kid" xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://purl.org/kid/ns#"> 
    22    <head> 
    33    <replace py:replace="pagehead()"/> 
     
    77        <div id="entirepage"> 
    88            ${XML(c.tbinfo)} 
     9            <div py:replace="searchOneLine(targets='NumSim')"/> 
    910            <div id="Simulated"> 
    10                 <div py:replace="numsimContent(c.xmlh)"/> 
     11                <h4> $c.name </h4> 
     12                <!-- Handle different versions of numsim --> 
     13                <div py:if="'{http://ndg.nerc.ac.uk/NumSim}NS_' in c.xmlh.tree[0].tag" py:replace="numsimContent(c.xmlh)"/> 
     14                <div py:if="'{http://ndg.nerc.ac.uk/numsim}' in c.xmlh.tree[0].tag" py:replace="simulationContent(c.xmlh)"/> 
    1115            </div> 
    1216        </div> 
Note: See TracChangeset for help on using the changeset viewer.