/**
  * 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);
     try {
         $this->getUser()->signIn($this->user, true);
         /** @var EiNodeTable $tableEiNode */
         $tableEiNode = Doctrine_Core::getTable("EiNode");
         // Récupération du noeud du scénario.
         $node = $this->scenario->getEiNode();
         // Recherche de la structure des fichiers des jeux de données.
         $rootFolder = Doctrine_Core::getTable('EiNode')->findOneByRootIdAndType($node->getId(), 'EiDataSetFolder');
         // On récupère ensuite la structure brute des dossiers.
         $structureBrute = $tableEiNode->getStructureDataSets($rootFolder);
         $structureBrute["root"]["name"] = "Root";
         // Puis on la retravaille.
         //            $structure = $this->getReorderedStructure(array(), $structureBrute);
         $response = json_encode(array("tree" => array($structureBrute)));
     } catch (Exception $e) {
         $response = array();
     }
     return $this->renderText($response);
 }
Exemplo n.º 2
0
 public function checkLogicBetweenProjectAndScenario(EiProjet $ei_project, EiScenario $ei_scenario)
 {
     //On vérifie si le scénario appartient bien au projet
     if ($ei_project->getProjectId() != $ei_scenario->getProjectId() || $ei_project->getRefId() != $ei_scenario->getProjectRef()) {
         $this->forward404('Scenario  don\'t belong to project');
     }
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
 /**
  * @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);
 }
 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());
 }
 /**
  * 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;
 }
 /**
  * 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));
 }
 /**
  * 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));
 }
Exemplo n.º 13
0
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;
}
Exemplo n.º 14
0
 /**
  * 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');
     }
 }
Exemplo n.º 15
0
 public function evaluatePathToObject(EiScenario $ei_scenario)
 {
     $this->chemin = "";
     $this->chemin = $ei_scenario->getPathTo();
 }
Exemplo n.º 16
0
 public function evaluatePathToScenario(EiScenario $ei_scenario, $breadcrumb, EiProjet $ei_project, EiProfil $ei_profile)
 {
     return $ei_scenario->getPathTo($breadcrumb, $ei_project, $ei_profile);
 }
Exemplo n.º 17
0
 public function createCopie($new_name, $conn = null)
 {
     //Récupération de la variable de connexion pour éffectuer les transactions
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     //Récupération du noeud associé au scénario
     try {
         $conn->beginTransaction();
         $copie = new EiScenario();
         $copie->setProjectId($this->getProjectId());
         $copie->setProjectRef($this->getProjectRef());
         $copie->setNomScenario($new_name);
         $copie->setNbJoue(0);
         $copie->setDescription($this->getDescription());
         $this->createNodeCopie($copie, $conn);
         $this->createEiVersionsCopies($copie, $conn);
         $this->createProfilScenarioForClone($copie, $conn);
         $conn->commit();
         //return $copie;
     } catch (Exception $e) {
         $conn->rollback();
         throw $e;
     }
     return $copie;
 }
Exemplo n.º 18
0
 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);
 }
 /**
  * Action permettant de créer un data set.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->logger = sfContext::getInstance()->getLogger();
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   DEBUT SAUVEGARDE DATA SET");
     $this->setLayout(false);
     $this->getResponse()->setContentType('application/json');
     $this->getUser()->signIn($this->user, true);
     // On récupère le noeud parent du scénario.
     $noeud_id = $this->scenario->getEiNode()->getId();
     $noeud_parent = Doctrine_Core::getTable("EiNode")->findOneByRootIdAndType($noeud_id, "EiDataSetFolder");
     $noeud_parent_id = $noeud_parent->getId();
     // Récupération du nom & description.
     $nom = $request->getPostParameter("name");
     $desc = $request->getPostParameter("description");
     // On récupère le data set source (si enregistrement).
     $dataSetSourceId = $request->getPostParameter("jddSource");
     // On récupère le data set template source (si enregistrement).
     $dataSetTemplateSourceId = $request->getPostParameter("jddTemplateSource");
     // On récupère le dossier où enregistrer le JDD.
     $dataSetDirId = $request->getPostParameter("jddDir");
     // On décode le fichier.
     $request->setParameter("file", str_replace("%3E", ">", str_replace("%3C", "<", $request->getParameter("file"))));
     // LOGS
     $this->logger->info("-- NOM : " . $nom);
     $this->logger->info("-- DESCRIPTION : " . $desc);
     $this->logger->info("-- JDD SOURCE ID : " . $dataSetSourceId);
     $this->logger->info("-- JDD TEMPLATE SOURCE ID : " . $dataSetTemplateSourceId);
     $this->logger->info("-- NOEUD ID PARENT : " . $noeud_parent_id);
     $this->logger->info("----------------------------------------------------------");
     $this->logger->info("---   FIN SAUVEGARDE DATA SET");
     $this->logger->info("----------------------------------------------------------");
     $request->setParameter("ei_user", $this->user->getEiUser());
     $request->setParameter("name", $nom);
     $request->setParameter("description", $desc);
     $request->setParameter("ei_node_parent_id", $noeud_parent_id);
     if ($dataSetSourceId != null && $dataSetSourceId != -1) {
         $request->setParameter("dataSetSource", $dataSetSourceId);
     }
     if ($dataSetTemplateSourceId != null && $dataSetTemplateSourceId != -1) {
         $request->setParameter("dataSetTemplateSource", $dataSetTemplateSourceId);
     }
     if ($dataSetDirId != null && $dataSetDirId != -1) {
         $oJddDir = Doctrine_Core::getTable("EiNode")->find($dataSetDirId);
         if ($oJddDir != null && $oJddDir->getObjId() != "") {
             $request->setParameter("dataSetDir", $dataSetDirId);
             $request->setParameter("ei_node_parent_id", $dataSetDirId);
         }
     }
     $this->logger->info("----------------------------------------------------------");
     $chronometre = new Chronometre();
     $chronometre->lancerChrono("PERFORMANCE CREATION JDD");
     try {
         $content = $this->getController()->getPresentationFor("eidataset", "lightCreateFromXml");
     } catch (Exception $exc) {
         $this->logger->info("--- ERREUR : " . $exc->getMessage() . " ---");
     }
     // Fin mesure
     $chronometre->arreterEtAfficherChrono();
     $this->logger->info("----------------------------------------------------------");
     return $this->renderText($content);
 }
Exemplo n.º 20
0
 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;
 }
Exemplo n.º 21
0
 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);
 }