source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19133_tracking_and_navigation/network/turn_and_junction/nt_turn.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/turn_and_junction/nt_turn.py@8457
Revision 8457, 2.9 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:10
25
26@author: mnagni
27'''
28
29class NT_Turn(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._constraint_nt_temporalconstraint = []
43                self._constraint_nt_vehicleconstraint = []
44                self._constraint_nt_laneconstraint = []
45                self._constraint = []
46                self.entryCount = None
47                self.advisory = []
48                self.toLink = None
49                self.junction = None
50                self.costedTurn = []
51                self.exitCount = None
52                self.maneuver = []
53                self.turnDirection = None
54                self.isManuever = None
55                self.isTraversable = None
56                self.fromLink = None
57                super(NT_Turn, self).__init__()
58        @property
59        def constraint(self):   
60                try:
61                        ret = []
62                        ret.extend(self._constraint_nt_temporalconstraint)
63                        ret.extend(self._constraint_nt_vehicleconstraint)
64                        ret.extend(self._constraint_nt_laneconstraint)
65                        if not hasattr(self, '_constraint'):
66                                self._constraint = []
67                        if self._constraint is not None:
68                                ret.extend(self._constraint)
69                        del self._constraint[:]
70                        self._constraint.extend(set(ret))
71                except Exception as e:
72                        pass
73                return self._constraint
74
75
76        def synchronize(self):
77                int_constraint = self.constraint       
78                del self._constraint_nt_temporalconstraint[:]
79                del self._constraint_nt_vehicleconstraint[:]
80                del self._constraint_nt_laneconstraint[:]
81                for item in int_constraint:     
82                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
83                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_temporalconstraint.NT_TemporalConstraint":
84                                self._constraint_nt_temporalconstraint.append(item)
85                                continue
86                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_vehicleconstraint.NT_VehicleConstraint":
87                                self._constraint_nt_vehicleconstraint.append(item)
88                                continue
89                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_laneconstraint.NT_LaneConstraint":
90                                self._constraint_nt_laneconstraint.append(item)
91                                continue
92                pass
93
94        def __key(self):
95                return (self.constraint, self.entryCount, self.advisory, self.toLink, self.junction, self.costedTurn, self.exitCount, self.maneuver, self.turnDirection, self.isManuever, self.isTraversable, self.fromLink)
96
97        def __eq__(self, y):
98                if type(self) != type(y):
99                        return False
100                '''
101                Cannot compare classes which do not define a "__key" attribute
102                '''
103                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
104                        return self.__key() == y.__key()
105                return id(self) == id(y)
106
107        def __hash__(self):
108                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.