source: mauRepo/CedaMolesModel/trunk/ceda_moles_model/ea_model/iso_19133_tracking_and_navigation/tracking/linear_reference_systems/lr_linearreferencemethod.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/tracking/linear_reference_systems/lr_linearreferencemethod.py@8457
Revision 8457, 2.4 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:06
25
26@author: mnagni
27'''
28
29class LR_LinearReferenceMethod(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.name = None
43                self.positiveOffsetDirection = None
44                self.units = None
45                self.type = None
46                self.offsetUnits = None
47                self.marker = []
48                self._referenceElement_nt_link = []
49                self._referenceElement_lr_feature = []
50                self._referenceElement = []
51                super(LR_LinearReferenceMethod, self).__init__()
52        @property
53        def referenceElement(self):     
54                try:
55                        ret = []
56                        ret.extend(self._referenceElement_nt_link)
57                        ret.extend(self._referenceElement_lr_feature)
58                        if not hasattr(self, '_referenceElement'):
59                                self._referenceElement = []
60                        if self._referenceElement is not None:
61                                ret.extend(self._referenceElement)
62                        del self._referenceElement[:]
63                        self._referenceElement.extend(set(ret))
64                except Exception as e:
65                        pass
66                return self._referenceElement
67
68
69        def synchronize(self):
70                int_referenceElement = self.referenceElement   
71                del self._referenceElement_nt_link[:]
72                del self._referenceElement_lr_feature[:]
73                for item in int_referenceElement:       
74                        valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
75                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.network.link.nt_link.NT_Link":
76                                self._referenceElement_nt_link.append(item)
77                                continue
78                        if valueClass == "ea_model.iso_19133_tracking_and_navigation.tracking.linear_reference_systems.lr_feature.LR_Feature":
79                                self._referenceElement_lr_feature.append(item)
80                                continue
81                pass
82
83        def __key(self):
84                return (self.name, self.positiveOffsetDirection, self.units, self.type, self.offsetUnits, self.marker, self.referenceElement)
85
86        def __eq__(self, y):
87                if type(self) != type(y):
88                        return False
89                '''
90                Cannot compare classes which do not define a "__key" attribute
91                '''
92                if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
93                        return self.__key() == y.__key()
94                return id(self) == id(y)
95
96        def __hash__(self):
97                return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.