source: mauRepo/MolesManager/trunk/src/ea_model/iso_19115_2006_metadata_corrigendum/metadata_entity_set_information/md_metadata.py @ 8160

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/ea_model/iso_19115_2006_metadata_corrigendum/metadata_entity_set_information/md_metadata.py@8160
Revision 8160, 12.3 KB checked in by mnagni, 8 years ago (diff)

This new DB library adds better hash algorithm and a bug fix for the classes eq method

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 13-Mar-2012 11:08:05
25
26@author: mnagni
27'''
28
29class MD_Metadata(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.dataSet = None
43        self.fileIdentifier = None
44        self._propertyType_gf_associationrole = []
45        self._propertyType_gf_operation = []
46        self._propertyType_gf_attributetype = []
47        self.applicationSchemaInfo = []
48        self.language = None
49        self.characterSet = None
50        self.metadataStandardVersion = None
51        self.dateStamp = None
52        self.referenceSystemInfo = []
53        self.hierarchyLevel = []
54        self._metadataConstraints_md_legalconstraints = []
55        self._metadataConstraints_md_securityconstraints = []
56        self.metadataStandardName = None
57        self.identificationInfo = []
58        self.distributionInfo = None
59        self.dataQualityInfo = []
60        self.metadataMaintenance = None
61        self._contentInfo_md_featurecataloguedescription = []
62        self._contentInfo_md_coveragedescription = []
63        self.hierarchyLevelName = []
64        self._featureAttribute_gf_locationalattributetype = []
65        self._featureAttribute_gf_metadataattributetype = []
66        self._featureAttribute_gf_thematicattributetype = []
67        self._featureAttribute_gf_temporalattributetype = []
68        self._featureAttribute_gf_spatialattributetype = []
69        self._featureAttribute_if_classificationattributetype = []
70        self.portrayalCatalogueInfo = []
71        self._series_ds_series = []
72        self._series_ds_initiative = []
73        self._series_ds_otheraggregate = []
74        self._spatialRepresentationInfo_md_gridspatialrepresentation = []
75        self._spatialRepresentationInfo_md_vectorspatialrepresentation = []
76        self.describes = []
77        self.parentIdentifier = None
78        self.contact = []
79        self.metadataExtensionInfo = []
80        self.featureType = []
81        super(MD_Metadata, self).__init__()
82
83    @property
84    def propertyType(self):     
85        ret = []
86        for item in self._propertyType_gf_associationrole:
87            ret.append(item)
88        for item in self._propertyType_gf_operation:
89            ret.append(item)
90        for item in self._propertyType_gf_attributetype:
91            ret.append(item)
92        return ret
93
94    @propertyType.setter
95    def propertyType(self, value):     
96        if isinstance(value, list):
97            self._propertyType_gf_associationrole[:]
98            self._propertyType_gf_operation[:]
99            self._propertyType_gf_attributetype[:]
100            for item in value:
101                valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
102                if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_associationrole.GF_AssociationRole":
103                    self._propertyType_gf_associationrole.append(item)
104                    continue
105                if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_operation.GF_Operation":
106                    self._propertyType_gf_operation.append(item)
107                    continue
108                if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_attributetype.GF_AttributeType":
109                    self._propertyType_gf_attributetype.append(item)
110                    continue
111
112    @property
113    def metadataConstraints(self):     
114        ret = []
115        for item in self._metadataConstraints_md_legalconstraints:
116            ret.append(item)
117        for item in self._metadataConstraints_md_securityconstraints:
118            ret.append(item)
119        return ret
120
121    @metadataConstraints.setter
122    def metadataConstraints(self, value):       
123        if isinstance(value, list):
124            self._metadataConstraints_md_legalconstraints[:]
125            self._metadataConstraints_md_securityconstraints[:]
126            for item in value:
127                valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
128                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_legalconstraints.MD_LegalConstraints":
129                    self._metadataConstraints_md_legalconstraints.append(item)
130                    continue
131                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.constraint_information.md_securityconstraints.MD_SecurityConstraints":
132                    self._metadataConstraints_md_securityconstraints.append(item)
133                    continue
134
135    @property
136    def contentInfo(self):     
137        ret = []
138        for item in self._contentInfo_md_featurecataloguedescription:
139            ret.append(item)
140        for item in self._contentInfo_md_coveragedescription:
141            ret.append(item)
142        return ret
143
144    @contentInfo.setter
145    def contentInfo(self, value):       
146        if isinstance(value, list):
147            self._contentInfo_md_featurecataloguedescription[:]
148            self._contentInfo_md_coveragedescription[:]
149            for item in value:
150                valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
151                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.content_information.md_featurecataloguedescription.MD_FeatureCatalogueDescription":
152                    self._contentInfo_md_featurecataloguedescription.append(item)
153                    continue
154                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.content_information.md_coveragedescription.MD_CoverageDescription":
155                    self._contentInfo_md_coveragedescription.append(item)
156                    continue
157
158    @property
159    def featureAttribute(self): 
160        ret = []
161        for item in self._featureAttribute_gf_locationalattributetype:
162            ret.append(item)
163        for item in self._featureAttribute_gf_metadataattributetype:
164            ret.append(item)
165        for item in self._featureAttribute_gf_thematicattributetype:
166            ret.append(item)
167        for item in self._featureAttribute_gf_temporalattributetype:
168            ret.append(item)
169        for item in self._featureAttribute_gf_spatialattributetype:
170            ret.append(item)
171        for item in self._featureAttribute_if_classificationattributetype:
172            ret.append(item)
173        return ret
174
175    @featureAttribute.setter
176    def featureAttribute(self, value): 
177        if isinstance(value, list):
178            self._featureAttribute_gf_locationalattributetype[:]
179            self._featureAttribute_gf_metadataattributetype[:]
180            self._featureAttribute_gf_thematicattributetype[:]
181            self._featureAttribute_gf_temporalattributetype[:]
182            self._featureAttribute_gf_spatialattributetype[:]
183            self._featureAttribute_if_classificationattributetype[:]
184            for item in value:
185                valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
186                if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_locationalattributetype.GF_LocationalAttributeType":
187                    self._featureAttribute_gf_locationalattributetype.append(item)
188                    continue
189                if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_metadataattributetype.GF_MetaDataAttributeType":
190                    self._featureAttribute_gf_metadataattributetype.append(item)
191                    continue
192                if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_thematicattributetype.GF_ThematicAttributeType":
193                    self._featureAttribute_gf_thematicattributetype.append(item)
194                    continue
195                if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_temporalattributetype.GF_TemporalAttributeType":
196                    self._featureAttribute_gf_temporalattributetype.append(item)
197                    continue
198                if valueClass == "ea_model.iso_19109_2005_application_schema.general_feature_model.gf_spatialattributetype.GF_SpatialAttributeType":
199                    self._featureAttribute_gf_spatialattributetype.append(item)
200                    continue
201                if valueClass == "ea_model.iso_19129_2009_igcd.igcd_framework.if_classificationattributetype.IF_ClassificationAttributeType":
202                    self._featureAttribute_if_classificationattributetype.append(item)
203                    continue
204
205    @property
206    def series(self):   
207        ret = []
208        for item in self._series_ds_series:
209            ret.append(item)
210        for item in self._series_ds_initiative:
211            ret.append(item)
212        for item in self._series_ds_otheraggregate:
213            ret.append(item)
214        return ret
215
216    @series.setter
217    def series(self, value):   
218        if isinstance(value, list):
219            self._series_ds_series[:]
220            self._series_ds_initiative[:]
221            self._series_ds_otheraggregate[:]
222            for item in value:
223                valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
224                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.metadata_application_information.ds_series.DS_Series":
225                    self._series_ds_series.append(item)
226                    continue
227                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.metadata_application_information.ds_initiative.DS_Initiative":
228                    self._series_ds_initiative.append(item)
229                    continue
230                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.metadata_application_information.ds_otheraggregate.DS_OtherAggregate":
231                    self._series_ds_otheraggregate.append(item)
232                    continue
233
234    @property
235    def spatialRepresentationInfo(self):       
236        ret = []
237        for item in self._spatialRepresentationInfo_md_gridspatialrepresentation:
238            ret.append(item)
239        for item in self._spatialRepresentationInfo_md_vectorspatialrepresentation:
240            ret.append(item)
241        return ret
242
243    @spatialRepresentationInfo.setter
244    def spatialRepresentationInfo(self, value): 
245        if isinstance(value, list):
246            self._spatialRepresentationInfo_md_gridspatialrepresentation[:]
247            self._spatialRepresentationInfo_md_vectorspatialrepresentation[:]
248            for item in value:
249                valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
250                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.spatial_representation_information.md_gridspatialrepresentation.MD_GridSpatialRepresentation":
251                    self._spatialRepresentationInfo_md_gridspatialrepresentation.append(item)
252                    continue
253                if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.spatial_representation_information.md_vectorspatialrepresentation.MD_VectorSpatialRepresentation":
254                    self._spatialRepresentationInfo_md_vectorspatialrepresentation.append(item)
255                    continue
256
257    def __key(self):
258        return (self.dataSet, self.fileIdentifier, self.propertyType, self.applicationSchemaInfo, self.language, self.characterSet, self.metadataStandardVersion, self.dateStamp, self.referenceSystemInfo, self.hierarchyLevel, self.metadataConstraints, self.metadataStandardName, self.identificationInfo, self.distributionInfo, self.dataQualityInfo, self.metadataMaintenance, self.contentInfo, self.hierarchyLevelName, self.featureAttribute, self.portrayalCatalogueInfo, self.series, self.spatialRepresentationInfo, self.describes, self.parentIdentifier, self.contact, self.metadataExtensionInfo, self.featureType)
259
260    def __eq__(self, y):
261        if type(self) != type(y):
262            return False
263        '''
264        Cannot compare classes which do not define a "__key" attribute
265        '''
266        if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
267            return self.__key() == y.__key()
268        return id(self) == id(y)
269
270    def __hash__(self):
271        return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.