source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/informative/iso_gdf/gdf_feature/gdf_complexfeature.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/informative/iso_gdf/gdf_feature/gdf_complexfeature.py@8457
Revision 8457, 3.4 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.informative.iso_gdf.gdf_feature.gdf_feature import  GDF_Feature
22from ascore.utils import has_value, collectionProofHash
23
24'''
25Created on 10-Jul-2012 14:15:05
26
27@author: mnagni
28'''
29
30class GDF_ComplexFeature(GDF_Feature):
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._gdf_feature = GDF_Feature()       
43
44                self.attribute = None
45                self.id = None
46                self.bounds = []
47                self.category = None
48                self.boundary = None
49                self._subfeature_gdf_complexfeature = []
50                self._subfeature_gdf_simplefeature = []
51                self._subfeature = []
52                self.class_ = None
53                super(GDF_ComplexFeature, self).__init__()
54        @property
55        def attribute(self):   
56                return self._gdf_feature.attribute
57
58        @attribute.setter
59        def attribute(self, value):     
60                        self._gdf_feature.attribute = value
61        @property
62        def theGDF_SemanticRelationship(self): 
63                return self._gdf_feature.theGDF_SemanticRelationship
64
65        @theGDF_SemanticRelationship.setter
66        def theGDF_SemanticRelationship(self, value):   
67                        self._gdf_feature.theGDF_SemanticRelationship = value
68        @property
69        def id(self):   
70                return self._gdf_feature.id
71
72        @id.setter
73        def id(self, value):   
74                        self._gdf_feature.id = value
75        @property
76        def category(self):     
77                return self._gdf_feature.category
78
79        @category.setter
80        def category(self, value):     
81                        self._gdf_feature.category = value
82        @property
83        def container(self):   
84                return self._gdf_feature.container
85
86        @container.setter
87        def container(self, value):     
88                        self._gdf_feature.container = value
89        @property
90        def subfeature(self):   
91                try:
92                        ret = []
93                        ret.extend(self._subfeature_gdf_complexfeature)
94                        ret.extend(self._subfeature_gdf_simplefeature)
95                        if not hasattr(self, '_subfeature'):
96                                self._subfeature = []
97                        if self._subfeature is not None:
98                                ret.extend(self._subfeature)
99                        del self._subfeature[:]
100                        self._subfeature.extend(set(ret))
101                except Exception as e:
102                        pass
103                return self._subfeature
104
105        @property
106        def class_(self):       
107                return self._gdf_feature.class_
108
109        @class_.setter
110        def class_(self, value):       
111                        self._gdf_feature.class_ = value
112
113        def synchronize(self):
114                int_subfeature = self.subfeature       
115                del self._subfeature_gdf_complexfeature[:]
116                del self._subfeature_gdf_simplefeature[:]
117                for item in int_subfeature:     
118                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
119                        if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_complexfeature.GDF_ComplexFeature":
120                                self._subfeature_gdf_complexfeature.append(item)
121                                continue
122                        if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_simplefeature.GDF_SimpleFeature":
123                                self._subfeature_gdf_simplefeature.append(item)
124                                continue
125                pass
126
127        def __key(self):
128                return (self.attribute, self.theGDF_SemanticRelationship, self.id, self.bounds, self.category, self.container, self.boundary, self.subfeature, self.class_)
129
130        def __eq__(self, y):
131                if type(self) != type(y):
132                        return False
133                '''
134                Cannot compare classes which do not define a "__key" attribute
135                '''
136                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
137                        return self.__key() == y.__key()
138                return id(self) == id(y)
139
140        def __hash__(self):
141                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.