public function createAssignmentHistory(EiSubjectAssignment $assignment, $is_assignment = true, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     return $conn->insert($this->getInstance(), array('author_of_assignment' => MyFunction::getGuard()->getId(), 'subject_id' => $assignment->getSubjectId(), 'assign_to' => $assignment->getGuardId(), 'date' => date("Y-m-d H:i:s"), 'is_assignment' => $is_assignment));
 }
Example #2
0
 public function getPackage(Doctrine_Connection $conn = null)
 {
     $conn2 = Doctrine_Manager::connection();
     $conn2->execute("update ei_subject s left join ei_ticket t \n                            on s.package_id =t.ticket_id and s.package_ref=t.ticket_ref\n                            set s.package_id =NULL and s.package_ref=NULL\n                            where CONCAT('Package_S',s.id)!=t.name");
     $conn2->execute("update ei_subject s  left join ei_ticket t on s.package_id=t.ticket_id and s.package_ref=t.ticket_ref\n            set package_id=NULL , package_ref=NULL \n            where   t.ticket_id IS   NULL OR   t.ticket_ref is   NULL ");
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     /* Le package existe déjà mais on procède aux vérifications permettant d'avoir l'unicité d'un bug pour un package.
         En effet un Package doit être lié à un bug au plus.
        */
     if ($this->getPackageId() != null && $this->getPackageId() != 0 && $this->getPackageRef() != null && $this->getPackageRef() != 0) {
         $package_bugs_links = $conn->fetchAll("select t.ticket_id , t.ticket_ref, s.id  \n                        from  ei_ticket t \n                        inner join  ei_subject s on s.package_id=t.ticket_id and s.package_ref=t.ticket_ref\n                        where t.ticket_id= " . $this->getPackageId() . " and t.ticket_ref=" . $this->getPackageRef());
     } else {
         $package_bugs_links = array();
     }
     if (count($package_bugs_links) == 0) {
         //Le ticket du bug est null ou n'existe pas : on le crée par le web service
         //Si le package du bug est   null
         if ($this->getPackageId() != null && $this->getPackageRef() != null) {
             $conn->execute("update ei_subject set package_id=NULL And package_ref=NULL where package_id=" . $this->getPackageId() . " And package_ref=" . $this->getPackageRef());
         }
         /* On recharge le projet si nécessaire */
         $ei_project = $this->getEiProject();
         if ($ei_project->needsReload()) {
             $xml = $ei_project->downloadKalFonctions();
             if ($xml != null) {
                 $ei_project->transactionToLoadObjectsOfProject($xml);
             }
         }
         /* Préparation des données de création du web service de création de l'intervention */
         $guard = MyFunction::getGuard();
         $data = array('package_name' => 'Package_S' . $this->getId(), 'guard_id' => $guard->getId());
         /* Création de l'intervention */
         $pack = EiTicket::createDistantPackage($this->getEiProject(), json_encode($data));
         if (is_array($pack) && isset($pack['package_id']) && isset($pack['package_ref'])) {
             return array("package_id" => $pack['package_id'], "package_ref" => $pack['package_ref']);
         } else {
             //Echec de la création de l'intervention du bug.
             throw new Exception("Fatal error . Failed to create  intervention package! Contact administrator...");
             //$conn->execute("update ei_subject set package_id=" . $pack['package_id'] . " , package_ref=" . $pack['package_ref'] . " , updated_at='" . date('Y-m-d H:i:s') . "' where id=" . $this->getId());
             //$package = Doctrine_Core::getTable('EiTicket')->findOneByTicketIdAndTicketRef($pack['package_id'], $pack['package_ref']);
         }
     } elseif (count($package_bugs_links) > 1) {
         //Le ticket est lié à plusieurs bugs : On génère une exception et on alerte l'administrateur
         throw new Exception("Fatal error . Many interventions for a package! Contact administrator...");
     } else {
         //Le package du bug/intervention est bien définit et l'objet EiTicket associé existe.
         return array("package_id" => $this->getPackageId(), "package_ref" => $this->getPackageRef());
     }
 }
