source: mauRepo/MolesManager/trunk/src/ea_model/iso_19135_2005_procedures_for_registration/re_itemclass.py @ 8197

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/ea_model/iso_19135_2005_procedures_for_registration/re_itemclass.py@8197
Revision 8197, 5.0 KB checked in by mnagni, 8 years ago (diff)

New database schema where URL class is a string and MO_Project.subProject use CEDA_Project as subType

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 30-Mar-2012 16:45:24
25
26@author: mnagni
27'''
28
29class RE_ItemClass(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.alternativeName = []
44        self._register_cl_classificationregister = []
45        self._register_cl_classificationregister = []
46        self._describedItem_cl_classificationruleitem = []
47        self._describedItem_re_subregisterdescription = []
48        self._describedItem_cl_classificationlegenditem = []
49        self._describedItem_cl_classificationlegenditem = []
50        self._describedItem_cl_classificationruleitem = []
51        self.technicalStandard = None
52        self.subregister = []
53        super(RE_ItemClass, self).__init__()
54
55    @property
56    def register(self): 
57        ret = []
58        for item in self._register_cl_classificationregister:
59            ret.append(item)
60        for item in self._register_cl_classificationregister:
61            ret.append(item)
62        return ret
63
64    @register.setter
65    def register(self, value): 
66        if isinstance(value, list):
67            self._register_cl_classificationregister[:]
68            self._register_cl_classificationregister[:]
69            for item in value:
70                valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
71                if valueClass == "ea_model.iso_19144_1_classification_systems.cl_classificationregister.CL_ClassificationRegister":
72                    self._register_cl_classificationregister.append(item)
73                    continue
74                if valueClass == "ea_model.iso_19144_1_classification_systems.cl_classificationregister.CL_ClassificationRegister":
75                    self._register_cl_classificationregister.append(item)
76                    continue
77
78    @property
79    def describedItem(self):   
80        ret = []
81        for item in self._describedItem_cl_classificationruleitem:
82            ret.append(item)
83        for item in self._describedItem_re_subregisterdescription:
84            ret.append(item)
85        for item in self._describedItem_cl_classificationlegenditem:
86            ret.append(item)
87        for item in self._describedItem_cl_classificationlegenditem:
88            ret.append(item)
89        for item in self._describedItem_cl_classificationruleitem:
90            ret.append(item)
91        return ret
92
93    @describedItem.setter
94    def describedItem(self, value):     
95        if isinstance(value, list):
96            self._describedItem_cl_classificationruleitem[:]
97            self._describedItem_re_subregisterdescription[:]
98            self._describedItem_cl_classificationlegenditem[:]
99            self._describedItem_cl_classificationlegenditem[:]
100            self._describedItem_cl_classificationruleitem[:]
101            for item in value:
102                valueClass = "%s.%s" % (type(item).__module__,type(item).__name__)
103                if valueClass == "ea_model.iso_19144_1_classification_systems.cl_classificationruleitem.CL_ClassificationRuleItem":
104                    self._describedItem_cl_classificationruleitem.append(item)
105                    continue
106                if valueClass == "ea_model.iso_19135_2005_procedures_for_registration.re_subregisterdescription.RE_SubregisterDescription":
107                    self._describedItem_re_subregisterdescription.append(item)
108                    continue
109                if valueClass == "ea_model.iso_19144_1_classification_systems.cl_classificationlegenditem.CL_ClassificationLegendItem":
110                    self._describedItem_cl_classificationlegenditem.append(item)
111                    continue
112                if valueClass == "ea_model.iso_19144_1_classification_systems.cl_classificationlegenditem.CL_ClassificationLegendItem":
113                    self._describedItem_cl_classificationlegenditem.append(item)
114                    continue
115                if valueClass == "ea_model.iso_19144_1_classification_systems.cl_classificationruleitem.CL_ClassificationRuleItem":
116                    self._describedItem_cl_classificationruleitem.append(item)
117                    continue
118
119    def __key(self):
120        return (self.name, self.alternativeName, self.register, self.describedItem, self.technicalStandard, self.subregister)
121
122    def __eq__(self, y):
123        if type(self) != type(y):
124            return False
125        '''
126        Cannot compare classes which do not define a "__key" attribute
127        '''
128        if hasattr(self, '_%s__key' % (type(self).__name__)) and hasattr(y, '_%s__key' % (type(y).__name__)):
129            return self.__key() == y.__key()
130        return id(self) == id(y)
131
132    def __hash__(self):
133        return collectionProofHash(self.__key())
Note: See TracBrowser for help on using the repository browser.