source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/informative/iso_gdf/gdf_feature/gdf_featureclass.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_featureclass.py@8457
Revision 8457, 3.7 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:07
25
26@author: mnagni
27'''
28
29class GDF_FeatureClass(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.name = None
43                self._belongsTo_gdf_complexfeature = []
44                self._belongsTo_gdf_simplefeature = []
45                self._belongsTo = []
46                self.code = None
47                self._character_gdf_restrictedsubattributetype = None
48                self._character_gdf_complexattributetype = None
49                self._character_gdf_simpleattributetype = None
50                self._character = None
51                self.theme = None
52                self.represents = []
53                super(GDF_FeatureClass, self).__init__()
54        @property
55        def belongsTo(self):   
56                try:
57                        ret = []
58                        ret.extend(self._belongsTo_gdf_complexfeature)
59                        ret.extend(self._belongsTo_gdf_simplefeature)
60                        if not hasattr(self, '_belongsTo'):
61                                self._belongsTo = []
62                        if self._belongsTo is not None:
63                                ret.extend(self._belongsTo)
64                        del self._belongsTo[:]
65                        self._belongsTo.extend(set(ret))
66                except Exception as e:
67                        pass
68                return self._belongsTo
69
70        @property
71        def character(self):   
72                if(has_value(self._character_gdf_restrictedsubattributetype)):
73                        return self._character_gdf_restrictedsubattributetype
74                if(has_value(self._character_gdf_complexattributetype)):
75                        return self._character_gdf_complexattributetype
76                if(has_value(self._character_gdf_simpleattributetype)):
77                        return self._character_gdf_simpleattributetype
78                return  None
79
80        @character.setter
81        def character(self, value):     
82                valueClass = "%s.%s" % (type(value).__module__,type(value).__name__)
83                if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_restrictedsubattributetype.GDF_RestrictedSubAttributeType":
84                        self._character_gdf_restrictedsubattributetype = value
85                        self._character_gdf_complexattributetype = None
86                        self._character_gdf_simpleattributetype = None
87                if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_complexattributetype.GDF_ComplexAttributeType":
88                        self._character_gdf_complexattributetype = value
89                        self._character_gdf_restrictedsubattributetype = None
90                        self._character_gdf_simpleattributetype = None
91                if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_simpleattributetype.GDF_SimpleAttributeType":
92                        self._character_gdf_simpleattributetype = value
93                        self._character_gdf_restrictedsubattributetype = None
94                        self._character_gdf_complexattributetype = None
95
96        def synchronize(self):
97                int_belongsTo = self.belongsTo 
98                del self._belongsTo_gdf_complexfeature[:]
99                del self._belongsTo_gdf_simplefeature[:]
100                for item in int_belongsTo:     
101                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
102                        if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_complexfeature.GDF_ComplexFeature":
103                                self._belongsTo_gdf_complexfeature.append(item)
104                                continue
105                        if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_simplefeature.GDF_SimpleFeature":
106                                self._belongsTo_gdf_simplefeature.append(item)
107                                continue
108                pass
109
110        def __key(self):
111                return (self.name, self.belongsTo, self.code, self.character, self.theme, self.represents)
112
113        def __eq__(self, y):
114                if type(self) != type(y):
115                        return False
116                '''
117                Cannot compare classes which do not define a "__key" attribute
118                '''
119                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
120                        return self.__key() == y.__key()
121                return id(self) == id(y)
122
123        def __hash__(self):
124                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.