|
@@ -188,22 +188,19 @@ class EmType(EmComponent):
|
188
|
188
|
def subordinates(self):
|
189
|
189
|
return { nature: [ self.model.component(tuid) for tuid in self.subordinates_list[nature] ] for nature in self.subordinates_list }
|
190
|
190
|
|
191
|
|
- ## @brief Get the list of subordinates EmType
|
192
|
|
- # Get a list of EmType instance that have this EmType for superior
|
193
|
|
- # @return Return a dict with relation nature as keys and values as a list of subordinates
|
194
|
|
- # EmType instance
|
195
|
|
- # @throw RuntimeError if a nature fetched from db is not valid
|
196
|
|
- # @see EmType::_sub_or_sup()
|
197
|
|
- # @todo reimplementation needed
|
|
191
|
+ ## @brief Get the list of superiors by relation's nature
|
|
192
|
+ # Get a list of EmType that are superiors of this type
|
|
193
|
+ # @return Return a dict with relation nature as keys and an EmType as value
|
|
194
|
+ # @throw RuntimeError if a nature has multiple superiors
|
198
|
195
|
def superiors(self):
|
199
|
196
|
superiors = {}
|
200
|
197
|
for em_type in self.model.components(EmType):
|
201
|
|
- for nature, field_uids in em_type.subordinates_list.items():
|
202
|
|
- if self.uid in field_uids:
|
|
198
|
+ for nature, sub_uids in em_type.subordinates_list.items():
|
|
199
|
+ if self.uid in sub_uids:
|
203
|
200
|
if nature in superiors:
|
204
|
|
- superiors[nature].append(em_type)
|
|
201
|
+ raise RuntimeError("Multiple superiors found for relation of nature '%s' for EmType %d"%(nature, self.uid))
|
205
|
202
|
else:
|
206
|
|
- superiors[nature] = [em_type]
|
|
203
|
+ superiors[nature] = em_type
|
207
|
204
|
return superiors
|
208
|
205
|
|
209
|
206
|
## Add a superior in the type hierarchy
|