source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19123_2005_coverages/coverages/coverage_core/cv_geometryvaluepair.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19123_2005_coverages/coverages/coverage_core/cv_geometryvaluepair.py@8457
Revision 8457, 5.8 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 ascore.utils import has_value, collectionProofHash
22
23'''
24Created on 10-Jul-2012 14:15:10
25
26@author: mnagni
27'''
28
29class CV_GeometryValuePair(object):
30        '''
31                Represents a data entity defined in a UML diagram and supposed to
32                be persisted in a relational database.
33 
34                This class has been genererated automatically using the Apache Velocity project.
35        '''
36        '''
37                Please note that any access to the inner attributes should be done using
38                the given get/set methods and NOT accessing them directly.
39        '''
40        def __init__(self):
41
42                self._collection_cvt_discretetimeinstantcoverage = []
43                self._collection_cv_discretesolidcoverage = []
44                self._collection_cv_discretecurvecoverage = []
45                self._collection_cv_discretesurfacecoverage = []
46                self._collection_cv_discretepointcoverage = []
47                self._collection_cv_discretegridpointcoverage = []
48                self._collection = []
49                self.value = None
50                self.geometry = None
51                self._extension_cv_valuehexagon = []
52                self._extension_cv_thiessenvaluepolygon = []
53                self._extension_cv_valuetriangle = []
54                self._extension_cv_valuecurve = []
55                self._extension_cv_gridvaluecell = []
56                self._extension = []
57                super(CV_GeometryValuePair, self).__init__()
58        @property
59        def collection(self):   
60                try:
61                        ret = []
62                        ret.extend(self._collection_cvt_discretetimeinstantcoverage)
63                        ret.extend(self._collection_cv_discretesolidcoverage)
64                        ret.extend(self._collection_cv_discretecurvecoverage)
65                        ret.extend(self._collection_cv_discretesurfacecoverage)
66                        ret.extend(self._collection_cv_discretepointcoverage)
67                        ret.extend(self._collection_cv_discretegridpointcoverage)
68                        if not hasattr(self, '_collection'):
69                                self._collection = []
70                        if self._collection is not None:
71                                ret.extend(self._collection)
72                        del self._collection[:]
73                        self._collection.extend(set(ret))
74                except Exception as e:
75                        pass
76                return self._collection
77
78        @property
79        def extension(self):   
80                try:
81                        ret = []
82                        ret.extend(self._extension_cv_valuehexagon)
83                        ret.extend(self._extension_cv_thiessenvaluepolygon)
84                        ret.extend(self._extension_cv_valuetriangle)
85                        ret.extend(self._extension_cv_valuecurve)
86                        ret.extend(self._extension_cv_gridvaluecell)
87                        if not hasattr(self, '_extension'):
88                                self._extension = []
89                        if self._extension is not None:
90                                ret.extend(self._extension)
91                        del self._extension[:]
92                        self._extension.extend(set(ret))
93                except Exception as e:
94                        pass
95                return self._extension
96
97
98        def synchronize(self):
99                int_collection = self.collection       
100                del self._collection_cvt_discretetimeinstantcoverage[:]
101                del self._collection_cv_discretesolidcoverage[:]
102                del self._collection_cv_discretecurvecoverage[:]
103                del self._collection_cv_discretesurfacecoverage[:]
104                del self._collection_cv_discretepointcoverage[:]
105                del self._collection_cv_discretegridpointcoverage[:]
106                int_extension = self.extension 
107                del self._extension_cv_valuehexagon[:]
108                del self._extension_cv_thiessenvaluepolygon[:]
109                del self._extension_cv_valuetriangle[:]
110                del self._extension_cv_valuecurve[:]
111                del self._extension_cv_gridvaluecell[:]
112                for item in int_collection:     
113                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
114                        if valueClass == "ea_model.iso_19156_2011_observations_and_measurements.temporal_coverage.cvt_discretetimeinstantcoverage.CVT_DiscreteTimeInstantCoverage":
115                                self._collection_cvt_discretetimeinstantcoverage.append(item)
116                                continue
117                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretesolidcoverage.CV_DiscreteSolidCoverage":
118                                self._collection_cv_discretesolidcoverage.append(item)
119                                continue
120                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretecurvecoverage.CV_DiscreteCurveCoverage":
121                                self._collection_cv_discretecurvecoverage.append(item)
122                                continue
123                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretesurfacecoverage.CV_DiscreteSurfaceCoverage":
124                                self._collection_cv_discretesurfacecoverage.append(item)
125                                continue
126                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretepointcoverage.CV_DiscretePointCoverage":
127                                self._collection_cv_discretepointcoverage.append(item)
128                                continue
129                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.discrete_coverages.cv_discretegridpointcoverage.CV_DiscreteGridPointCoverage":
130                                self._collection_cv_discretegridpointcoverage.append(item)
131                                continue
132                for item in int_extension:     
133                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
134                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.hexagonal_grid.cv_valuehexagon.CV_ValueHexagon":
135                                self._extension_cv_valuehexagon.append(item)
136                                continue
137                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.thiessen_polygon.cv_thiessenvaluepolygon.CV_ThiessenValuePolygon":
138                                self._extension_cv_thiessenvaluepolygon.append(item)
139                                continue
140                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.tin.cv_valuetriangle.CV_ValueTriangle":
141                                self._extension_cv_valuetriangle.append(item)
142                                continue
143                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.segmented_curve.cv_valuecurve.CV_ValueCurve":
144                                self._extension_cv_valuecurve.append(item)
145                                continue
146                        if valueClass == "ea_model.iso_19123_2005_coverages.coverages.quadrilateral_grid.cv_gridvaluecell.CV_GridValueCell":
147                                self._extension_cv_gridvaluecell.append(item)
148                                continue
149                pass
150
151        def __key(self):
152                return (self.collection, self.value, self.geometry, self.extension)
153
154        def __eq__(self, y):
155                if type(self) != type(y):
156                        return False
157                '''
158                Cannot compare classes which do not define a "__key" attribute
159                '''
160                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
161                        return self.__key() == y.__key()
162                return id(self) == id(y)
163
164        def __hash__(self):
165                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.