source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19130_sensor_data/parameter_model/sd_sensorparameters.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19130_sensor_data/parameter_model/sd_sensorparameters.py@8457
Revision 8457, 2.5 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:06
25
26@author: mnagni
27'''
28
29class SD_SensorParameters(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._distortionCorrection_sd_distortion = []
43                self._distortionCorrection_sd_decentering = []
44                self._distortionCorrection = []
45                self.positionAndOrientation = []
46                self.identifiedBy = None
47                self.operationalMode = None
48                self.referenceTime = None
49                self.covariance = []
50                self.optics = []
51                super(SD_SensorParameters, self).__init__()
52        @property
53        def distortionCorrection(self):
54                try:
55                        ret = []
56                        ret.extend(self._distortionCorrection_sd_distortion)
57                        ret.extend(self._distortionCorrection_sd_decentering)
58                        if not hasattr(self, '_distortionCorrection'):
59                                self._distortionCorrection = []
60                        if self._distortionCorrection is not None:
61                                ret.extend(self._distortionCorrection)
62                        del self._distortionCorrection[:]
63                        self._distortionCorrection.extend(set(ret))
64                except Exception as e:
65                        pass
66                return self._distortionCorrection
67
68
69        def synchronize(self):
70                int_distortionCorrection = self.distortionCorrection   
71                del self._distortionCorrection_sd_distortion[:]
72                del self._distortionCorrection_sd_decentering[:]
73                for item in int_distortionCorrection:   
74                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
75                        if valueClass == "ea_model.iso_19130_sensor_data.sensor_model.sd_distortion.SD_Distortion":
76                                self._distortionCorrection_sd_distortion.append(item)
77                                continue
78                        if valueClass == "ea_model.iso_19130_sensor_data.sensor_model.sd_decentering.SD_Decentering":
79                                self._distortionCorrection_sd_decentering.append(item)
80                                continue
81                pass
82
83        def __key(self):
84                return (self.distortionCorrection, self.positionAndOrientation, self.identifiedBy, self.operationalMode, self.referenceTime, self.covariance, self.optics)
85
86        def __eq__(self, y):
87                if type(self) != type(y):
88                        return False
89                '''
90                Cannot compare classes which do not define a "__key" attribute
91                '''
92                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
93                        return self.__key() == y.__key()
94                return id(self) == id(y)
95
96        def __hash__(self):
97                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.