source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/informative/spatial_examples_from_iso_19107/application_schema/topology_simple/simple_topology/ts_theme.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/informative/spatial_examples_from_iso_19107/application_schema/topology_simple/simple_topology/ts_theme.py@8457
Revision 8457, 2.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:14:57
25
26@author: mnagni
27'''
28
29class TS_Theme(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._element_ts_surfacecomponent = []
43                self._element_ts_curvecomponent = []
44                self._element_ts_pointcomponent = []
45                self._element_ft_primitive = []
46                self._element = []
47                super(TS_Theme, self).__init__()
48        @property
49        def element(self):     
50                try:
51                        ret = []
52                        ret.extend(self._element_ts_surfacecomponent)
53                        ret.extend(self._element_ts_curvecomponent)
54                        ret.extend(self._element_ts_pointcomponent)
55                        ret.extend(self._element_ft_primitive)
56                        if not hasattr(self, '_element'):
57                                self._element = []
58                        if self._element is not None:
59                                ret.extend(self._element)
60                        del self._element[:]
61                        self._element.extend(set(ret))
62                except Exception as e:
63                        pass
64                return self._element
65
66
67        def synchronize(self):
68                int_element = self.element     
69                del self._element_ts_surfacecomponent[:]
70                del self._element_ts_curvecomponent[:]
71                del self._element_ts_pointcomponent[:]
72                del self._element_ft_primitive[:]
73                for item in int_element:       
74                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
75                        if valueClass == "ea_model.informative.spatial_examples_from_iso_19107.application_schema.topology_simple.simple_topology.ts_surfacecomponent.TS_SurfaceComponent":
76                                self._element_ts_surfacecomponent.append(item)
77                                continue
78                        if valueClass == "ea_model.informative.spatial_examples_from_iso_19107.application_schema.topology_simple.simple_topology.ts_curvecomponent.TS_CurveComponent":
79                                self._element_ts_curvecomponent.append(item)
80                                continue
81                        if valueClass == "ea_model.informative.spatial_examples_from_iso_19107.application_schema.topology_simple.simple_topology.ts_pointcomponent.TS_PointComponent":
82                                self._element_ts_pointcomponent.append(item)
83                                continue
84                        if valueClass == "ea_model.informative.spatial_examples_from_iso_19107.application_schema.topology_simple.feature_topology.ft_primitive.FT_Primitive":
85                                self._element_ft_primitive.append(item)
86                                continue
87                pass
88
89        def __key(self):
90                return (self.element)
91
92        def __eq__(self, y):
93                if type(self) != type(y):
94                        return False
95                '''
96                Cannot compare classes which do not define a "__key" attribute
97                '''
98                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
99                        return self.__key() == y.__key()
100                return id(self) == id(y)
101
102        def __hash__(self):
103                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.