source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19133_tracking_and_navigation/network/constraint_and_advisory/nt_advisory.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_advisory.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:07
25
26@author: mnagni
27'''
28
29class NT_Advisory(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.category = None
43                self._element_nt_advisoryspatialrelation = []
44                self._element_nt_exitassociation = []
45                self._element_nt_advisorydistance = []
46                self._element_nt_advisorydirection = []
47                self._element = []
48                self.description = None
49                super(NT_Advisory, self).__init__()
50        @property
51        def element(self):     
52                try:
53                        ret = []
54                        ret.extend(self._element_nt_advisoryspatialrelation)
55                        ret.extend(self._element_nt_exitassociation)
56                        ret.extend(self._element_nt_advisorydistance)
57                        ret.extend(self._element_nt_advisorydirection)
58                        if not hasattr(self, '_element'):
59                                self._element = []
60                        if self._element is not None:
61                                ret.extend(self._element)
62                        del self._element[:]
63                        self._element.extend(set(ret))
64                except Exception as e:
65                        pass
66                return self._element
67
68
69        def synchronize(self):
70                int_element = self.element     
71                del self._element_nt_advisoryspatialrelation[:]
72                del self._element_nt_exitassociation[:]
73                del self._element_nt_advisorydistance[:]
74                del self._element_nt_advisorydirection[:]
75                for item in int_element:       
76                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
77                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_advisoryspatialrelation.NT_AdvisorySpatialRelation":
78                                self._element_nt_advisoryspatialrelation.append(item)
79                                continue
80                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_exitassociation.NT_ExitAssociation":
81                                self._element_nt_exitassociation.append(item)
82                                continue
83                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_advisorydistance.NT_AdvisoryDistance":
84                                self._element_nt_advisorydistance.append(item)
85                                continue
86                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.constraint_and_advisory.nt_advisorydirection.NT_AdvisoryDirection":
87                                self._element_nt_advisorydirection.append(item)
88                                continue
89                pass
90
91        def __key(self):
92                return (self.category, self.element, self.description)
93
94        def __eq__(self, y):
95                if type(self) != type(y):
96                        return False
97                '''
98                Cannot compare classes which do not define a "__key" attribute
99                '''
100                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
101                        return self.__key() == y.__key()
102                return id(self) == id(y)
103
104        def __hash__(self):
105                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.