|
|
|
|
102
|
return self._datasource(leo, self, nature)
|
102
|
return self._datasource(leo, self, nature)
|
103
|
|
103
|
|
104
|
## @brief Get the linked objects lodel_id
|
104
|
## @brief Get the linked objects lodel_id
|
|
|
105
|
+ # @param rel2type_name str : the name of the relation
|
105
|
# @return an array of lodel_id linked with this object
|
106
|
# @return an array of lodel_id linked with this object
|
106
|
# @todo unit tests
|
107
|
# @todo unit tests
|
107
|
- def linked(self):
|
|
|
|
|
108
|
+ def linked(self, rel2type_name):
|
108
|
return [ rel['id_sub'] for rel in self._datasource.get_relations(self.lodel_id) ]
|
109
|
return [ rel['id_sub'] for rel in self._datasource.get_relations(self.lodel_id) ]
|
109
|
|
110
|
|
110
|
## @brief Link this object with a LeObject
|
111
|
## @brief Link this object with a LeObject
|
111
|
# @note rel2type
|
112
|
# @note rel2type
|
112
|
# @param leo LeObject : The object to be linked with
|
113
|
# @param leo LeObject : The object to be linked with
|
|
|
114
|
+ # @param rel2type_name : The name of the rel2type field (the name of the relation)
|
113
|
# @param **rel_attr : keywords arguments for relations attributes
|
115
|
# @param **rel_attr : keywords arguments for relations attributes
|
114
|
# @return True if success False allready done
|
116
|
# @return True if success False allready done
|
115
|
# @throw A Leo exception if the link is not allowed
|
117
|
# @throw A Leo exception if the link is not allowed
|
116
|
# @todo unit tests
|
118
|
# @todo unit tests
|
117
|
# @todo find a value for depth and rank....
|
119
|
# @todo find a value for depth and rank....
|
118
|
- def link_to(self, leo, **rel_attr):
|
|
|
|
|
120
|
+ def link_to(self, leo, rel2type_name, **rel_attr):
|
119
|
if leo.__class__ not in self._linked_types.keys():
|
121
|
if leo.__class__ not in self._linked_types.keys():
|
120
|
raise leobject.leobject.LeObjectError("Constraint error : %s cannot be linked with %s"%(self.__class__.__name__, leo.__class__.__name__))
|
122
|
raise leobject.leobject.LeObjectError("Constraint error : %s cannot be linked with %s"%(self.__class__.__name__, leo.__class__.__name__))
|
121
|
|
123
|
|
|
|
|
|
125
|
if not self._linked_types[leo.__class__][1].check(rel_attr[attr_name]):
|
127
|
if not self._linked_types[leo.__class__][1].check(rel_attr[attr_name]):
|
126
|
raise ValueError("Wrong value '%s' for attribute %s"%(rel_attr[attr_name], attr_name))
|
128
|
raise ValueError("Wrong value '%s' for attribute %s"%(rel_attr[attr_name], attr_name))
|
127
|
|
129
|
|
128
|
- return self._datasource.add_relation(self, leo, nature=None, depth=None, rank=None, **rel_attr)
|
|
|
|
|
130
|
+ return self._datasource.add_relation(self, leo, nature=None, depth=None, rank=None, **rel_attr)#Broken ! need to give the rel2type_name
|
129
|
|
131
|
|
130
|
## @brief Remove a link bewteen this object and another
|
132
|
## @brief Remove a link bewteen this object and another
|
131
|
# @param leo LeObject : A LeObject instance linked with self
|
133
|
# @param leo LeObject : A LeObject instance linked with self
|
|
|
134
|
+ # @param rel2type_name : the name of the relation
|
132
|
# @todo unit tests
|
135
|
# @todo unit tests
|
133
|
- def unlink(self, leo):
|
|
|
134
|
- return self._datasource.del_relation(self, leo)
|
|
|
|
|
136
|
+ def unlink(self, leo, rel2type_name):
|
|
|
137
|
+ return self._datasource.del_relation(self, leo) #Broken ! need to give the rel2type_name
|
135
|
|
138
|
|
136
|
## @brief Delete a LeType from the datasource
|
139
|
## @brief Delete a LeType from the datasource
|
137
|
# @param filters list : list of filters (see @ref leobject_filters)
|
140
|
# @param filters list : list of filters (see @ref leobject_filters)
|