source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19133_tracking_and_navigation/network/constraint_and_advisory/nt_constraint.py @ 8457

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19133_tracking_and_navigation/network/constraint_and_advisory/nt_constraint.py@8457
Revision 8457, 3.6 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:14:58
25
26@author: mnagni
27'''
28
29class NT_Constraint(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._coConstraint_nt_temporalconstraint = []
43                self._coConstraint_nt_vehicleconstraint = []
44                self._coConstraint_nt_laneconstraint = []
45                self._coConstraint = []
46                self.description = None
47                self._temporalValidity_tm_topologicalprimitive = None
48                self._temporalValidity_tm_geometricprimitive = None
49                self._temporalValidity = None
50                super(NT_Constraint, self).__init__()
51        @property
52        def coConstraint(self):
53                try:
54                        ret = []
55                        ret.extend(self._coConstraint_nt_temporalconstraint)
56                        ret.extend(self._coConstraint_nt_vehicleconstraint)
57                        ret.extend(self._coConstraint_nt_laneconstraint)
58                        if not hasattr(self, '_coConstraint'):
59                                self._coConstraint = []
60                        if self._coConstraint is not None:
61                                ret.extend(self._coConstraint)
62                        del self._coConstraint[:]
63                        self._coConstraint.extend(set(ret))
64                except Exception as e:
65                        pass
66                return self._coConstraint
67
68        @property
69        def temporalValidity(self):     
70                if(has_value(self._temporalValidity_tm_topologicalprimitive)):
71                        return self._temporalValidity_tm_topologicalprimitive
72                if(has_value(self._temporalValidity_tm_geometricprimitive)):
73                        return self._temporalValidity_tm_geometricprimitive
74                return  None
75
76        @temporalValidity.setter
77        def temporalValidity(self, value):     
78                valueClass = "%s.%s" % (type(value).__module__,type(value).__name__)
79                if valueClass == "ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_topologicalprimitive.TM_TopologicalPrimitive":
80                        self._temporalValidity_tm_topologicalprimitive = value
81                        self._temporalValidity_tm_geometricprimitive = None
82                if valueClass == "ea_model.iso_19108_2006_temporal_schema.temporal_objects.tm_geometricprimitive.TM_GeometricPrimitive":
83                        self._temporalValidity_tm_geometricprimitive = value
84                        self._temporalValidity_tm_topologicalprimitive = None
85
86        def synchronize(self):
87                int_coConstraint = self.coConstraint   
88                del self._coConstraint_nt_temporalconstraint[:]
89                del self._coConstraint_nt_vehicleconstraint[:]
90                del self._coConstraint_nt_laneconstraint[:]
91                for item in int_coConstraint:   
92                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
93                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_temporalconstraint.NT_TemporalConstraint":
94                                self._coConstraint_nt_temporalconstraint.append(item)
95                                continue
96                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_vehicleconstraint.NT_VehicleConstraint":
97                                self._coConstraint_nt_vehicleconstraint.append(item)
98                                continue
99                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_laneconstraint.NT_LaneConstraint":
100                                self._coConstraint_nt_laneconstraint.append(item)
101                                continue
102                pass
103
104        def __key(self):
105                return (self.coConstraint, self.description, self.temporalValidity)
106
107        def __eq__(self, y):
108                if type(self) != type(y):
109                        return False
110                '''
111                Cannot compare classes which do not define a "__key" attribute
112                '''
113                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
114                        return self.__key() == y.__key()
115                return id(self) == id(y)
116
117        def __hash__(self):
118                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.