public function setDefaultPackage($ticket_id, $ticket_ref, EiProjet $ei_project, EiUser $ei_user, $is_new, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } if ($ticket_id != null && $ticket_ref != null) { if ($is_new == 0) { $conn->insert($this->getInstance(), array('user_ref' => $ei_user->getRefId(), 'user_id' => $ei_user->getUserId(), 'project_id' => $ei_project->getProjectId(), 'project_ref' => $ei_project->getRefId(), 'ticket_id' => $ticket_id, 'ticket_ref' => $ticket_ref, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s"))); } else { $conn->update($this->getInstance(), array('ticket_id' => $ticket_id, 'ticket_ref' => $ticket_ref, 'updated_at' => date("Y-m-d H:i:s")), array('user_ref' => $ei_user->getRefId(), 'user_id' => $ei_user->getUserId(), 'project_ref' => $ei_project->getRefId(), 'project_id' => $ei_project->getProjectId())); } return true; } return false; }
/** * @param $nom * @param $description * @param EiNode $noeud * @param EiScenario $scenario * @throws Exception */ public function createEmpty($nom, $description, EiNode $noeud, EiUser $user) { // On affecte le nom, la description, le noeud. $this->name = $nom; $this->description = $description; $this->setEiNode($noeud); // On affecte également l'utilisateur. $this->setUserId($user->getUserId()); $this->setUserRef($user->getRefId()); }
public function getUserParams(EiUser $ei_user = null, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $q = $conn->createQuery()->from('EiUserParam up'); if ($ei_user != null) { $q = $q->where('up.user_id=? And up.user_ref=?', array($ei_user->getUserId(), $ei_user->getRefId())); } $q = $q->orderBy('up.name'); return $q->execute(); }
public function executeVersionProjet(sfWebRequest $request) { $project_id = $request->getParameter('project_id'); $project_ref = $request->getParameter('project_ref'); $this->ei_project = null; if ($project_id != null && $project_ref != null) { //On verifie que l'utilisateur appartient au dit projet $userprojet = Doctrine_Core::getTable('EiProjectUser')->findOneByProjectIdAndProjectRefAndUserIdAndUserRef($project_id, $project_ref, $this->user->getUserId(), $this->user->getRefId()); if ($userprojet != null) { $this->ei_project = Doctrine_Core::getTable('EiProjet')->findOneByProjectIdAndRefId($project_id, $project_ref); } } }
/** * Ordonne au serveur de cloturer la log en lui associant la date de fin d'execution * @param sfWebRequest $request * @return type * @throws Exception */ public function executeEndCurrentLog(sfWebRequest $request) { $this->setLayout(false); $this->getResponse()->setContentType('application/json'); try { $this->getUrlParameters($request); $log = Doctrine_Core::getTable('EiLog')->findOneByIdAndUserIdAndUserRefAndEiTestSetId($request->getParameter('ei_log_id'), $this->user->getUserId(), $this->user->getRefId(), $this->ei_test_set->getId()); if ($log) { $log->closeExecution(); $JSONResponse = array("ok" => "Log closed successfully."); } else { throw new Exception('Log not found.'); } } catch (Exception $e) { $JSONResponse = array("error" => $e->getMessage()); } return $this->renderText(json_encode($JSONResponse)); }
public function getParamsWithName(EiUser $ei_user) { $conn = Doctrine_Manager::connection(); $q = "\n \n SELECT p1.*, p2.name ,upp.id as upp_id,upp.value as upp_value\n\n FROM ei_profile_param p1\n LEFT JOIN ei_user_profile_param upp ON upp.profile_param_id=p1.id And upp.user_id=" . $ei_user->getUserId() . "\n And upp.user_ref=" . $ei_user->getRefId() . "\n LEFT JOIN ei_project_param p2\n ON p1.name = p2.param_id \n \n WHERE\n p1.profile_id= " . $this->getProfileId() . "\n AND p1.profile_ref= " . $this->getProfileRef() . " \n \n "; return $conn->fetchAll($q); }
public function getDefaultPackage(EiUser $ei_user, EiProjet $ei_project) { return Doctrine_Core::getTable('EiUserDefaultPackage')->findOneByUserRefAndUserIdAndProjectRefAndProjectId($ei_user->getRefId(), $ei_user->getUserId(), $ei_project->getRefId(), $ei_project->getProjectId()); }
/** * @param sfWebRequest $request * @return sfView */ public function executeGetFunctionsFromPosition(sfWebRequest $request) { $this->setLayout(false); $this->getResponse()->setContentType('application/xml'); $this->error = false; $chronometre1 = new Chronometre(); $chronometre2 = new Chronometre(); $chronometre3 = new Chronometre(); $chronometre4 = new Chronometre(); $this->chronometre5 = new Chronometre(); $keyword = "PERFORMANCE NEXT BLOCK - "; $this->keyword = $keyword; // Début mesure. $chronometre1->lancerChrono($keyword . "LANCEMENT GENERATION DU BLOCK SUIVANT"); if (is_bool($this->error)) { try { $this->getUrlParameters($request); //***********************************************************// //***** RECUPERATION ITERATION ACTIVE *****// //***********************************************************// // Récupération de l'itération active. $iterationActive = $this->ei_test_set->getEiIteration(); //Récupération du package par défaut $this->defPack = Doctrine_Core::getTable('EiUserDefaultPackage')->findOneByProjectIdAndProjectRefAndUserIdAndUserRef($this->ei_project->getProjectId(), $this->ei_project->getRefId(), $this->user->getUserId(), $this->user->getRefId()); //******************************************************************// //***** GENERATION FONCTIONS DEPUIS POSITION *****// //******************************************************************// $position = $request->getParameter("position"); $this->getLogger()->info("----- Début génération de la fonction à partir de la position " . $position . " pour le JDT N°" . $this->ei_test_set->getId() . "."); // Début mesure. $chronometre2->lancerChrono($keyword . "GENERATION FONCTION A PARTIR DE LA POSITION"); $this->generateTestSetFunctionFromPosition($this->ei_test_set, $position, $iterationActive); // Fin mesure. $chronometre2->arreterEtAfficherChrono(); //********************************************************************// //***** TRAITEMENT DES FONCTIONS POUR TEMPLATE *****// //********************************************************************// $this->functions = Doctrine_Core::getTable('EiTestSetFunction')->getFunctionsFromPosition($this->ei_test_set->getId(), $position, $this->ei_test_set->getProfileId(), $this->ei_test_set->getProfileRef()); $this->params = array(); $treated = array(); // Début mesure. $chronometre3->lancerChrono($keyword . "FONCTIONS TO ARRAY"); foreach ($this->functions as $function) { $idFunc = $function["id"]; if (!in_array($idFunc, $treated)) { $this->params[$idFunc] = Doctrine_Core::getTable("EiFunctionHasParam")->findByFunctionRefAndFunctionId($function["function_ref"], $function["function_id"])->toArray(); } } // Fin mesure. $chronometre3->arreterEtAfficherChrono(); //*********************************************// //***** SI FIN SCENARIO *****// //*********************************************// // Début mesure. $chronometre4->lancerChrono($keyword . "FIN DE SCENARIO"); if (count($this->functions) == 0) { $this->getLogger()->info("----- Fin de scénario."); $this->ei_test_set->finish(); } // Fin mesure. $chronometre4->arreterEtAfficherChrono(); // Fin mesure. $chronometre1->arreterEtAfficherChrono(); } catch (Exception $e) { // var_dump($e); // exit; return $this->renderText('<error>' . $e->getMessage() . '</error>'); } } else { return $this->renderText('<error>' . $this->error . '</error>'); } }
public static function getScriptUpdateResult(EiProjet $ei_project, EiProfil $kal_profil, EiTicket $ei_ticket, $json_string, KalFunction $kal_function, EiUser $ei_user, $script_id = 0, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $ei_subject = Doctrine_Core::getTable("EiSubject")->findOneByPackageIdAndPackageRef($ei_ticket->getTicketId(), $ei_ticket->getTicketRef()); if ($ei_subject == null) { return array("success" => false, "message" => "Intervention not found ... "); } //Intervention non trouvée //Appel du webservice $result_update = MyFunction::loadResultOfWebServiceByPostJson(MyFunction::getPrefixPath(null) . "serviceweb/project/script/update.json", array('project_id' => $ei_project->getProjectId(), 'project_ref' => $ei_project->getRefId(), 'ticket_id' => $ei_ticket->getTicketId(), 'ticket_ref' => $ei_ticket->getTicketRef(), 'profile_id' => $kal_profil->getProfileId(), 'profile_ref' => $kal_profil->getProfileRef(), 'function_id' => $kal_function->getFunctionId(), 'function_ref' => $kal_function->getFunctionRef(), 'script_id' => $script_id, 'user_id' => $ei_user->getUserId(), 'user_ref' => $ei_user->getRefId(), 'package_name' => "Package_S" . $ei_subject->getId(), 'json_string' => rawurlencode($json_string))); //Récupération du projet pour traitement // if ($result_update == null) return null; // $result_file->loadXML($result_update); // $result_file->save('result_update.xml'); /* sauvegarde du fichier pour vérifier le bon fonctionnement du web service */ // $result_item=$result_file->documentElement; // if ($result_item->getElementsByTagName("error")->item(0)): // return -1; // endif; // if ($result_item->getElementsByTagName("process_error")->item(0)): // return 0; // endif; // if ($result_item->getElementsByTagName("process_ok")->item(0)): // return 1; // endif; try { $conn->beginTransaction(); //Récupération du ticket pour traitement $array_result = json_decode(html_entity_decode($result_update), true); //Récupération du projet pour traitement if (count($array_result) == 0) { return array("success" => false, "message" => "Error on transaction"); } if (array_key_exists("error", $array_result)) { return array("success" => false, "message" => $array_result["error"]); } if (array_key_exists("process_error", $array_result)) { return array("success" => false, "message" => $array_result["process_error"]); } if (!$array_result[0]) { return array("success" => false, "message" => "Empty result content"); } self::reload($array_result, $conn); $conn->commit(); return array("success" => true, "message" => "Transaction maded successfully"); } catch (Exception $e) { throw new Exception($e); $conn->rollback(); return array("success" => false, "message" => "Error on reload process ..."); } }
/** * Retourne la liste des scénarios dont l'utilisateur est ayant droit. * * @param EiUser $user * @return array|null */ public function getScenariosFromUser(EiUser $user) { // On définit la liste qui sera retournée à null. $liste = null; // On définit la requête SQL qui va interroger la base de données afin de récupérer les scénarios visibles par // l'utilisateur. $query = "\n SELECT *\n FROM ei_scenario\n WHERE (project_ref, project_id) IN (\n SELECT project_ref, project_id\n FROM ei_project_user\n WHERE user_ref = " . $user->getRefId() . "\n AND user_id = " . $user->getUserId() . "\n );\n "; // On récupère sous forme de tableau les scénarios. $scenarios = Doctrine_Manager::getInstance()->getCurrentConnection()->fetchAll($query); // Si le nombre de scénarios est supérieur à zéro, on crée les objets associés. if (count($scenarios) > 0) { foreach ($scenarios as $scenarioArray) { $temp = new EiScenario(); $temp->setArray($scenarioArray); $liste[] = $temp; } } return $liste; }
protected function setEiUser(EiUser $ei_user) { $this->ei_user = $ei_user; $this->setUserId($ei_user->getUserId()); $this->setUserRef($ei_user->getRefId()); }