Changeset 4427


Ignore:
Timestamp:
13/11/08 15:30:13 (11 years ago)
Author:
cbyrom
Message:

Upgrade the various 'list' xqueries - to nest all results in a single
root element - so that only one document need be retrieved to get all
results + adjust ndgDirectory to cope with processing the new results +
fix the various namespaces mentioned in the codebase to map to the
current atom/moles ones.

Location:
exist/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/eXistInterface.py

    r4295 r4427  
    156156        logging.debug("providerID: '%s', atomTypeID: '%s', term: '%s'"  
    157157                      %(providerID, atomTypeID, term)) 
    158         xquery = "declare namespace moles='http://ndg.nerc.ac.uk/schema/moles2alpha';\n" + \ 
     158        xquery = "declare namespace moles='http://ndg.nerc.ac.uk/schema/moles2beta';\n" + \ 
    159159            "declare namespace atom='http://www.w3.org/2005/Atom';\n" + \ 
    160160            "for $DE in collection('/db/atoms')//root()[" 
  • exist/trunk/python/ndgUtils/models/Atom.py

    r4419 r4427  
    568568        root = ET.Element("entry") 
    569569        root.attrib["xmlns"] = "http://www.w3.org/2005/Atom" 
    570         root.attrib["xmlns:moles"] = "http://ndg.nerc.ac.uk/schema/moles2alpha" 
    571         root.attrib["xmlns:georss"] = "http://www.georss.org/georss" 
     570        root.attrib["xmlns:moles"] = "http://ndg.nerc.ac.uk/schema/moles2beta" 
     571        root.attrib["xmlns:georss"] = "http://www.georss.org/georss/10" 
    572572        root.attrib["xmlns:gml"] = "http://www.opengis.net/gml" 
    573573        id = ET.SubElement(root, "id") 
  • exist/trunk/python/ndgUtils/models/MolesEntity.py

    r4314 r4427  
    218218        logging.info("Creating formatted XML version of MolesEntity") 
    219219        molesEntity = ET.Element("moles:entity") 
    220         molesEntity.attrib["xmlns:moles"] = "http://ndg.nerc.ac.uk/schema/moles2alpha" 
     220        molesEntity.attrib["xmlns:moles"] = "http://ndg.nerc.ac.uk/schema/moles2beta" 
    221221         
    222222        molesISO = ET.SubElement(molesEntity, "moles:molesISO") 
  • exist/trunk/python/ndgUtils/models/testatom.py

    r4314 r4427  
    3636    name = 'famous_control_month.atom' 
    3737     
    38     xmlString = '<entry xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" ' + \ 
    39         'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2alpha">' + \ 
     38    xmlString = '<entry xmlns:georss="http://www.georss.org/georss/10" xmlns:gml="http://www.opengis.net/gml" ' + \ 
     39        'xmlns:moles="http://ndg.nerc.ac.uk/schema/moles2beta">' + \ 
    4040        '<id>' + id + '</id>' + \ 
    4141        '<title>' + title + '</title>' + \ 
  • exist/trunk/python/ndgUtils/models/utilities.py

    r4419 r4427  
    1919esc_chars = {'\xb0':'&#xb0;','&deg;':'&#176;'} 
    2020 
    21 YEAR_FORMAT = '%Y-%m-%d' 
    22      
    2321def getTripleData(tripleString): 
    2422    ''' 
  • exist/trunk/python/ndgUtils/ndgDirectory.py

    r4229 r4427  
    77        ''' Initialise a targetCollection directory of a particular docType. 
    88        Valid docTypes are: 
    9             dgObservationStation, dgDataEntity, dgActivity, dgDataProductionTool 
    10             DIF, MDIP 
     9            DIF, MDIP, ATOM, MOLES 
    1110            (Not all supported ...yet ) 
    1211            Note that if fast is set true, the members attribute is not populated 
     
    1817        self.lastUpdated=None 
    1918        self.targetCollection=targetCollection 
     19        self.docType = docType 
    2020         
    2121        #get the right namespace 
     
    3939       
    4040        if not fast: m=self.getMembers() 
     41 
    4142         
    4243    def getMembers(self): 
     
    4546        if s['hits']==0: return [] 
    4647        indices=range(s['hits']) 
    47         self.members=[self.__loadxml(id,i) for i in indices] 
     48         
     49        doc = self.xmldb.retrieve(id, 0) 
     50        et = ET.fromstring(doc) 
     51        for member in et: 
     52            fn = member.findtext('{%s}fileName'%self.ns) 
     53            eid = member.findtext('{%s}repositoryID'%self.ns) 
     54            c = member.findtext('{%s}created'%self.ns) 
     55            self.members.append({'fileName':fn,'EntryID':eid,'created':c}) 
     56         
    4857        self.xmldb.release(id) 
    4958        self.files=[i['fileName'] for i in self.members] 
    5059        self.entries=[i['EntryID'] for i in self.members] 
    5160        return self.members 
    52          
    53     def __loadxml(self,id,i): 
    54         ''' Returns the i'th xml document name in result set id ''' 
    55         r=self.xmldb.retrieve(id,i) 
    56         e=ET.fromstring(r) 
    57         fn=e.findtext('{%s}fileName'%self.ns) 
    58         eid=e.findtext('{%s}repositoryID'%self.ns) 
    59         c=e.findtext('{%s}created'%self.ns) 
    60         return {'fileName':fn,'EntryID':eid,'created':c} 
     61 
    6162    
    6263    def get(self,fileName): 
     
    6465        #Use the fact that we know its document name ... 
    6566        return self.xmldb.getDoc(self.targetCollection,fileName) 
     67 
    6668     
    6769    def created(self,fileName=None): 
  • exist/trunk/python/ndgUtils/ndgObject.py

    r4200 r4427  
    2222        # various namespaces used in the docs 
    2323    ATOM_NS = 'http://www.w3.org/2005/Atom' 
    24     MOLES_NS = 'http://ndg.nerc.ac.uk/schema/moles2alpha' 
    25     GEOSS_NS = 'http://www.georss.org/georss' 
     24    MOLES_NS = 'http://ndg.nerc.ac.uk/schema/moles2beta' 
     25    GEOSS_NS = 'http://www.georss.org/georss/10' 
    2626    GML_NS = 'http://www.opengis.net/gml' 
    2727         
  • exist/trunk/xquery/DIFList.xq

    r3841 r4427  
    22declare default element namespace 'http://gcmd.gsfc.nasa.gov/Aboutus/xml/dif/'; 
    33declare variable $targetCollection as xs:string := 'TargetCollection'; 
     4<docs> 
     5{ 
    46for $DE in collection($targetCollection)/DIF/Entry_ID let $f:=util:document-name($DE) return  
    57<dgMetadataRecord> 
     
    810    <created>{xmldb:created(util:collection-name($DE),$f)}</created> 
    911</dgMetadataRecord> 
     12} 
     13</docs> 
  • exist/trunk/xquery/MDIPList.xq

    r3841 r4427  
    11declare default element namespace 'http://www.oceannet.org/mdip/xml'; 
    22declare variable $targetCollection as xs:string := 'TargetCollection'; 
     3<docs> 
     4{ 
    35for $DE in collection($targetCollection)/Metadata/DatasetIdentifier 
    46let $f:=util:document-name($DE) 
     
    810    <created>{xmldb:created(util:collection-name($DE),$f)}</created> 
    911</dgMetadataRecord> 
     12} 
     13</docs> 
  • exist/trunk/xquery/atomList.xq

    r4231 r4427  
    22declare default element namespace 'http://www.w3.org/2005/Atom'; 
    33declare variable $targetCollection as xs:string := 'TargetCollection'; 
     4<docs> 
     5{ 
    46for $DE in collection($targetCollection)/entry/id let $f:=util:document-name($DE) return 
    57<dgMetadataRecord> 
    6     <repositoryID>{string($DE)}</repositoryID> 
     8    <repositoryID>{tokenize(string($DE), '__ATOM__')[2]}</repositoryID> 
    79    <fileName>{util:collection-name($DE)}/{$f}</fileName> 
    810    <created>{xmldb:created(util:collection-name($DE),$f)}</created> 
    911</dgMetadataRecord> 
     12} 
     13</docs> 
  • exist/trunk/xquery/molesList.xq

    r3841 r4427  
    22declare default element namespace 'http://ndg.nerc.ac.uk/moles'; 
    33declare variable $targetCollection as xs:string := 'TargetCollection'; 
     4<docs> 
     5{ 
    46for $DE in collection($targetCollection)/dgMetadata/dgMetadataRecord[exists(dgDataEntity)] 
    57let $f:=util:document-name($DE) 
    68return 
    79<dgMetadataRecord> 
    8 (: Yes, there is redundant info, we'll sort that out later, rapid bug fix 
    9 mode :) 
    1010{$DE/dgMetadataID/repositoryIdentifier}{$DE/dgMetadataID/localIdentifier}  
    1111<repositoryID>{string($DE/dgMetadataID/localIdentifier)}</repositoryID> 
     
    1313<created>{xmldb:created(util:collection-name($DE),$f)}</created> 
    1414</dgMetadataRecord> 
     15} 
     16</docs> 
Note: See TracChangeset for help on using the changeset viewer.