source: TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/DIF.py @ 938

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI07-MOLES/trunk/StubB/XSLT/browse/portal/cgi/DIF.py@938
Revision 938, 2.6 KB checked in by lawrence, 14 years ago (diff)

First code to support a GUI for python based searching through the
discovery WS interface. Includes some refactoring of the browse code
to support multiple entities (i.e. DIF etc). (NB: browse still
wont work properly until we get the security stuff working ok).

Line 
1# python class to support methods on a DIF ... to conform with
2# renderEntity etc ...
3#
4import ElementTree as ET
5from Utilities import *
6from geoUtilities import *
7from People import *
8from ServiceBinding import Service
9
10class DIF:
11    ''' Supports the NASA GCMD DIF format for python operations,
12    note ... not a complete implementation, currently minimum to
13    show a reasonable piece of content '''
14    def __init__(self,xml):
15        '''Initialise a python dif instance based on an xml document '''
16        self.metadataType='DIF'
17        self.elem=ET.fromstring(xml)
18       
19        self.abstract=wrapGetText(self.elem,'Summary')
20        self.name=wrapGetText(self.elem,'Entry_Title')
21       
22        #Note that entity.constraints.html is about access control on the metadata,
23        #and so we don't populate this here ...
24       
25        #need entity.parameters, entity.bbox, entity.timeCoverage, entity.curator, entity.creators ...
26       
27        #load up all the information about parameters
28        self.categories=[]
29        self.topics=[]
30        self.terms=[]
31        self.variables=[]
32        self.parameters=[]
33        match={'Category':self.categories,'Topic':self.topics,'Term':self.terms,
34                'Variable':self.variables,'Detailed_Variable':self.parameters}
35        for level in ['Category','Topic','Term','Variable','Detailed_Variable']:
36            for item in self.elem.findall('Parameters/'+level):
37                value=item.text
38                if value not in match[level]: match[level].append(value)
39           
40        #load up information about spatial bounding box
41        self.bbox=Bounding(self.elem,entity='DIF')
42       
43        #load up information about temporal extent
44        self.timeCoverage='Start Date:%s Stop Date:%s (%s)'%(
45            wrapGetText(self.elem,'Temporal_Coverage/Start_Date'),
46            wrapGetText(self.elem,'Temporal_Coverage/Stop_Date'),
47            wrapGetText(self.elem,'Data_Set_Progress') )
48           
49        #Data curator information
50        self.centre=DIFcontact(self.elem.find('Data_Center'),ctype='centre')
51        self.curator=DIFcontact(self.elem)
52           
53        #Data Creators
54        self.creators=[]
55
56        #should create a class for the service links (i.e. similar to data granules for stubB)
57        #that would include any security info ...
58       
59        self.services=[]
60        for item in self.elem.find('Related_URL'):
61            s=Service()
62            s.name=item.find('URL_Content_Type')
63            s.description=item.find('Description')
64            s.url=item.find('URL')
65            self.services.append(s)
66           
67       
68       
69       
70       
71       
Note: See TracBrowser for help on using the repository browser.