Example #3
0
 /**
  * Méthode appelée avant chaque appel d'action.
  */
 public function preExecute()
 {
     /** @var EiUserTable $table */
     $table = Doctrine_Core::getTable('EiUser');
     $this->token = $this->getRequest()->getParameter("token");
     $this->user = $table::getInstance()->getUserByTokenApi($this->token);
     $this->forward404If(is_bool($this->user) && $this->user === false, "You are not allowed to access this page.");
     // On récupère le nom d'utilisateur ainsi que le mot de passe pour les intéractions avec script.
     $this->login = $this->user->getGuardUser()->getUsername();
     // On authentifie l'utilisateur s'il ne l'est pas.
     if (MyFunction::getGuard() == null) {
         $this->getUser()->signIn($this->user->getGuardUser(), true);
     }
 }
 function checkIfDefaultPackageExist($validator, $values, $arguments)
 {
     if (!$this->getObject()->isNew()) {
         return $values;
     }
     // C'est n 'est pas un nouveau scénario , on retourne les valeurs du formulaire
     //On récupère l'utilisateur courant
     $ei_user = MyFunction::getGuard()->getEiUser();
     $defPack = Doctrine_Core::getTable('EiUserDefaultPackage')->findOneByProjectIdAndProjectRefAndUserIdAndUserRef($values['project_id'], $values['project_ref'], $ei_user->getUserId(), $ei_user->getRefId());
     if ($defPack != null) {
         //On et la propriété défaultPackage du scénario pour la sauvegarde de sa version par défaut
         $this->getObject()->setDefaultPackage($defPack);
         return $values;
         //Le package par défaut existe
     }
     throw new sfValidatorError($validator, 'You have to select package before create à test suite ...');
     return $values;
 }
Example #5
0
 /**
  * Appel le webservice ScriptVersion et parse le résultat afin d'obtenir le numéro
  * de version du côté de script.kalifast.
  * 
  * Si le fichier XML est mauvais, on retourne null.
  * 
  * @return null ou numéro de version côté script.kalifast
  */
 public function getScriptNumVersion($username = null)
 {
     if ($username == null) {
         $username = MyFunction::getGuard()->getUsername();
     }
     if ($username == null) {
         return null;
     }
     $scriptVersion = $this->getScriptVersion($username);
     if ($scriptVersion == null) {
         return null;
     } else {
         if ($scriptVersion->getElementsByTagName("project_ref")->item(0) != null && $scriptVersion->getElementsByTagName("project_id")->item(0) != null && $scriptVersion->getElementsByTagName("version")->item(0) != null) {
             if ($this->getProjectId() == $scriptVersion->getElementsByTagName("project_id")->item(0)->nodeValue && $this->getRefId() == $scriptVersion->getElementsByTagName("project_ref")->item(0)->nodeValue) {
                 return $scriptVersion->getElementsByTagName("version")->item(0)->nodeValue;
             } else {
                 throw new Exception('Mauvais projet récupéré');
             }
         } elseif (!$scriptVersion->getElementsByTagName("error")) {
             throw new Exception('Fichier XML erroné');
         }
     }
     return null;
 }
