source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19109_2005_application_schema/general_feature_model/gf_featuretype.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19109_2005_application_schema/general_feature_model/gf_featuretype.py@8457
Revision 8457, 4.6 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:08
25
26@author: mnagni
27'''
28
29class GF_FeatureType(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._carrierOfCharacteristics_gf_attributetype = []
43                self._carrierOfCharacteristics_gf_operation = []
44                self._carrierOfCharacteristics_gf_associationrole = []
45                self._carrierOfCharacteristics = []
46                self.theGF_InheritanceRelation = []
47                self._linkBetween_gf_aggregationtype = []
48                self._linkBetween_gf_spatialassociationtype = []
49                self._linkBetween_gf_temporalassociationtype = []
50                self._linkBetween = []
51                self.featureTypeMetadata = []
52                self.typeName = None
53                self.isAbstract = None
54                self.constrainedBy = []
55                self.definition = None
56                super(GF_FeatureType, self).__init__()
57        @property
58        def carrierOfCharacteristics(self):     
59                try:
60                        ret = []
61                        ret.extend(self._carrierOfCharacteristics_gf_attributetype)
62                        ret.extend(self._carrierOfCharacteristics_gf_operation)
63                        ret.extend(self._carrierOfCharacteristics_gf_associationrole)
64                        if not hasattr(self, '_carrierOfCharacteristics'):
65                                self._carrierOfCharacteristics = []
66                        if self._carrierOfCharacteristics is not None:
67                                ret.extend(self._carrierOfCharacteristics)
68                        del self._carrierOfCharacteristics[:]
69                        self._carrierOfCharacteristics.extend(set(ret))
70                except Exception as e:
71                        pass
72                return self._carrierOfCharacteristics
73
74        @property
75        def linkBetween(self): 
76                try:
77                        ret = []
78                        ret.extend(self._linkBetween_gf_aggregationtype)
79                        ret.extend(self._linkBetween_gf_spatialassociationtype)
80                        ret.extend(self._linkBetween_gf_temporalassociationtype)
81                        if not hasattr(self, '_linkBetween'):
82                                self._linkBetween = []
83                        if self._linkBetween is not None:
84                                ret.extend(self._linkBetween)
85                        del self._linkBetween[:]
86                        self._linkBetween.extend(set(ret))
87                except Exception as e:
88                        pass
89                return self._linkBetween
90
91
92        def synchronize(self):
93                int_carrierOfCharacteristics = self.carrierOfCharacteristics   
94                del self._carrierOfCharacteristics_gf_attributetype[:]
95                del self._carrierOfCharacteristics_gf_operation[:]
96                del self._carrierOfCharacteristics_gf_associationrole[:]
97                int_linkBetween = self.linkBetween     
98                del self._linkBetween_gf_aggregationtype[:]
99                del self._linkBetween_gf_spatialassociationtype[:]
100                del self._linkBetween_gf_temporalassociationtype[:]
101                for item in int_carrierOfCharacteristics:       
102                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
103                        if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_attributetype.GF_AttributeType":
104                                self._carrierOfCharacteristics_gf_attributetype.append(item)
105                                continue
106                        if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_operation.GF_Operation":
107                                self._carrierOfCharacteristics_gf_operation.append(item)
108                                continue
109                        if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_associationrole.GF_AssociationRole":
110                                self._carrierOfCharacteristics_gf_associationrole.append(item)
111                                continue
112                for item in int_linkBetween:   
113                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
114                        if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_aggregationtype.GF_AggregationType":
115                                self._linkBetween_gf_aggregationtype.append(item)
116                                continue
117                        if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_spatialassociationtype.GF_SpatialAssociationType":
118                                self._linkBetween_gf_spatialassociationtype.append(item)
119                                continue
120                        if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_temporalassociationtype.GF_TemporalAssociationType":
121                                self._linkBetween_gf_temporalassociationtype.append(item)
122                                continue
123                pass
124
125        def __key(self):
126                return (self.carrierOfCharacteristics, self.theGF_InheritanceRelation, self.linkBetween, self.featureTypeMetadata, self.typeName, self.isAbstract, self.constrainedBy, self.definition)
127
128        def __eq__(self, y):
129                if type(self) != type(y):
130                        return False
131                '''
132                Cannot compare classes which do not define a "__key" attribute
133                '''
134                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
135                        return self.__key() == y.__key()
136                return id(self) == id(y)
137
138        def __hash__(self):
139                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.