source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19115_2006_metadata_corrigendum/data_quality_information/dq_element.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19115_2006_metadata_corrigendum/data_quality_information/dq_element.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:15:04
25
26@author: mnagni
27'''
28
29class DQ_Element(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.evaluationMethodType = None
43                self.nameOfMeasure = []
44                self.evaluationMethodDescription = None
45                self._result_qe_coverageresult = []
46                self._result_dq_quantitativeresult = []
47                self._result_dq_conformanceresult = []
48                self._result = []
49                self.evaluationProcedure = None
50                self.measureIdentification = None
51                self.dateTime = []
52                self.measureDescription = None
53                super(DQ_Element, self).__init__()
54        @property
55        def result(self):       
56                try:
57                        ret = []
58                        ret.extend(self._result_qe_coverageresult)
59                        ret.extend(self._result_dq_quantitativeresult)
60                        ret.extend(self._result_dq_conformanceresult)
61                        if not hasattr(self, '_result'):
62                                self._result = []
63                        if self._result is not None:
64                                ret.extend(self._result)
65                        del self._result[:]
66                        self._result.extend(set(ret))
67                except Exception as e:
68                        pass
69                return self._result
70
71
72        def synchronize(self):
73                int_result = self.result       
74                del self._result_qe_coverageresult[:]
75                del self._result_dq_quantitativeresult[:]
76                del self._result_dq_conformanceresult[:]
77                for item in int_result:
78                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
79                        if valueClass == "ea_model.iso_19115_2_2009_metadata___imagery.data_quality_information___imagery.qe_coverageresult.QE_CoverageResult":
80                                self._result_qe_coverageresult.append(item)
81                                continue
82                        if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.data_quality_information.dq_quantitativeresult.DQ_QuantitativeResult":
83                                self._result_dq_quantitativeresult.append(item)
84                                continue
85                        if valueClass == "ea_model.iso_19115_2006_metadata_corrigendum.data_quality_information.dq_conformanceresult.DQ_ConformanceResult":
86                                self._result_dq_conformanceresult.append(item)
87                                continue
88                pass
89
90        def __key(self):
91                return (self.evaluationMethodType, self.nameOfMeasure, self.evaluationMethodDescription, self.result, self.evaluationProcedure, self.measureIdentification, self.dateTime, self.measureDescription)
92
93        def __eq__(self, y):
94                if type(self) != type(y):
95                        return False
96                '''
97                Cannot compare classes which do not define a "__key" attribute
98                '''
99                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
100                        return self.__key() == y.__key()
101                return id(self) == id(y)
102
103        def __hash__(self):
104                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.