source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/informative/iso_gdf/gdf_feature/gdf_layer.py @ 8437

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/informative/iso_gdf/gdf_feature/gdf_layer.py@8437
Revision 8437, 3.9 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 ascore.utils import has_value, collectionProofHash
22
23'''
24Created on 06-Jul-2012 07:43:11
25
26@author: mnagni
27'''
28
29class GDF_Layer(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._topology_gdf_node = []
43                self._topology_gdf_face = []
44                self._topology_gdf_edge = []
45                self._topology = []
46                self._geometricFeature_gdf_areafeature = []
47                self._geometricFeature_gdf_pointfeature = []
48                self._geometricFeature_gdf_linefeature = []
49                self._geometricFeature = []
50                self.id = None
51                self.topologyType = None
52                super(GDF_Layer, self).__init__()
53        @property
54        def topology(self):     
55                try:
56                        ret = []
57                        ret.extend(self._topology_gdf_node)
58                        ret.extend(self._topology_gdf_face)
59                        ret.extend(self._topology_gdf_edge)
60                        if not hasattr(self, '_topology'):
61                                self._topology = []
62                        if self._topology is not None:
63                                ret.extend(self._topology)
64                        del self._topology[:]
65                        self._topology.extend(set(ret))
66                except Exception as e:
67                        pass
68                return self._topology
69
70        @property
71        def geometricFeature(self):     
72                try:
73                        ret = []
74                        ret.extend(self._geometricFeature_gdf_areafeature)
75                        ret.extend(self._geometricFeature_gdf_pointfeature)
76                        ret.extend(self._geometricFeature_gdf_linefeature)
77                        if not hasattr(self, '_geometricFeature'):
78                                self._geometricFeature = []
79                        if self._geometricFeature is not None:
80                                ret.extend(self._geometricFeature)
81                        del self._geometricFeature[:]
82                        self._geometricFeature.extend(set(ret))
83                except Exception as e:
84                        pass
85                return self._geometricFeature
86
87
88        def synchronize(self):
89                del self._topology_gdf_node[:]
90                del self._topology_gdf_face[:]
91                del self._topology_gdf_edge[:]
92                del self._geometricFeature_gdf_areafeature[:]
93                del self._geometricFeature_gdf_pointfeature[:]
94                del self._geometricFeature_gdf_linefeature[:]
95                for item in self.topology:     
96                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
97                        if valueClass == "ea_model.informative.iso_gdf.gdf_topology.gdf_node.GDF_Node":
98                                self._topology_gdf_node.append(item)
99                                continue
100                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
101                        if valueClass == "ea_model.informative.iso_gdf.gdf_topology.gdf_face.GDF_Face":
102                                self._topology_gdf_face.append(item)
103                                continue
104                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
105                        if valueClass == "ea_model.informative.iso_gdf.gdf_topology.gdf_edge.GDF_Edge":
106                                self._topology_gdf_edge.append(item)
107                                continue
108                for item in self.geometricFeature:     
109                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
110                        if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_areafeature.GDF_AreaFeature":
111                                self._geometricFeature_gdf_areafeature.append(item)
112                                continue
113                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
114                        if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_pointfeature.GDF_PointFeature":
115                                self._geometricFeature_gdf_pointfeature.append(item)
116                                continue
117                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
118                        if valueClass == "ea_model.informative.iso_gdf.gdf_feature.gdf_linefeature.GDF_LineFeature":
119                                self._geometricFeature_gdf_linefeature.append(item)
120                                continue
121                pass
122
123        def __key(self):
124                return (self.topology, self.geometricFeature, self.id, self.topologyType)
125
126        def __eq__(self, y):
127                if type(self) != type(y):
128                        return False
129                '''
130                Cannot compare classes which do not define a "__key" attribute
131                '''
132                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
133                        return self.__key() == y.__key()
134                return id(self) == id(y)
135
136        def __hash__(self):
137                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.