Example #6
0
 public function executeMigrateManyBugFunction(sfWebRequest $request)
 {
     $this->checkProject($request);
     //Récupération du projet
     $this->checkProfile($request, $this->ei_project);
     //Récupération du projet
     $this->checkFunction($request, $this->ei_project);
     if ($request->getParameter('subject_id') != null) {
         $this->checkSubject($request, $this->ei_project);
     }
     if ($request->getParameter('delivery_id') != null) {
         $this->checkDelivery($request, $this->ei_project);
     }
     $guardUser = MyFunction::getGuard();
     $this->html = 'Error';
     //Traitement éffective de la migration
     $result = Doctrine_Core::getTable('EiTicket')->MigrateManyFunctions($this->ei_project, $this->ei_profile, $guardUser, $request->getParameter('tab'));
     if ($result == true) {
         $xml = $this->ei_project->downloadKalFonctions();
         if ($xml != null) {
             $this->ei_project->transactionToLoadObjectsOfProject($xml);
         }
     }
     if ($result) {
         $criteria = array('project_id' => $this->project_id, 'project_ref' => $this->project_ref);
         if ($this->ei_delivery && $this->ei_delivery != null) {
             $criteria['delivery_id'] = $this->ei_delivery->getId();
         }
         if ($this->ei_subject && $this->ei_subject != null) {
             $criteria['ticket_id'] = $this->ei_subject->getPackageId();
             $criteria['ticket_ref'] = $this->ei_subject->getPackageRef();
             $criteria['subject_id'] = $this->ei_subject->getId();
             if ($this->ei_subject->getDeliveryId() != null) {
                 $criteria['delivery_id'] = $this->ei_subject->getDeliveryId();
             }
         }
         $this->migrateFuncts = Doctrine_Core::getTable('EiDelivery')->getFunctionsToMigrate($criteria, "SELECT COUNT(t_id) as nb_occurences,df_vw.*");
         $this->migrateFunctsWithoutCount = Doctrine_Core::getTable('EiDelivery')->getFunctionsToMigrate($criteria, "SELECT df_vw.*", false);
         $this->ei_profiles = $this->ei_project->getProfils();
         //Récupération des profils
         if ($this->ei_subject && $this->ei_subject != null) {
             $implicatedTikets = "((" . $this->ei_subject->getPackageId() . "," . $this->ei_subject->getPackageRef() . "))";
         } else {
             $implicatedTikets = '(';
             $k = count($this->migrateFuncts);
             $i = 1;
             foreach ($this->migrateFuncts as $migrateFunc) {
                 $implicatedTikets .= "(" . $migrateFunc['s_package_id'] . "," . $migrateFunc['s_package_ref'] . ")";
                 if ($k != $i) {
                     $implicatedTikets .= ",";
                 }
                 $i++;
             }
             $implicatedTikets .= ")";
         }
         //Récupération des relations script-profil impliquant le ticket en question
         $this->TabScriptProfiles = Doctrine_Core::getTable('EiTicket')->getAssociatedProfilesForDelivery($implicatedTikets);
         $this->scriptProfiles = array();
         if (!empty($this->TabScriptProfiles)) {
             foreach ($this->TabScriptProfiles as $scriptProfile) {
                 $tab[$scriptProfile['function_id'] . '_' . $scriptProfile['function_ref'] . '_' . $scriptProfile['profile_id'] . '_' . $scriptProfile['profile_ref']] = $scriptProfile['script_id'];
             }
             $this->scriptProfiles = $tab;
             //Récupération des conflits résolus sur la livraison  (si on est sur une livraison
             if ($this->ei_delivery && $this->ei_delivery != null) {
                 $resolved_conflicts_list = $this->ei_delivery->getResolvedConflictsOnFunctions();
                 $resolved_conflicts = array();
                 if (count($resolved_conflicts_list) > 0) {
                     foreach ($resolved_conflicts_list as $conflict) {
                         if (array_key_exists($conflict['function_id'] . '_' . $conflict['function_ref'] . '_' . $conflict['delivery_id'], $resolved_conflicts)) {
                             $resolved_conflicts[$conflict['function_id'] . '_' . $conflict['function_ref'] . '_' . $conflict['delivery_id']]['profile'][] = array('profile_id' => $conflict['profile_id'], 'profile_ref' => $conflict['profile_ref']);
                         } else {
                             $resolved_conflicts[$conflict['function_id'] . '_' . $conflict['function_ref'] . '_' . $conflict['delivery_id']] = array("package_id" => $conflict['package_id'], 'package_ref' => $conflict['package_ref'], 'profile' => array(0 => array('profile_id' => $conflict['profile_id'], 'profile_ref' => $conflict['profile_ref'])));
                         }
                     }
                 }
             }
             $functionsToMigrateListUri = $this->urlParameters;
             $functionsToMigrateListUri['migrateFuncts'] = $this->migrateFuncts;
             $functionsToMigrateListUri['migrateFunctsWithoutCount'] = $this->migrateFunctsWithoutCount;
             $functionsToMigrateListUri['ei_project'] = $this->ei_project;
             $functionsToMigrateListUri['ei_profiles'] = $this->ei_profiles;
             $functionsToMigrateListUri['scriptProfiles'] = $this->scriptProfiles;
             $functionsToMigrateListUri['ei_delivery'] = $this->ei_delivery && $this->ei_delivery != null ? $this->ei_delivery : null;
             $functionsToMigrateListUri['resolved_conflicts'] = isset($resolved_conflicts) ? $resolved_conflicts : array();
             // Liste des conflits de fonction résolus sur la livraison
             $this->html = $this->getPartial('eidelivery/functionsToMigrateList', $functionsToMigrateListUri);
         }
     }
     return $this->renderText(json_encode(array('html' => $this->html, 'success' => $result ? true : false)));
     return sfView::NONE;
 }