source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/informative/other_location_services/directory/di_location.py @ 8437

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/informative/other_location_services/directory/di_location.py@8437
Revision 8437, 3.2 KB checked in by mnagni, 7 years ago (diff)

Added a new function to ascore.utils in order to synchronize classes before committing to database

The following constraints has been added to the official model:

MO_ObservationCollection:member:CEDA_Observation
MO_ObservationCollection:phenomenonTime:TM_GeometricPrimitive
MO_Project:observationCollection:CEDA_ObservationCollection
MO_Observation:result:CEDA_Result
MO_Observation:inSupportOf:CEDA_Project
MO_Project:subProject:CEDA_Project
OM_Observation:procedure:CEDA_Process
OM_Observation:phenomenonTime:TM_GeometricPrimitive
MO_ResponsiblePartyFunctionValue:CEDA_RoleValue

  • 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 ea_model.informative.other_location_services.directory.di_abstractlocation import  DI_AbstractLocation
22from ascore.utils import has_value, collectionProofHash
23
24'''
25Created on 06-Jul-2012 07:43:16
26
27@author: mnagni
28'''
29
30class DI_Location(DI_AbstractLocation):
31        '''
32                Represents a data entity defined in a UML diagram and supposed to
33                be persisted in a relational database.
34 
35                This class has been genererated automatically using the Apache Velocity project.
36        '''
37        '''
38                Please note that any access to the inner attributes should be done using
39                the given get/set methods and NOT accessing them directly.
40        '''
41        def __init__(self):
42                self._di_abstractlocation = DI_AbstractLocation()       
43
44                self._position_gm_complex = None
45                self._position_gm_primitive = None
46                self._position_gm_aggregate = None
47                self._position = None
48                self._address_ad_usaddress = None
49                self._address_ad_address = None
50                self._address = None
51                super(DI_Location, self).__init__()
52        @property
53        def position(self):     
54                if(has_value(self._position_gm_complex)):
55                        return self._position_gm_complex
56                if(has_value(self._position_gm_primitive)):
57                        return self._position_gm_primitive
58                if(has_value(self._position_gm_aggregate)):
59                        return self._position_gm_aggregate
60                return  None
61
62        @position.setter
63        def position(self, value):     
64                valueClass = "%s.%s" % (type(value).__module__,type(value).__name__)
65                if valueClass == "ea_model.iso_19107_2003_spatial_schema.geometry.geometric_complex.gm_complex.GM_Complex":
66                        self._position_gm_complex = value
67                        self._position_gm_primitive = None
68                        self._position_gm_aggregate = None
69                if valueClass == "ea_model.iso_19107_2003_spatial_schema.geometry.geometric_primitive.gm_primitive.GM_Primitive":
70                        self._position_gm_primitive = value
71                        self._position_gm_complex = None
72                        self._position_gm_aggregate = None
73                if valueClass == "ea_model.iso_19107_2003_spatial_schema.geometry.geometric_aggregates.gm_aggregate.GM_Aggregate":
74                        self._position_gm_aggregate = value
75                        self._position_gm_complex = None
76                        self._position_gm_primitive = None
77        @property
78        def address(self):     
79                if(has_value(self._address_ad_usaddress)):
80                        return self._address_ad_usaddress
81                if(has_value(self._address_ad_address)):
82                        return self._address_ad_address
83                return  None
84
85        @address.setter
86        def address(self, value):       
87                valueClass = "%s.%s" % (type(value).__module__,type(value).__name__)
88                if valueClass == "ea_model.iso_19133_tracking_and_navigation.address_model.address.ad_usaddress.AD_USAddress":
89                        self._address_ad_usaddress = value
90                        self._address_ad_address = None
91                if valueClass == "ea_model.iso_19133_tracking_and_navigation.address_model.address.ad_address.AD_Address":
92                        self._address_ad_address = value
93                        self._address_ad_usaddress = None
94
95        def synchronize(self):
96                pass
97
98        def __key(self):
99                return (self.position, self.address)
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.