source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19156_2011_observations_and_measurements/sampling_features/spatialsamplingfeature/sf_spatialsamplingfeature.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19156_2011_observations_and_measurements/sampling_features/spatialsamplingfeature/sf_spatialsamplingfeature.py@8457
Revision 8457, 5.9 KB checked in by mnagni, 7 years ago (diff)

Corrected an error in the generation of the classes "synchronize" method.

  • Property svn:mime-type set to text/plain
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.sampling_features.samplingfeature.sf_samplingfeature import  SF_SamplingFeature
22from ascore.utils import has_value, collectionProofHash
23
24'''
25Created on 10-Jul-2012 14:15:03
26
27@author: mnagni
28'''
29
30class SF_SpatialSamplingFeature(SF_SamplingFeature):
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._sf_samplingfeature = SF_SamplingFeature()         
43
44                self.lineage = None
45                self._positionalAccuracy_dq_griddeddatapositionalaccuracy = []
46                self._positionalAccuracy_dq_absoluteexternalpositionalaccuracy = []
47                self._positionalAccuracy_dq_relativeinternalpositionalaccuracy = []
48                self._positionalAccuracy = []
49                self._shape_gm_aggregate = None
50                self._shape_gm_primitive = None
51                self._shape_gm_complex = None
52                self._shape = None
53                self.hostedProcedure = []
54                super(SF_SpatialSamplingFeature, self).__init__()
55        @property
56        def relatedObservation(self):   
57                return self._sf_samplingfeature.relatedObservation
58
59        @relatedObservation.setter
60        def relatedObservation(self, value):   
61                        self._sf_samplingfeature.relatedObservation = value
62        @property
63        def lineage(self):     
64                return self._sf_samplingfeature.lineage
65
66        @lineage.setter
67        def lineage(self, value):       
68                        self._sf_samplingfeature.lineage = value
69        @property
70        def relatedSamplingFeature(self):       
71                return self._sf_samplingfeature.relatedSamplingFeature
72
73        @relatedSamplingFeature.setter
74        def relatedSamplingFeature(self, value):       
75                        self._sf_samplingfeature.relatedSamplingFeature = value
76        @property
77        def propertyValueProvider(self):       
78                return self._sf_samplingfeature.propertyValueProvider
79
80        @propertyValueProvider.setter
81        def propertyValueProvider(self, value):
82                        self._sf_samplingfeature.propertyValueProvider = value
83        @property
84        def positionalAccuracy(self):   
85                try:
86                        ret = []
87                        ret.extend(self._positionalAccuracy_dq_griddeddatapositionalaccuracy)
88                        ret.extend(self._positionalAccuracy_dq_absoluteexternalpositionalaccuracy)
89                        ret.extend(self._positionalAccuracy_dq_relativeinternalpositionalaccuracy)
90                        if not hasattr(self, '_positionalAccuracy'):
91                                self._positionalAccuracy = []
92                        if self._positionalAccuracy is not None:
93                                ret.extend(self._positionalAccuracy)
94                        del self._positionalAccuracy[:]
95                        self._positionalAccuracy.extend(set(ret))
96                except Exception as e:
97                        pass
98                return self._positionalAccuracy
99
100        @property
101        def sampledFeature(self):       
102                return self._sf_samplingfeature.sampledFeature
103
104        @sampledFeature.setter
105        def sampledFeature(self, value):       
106                        self._sf_samplingfeature.sampledFeature = value
107        @property
108        def sampledFeature(self):       
109                return self._sf_samplingfeature.sampledFeature
110
111        @sampledFeature.setter
112        def sampledFeature(self, value):       
113                        self._sf_samplingfeature.sampledFeature = value
114        @property
115        def shape(self):       
116                if(has_value(self._shape_gm_aggregate)):
117                        return self._shape_gm_aggregate
118                if(has_value(self._shape_gm_primitive)):
119                        return self._shape_gm_primitive
120                if(has_value(self._shape_gm_complex)):
121                        return self._shape_gm_complex
122                return  None
123
124        @shape.setter
125        def shape(self, value):
126                valueClass = "%s.%s" % (type(value).__module__,type(value).__name__)
127                if valueClass == "ea_model.iso_19107_2003_spatial_schema.geometry.geometric_aggregates.gm_aggregate.GM_Aggregate":
128                        self._shape_gm_aggregate = value
129                        self._shape_gm_primitive = None
130                        self._shape_gm_complex = None
131                if valueClass == "ea_model.iso_19107_2003_spatial_schema.geometry.geometric_primitive.gm_primitive.GM_Primitive":
132                        self._shape_gm_primitive = value
133                        self._shape_gm_aggregate = None
134                        self._shape_gm_complex = None
135                if valueClass == "ea_model.iso_19107_2003_spatial_schema.geometry.geometric_complex.gm_complex.GM_Complex":
136                        self._shape_gm_complex = value
137                        self._shape_gm_aggregate = None
138                        self._shape_gm_primitive = None
139        @property
140        def parameter(self):   
141                return self._sf_samplingfeature.parameter
142
143        @parameter.setter
144        def parameter(self, value):     
145                        self._sf_samplingfeature.parameter = value
146
147        def synchronize(self):
148                int_positionalAccuracy = self.positionalAccuracy       
149                del self._positionalAccuracy_dq_griddeddatapositionalaccuracy[:]
150                del self._positionalAccuracy_dq_absoluteexternalpositionalaccuracy[:]
151                del self._positionalAccuracy_dq_relativeinternalpositionalaccuracy[:]
152                for item in int_positionalAccuracy:     
153                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
154                        if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.data_quality_information.dq_griddeddatapositionalaccuracy.DQ_GriddedDataPositionalAccuracy":
155                                self._positionalAccuracy_dq_griddeddatapositionalaccuracy.append(item)
156                                continue
157                        if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.data_quality_information.dq_absoluteexternalpositionalaccuracy.DQ_AbsoluteExternalPositionalAccuracy":
158                                self._positionalAccuracy_dq_absoluteexternalpositionalaccuracy.append(item)
159                                continue
160                        if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.data_quality_information.dq_relativeinternalpositionalaccuracy.DQ_RelativeInternalPositionalAccuracy":
161                                self._positionalAccuracy_dq_relativeinternalpositionalaccuracy.append(item)
162                                continue
163                pass
164
165        def __key(self):
166                return (self.relatedObservation, self.lineage, self.relatedSamplingFeature, self.propertyValueProvider, self.positionalAccuracy, self.sampledFeature, self.sampledFeature, self.shape, self.hostedProcedure, self.parameter)
167
168        def __eq__(self, y):
169                if type(self) != type(y):
170                        return False
171                '''
172                Cannot compare classes which do not define a "__key" attribute
173                '''
174                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
175                        return self.__key() == y.__key()
176                return id(self) == id(y)
177
178        def __hash__(self):
179                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.