public function reload($projets, $project_id, $project_ref, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } //Création de la collection d'objet EiVersionNotice à ajouter $collection = new Doctrine_Collection("EiVersionNotice"); //Supression des versions de notice qui n'existent plus sur script $this->deleteNotFoundVersionNotice($conn); $items = $projets->getElementsByTagName("ei_version_notices"); if ($items->length > 0) { //ya t-il des éléments à traiter? $ei_version_notices = $items->item(0)->getElementsByTagName("ei_version_notice"); if ($ei_version_notices->length > 0) { foreach ($ei_version_notices as $ei_version_notice) { $notice_id = $ei_version_notice->getAttribute("notice_id"); $notice_ref = $ei_version_notice->getAttribute("notice_ref"); $version_notice_id = $ei_version_notice->getAttribute("version_notice_id"); $lang = $ei_version_notice->getAttribute("lang"); //recherche du profil en base if ($notice_id != null && $notice_ref != null && $version_notice_id != null && $lang != null) { $q = Doctrine_Core::getTable('EiVersionNotice')->findOneByNoticeIdAndNoticeRefAndVersionNoticeIdAndLang($notice_id, $notice_ref, $version_notice_id, $lang); if ($q && $q != null) { //si l'element existe , on fait une mise à jour $q->setName($ei_version_notice->getElementsByTagName("name")->item(0)->nodeValue); $q->setDescription($ei_version_notice->getElementsByTagName("description")->item(0)->nodeValue); $q->setExpected($ei_version_notice->getElementsByTagName("expected")->item(0)->nodeValue); $q->setResult($ei_version_notice->getElementsByTagName("result")->item(0)->nodeValue); $q->setIsActive($ei_version_notice->getElementsByTagName("is_active")->item(0)->nodeValue); $q->save($conn); } else { //l'élément n'existe pas encore, et dans ce cas on le crée $new_ei_version_notice = new EiVersionNotice(); $new_ei_version_notice->setNoticeId($notice_id); $new_ei_version_notice->setNoticeRef($notice_ref); $new_ei_version_notice->setVersionNoticeId($version_notice_id); $new_ei_version_notice->setLang($lang); $new_ei_version_notice->setDescription($ei_version_notice->getElementsByTagName("description")->item(0)->nodeValue); $new_ei_version_notice->setExpected($ei_version_notice->getElementsByTagName("expected")->item(0)->nodeValue); $new_ei_version_notice->setResult($ei_version_notice->getElementsByTagName("result")->item(0)->nodeValue); $new_ei_version_notice->setName($ei_version_notice->getElementsByTagName("name")->item(0)->nodeValue); $new_ei_version_notice->setIsActive($ei_version_notice->getElementsByTagName("is_active")->item(0)->nodeValue); $collection->add($new_ei_version_notice); } } } if ($collection->getFirst()) { $collection->save($conn); } //Sauvegarde de la collection return 1; } return null; } }