source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19111_referencing_by_coordinates/coordinate_operations/cc_generalparametervalue.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19111_referencing_by_coordinates/coordinate_operations/cc_generalparametervalue.py@8457
Revision 8457, 3.2 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:11
25
26@author: mnagni
27'''
28
29class CC_GeneralParameterValue(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.group = None
43                self._coordOperation_cc_transformation = []
44                self._coordOperation_cc_conversion = []
45                self._coordOperation = []
46                self._parameter_cc_operationparametergroup = None
47                self._parameter_cc_operationparameter = None
48                self._parameter = None
49                super(CC_GeneralParameterValue, self).__init__()
50        @property
51        def coordOperation(self):       
52                try:
53                        ret = []
54                        ret.extend(self._coordOperation_cc_transformation)
55                        ret.extend(self._coordOperation_cc_conversion)
56                        if not hasattr(self, '_coordOperation'):
57                                self._coordOperation = []
58                        if self._coordOperation is not None:
59                                ret.extend(self._coordOperation)
60                        del self._coordOperation[:]
61                        self._coordOperation.extend(set(ret))
62                except Exception as e:
63                        pass
64                return self._coordOperation
65
66        @property
67        def parameter(self):   
68                if(has_value(self._parameter_cc_operationparametergroup)):
69                        return self._parameter_cc_operationparametergroup
70                if(has_value(self._parameter_cc_operationparameter)):
71                        return self._parameter_cc_operationparameter
72                return  None
73
74        @parameter.setter
75        def parameter(self, value):     
76                valueClass = "%s.%s" % (type(value).__module__,type(value).__name__)
77                if valueClass == "ea_model.iso_19111_referencing_by_coordinates.coordinate_operations.cc_operationparametergroup.CC_OperationParameterGroup":
78                        self._parameter_cc_operationparametergroup = value
79                        self._parameter_cc_operationparameter = None
80                if valueClass == "ea_model.iso_19111_referencing_by_coordinates.coordinate_operations.cc_operationparameter.CC_OperationParameter":
81                        self._parameter_cc_operationparameter = value
82                        self._parameter_cc_operationparametergroup = None
83
84        def synchronize(self):
85                int_coordOperation = self.coordOperation       
86                del self._coordOperation_cc_transformation[:]
87                del self._coordOperation_cc_conversion[:]
88                for item in int_coordOperation:
89                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
90                        if valueClass == "ea_model.iso_19111_referencing_by_coordinates.coordinate_operations.cc_transformation.CC_Transformation":
91                                self._coordOperation_cc_transformation.append(item)
92                                continue
93                        if valueClass == "ea_model.iso_19111_referencing_by_coordinates.coordinate_operations.cc_conversion.CC_Conversion":
94                                self._coordOperation_cc_conversion.append(item)
95                                continue
96                pass
97
98        def __key(self):
99                return (self.group, self.coordOperation, self.parameter)
100
101        def __eq__(self, y):
102                if type(self) != type(y):
103                        return False
104                '''
105                Cannot compare classes which do not define a "__key" attribute
106                '''
107                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
108                        return self.__key() == y.__key()
109                return id(self) == id(y)
110
111        def __hash__(self):
112                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.