示例#1
0
 public function createProfilScenarioForClone($copie, Doctrine_Connection $conn)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     //Attribution des profils scenario à la première version trouvée
     if ($copie != null) {
         $clones_version = $conn->getTable('EiVersion')->findByEiScenarioId($copie->getId());
         if (count($clones_version) > 0) {
             $first_clone_version = $clones_version->getFirst();
             foreach ($this->getEiProjet()->getProfils() as $pf) {
                 $profil_scenario = new EiProfilScenario();
                 $profil_scenario->setProfileId($pf->getProfileId());
                 $profil_scenario->setProfileRef($pf->getProfileRef());
                 $profil_scenario->setEiVersionId($first_clone_version->getId());
                 $profil_scenario->setEiScenarioId($copie->getId());
                 $profil_scenario->setCreatedAt($first_clone_version->getCreatedAt());
                 $profil_scenario->setUpdatedAt($first_clone_version->getUpdatedAt());
                 $profil_scenario->save($conn);
             }
         }
     }
 }
 public function createRelationForProfileChild(EiProfil $profileParent, EiProfil $profile, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     $collection1 = $conn->getTable('EiProfilScenario')->findByProfileIdAndProfileRef($profileParent->getProfileId(), $profileParent->getProfileRef());
     //Si des relations existent alors on les recrée pour le profil enfant
     if ($collection1->getFirst()) {
         $collection2 = new Doctrine_Collection('EiProfilScenario');
         foreach ($collection1 as $profil_scenario) {
             $new_obj = new EiProfilScenario();
             $new_obj->setProfileId($profile->getProfileId());
             $new_obj->setProfileRef($profile->getProfileRef());
             $new_obj->setEiScenarioId($profil_scenario->getEiScenarioId());
             $new_obj->setEiVersionId($profil_scenario->getEiVersionId());
             $collection2->add($new_obj);
         }
         if ($collection2->getFirst()) {
             $collection2->save($conn);
         }
         //Sauvegarde des nouvelles relations
     }
 }
示例#3
0
 public function executeMajProfilScenario(sfWebRequest $request)
 {
     //recuperation des paramètres
     $profile_id = $request->getParameter('profile_id');
     $profile_ref = $request->getParameter('profile_ref');
     $id_version = $request->getParameter('id_version');
     $ei_scenario_id = $request->getParameter('ei_scenario_id');
     //traitement
     $profilscenario = Doctrine_Core::getTable('EiProfilScenario')->findOneByProfileIdAndProfileRefAndEiScenarioId($profile_id, $profile_ref, $ei_scenario_id);
     if ($profilscenario != null) {
         //est-ce ma version
         if ($profilscenario->id_version != $id_version) {
             $profilscenario->id_version = $id_version;
             $profilscenario->save();
         }
     } else {
         $profilscenario = new EiProfilScenario();
         $profilscenario->profile_id = $profile_id;
         $profilscenario->profile_ref = $profile_ref;
         $profilscenario->id_version = $id_version;
         $profilscenario->ei_scenario_id = $ei_scenario_id;
         $profilscenario->save();
     }
     return sfView::NONE;
 }
示例#4
0
 public function executeEditVersionWithoutId(sfWebRequest $request)
 {
     $this->checkProject($request);
     $this->checkProfile($request, $this->ei_project);
     $this->checkEiScenario($request, $this->ei_project);
     //On recherche une association version-profil pour le scénario
     $this->profil_scenario = Doctrine_Core::getTable("EiProfilScenario")->findOneByEiScenarioIdAndProfileIdAndProfileRef($this->ei_scenario->getId(), $this->ei_profile->getProfileId(), $this->ei_profile->getProfileRef());
     /* Si le profil a été récemment ajouté sur script, alors il n'est affecté à aucune version ,
      *  du coup on affecte le profil à la première version rencontrée
      */
     if ($this->profil_scenario == null) {
         $pf = Doctrine_Core::getTable("EiProfilScenario")->findByEiScenarioId($this->ei_scenario->getId())->getFirst();
         $new_profil_scenario = new EiProfilScenario();
         $new_profil_scenario->setEiScenarioId($this->ei_scenario->getId());
         $new_profil_scenario->setProfileId($this->ei_profile->getProfileId());
         $new_profil_scenario->setProfileRef($this->ei_profile->getProfileRef());
         $new_profil_scenario->setEiVersionId($pf->getEiVersionId());
         $new_profil_scenario->save();
         $this->profil_scenario = $new_profil_scenario;
     }
     $this->forward404If(!$this->profil_scenario, 'System error : Environment must be associated to at least one version
             of test suit');
     //On récupère la version
     $this->ei_version = Doctrine_Core::getTable("EiVersion")->findOneById($this->profil_scenario->getEiVersionId());
     // On redirige ensuite l'utilisateur vers la version trouvée
     $projet_edit_eiversion = $this->urlParameters;
     $projet_edit_eiversion['ei_scenario_id'] = $this->ei_scenario->getId();
     $projet_edit_eiversion['action'] = 'edit';
     $projet_edit_eiversion['ei_version_id'] = $this->ei_version->getId();
     $this->redirect($this->generateUrl('projet_edit_eiversion', $projet_edit_eiversion));
     return sfView::NONE;
 }