source: TI02-CSML/trunk/parser/API/ops_Dataset.py @ 1170

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI02-CSML/trunk/parser/API/ops_Dataset.py@1170
Revision 1170, 1.7 KB checked in by domlowe, 14 years ago (diff)

Added !getSecurity method to CSML API

Line 
1''' ops_Dataset  contains operations for root Dataset class'''
2from API import *
3
4def testmethod(self):
5    print 'testmethod for dataset'
6    return 'testmethod dataset'
7
8def parse(self,csmlfile):
9        """must be provided with csmlfile
10        parses the csmlfile into self """
11        tree = ElementTree(file=csmlfile)
12        self.fromXML(tree.getroot())
13        self =parser_extra.ParserPostProcessor(self).resolveReferences()
14
15def getSecurity(self):
16    """ returns a dictonary containing attributeAuthority: role"""
17    security=[]
18    if hasattr(self, 'accessControlPolicy'):
19        if hasattr(self.accessControlPolicy,'dgSecurityConditions'):
20            for condition in self.accessControlPolicy.dgSecurityConditions:
21                print dir(condition)
22                #need to test for these but ok for alpha.
23                cond=[]
24                cond.append(condition.effect)
25                cond.append(condition.simpleCondition.dgAttributeAuthority)
26                cond.append(condition.simpleCondition.attrauthRole)
27                cond.append(condition.conditionExplanationText)
28                security.append(cond)
29    return security
30
31def getFeatureList(self):
32    #returns a list of feature ids for the dataset
33    self.featureList = []
34    for member in self.featureCollection.members:
35            self.featureList.append(member.id)
36    return self.featureList
37   
38def getFeature(self, featureID):
39    """ returns a single feature object """
40    for member in self.featureCollection.members:
41            if member.id == featureID:
42                return member   
43
44def getFileExtract(self,extractID):
45        for extract in self.dataset.arrayDescriptors:
46            if  extract.id==extractID:
47                return extract
Note: See TracBrowser for help on using the repository browser.