source: mauRepo/MolesManager/trunk/src/ea_model/moles3_4/observation/mo_observation.py @ 8160

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/ea_model/moles3_4/observation/mo_observation.py@8160
Revision 8160, 8.3 KB checked in by mnagni, 8 years ago (diff)

This new DB library adds better hash algorithm and a bug fix for the classes eq method

Line 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21from ea_model.iso_19156_2011_observations_and_measurements.observation_schema.observation.om_observation import  OM_Observation
22from ascore.utils import has_value, collectionProofHash
23
24'''
25Created on 13-Mar-2012 11:08:04
26
27@author: mnagni
28'''
29
30class MO_Observation(OM_Observation):
31    '''
32        Represents a data entity defined in a UML diagram and supposed to
33        be persisted in a relational database.
34 
35        This class has been genererated automatically using the Apache Velocity project.
36    '''
37    '''
38        Please note that any access to the inner attributes should be done using
39        the given get/set methods and NOT accessing them directly.
40    '''
41    def __init__(self):
42        self._om_observation = OM_Observation()         
43
44        self.resolution = None
45        self._geographicExtent_ex_boundingpolygon = []
46        self._geographicExtent_ex_geographicdescription = []
47        self._geographicExtent_ex_geographicboundingbox = []
48        self._procedure_ceda_processing = None
49        self._procedure_ceda_acquisition = None
50        self._procedure_ceda_compositeprocess = None
51        self.relatedParty = []
52        self._permission_md_legalconstraints = None
53        self._permission_md_securityconstraints = None
54        self.result = None
55        self.resultTime = None
56        self.verticalExtent = []
57        self._observedProperty_gf_associationrole = None
58        self._observedProperty_gf_operation = None
59        self._observedProperty_gf_attributetype = None
60        self.resultAccumulation = None
61        self.parameter = []
62        self.inSupportOf = None
63        self.metadata = None
64        self.identifier = []
65        self.publicationState = None
66        self._featureOfInterest_mo_featureofinterest = None
67        self._featureOfInterest_gfi_domainfeature = None
68        self._featureOfInterest_sf_samplingfeature = None
69        self._relatedObservation_om_complexobservation = []
70        self._relatedObservation_om_geometryobservation = []
71        self._relatedObservation_om_temporalobservation = []
72        self._relatedObservation_om_truthobservation = []
73        self._relatedObservation_om_categoryobservation = []
74        self._relatedObservation_om_measurement = []
75        self._relatedObservation_om_countobservation = []
76        self._relatedObservation_om_discretecoverageobservation = []
77        self._relatedObservation_mo_observation = []
78        self._phenomenonTime_tm_primitive = None
79        self._phenomenonTime_tm_complex = None
80        self.status = None
81        self.documentation = []
82        self._resultQuality_qe_usability = []
83        self._resultQuality_dq_positionalaccuracy = []
84        self._resultQuality_dq_logicalconsistency = []
85        self._resultQuality_dq_temporalaccuracy = []
86        self._resultQuality_dq_thematicaccuracy = []
87        self._resultQuality_dq_completeness = []
88        self.validTime = None
89        self.description = None
90        super(MO_Observation, self).__init__()
91
92    @property
93    def geographicExtent(self): 
94        ret = []
95        for item in self._geographicExtent_ex_boundingpolygon:
96            ret.append(item)
97        for item in self._geographicExtent_ex_geographicdescription:
98            ret.append(item)
99        for item in self._geographicExtent_ex_geographicboundingbox:
100            ret.append(item)
101        return ret
102
103    @geographicExtent.setter
104    def geographicExtent(self, value): 
105        if isinstance(value, list):
106            self._geographicExtent_ex_boundingpolygon[:]
107            self._geographicExtent_ex_geographicdescription[:]
108            self._geographicExtent_ex_geographicboundingbox[:]
109            for item in value:
110                valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
111                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.extent_information.ex_boundingpolygon.EX_BoundingPolygon":
112                    self._geographicExtent_ex_boundingpolygon.append(item)
113                    continue
114                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.extent_information.ex_geographicdescription.EX_GeographicDescription":
115                    self._geographicExtent_ex_geographicdescription.append(item)
116                    continue
117                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.extent_information.ex_geographicboundingbox.EX_GeographicBoundingBox":
118                    self._geographicExtent_ex_geographicboundingbox.append(item)
119                    continue
120
121    @property
122    def procedure(self):       
123        return self._om_observation.procedure
124
125    @procedure.setter
126    def procedure(self, value): 
127            self._om_observation.procedure = value
128
129    @property
130    def permission(self):       
131        if(has_value(self._permission_md_legalconstraints)):
132            return self._permission_md_legalconstraints
133        if(has_value(self._permission_md_securityconstraints)):
134            return self._permission_md_securityconstraints
135        return  None
136
137    @permission.setter
138    def permission(self, value):       
139        valueClass = "%s.%s" % (type(value).__module__,type(value).__name__)
140        if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_legalconstraints.MD_LegalConstraints":
141            self._permission_md_legalconstraints = value
142            self._permission_md_securityconstraints = None
143        if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_securityconstraints.MD_SecurityConstraints":
144            self._permission_md_securityconstraints = value
145            self._permission_md_legalconstraints = None
146
147    @property
148    def resultTime(self):       
149        return self._om_observation.resultTime
150
151    @resultTime.setter
152    def resultTime(self, value):       
153            self._om_observation.resultTime = value
154
155    @property
156    def observedProperty(self): 
157        return self._om_observation.observedProperty
158
159    @observedProperty.setter
160    def observedProperty(self, value): 
161            self._om_observation.observedProperty = value
162
163    @property
164    def parameter(self):       
165        return self._om_observation.parameter
166
167    @parameter.setter
168    def parameter(self, value): 
169            self._om_observation.parameter = value
170
171    @property
172    def metadata(self): 
173        return self._om_observation.metadata
174
175    @metadata.setter
176    def metadata(self, value): 
177            self._om_observation.metadata = value
178
179    @property
180    def featureOfInterest(self):       
181        return self._om_observation.featureOfInterest
182
183    @featureOfInterest.setter
184    def featureOfInterest(self, value): 
185            self._om_observation.featureOfInterest = value
186
187    @property
188    def relatedObservation(self):       
189        return self._om_observation.relatedObservation
190
191    @relatedObservation.setter
192    def relatedObservation(self, value):       
193            self._om_observation.relatedObservation = value
194
195    @property
196    def phenomenonTime(self):   
197        return self._om_observation.phenomenonTime
198
199    @phenomenonTime.setter
200    def phenomenonTime(self, value):   
201            self._om_observation.phenomenonTime = value
202
203    @property
204    def resultQuality(self):   
205        return self._om_observation.resultQuality
206
207    @resultQuality.setter
208    def resultQuality(self, value):     
209            self._om_observation.resultQuality = value
210
211    @property
212    def validTime(self):       
213        return self._om_observation.validTime
214
215    @validTime.setter
216    def validTime(self, value): 
217            self._om_observation.validTime = value
218
219    def __key(self):
220        return (self.resolution, self.geographicExtent, self.procedure, self.relatedParty, self.permission, self.result, self.resultTime, self.verticalExtent, self.observedProperty, self.resultAccumulation, self.parameter, self.inSupportOf, self.metadata, self.identifier, self.publicationState, self.featureOfInterest, self.relatedObservation, self.phenomenonTime, self.status, self.documentation, self.resultQuality, self.validTime, self.description)
221
222    def __eq__(self, y):
223        if type(self) != type(y):
224            return False
225        '''
226        Cannot compare classes which do not define a "__key" attribute
227        '''
228        if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
229            return self.__key() == y.__key()
230        return id(self) == id(y)
231
232    def __hash__(self):
233        return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.