function setAgentRelation(AgentRelation $relation)
 {
     $this->destination = $relation->agent;
     $this->origin = $relation->owner;
     $this->metadata['class'] = $relation->getClassName();
     $this->metadata['relationId'] = $relation->id;
 }
 public function save($flush = false)
 {
     $old_relations = $this->repo()->findBy(['group' => $this->group, 'owner' => $this->owner]);
     foreach ($old_relations as $rel) {
         if (!$this->equals($rel)) {
             $rel->delete($flush);
         }
     }
     parent::save($flush);
 }
 function jsonSerialize()
 {
     $result = parent::jsonSerialize();
     return $result;
 }