|
@@ -288,7 +288,24 @@ class _LeObject(object):
|
288
|
288
|
#How to handler this ?
|
289
|
289
|
res = False
|
290
|
290
|
return res
|
291
|
|
-
|
|
291
|
+
|
|
292
|
+ ## @brief Fetch neighbour in hierarchy relation
|
|
293
|
+ # @param leo LeType | LeRoot : We want the neighbour of this LeObject (can be the root)
|
|
294
|
+ # @param nature str : @ref EditorialModel.classtypes
|
|
295
|
+ # @param leo_is_sup bool : if True leo is the superior and we want to fetch the subordinates else its the oposite
|
|
296
|
+ # @return A list of LeObject ordered by depth if leo_is_sup, else a list of subordinates
|
|
297
|
+ @classmethod
|
|
298
|
+ def hierarchy_get(cls, leo, nature, leo_is_sup = True):
|
|
299
|
+ #Checking arguments
|
|
300
|
+ if not (nature is None) and not cls.is_root(leo):
|
|
301
|
+ if nature not in EditorialModel.classtypes.EmClassType.natures(leo._classtype):
|
|
302
|
+ raise ValueError("Invalid nature '%s' for %s"%(nature, lesup.__class__.__name__))
|
|
303
|
+
|
|
304
|
+ if leo_is_sup:
|
|
305
|
+ return cls._datasource.get_subordinates(leo, nature)
|
|
306
|
+ else:
|
|
307
|
+ return cls._datasource.get_superior(leo, nature)
|
|
308
|
+
|
292
|
309
|
## @brief Prepare a field_list
|
293
|
310
|
# @param field_list list : List of string representing fields
|
294
|
311
|
# @param letype LeType : LeType child class
|