|
@@ -223,7 +223,13 @@ class EmType(EmComponent):
|
223
|
223
|
# @throw ValueError when relation_nature isn't reconized or not allowed for this type
|
224
|
224
|
# @throw ValueError when relation_nature don't allow to link this types together
|
225
|
225
|
def add_superior(self, em_type, relation_nature):
|
226
|
|
- #Checking that this relation is allowed by the nature of the relation
|
|
226
|
+ # check if relation_nature is valid for this type
|
|
227
|
+ if relation_nature not in EmClassType.natures(self.classtype['name']):
|
|
228
|
+ raise ValueError("Invalid nature for add_superior : '" + relation_nature + "'. Allowed relations for this type are " + str(EmClassType.natures(self.classtype['name'])))
|
|
229
|
+
|
|
230
|
+ if relation_nature in self.superiors_list and em_type.uid in self.superiors_list[relation_nature]:
|
|
231
|
+ return True
|
|
232
|
+
|
227
|
233
|
att = self.classtype['hierarchy'][relation_nature]['attach']
|
228
|
234
|
if att == 'classtype':
|
229
|
235
|
if self.classtype['name'] != em_type.classtype['name']:
|
|
@@ -239,6 +245,8 @@ class EmType(EmComponent):
|
239
|
245
|
# @throw TypeError when em_type isn't an EmType instance
|
240
|
246
|
# @throw ValueError when relation_nature isn't reconized or not allowed for this type
|
241
|
247
|
def del_superior(self, em_type, relation_nature):
|
|
248
|
+ if relation_nature not in self.superiors_list or em_type.uid not in self.superiors_list[relation_nature]:
|
|
249
|
+ return True
|
242
|
250
|
self._change_superiors_list(em_type, relation_nature, False)
|
243
|
251
|
|
244
|
252
|
## Apply changes to the superiors_list
|
|
@@ -249,9 +257,6 @@ class EmType(EmComponent):
|
249
|
257
|
# check instance of parameters
|
250
|
258
|
if not isinstance(em_type, EmType) or not isinstance(relation_nature, str):
|
251
|
259
|
raise TypeError("Excepted <class EmType> and <class str> as em_type argument. But got : " + str(type(em_type)) + " " + str(type(relation_nature)))
|
252
|
|
- # check if relation_nature is valid for this type
|
253
|
|
- if relation_nature not in EmClassType.natures(self.classtype['name']):
|
254
|
|
- raise ValueError("Invalid nature for add_superior : '" + relation_nature + "'. Allowed relations for this type are " + str(EmClassType.natures(self.classtype['name'])))
|
255
|
260
|
|
256
|
261
|
try:
|
257
|
262
|
if add:
|