public function getScenarioVersionsWithPackage(EiScenario $ei_scenario, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $q = "( SELECT \n v.id as v_id, v.libelle as v_libelle, v.description as v_description, v.created_at as v_created_at, v.updated_at as v_updated_at,\n sp.ei_scenario_id as sp_ei_scenario_id, sp.package_id as sp_package_id, sp.package_ref as sp_package_ref, sp.ei_version_id as sp_ei_version_id,\n t.ticket_id as t_ticket_id, t.ticket_ref as t_ticket_ref, t.name as t_name ,\n s.id as subject_id, s.name as subject_name,s.delivery_id as delivery_id,\n d.name as delivery_name\n FROM ei_version v \n left join ei_scenario_package sp on v.id=sp.ei_version_id \n left join ei_ticket t on t.ticket_id=sp.package_id and t.ticket_ref=sp.package_ref\n left join ei_subject s on s.package_id=t.ticket_id and s.package_ref=t.ticket_ref\n left join ei_delivery d on s.delivery_id=d.id\n Where v.ei_scenario_id =" . $ei_scenario->getId() . " )"; return $conn->fetchAll($q); }
public function getLastScenarioExecution(EiProjet $ei_project, EiScenario $ei_scenario = null) { $q = Doctrine_Query::create()->from('EiLogFunction elf ')->where('EiScenario.id=elf.ei_scenario_id')->andWhere(" EiScenario.project_ref=? And EiScenario.project_id=?", array($ei_project->getRefId(), $ei_project->getProjectId())); if ($ei_scenario != null) { $q = $q->andWhere('EiScenario.id=' . $ei_scenario->getId()); } return $q->orderBy('elf.date_debut DESC')->limit(1); }
/** * Action permettant de créer un data set. * * @param sfWebRequest $request */ public function execute($request) { $this->ei_scenario = Doctrine_Core::getTable('EiScenario')->find($this->scenario->getId()); $this->forward404Unless($this->ei_scenario); $this->forward404Unless(Doctrine_Core::getTable("EiProjectUser")->getEiProjet($this->ei_scenario->getProjectId(), $this->ei_scenario->getProjectRef(), $this->user->getEiUser())); /** @var EiDataSetStructure $ei_root_node */ $ei_root_node = Doctrine_Core::getTable("EiDataSetStructure")->getRoot($this->ei_scenario->getId()); $this->forward404Unless($ei_root_node); /** @var DOMDocument $xsd */ $xsd = EiDataSetStructure::createXSD($ei_root_node); $xsd->formatOutput = true; $xsd = $xsd->saveXML(); $response = $this->getResponse(); $response->setContentType('text/xml'); $response->setHttpHeader('Content-Disposition', 'attachment; filename="' . $this->ei_scenario->getNomScenario() . '-XSD.xsd'); $response->setContent($xsd); return sfView::NONE; }
public function findEiScenarioTestsSet(EiScenario $ei_scenario) { // $this->EiScenarioTestsSet= Doctrine_Query::create() // ->from('EiTestSet') // ->where('ei_scenario_id='.$ei_scenario->getId()) // ->orderBy('id DESC') // ->execute() // ; $this->EiScenarioTestsSet = Doctrine_Core::getTable("EiTestSet")->findAllTestSet($ei_scenario->getId()); }
/** * Action permettant de récupérer l'arbre des jeux de données. * * @param sfWebRequest $request */ public function execute($request) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT RECUPERATION ARBRE DATA SET"); $this->getResponse()->setContentType('application/json'); $this->setLayout(false); $response = array("error" => "An error occured when we try to create your directory."); try { $this->getUser()->signIn($this->user, true); /** @var EiNodeTable $tableEiNode */ $tableEiNode = Doctrine_Core::getTable("EiNode"); // Récupération des données. $nom = $request->getPostParameter("name"); $parentNodeId = $request->getPostParameter("parent_node_id"); if ($nom == null || $parentNodeId == null) { $response["error"] = "You have to select a parent directory and type a valid directory name"; } else { /** @var EiNode $parentNode Récupération du noeud parent. */ $parentNode = $tableEiNode->find($parentNodeId); if ($parentNode != null && $parentNode->getId() != "" && $parentNode->getEiScenarioNode()->getObjId() == $this->scenario->getId()) { try { $folder = new EiNode(); $folder->setName($nom); $folder->setType(EiNode::$TYPE_DATASET_FOLDER); $folder->setProjectId($parentNode->getProjectId()); $folder->setProjectRef($parentNode->getProjectRef()); $folder->setRootId($parentNode->getId()); $folder->save(); unset($response["error"]); $response["id"] = $folder->getId(); } catch (Exception $exc) { $response["error"] = "An error occured when we tried to create directory : " . $exc->getMessage(); } } else { $response["error"] = "We are not able to accommodate your request."; } } } catch (Exception $e) { $response = array(); } return $this->renderText(json_encode($response)); }
public function getFunctionByScenarioTestSetAndPosition($position, EiScenario $ei_scenario = null, EiTestSet $ei_test_set = null) { if ($position == null || $ei_scenario == null || $ei_test_set == null) { return null; } $q = Doctrine_Core::getTable('EiFonction')->createQuery('f')->where('EiTestSetFunction.ei_fonction_id=f.id And EiTestSetFunction.ei_test_set_id=? And EiTestSetFunction.position=?', array($ei_test_set->getId(), $position))->andWhere('EiTestSet.id=EiTestSetFunction.ei_test_set_id And EiTestSet.ei_scenario_id=?', array($ei_scenario->getId()))->execute(); if (count($q) > 0) { return $q->getFirst(); } return null; }
public function verifyMatchingBetweenJddAndScenario(EiDataSet $ei_data_set, EiScenario $ei_scenario) { $data_set_scenario = $this->getDataSetScenario($ei_data_set); if ($data_set_scenario == null) { return false; } if ($data_set_scenario->getId() == $ei_scenario->getId()) { return true; } return false; }
/** * @param $nom * @param $description * @param EiScenario $scenario * @throws Exception */ public function createEmpty($nom, $description, EiNode $noeud, EiScenario $scenario) { $this->name = $nom; $this->description = $description; $this->setEiNode($noeud); $root_str = $this->tableStructure->getRoot($scenario->getId()); if (is_null($root_str)) { throw new Exception("Scenario's not found."); } $this->setRootStr($root_str); }
/** * Action permettant de créer un data set. * * @param sfWebRequest $request */ public function execute($request) { $this->setLayout(false); $this->getResponse()->setContentType('application/json'); try { // Création du tableau de résultats. $profils = array(); /** @var EiProfilTable $tableProfilScenario */ $tableProfilScenario = Doctrine_Core::getTable("EiProfil"); $profilsListe = $tableProfilScenario->getProfilsScenarioForUser($this->user, $this->scenario->getId()); if ($profilsListe !== null) { /** @var EiProfil $profil */ foreach ($profilsListe as $profil) { $profils[] = array("ref" => $profil->getProfileRef(), "id" => $profil->getProfileId(), "nom" => $profil->getName()); } } } catch (Exception $e) { $profils = array(); } return $this->renderText(json_encode(array("environnements" => $profils))); }
/** * Action permettant de récupérer l'arbre des jeux de données. * * @param sfWebRequest $request */ public function execute($request) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT RECUPERATION ARBRE DATA SET"); $this->getResponse()->setContentType('application/json'); $this->setLayout(false); $response = array("error" => "An error occured when we try to delete your directory."); try { $this->getUser()->signIn($this->user, true); /** @var EiNodeTable $tableEiNode */ $tableEiNode = Doctrine_Core::getTable("EiNode"); // Récupération des données. $nodeId = $request->getPostParameter("node_id"); if ($nodeId == null) { $response["error"] = "You have to select a directory"; } else { /** @var EiNode $node Récupération du noeud à modifier. */ $node = $tableEiNode->find($nodeId); if ($node != null && $node->getId() != "" && $node->getEiScenarioNode()->getObjId() == $this->scenario->getId()) { try { if ($node->getNodes(true, true, true)->count() == 0) { unset($response["error"]); $node->delete(); $response["status"] = "OK"; } else { $response["error"] = "We are not able to accommodate your request because the directory is not empty."; } } catch (Exception $exc) { $response["error"] = "An error occured when we tried to delete directory : " . $exc->getMessage(); } } else { $response["error"] = "We are not able to accommodate your request."; } } } catch (Exception $e) { $response = array(); } return $this->renderText(json_encode($response)); }
public function createItem(EiScenario $ei_scenario, EiDelivery $ei_delivery, EiTicket $ei_ticket, sfGuardUser $guard_user, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $stmt = $conn->prepare("INSERT INTO ei_package_scenario_conflict (ei_scenario_id,delivery_id,package_id, package_ref,resolved_date,resolved_author,created_at,updated_at) " . "VALUES (:ei_scenario_id,:delivery_id,:package_id, :package_ref,:resolved_date,:resolved_author,:created_at,:updated_at) " . "ON DUPLICATE KEY UPDATE ei_scenario_id=ei_scenario_id, delivery_id=delivery_id, package_id=:package_id,package_ref=:package_ref"); $stmt->bindValue("ei_scenario_id", $ei_scenario->getId()); $stmt->bindValue("delivery_id", $ei_delivery->getId()); $stmt->bindValue("package_id", $ei_ticket->getTicketId()); $stmt->bindValue("package_ref", $ei_ticket->getTicketRef()); $stmt->bindValue("resolved_date", date('Y-m-d H:i:s')); $stmt->bindValue("resolved_author", $guard_user->getId()); $stmt->bindValue("created_at", date('Y-m-d H:i:s')); $stmt->bindValue("updated_at", date('Y-m-d H:i:s')); $stmt->execute(array()); }
function createAndSaveScenario(EiProjet $ei_project, EiNode $root_node) { //On crée le noeud du scénario avant de créer le scénario en soit $ei_node = new EiNode(); $ei_scenario = new EiScenario(); $ei_node->setIsRoot(false); $ei_node->setProjectId($ei_project->getProjectId()); $ei_node->setProjectRef($ei_project->getRefId()); $ei_node->setName('testNomScenario'); $ei_node->setPosition(Doctrine_Core::getTable('EiNode')->getLastPositionInNode($ei_project->getProjectId(), $ei_project->getRefId(), $root_node->getId())); $ei_node->setType('EiScenario'); $ei_node->setRootId($root_node->getId()); $ei_scenario->project_id = $ei_project->getProjectId(); $ei_scenario->project_ref = $ei_project->getRefId(); $ei_scenario->setNomScenario('testNomScenario'); $ei_scenario->setEiNode($ei_node); $ei_scenario->save(); $ei_node->setObjId($ei_scenario->getId()); $ei_node->save(); return $ei_scenario; }
/** * Copie le noeud du scenario. * @param EiScenario $copie * @param type $conn * @throws Exception */ private function createNodeCopie(EiScenario $copie, $conn) { try { $root_folder = $this->getNode(); $ei_node = new EiNode(); $ei_node->setProjectId($this->getProjectId()); $ei_node->setProjectRef($this->getProjectRef()); $ei_node->setName($copie->getNomScenario()); $ei_node->setPosition(Doctrine_Core::getTable('EiNode')->getLastPositionInNode($this->getProjectId(), $this->getProjectRef(), $root_folder->getRootId())); $ei_node->setIsRoot(false); $ei_node->setIsShortcut(false); $ei_node->setRootId($root_folder->getRootId()); $ei_node->setType("EiScenario"); $copie->setEiNode($ei_node); $copie->save($conn, true); //$copie->createDefaultEiDataSetFolder($conn); $ei_node->setObjId($copie->getId()); $copie->save($conn, true); } catch (Exception $e) { throw $e; } }
public function getAssociatedProfilesForScenario($package_id, $package_ref, EiScenario $ei_scenario = null, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $q = "SELECT v.ei_scenario_id,ps.ei_version_id, ps.profile_id, ps.profile_ref\n FROM `ei_profil_scenario` AS ps\n LEFT JOIN ei_version AS v ON v.id = ps.ei_version_id\n LEFT JOIN ei_scenario_package AS sp ON sp.ei_version_id=v.id \n WHERE sp.package_id =" . $package_id . "\n AND sp.package_ref =" . $package_ref; if ($ei_scenario != null) { $q .= " And v.ei_scenario_id=" . $ei_scenario->getId(); } $q .= " ORDER BY v.ei_scenario_id ASC"; return $conn->fetchAll($q); }
/** * Méthode permettant de vérifier que le jeu de données est valide et concorde avec le scénario. * * A savoir : * - scénario/jeu de données -> le second doit être contenu dans le premier * * @param sfWebRequest $request * @param EiScenario $scenario */ public function checkEiDataSet(sfWebRequest $request, EiScenario $scenario) { $this->ei_data_set_id = $request->getParameter("ei_data_set_id"); // On vérifie que l'identifiant du JDD est bien renseigné. if ($this->ei_data_set_id != null) { // Puis, on récupère le jeu de données. $this->ei_data_set = Doctrine_Core::getTable("EiDataSet")->find($this->ei_data_set_id); // Et on vérifie que le jeu de données existe. if ($this->ei_data_set != null) { // Enfin, on vérifie que ces deux derniers sont cohérents if (!($this->ei_data_set->getEiNode()->getEiScenarioNode()->getObjId() == $scenario->getId())) { $this->forward404("Bad data set : It's not related to the input scenario"); } } else { $this->forward404("Data set not found"); } } else { $this->forward404('Missing data line parameters'); } }
public function checkJdtWithScenario($ei_test_set_id, EiScenario $ei_scenario = null) { $this->ei_test_set_id = $ei_test_set_id; if ($ei_scenario == null || $this->ei_test_set_id == null) { $this->ei_test_set_id = null; $this->ei_test_set = null; return 0; } //Recherche du profil en base $this->ei_test_set = Doctrine_Core::getTable('EiTestSet')->findOneByIdAndEiScenarioId($this->ei_test_set_id, $ei_scenario->getId()); return 1; }
public function getScenarioStats(EiScenario $ei_scenario, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $q = "\n SELECT ts.*, SUM(tsf.duree) as scenario_exe_time \n FROM `ei_test_set` as ts , ei_test_set_function as tsf, ei_scenario as s\n WHERE ts.id=tsf.ei_test_set_id \n And project_id=" . $ei_scenario->getProjectId() . " And project_ref=" . $ei_scenario->getProjectRef() . "\n And ts.ei_scenario_id=" . $ei_scenario->getId() . " \n GROUP BY ts.id\n ORDER BY ts.created_at ASC\n "; return $conn->fetchAll($q); }