|
@@ -222,5 +222,23 @@ class EmType(EmComponent):
|
222
|
222
|
# @return a list of EmType
|
223
|
223
|
# @see EmFields
|
224
|
224
|
def linked_types(self):
|
225
|
|
- pass
|
|
225
|
+ return self._linked_types_Db()
|
|
226
|
+
|
|
227
|
+ ## @brief Return the list of all the types linked to this type, should they be superiors or subordinates
|
|
228
|
+ # @return A list of EmType objects
|
|
229
|
+ def _linked_types_Db(self):
|
|
230
|
+ conn = self.getDbE().connect()
|
|
231
|
+ htable = self.__class__._tableHierarchy()
|
|
232
|
+ req = htable.select(htable.c.superior_id, htable.c.subordinate_id)
|
|
233
|
+ req = req.where(sql.or_(htable.c.subordinate_id == self.uid, htable.c.superior_id == self.uid))
|
|
234
|
+
|
|
235
|
+ res = conn.execute(req)
|
|
236
|
+ rows = res.fetchall()
|
|
237
|
+ conn.close()
|
|
238
|
+
|
|
239
|
+ rows = dict(zip(rows.keys(), rows))
|
|
240
|
+ result = []
|
|
241
|
+ for row in rows:
|
|
242
|
+ result.append(EmType(row['subordinate_id'] if row['superior_id']==self.uid else row['superior_id']))
|
226
|
243
|
|
|
244
|
+ return result
|