public function executeUpdate()
 {
     if (!$this->getRequestParameter('id')) {
         $collaboration = new Collaboration();
     } else {
         $collaboration = CollaborationPeer::retrieveByPk($this->getRequestParameter('id'));
         $this->forward404Unless($collaboration);
     }
     $collaboration->setId($this->getRequestParameter('id'));
     $collaboration->setName($this->getRequestParameter('name'));
     $collaboration->setDescription($this->getRequestParameter('description'));
     $collaboration->save();
     foreach ($collaboration->getCollaboratingOrganizations() as $co) {
         $co->delete();
     }
     foreach ($this->getRequestParameter('collaboratingOrganizations') as $orgId) {
         $collaboratingOranization = new CollaboratingOrganization();
         $collaboratingOranization->setCollaborationId($collaboration->getId());
         $collaboratingOranization->setOrganizationId($orgId);
         $collaboratingOranization->save();
         $this->logMessage("[kevin] orgid = {$orgId} ");
     }
     foreach ($collaboration->getCollaborationYears() as $cy) {
         $cy->delete();
     }
     foreach ($this->getRequestParameter('collaborationYears') as $year) {
         $collaborationYear = new Collaborationyear();
         $collaborationYear->setCollaborationId($collaboration->getId());
         $collaborationYear->setYear($year);
         $collaborationYear->save();
     }
     foreach ($collaboration->getCollaborationTypes() as $row) {
         $row->delete();
     }
     foreach ($this->getRequestParameter('collaborationTypes') as $type) {
         if ($type) {
             $collaborationType = new CollaborationType();
             $collaborationType->setCollaborationId($collaboration->getId());
             $collaborationType->setCollaborationType($type);
             $collaborationType->save();
         }
     }
     foreach ($collaboration->getCollaborationOutcomeTypes() as $row) {
         $row->delete();
     }
     foreach ($this->getRequestParameter('collaborationOutcomeTypes') as $type) {
         if ($type) {
             $collaborationOutcomeTypes = new CollaborationOutcomeType();
             $collaborationOutcomeTypes->setCollaborationId($collaboration->getId());
             $collaborationOutcomeTypes->setOutcomeType($type);
             $collaborationOutcomeTypes->save();
         }
     }
     return $this->redirect('collaboration/show?id=' . $collaboration->getId());
 }
 public function addCollaboratingOrganization(CollaboratingOrganization $l)
 {
     $this->collCollaboratingOrganizations[] = $l;
     $l->setOrganization($this);
 }