source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19107_2003_spatial_schema/geometry/geometric_aggregates/gm_aggregate.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19107_2003_spatial_schema/geometry/geometric_aggregates/gm_aggregate.py@8457
Revision 8457, 2.5 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_19107_2003_spatial_schema.geometry.geometry_root.gm_object import  GM_Object
22from ascore.utils import has_value, collectionProofHash
23
24'''
25Created on 10-Jul-2012 14:15:04
26
27@author: mnagni
28'''
29
30class GM_Aggregate(GM_Object):
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._gm_object = GM_Object()   
43
44                self.CRS = None
45                self._element_gm_aggregate = []
46                self._element_gm_primitive = []
47                self._element_gm_complex = []
48                self._element = []
49                super(GM_Aggregate, self).__init__()
50        @property
51        def CRS(self): 
52                return self._gm_object.CRS
53
54        @CRS.setter
55        def CRS(self, value):   
56                        self._gm_object.CRS = value
57        @property
58        def element(self):     
59                try:
60                        ret = []
61                        ret.extend(self._element_gm_aggregate)
62                        ret.extend(self._element_gm_primitive)
63                        ret.extend(self._element_gm_complex)
64                        if not hasattr(self, '_element'):
65                                self._element = []
66                        if self._element is not None:
67                                ret.extend(self._element)
68                        del self._element[:]
69                        self._element.extend(set(ret))
70                except Exception as e:
71                        pass
72                return self._element
73
74
75        def synchronize(self):
76                int_element = self.element     
77                del self._element_gm_aggregate[:]
78                del self._element_gm_primitive[:]
79                del self._element_gm_complex[:]
80                for item in int_element:       
81                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
82                        if valueClass == "ea_model.iso_19107_2003_spatial_schema.geometry.geometric_aggregates.gm_aggregate.GM_Aggregate":
83                                self._element_gm_aggregate.append(item)
84                                continue
85                        if valueClass == "ea_model.iso_19107_2003_spatial_schema.geometry.geometric_primitive.gm_primitive.GM_Primitive":
86                                self._element_gm_primitive.append(item)
87                                continue
88                        if valueClass == "ea_model.iso_19107_2003_spatial_schema.geometry.geometric_complex.gm_complex.GM_Complex":
89                                self._element_gm_complex.append(item)
90                                continue
91                pass
92
93        def __key(self):
94                return (self.CRS, self.element)
95
96        def __eq__(self, y):
97                if type(self) != type(y):
98                        return False
99                '''
100                Cannot compare classes which do not define a "__key" attribute
101                '''
102                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
103                        return self.__key() == y.__key()
104                return id(self) == id(y)
105
106        def __hash__(self):
107                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.