/**
  * Action permettant de créer un data set.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->setLayout(false);
     $this->logger = sfContext::getInstance()->getLogger();
     // On détermine le type de contenu retourné.
     $this->getResponse()->setContentType('application/xml');
     $this->getUser()->signIn($this->user, true);
     /** @var EiProfilTable $tableProfil */
     $tableProfil = Doctrine_Core::getTable("EiProfil");
     /* @var EiDataSet $data_set */
     $data_set = $this->getRoute()->getObject();
     /** @var EiScenario $scenario */
     $scenario = Doctrine_Core::getTable("EiDataSet")->getDataSetScenario($data_set);
     /** @var EiProfil $profil */
     $profil = $tableProfil->findOneByProfileRefAndProfileId($request->getParameter("profil_ref"), $request->getParameter("profil_id"));
     $request->setParameter("ei_test_set_id", $data_set->getId());
     $request->setParameter("project_ref", $scenario->getProjectRef());
     $request->setParameter("project_id", $scenario->getProjectId());
     $request->setParameter("profile_ref", $profil->getProfileRef());
     $request->setParameter("profile_id", $profil->getProfileId());
     $request->setParameter("profile_name", $profil->getName());
     $this->logger->info("----------------------------------------------------------");
     $chronometre = new Chronometre();
     $chronometre->lancerChrono("PERFORMANCE RECUPERATION JDD");
     $content = $this->getController()->getPresentationFor("eidataset", "download");
     // Fin mesure
     $chronometre->arreterEtAfficherChrono();
     $this->logger->info("----------------------------------------------------------");
     return $this->renderText($content);
 }
 /**
  * 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);
 }
Esempio n. 3
0
 /**
  * @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>');
     }
 }
Esempio n. 4
0
 /**
  * @param EiTestSet $testSet
  * @param EiTestSetBlockParam $parent
  * @param null $index
  * @param string $path
  * @return mixed
  */
 public function generateTestSetParameters(EiTestSet $testSet = null, $parent = null, $index = null, $path = "", $deep = false, Doctrine_Connection $conn = null)
 {
     $conn = $conn == null ? Doctrine_Manager::connection() : $conn;
     $path .= "/" . $this->getName();
     $chronometre = new Chronometre();
     $recupStr = $chronometre->lancerChrono("Récupération structure param", true);
     // Vérification si l'élément existe.
     /** @var EiTestSetBlockParam $element */
     $element = EiTestSetBlockParamTable::getInstance()->findOneByEiTestSetIdAndPath($testSet->getId(), $path);
     $chronometre->arreterEtAfficherChrono("Récupération structure param", $recupStr);
     $eltExists = $element == null ? false : true;
     if (!$eltExists) {
         $element = new EiTestSetBlockParam();
         $element->setEiVersionStructureId($this->getId());
         $element->setName($this->getName());
         $element->setSlug($this->getSlug());
         $element->setType($this->getType());
         $element->setEiTestSetId($testSet->getId());
         $element->setIndexRepetition($index);
         $element->setPath($path);
         if ($parent != null) {
             $element->setParentId($parent->getId());
         }
     }
     $recupMap = $chronometre->lancerChrono("Récupération du mapping", true);
     /** @var EiBlockDataSetMapping $mapping */
     $mapping = $this->getMapping(EiBlockDataSetMapping::$TYPE_IN);
     if ($mapping != null && $parent->getType() == EiVersionStructure::$TYPE_FOREACH) {
         /** @var EiMappingStructureSyncIn $iteratorMap */
         $iteratorMap = $parent->getEiVersionStructure()->getIteratorMapping();
         /** @var Doctrine_Node_NestedSet $node */
         $node = $mapping != null ? $mapping->getEiDataSetStructureMapping()->getNode() : null;
         $indexToMap = !$node->isDescendantOf($iteratorMap->getEiDataSetStructureMapping()) ? 1 : $index;
         $value = $mapping->getValueFromTestSetJdd($testSet, $indexToMap, $parent);
     } elseif ($mapping != null) {
         $value = $mapping->getValueFromTestSetJdd($testSet, $index, $parent);
     } else {
         $value = "";
     }
     $chronometre->arreterEtAfficherChrono("Récupération du mapping", $recupMap);
     // Sauvegarde de la valeur de l'élément.
     $element->setValue($value);
     $saveChro = $chronometre->lancerChrono("Sauvegarde paramètre de block", true);
     $element->save($conn);
     if (!$eltExists) {
         if (!$parent->getNode()->getChildren()) {
             $element->getNode()->insertAsFirstChildOf($parent);
         } else {
             $element->getNode()->insertAsNextSiblingOf($parent->getNode()->getLastChild());
         }
     }
     $chronometre->arreterEtAfficherChrono("Sauvegarde paramètre de block", $saveChro);
     return $element;
 }
 /**
  * Génération des paramètres des blocks à partir du jeu de test et de son jeu de données.
  *
  * @param EiTestSet $testSet
  * @param EiTestSetBlockStack $stack
  * @return EiTestSetBlockParam|void
  */
 public function generate(EiTestSet $testSet, EiTestSetBlockStack $stack, Doctrine_Connection $conn = null)
 {
     $conn = $conn == null ? Doctrine_Manager::connection() : $conn;
     $chronometre = new Chronometre();
     // Début mesure.
     $gen = $chronometre->lancerChrono("GENERATION PARAMETRES DE BLOCK", true);
     // On récupère le block à partir de la pile.
     $block = $stack->getEiVersionStructure();
     // Récupération du parent.
     $parent = $block->getNode()->getParent();
     $index = null;
     $path = "";
     if ($parent != null && ($parent instanceof EiTestSetBlockParam || $parent instanceof EiVersionStructure)) {
         /** @var EiTestSetBlockParam $parent */
         $parent = $this->getParentBlock($testSet, $parent);
         $path = $parent->getPath();
         // TODO: Calcul index.
         $index = $stack->getRepetitionIndex();
     } else {
         $index = 1;
     }
     // Si le fragment de l'élément de la pile est supérieur à 1 alors le père a déjà été généré et on le récupère.
     if ($stack->getPartIndex() > 1) {
         $blockParam = Doctrine_Core::getTable("EiTestSetBlockParam")->findOneByEiTestSetIdAndIndexRepetitionAndEiVersionStructureId($testSet->getId(), $index, $block->getId());
         //            var_dump($blockParam->toArray(false));
         //            var_dump($stack->toArray(false));
     } else {
         // Génération des paramètres du Block.
         $blockParam = $block->generateTestSetParameters($testSet, $parent, $index, $path, false, $conn);
     }
     if ($blockParam != null) {
         // Ajout du block param dans la stack.
         $stack->setEiTestSetBlockParam($blockParam);
         $stack->setPath($blockParam->getPath());
         $stack->save($conn);
     }
     // Fin de la mesure.
     $chronometre->arreterEtAfficherChrono("GENERATION PARAMETRES DE BLOCK", $gen);
     return $blockParam;
 }
