|
@@ -78,29 +78,6 @@ class LeType(object):
|
78
|
78
|
def db_delete(self):
|
79
|
79
|
return self.delete([('lodel_id','=',repr(self.lodel_id))])
|
80
|
80
|
|
81
|
|
- ## @brief Add a superior given a nature
|
82
|
|
- # @param leo LeObject : A LeObject instance that will be the superior
|
83
|
|
- # @param nature str : the relation nature
|
84
|
|
- # @throw leobject.leobject.LeObjectError if this
|
85
|
|
- # @todo find what value depth and rank should have....
|
86
|
|
- # @todo Unit tests
|
87
|
|
- def add_superior(self, leo, nature):
|
88
|
|
- if nature not in self._superiors.keys():
|
89
|
|
- raise LeObjectError("%s cannot have a superior with %s as relation nature"%(self.__class__.__name__, nature))
|
90
|
|
- if leo.__class__ not in self._superiors[nature]:
|
91
|
|
- raise LeObjectError("%s cannot have a %s superior in a %s relation"%(self.__class__.__name__, leo.__class__.__name__, nature))
|
92
|
|
-
|
93
|
|
- return self._datasource.add_relation(leo.lodel_id, self.lodel_id, nature = nature, depth=None, rank = None)
|
94
|
|
-
|
95
|
|
- ## @brief Delete a superior given a nature
|
96
|
|
- # @param leo LeObject : A LeObject instance
|
97
|
|
- # @param nature str : The relation nature
|
98
|
|
- # @todo Unit tests
|
99
|
|
- def del_superior(self, leo, nature):
|
100
|
|
- if nature is None:
|
101
|
|
- raise ValueError('The argument nature cannot be None')
|
102
|
|
- return self._datasource(leo, self, nature)
|
103
|
|
-
|
104
|
81
|
## @brief Get the linked objects lodel_id
|
105
|
82
|
# @param letype LeType : Filter the result with LeType child class (not instance)
|
106
|
83
|
# @return a dict with LeType instance as key and dict{attr_name:attr_val...} as value
|
|
@@ -174,7 +151,16 @@ class LeType(object):
|
174
|
151
|
# @return True if deletion is a success
|
175
|
152
|
def superior_del(self, leo, nature):
|
176
|
153
|
return leobject.lefactory.leobj_from_name('LeObject').hierarchy_del(leo, self, nature)
|
177
|
|
-
|
|
154
|
+
|
|
155
|
+ ## @brief Fetch superiors by depth
|
|
156
|
+ # @return A list of LeObject ordered by depth (the first is the one with the bigger depth)
|
|
157
|
+ def superiors(self):
|
|
158
|
+ return leobject.lefactory.leobj_from_name('LeObject').hierarchy_get(self,nature, leo_is_sup = False)
|
|
159
|
+
|
|
160
|
+ ## @brief Fetch subordinates ordered by rank
|
|
161
|
+ # @return A list of LeObject ordered by rank
|
|
162
|
+ def subordinates(self):
|
|
163
|
+ return leobject.lefactory.leobj_from_name('LeObject').hierarchy_get(self,nature, leo_is_sup = True)
|
178
|
164
|
|
179
|
165
|
## @brief Delete a LeType from the datasource
|
180
|
166
|
# @param filters list : list of filters (see @ref leobject_filters)
|