Esempio n. 6
0
 /**
  * @param EiTestSet $testSet
  * @param null $parent
  * @param null $index
  * @param string $path
  * @param bool $deep
  * @param Doctrine_Connection $conn
  *
  * @return EiTestSetBlockParam|mixed|void
  */
 public function generateTestSetParameters(EiTestSet $testSet = null, $parent = null, $index = null, $path = "", $deep = true, Doctrine_Connection $conn = null)
 {
     $conn = $conn == null ? Doctrine_Manager::connection() : $conn;
     $chronometre = new Chronometre();
     $index = $index == null ? 1 : $index;
     $path .= "/" . $this->getName() . "[" . $index . "]";
     // Vérification si l'élément existe.
     $element = EiTestSetBlockParamTable::getInstance()->findOneByEiTestSetIdAndPath($testSet->getId(), $path);
     if ($element == null) {
         // Création de l'élément.
         $element = new EiTestSetBlockParam();
         $element->setEiVersionStructureId($this->getId());
         $element->setName($this->getName());
         $element->setSlug($this->getSlug());
         $element->setType($this->getType());
         $element->setEiTestSetId($testSet->getId());
         $element->setIndexRepetition($index);
         $element->setPath($path);
         if ($parent != null) {
             $element->setParentId($parent->getId());
         }
         $element->save($conn);
         if ($parent == null) {
             $element->setRootId($element->getId());
             $element->setLft(1);
             $element->setRgt(2);
             $element->setLevel(0);
             $element->save($conn);
         } elseif ($parent != null) {
             /** @var EiTestSetBlockParam $parent */
             $parent->refresh(true);
             if (!$parent->getNode()->getChildren()) {
                 $element->getNode()->insertAsFirstChildOf($parent);
             } else {
                 $element->getNode()->insertAsNextSiblingOf($parent->getNode()->getLastChild());
             }
         }
     }
     $chronometre->lancerChrono("Récupération des paramètres");
     /** @var EiBlockParam[] $parametres */
     $parametres = $this->getParams();
     $chronometre->arreterEtAfficherChrono();
     $chronometre->lancerChrono("Génération des paramètres");
     /** @var EiBlockParam $param */
     foreach ($parametres as $param) {
         $param->generateTestSetParameters($testSet, $element, $index, $path);
     }
     $chronometre->arreterEtAfficherChrono();
     /** @var EiVersionStructure[] $descendants */
     $descendants = $this->getNode()->getDescendants(true);
     if ($deep === true && $descendants) {
         /** @var EiVersionStructure $descendant */
         foreach ($descendants as $descendant) {
             /** @var EiBlock $descendant */
             if ($descendant instanceof EiBlock || $descendant instanceof EiBlockForeach) {
                 $descendant->generateTestSetParameters($testSet, $element, $index, $path, false, $conn);
             }
         }
     } else {
         return $element;
     }
 }
 public function generateDataSet()
 {
     $this->chronometre->debug("------------------------------------------------------------------------------------");
     $this->chronometre->debug("-----   DEBUT GENERATION DU JEU DE DONNEES");
     $this->chronometre->debug("------------------------------------------------------------------------------------");
     $timerGlobalStart = microtime(true);
     /** @var EiDataLineTable $tableJdd */
     $tableJdd = Doctrine_Core::getTable("EiDataLine");
     /** @var EiTestSetDataSetTable $tableJdtJdd */
     $tableJdtJdd = Doctrine_Core::getTable("EiTestSetDataSet");
     /** @var EiDataSetStructureTable $tableStrJdd */
     $tableStrJdd = Doctrine_Core::getTable("EiDataSetStructure");
     $this->chronometre->lancerChrono("Recuperation arbre");
     // On récupère l'arbre de la structure du JDD.
     $structureArbre = $tableStrJdd->getTreeArrayForITree($this->testSet->getEiScenarioId());
     // Fin & affichage
     $this->chronometre->arreterEtAfficherChrono();
     $this->chronometre->lancerChrono("IMPORTATION ARBRE");
     // On créer le TreeExplorer.
     $this->tree = new TreeExplorer();
     // On importe la structure de l'arbre.
     $this->tree->import($structureArbre);
     // Fin & affichage
     $this->chronometre->arreterEtAfficherChrono();
     $chronoGeneration = new Chronometre();
     $chronoGeneration->lancerChrono("GENERATION JDD POUR JDT");
     // Si un jeu de données existe et que nous sommes à la première génération.
     if ($this->testSet->getEiDataSetId() != "" && $this->testSet->getEiTestSetDataSet()->count() == 0) {
         $conn = Doctrine_Manager::connection();
         $chronoSub = new Chronometre();
         $datas = array();
         $nodes = array();
         $chronoSub->lancerChrono("PERFORMANCE - COPIE JDD -> JDD FOR JDT");
         $tableJdtJdd->copyDataLinesFromDataSet($this->testSet->getId(), $this->testSet->getEiDataSetId(), $conn);
         $chronoSub->arreterEtAfficherChrono();
         $chronoSub->lancerChrono("PERFORMANCE - RECUPERATION ELTS");
         $lines = $tableJdtJdd->getLines($this->testSet->getId());
         $chronoSub->arreterEtAfficherChrono();
         $chronoSub->lancerChrono("PERFORMANCE - TRAITEMENT ELTS");
         foreach ($lines as $line) {
             $data = array("id" => $line["id"], "structure_id" => $line["ei_data_set_structure_id"], "type" => $line["type"], "lft" => $line["lft"], "rgt" => $line["rgt"], "level" => $line["level"]);
             $data = array_merge($data, $this->evaluateIndexes($nodes, $data["structure_id"], $data["lft"], $data["rgt"]));
             if ($data["type"] == EiDataSetStructure::$TYPE_NODE) {
                 array_unshift($nodes, $data);
             }
             $datas[] = $data;
         }
         $chronoSub->arreterEtAfficherChrono();
         try {
             // Début chrono.
             $chronoSub->lancerChrono("PERFORMANCE - SAUVEGARDE ELTS");
             // Début transaction
             $conn->beginTransaction();
             // Insertion des lignes.
             $tableJdtJdd->updateLinesIndexesFromTab($datas, $this->testSet->getId(), $conn);
             // COMMIT.
             $conn->commit();
             // Fin chrono.
             $chronoSub->arreterEtAfficherChrono();
         } catch (Exception $exc) {
             $conn->rollback();
         }
     } else {
         $this->lignes = $tableStrJdd->createQuery("q")->from("EiDataSetStructure dss")->where("dss.ei_scenario_id = ?", $this->testSet->getEiScenarioId())->andWhere("dss.type = ?", EiDataSetStructure::$TYPE_LEAF)->andWhere("dss.level = 1")->orderBy("dss.lft")->execute();
         $this->treatEmpty($this->tree->getRoot());
         $this->generate($this->tree->getRoot());
         if ($this->maxRight > 2) {
             // Mise à jour du root_id pour les éléments.
             $this->root->setRgt($this->maxRight + 1);
             $this->root->save();
         }
     }
     // Fin & affichage
     $chronoGeneration->arreterEtAfficherChrono();
     // Arrêt du timer global.
     $timerGlobalEnd = microtime(true);
     // Affichage du chrono.
     $this->chronometre->afficherChrono("GENERATION DU JEU DE DONNEES", $timerGlobalStart, $timerGlobalEnd);
 }
 /**
  * @param EiTestSet $testSet
  * @param null $parent
  * @param null $index
  * @param string $path
  * @param bool $deep
  * @return mixed|void
  */
 public function generateTestSetParameters(EiTestSet $testSet = null, $parent = null, $index = null, $path = "", $deep = true, Doctrine_Connection $conn = null)
 {
     $conn = $conn == null ? Doctrine_Manager::connection() : $conn;
     $chronometre = new Chronometre();
     $modeCreation = true;
     $index = $index == null ? 1 : $index;
     $newPath = $path . "/" . $this->getName();
     $nombreElts = 1;
     /** @var EiBlockParam[] $parametres */
     $parametres = $this->getParams();
     /** @var EiMappingStructureSyncIn $iteratorMap */
     $iteratorMap = $this->getIteratorMapping();
     $chronometre->lancerChrono("Calcul Mapping");
     //        if( $this->nombreElts != null ){
     //            $nombreElts = $this->nombreElts;
     //        }
     //        else{
     //            $nombreElts =  $iteratorMap->getCountMappingFromTestSetJdd($testSet, $parent);
     //            $this->nombreElts = $nombreElts;
     //        }
     $chronometre->arreterEtAfficherChrono();
     if ($index == null && $nombreElts > 1) {
         return $this->generateTestSetParameters($testSet, $parent, 1, $path);
     }
     $newPath .= "[" . $index . "]";
     // Vérification si l'élément existe.
     /** @var EiTestSetBlockParam $element */
     $element = EiTestSetBlockParamTable::getInstance()->findOneByEiTestSetIdAndPath($testSet->getId(), $newPath);
     if ($element == null) {
         // Création de l'élément.
         $element = new EiTestSetBlockParam();
         $element->setEiVersionStructureId($this->getId());
         $element->setName($this->getName());
         $element->setSlug($this->getSlug());
         $element->setType($this->getType());
         $element->setEiTestSetId($testSet->getId());
         $element->setIndexRepetition($index);
         $element->setPath($newPath);
         if ($parent != null) {
             $element->setParentId($parent->getId());
         }
         $element->save($conn);
         if ($parent == null) {
             $element->setRootId($element->getId());
             $element->setLft(1);
             $element->setRgt(2);
             $element->setLevel(0);
             $element->save($conn);
         } else {
             /** @var EiTestSetBlockParam $parent */
             $parent->refresh(true);
             if (!$parent->getNode()->getChildren()) {
                 $element->getNode()->insertAsFirstChildOf($parent);
             } else {
                 $element->getNode()->insertAsNextSiblingOf($parent->getNode()->getLastChild());
             }
         }
     } else {
         $modeCreation = false;
     }
     $element->getBlockContext();
     $chronometre->lancerChrono("Génération des paramètres");
     /** @var EiBlockParam $param */
     foreach ($parametres as $param) {
         $param->generateTestSetParameters($testSet, $element, $index, $newPath, false, $conn);
     }
     $chronometre->arreterEtAfficherChrono();
     /** @var EiVersionStructure[] $descendants */
     $descendants = $this->getNode()->getDescendants(true);
     if ($deep === true && $descendants) {
         /** @var EiVersionStructure $descendant */
         foreach ($descendants as $descendant) {
             /** @var EiBlock $descendant */
             if ($descendant instanceof EiBlock || $descendant instanceof EiBlockForeach) {
                 $descendant->generateTestSetParameters($testSet, $element, 1, $newPath);
             }
         }
     }
     if ($deep === true && $index < $nombreElts && $modeCreation == true) {
         return $this->generateTestSetParameters($testSet, $parent, $index + 1, $path);
     } else {
         return $element;
     }
 }