示例#1
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;
 }
示例#2
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;
     }
 }
示例#3
0
 /**
  * Webservice permettant la mise à jour des logs du jeu de test.
  *
  * @param sfWebRequest $request
  * @return type
  * @throws Exception
  */
 public function executeRetrieveLogs(sfWebRequest $request)
 {
     $this->setLayout(false);
     $this->getResponse()->setContentType('application/json');
     $this->logger = sfContext::getInstance()->getLogger();
     $statutPlaying = StatusConst::STATUS_PROCESSING_DB;
     $statutOk = StatusConst::STATUS_OK_DB;
     $statutKo = StatusConst::STATUS_KO_DB;
     /** @var EiTestSetTable $tableJDT */
     $tableJDT = Doctrine_Core::getTable("EiTestSet");
     $synchronized = false;
     try {
         $this->getUrlParameters($request);
         $JSONStr = $request->getParameter('logs');
         $ei_log = Doctrine_Core::getTable('EiLog')->findOneByEiTestSetIdAndEiScenarioIdAndProfileIdAndProfileRefAndId($this->ei_test_set->getId(), $this->ei_scenario->getId(), $this->profile_id, $this->profile_ref, $request->getParameter('ei_log_id'));
         $this->logger->debug($JSONStr);
         $JSONArray = json_decode($JSONStr);
         $ei_log_st = $statutPlaying;
         $i = 0;
         // Récupération de l'itération active selon le projet & profil.
         $iterationActive = $this->ei_test_set->getEiIteration();
         //***************************************************************************//
         //*****     PARCOURS DE LA LISTE DE FONCTIONS/LOGS EXECUTE(E)S JSON     *****//
         //***************************************************************************//
         foreach ($JSONArray as $i => $data) {
             /** @var EiTestSetFunction $test_set_function */
             $test_set_function = Doctrine_Core::getTable('EiTestSetFunction')->findOneByPositionAndEiTestSetId($data->{'position'}, $this->ei_test_set->getId());
             if (is_null($test_set_function)) {
                 throw new Exception($data->{'position'} . " not found.");
             }
             //si une fonction a le status KO, on met KO au log.
             if ($data->{'resultat'} == $statutKo) {
                 $ei_log_st = $statutKo;
             } elseif ($data->{'resultat'} == $statutOk) {
                 $ei_log_st = $statutOk;
             }
             //assignation des valeurs pour les logs de la dernière execution du jeu de test.
             $test_set_function->setStatus($data->{'resultat'});
             $test_set_function->setDateDebut($data->{'datedebut'});
             $test_set_function->setDateFin($data->{'datefin'});
             $test_set_function->setDuree($data->{'duree'});
             //*************************************************//
             //*****     Création des logs d'execution     *****//
             //*************************************************//
             $log = new EiLogFunction();
             $log->setEiFonction($test_set_function->getEiFonction());
             $log->setFunctionRef($test_set_function->getFunctionRef());
             $log->setFunctionId($test_set_function->getFunctionId());
             $log->setEiIteration($iterationActive);
             $log->setEiLogId($ei_log->getId());
             $log->setEiTestSetFunctionId($test_set_function->getId());
             $log->setEiTestSetId($this->ei_test_set->getId());
             $log->setEiScenarioId($this->ei_scenario->getId());
             $log->setPosition($test_set_function->getPosition());
             $log->setDateDebut($data->{'datedebut'});
             $log->setDateFin($data->{'datefin'});
             $log->setDuree($data->{'duree'});
             $log->setStatus($ei_log_st);
             //*******************************************************************//
             //*****     Création des logs des paramètres de la fonction     *****//
             //*******************************************************************//
             $params = $test_set_function->getEiTestSetParams();
             $paramsColl = new Doctrine_Collection('EiLogParam');
             if ($params) {
                 foreach ($params as $p => $param) {
                     $paramLog = new EiLogParam();
                     $paramLog->setEiLogId($ei_log->getId());
                     $paramLog->setEiIteration($iterationActive);
                     $paramLog->setFunctionId($test_set_function->getFunctionId());
                     $paramLog->setFunctionRef($test_set_function->getFunctionRef());
                     $paramLog->setEiTestSetId($this->ei_test_set->getId());
                     $paramLog->setParamId($param->getParamId());
                     $paramLog->setParamValeur($param->getValeur());
                     $paramLog->setParamName($param->getEiFunctionHasParam()->getName());
                     $ei_param = Doctrine_Core::getTable('EiParam')->findOneByParamIdAndIdFonction($param->getParamId(), $test_set_function->getEiFonction()->getId());
                     $paramLog->setEiParam($ei_param);
                     $paramLog->setEiLogFunction($log);
                     $paramsColl->add($paramLog);
                 }
             }
             //*****************************************************************//
             //*****     Traitement des paramètres retournés par l'IDE     *****//
             //*****************************************************************//
             foreach ($data->{"parameters"} as $paramName => $paramValue) {
                 //****************************************************************************//
                 //*****     Recherche du paramètre de sortie dans la base de données     *****//
                 //****************************************************************************//
                 /** @var EiFunctionHasParam $paramBD */
                 $paramBD = Doctrine_Core::getTable('EiFunctionHasParam')->findOneByFunctionRefAndFunctionIdAndNameAndParamType($test_set_function->getEiFonction()->getFunctionRef(), $test_set_function->getEiFonction()->getFunctionId(), $paramName, "OUT");
                 // On détermine le XPATH.
                 $xpathF = $test_set_function->getXpath();
                 $xpathF .= $xpathF == "/Root" ? "[1]" : "";
                 $paramsToUpdate = array();
                 $position = $data->{'position'};
                 $request->setParameter("position", $position);
                 //si un paramètre de sorti a été trouvé, alors on renseigne sa log.
                 if ($paramBD) {
                     $this->logger->info("---   Synchronisation des paramètres de fonction avec les paramètres de block   ---");
                     $this->logger->info("-----------------------------------------------------------------------------------");
                     $this->logger->info("---   Paramètre de fonction trouvé : " . $paramBD->getName());
                     $this->logger->info("---   Nb de mapping du paramètre trouvé(s) : " . $paramBD->getEiFunctionParamMapping()->count());
                     // Création du log du paramètre.
                     $paramLog = new EiLogParam();
                     $paramLog->setEiLogId($ei_log->getId());
                     $paramLog->setEiIteration($iterationActive);
                     $paramLog->setFunctionId($test_set_function->getFunctionId());
                     $paramLog->setFunctionRef($test_set_function->getFunctionRef());
                     $paramLog->setEiTestSetId($this->ei_test_set->getId());
                     $paramLog->setParamId($paramBD->getParamId());
                     $paramLog->setParamValeur($paramValue);
                     $paramLog->setParamName($paramBD->getName());
                     $paramLog->setParamType($paramBD->getParamType());
                     $paramLog->setEiLogFunction($log);
                     $paramsColl->add($paramLog);
                     $paramTestSet = Doctrine_Core::getTable('EiTestSetParam')->findOneByEiTestSetFunctionIdAndParamIdAndParamType($test_set_function->getId(), $paramBD->getParamId(), "OUT");
                     if ($paramTestSet) {
                         $paramTestSet->setValeur($paramValue);
                         $paramTestSet->save();
                     }
                     //****************************************************************************************************//
                     //*****     SYNCHRONISATION DES PARAMETRES DE FONCTION DANS LES PARAMETRES DE BLOCK ASSOCIES     *****//
                     //****************************************************************************************************//
                     /** @var EiParamBlockFunctionMapping[] $mappings */
                     $mappings = $paramBD->getEiFunctionParamMapping();
                     foreach ($mappings as $mapping) {
                         $this->logger->info("---   Mapping Fonction ID : " . $mapping->getEiFunctionId());
                         $this->logger->info("---   Log Fonction ID : " . $log->getEiFonctionId());
                         $this->logger->info("---   Mapping Param Block ID : " . $mapping->getEiParamBlockId());
                         $this->logger->info("---   Param Block PATH : " . $xpathF . "/" . $mapping->getEiBlockParamMapping()->getName());
                         if ($mapping->getEiFunctionId() == $log->getEiFonctionId() && $mapping->getEiParamBlockId() != "") {
                             // Récupération du paramètre du block correspondant du jeu de test.
                             /** @var EiTestSetBlockParam $blockParam */
                             $blockParam = EiTestSetBlockParamTable::getInstance()->findOneByPathAndEiVersionStructureIdAndEiTestSetId($xpathF . "/" . $mapping->getEiBlockParamMapping()->getName(), $mapping->getEiParamBlockId(), $test_set_function->getEiTestSetId());
                             if ($blockParam != null) {
                                 $this->logger->info("---   Param to UPDATE : " . "'#{" . $blockParam->getName() . "}'");
                                 $synchronized = true;
                                 $paramsToUpdate[] = "'#{" . $blockParam->getName() . "}'";
                                 $blockParam->setValue($paramValue);
                                 $blockParam->save();
                             }
                         }
                     }
                 }
                 //************************************************************************************************//
                 //*****     MISE A JOUR DES VALEURS DES PARAMETRES DES FONCTIONS SUIVANTES DEJA GENEREES     *****//
                 //************************************************************************************************//
                 $tableJDT->updateParamsFunctionToSynchronize($test_set_function->getEiTestSet(), $xpathF, $position, $paramsToUpdate);
             }
             $test_set_function->save();
             $log->setEiLogParams($paramsColl);
             $log->save();
             //*********************************//
             //*****     LOG DE SONDES     *****//
             //*********************************//
             $sensor = $data->{'sensors'};
             if (isset($sensor)) {
                 $logSensor = new EiLogSensor();
                 $logSensor->setEiLogFunctionId($log->getId());
                 $logSensor->setAppMemoryMean($sensor->{'app_memory_mean'});
                 $logSensor->setAppMemoryMin($sensor->{'app_memory_min'});
                 $logSensor->setAppMemoryMax($sensor->{'app_memory_max'});
                 $logSensor->setAppMemoryStart($sensor->{'app_memory_start'});
                 $logSensor->setAppMemoryEnd($sensor->{'app_memory_end'});
                 $logSensor->setAppCpuMean($sensor->{'app_cpu_mean'});
                 $logSensor->setAppCpuMin($sensor->{'app_cpu_min'});
                 $logSensor->setAppCpuMax($sensor->{'app_cpu_max'});
                 $logSensor->setAppCpuStart($sensor->{'app_cpu_start'});
                 $logSensor->setAppCpuEnd($sensor->{'app_cpu_end'});
                 $logSensor->setDbMemoryMean($sensor->{'db_memory_mean'});
                 $logSensor->setDbMemoryMin($sensor->{'db_memory_min'});
                 $logSensor->setDbMemoryMax($sensor->{'db_memory_max'});
                 $logSensor->setDbMemoryStart($sensor->{'db_memory_start'});
                 $logSensor->setDbMemoryEnd($sensor->{'db_memory_end'});
                 $logSensor->setDbCpuMean($sensor->{'db_cpu_mean'});
                 $logSensor->setDbCpuMin($sensor->{'db_cpu_min'});
                 $logSensor->setDbCpuMax($sensor->{'db_cpu_max'});
                 $logSensor->setDbCpuStart($sensor->{'db_cpu_start'});
                 $logSensor->setDbCpuEnd($sensor->{'db_cpu_end'});
                 $logSensor->setClientMemoryMean($sensor->{'client_memory_mean'});
                 $logSensor->setClientMemoryMin($sensor->{'client_memory_min'});
                 $logSensor->setClientMemoryMax($sensor->{'client_memory_max'});
                 $logSensor->setClientMemoryStart($sensor->{'client_memory_start'});
                 $logSensor->setClientMemoryEnd($sensor->{'client_memory_end'});
                 $logSensor->setClientCpuMean($sensor->{'client_cpu_mean'});
                 $logSensor->setClientCpuMin($sensor->{'client_cpu_min'});
                 $logSensor->setClientCpuMax($sensor->{'client_cpu_max'});
                 $logSensor->setClientCpuStart($sensor->{'client_cpu_start'});
                 $logSensor->setClientCpuEnd($sensor->{'client_cpu_end'});
                 $logSensor->save();
             }
             //******************************************************************//
             //*****     RECENSEMENT DES LOGS SELENIUM POUR LA FONCTION     *****//
             //******************************************************************//
             // Récupération de la connection.
             $dbh = Doctrine_Manager::connection();
             $logS = new EiLogFunctionSelenium();
             // Création de la requête préparée pour l'insertion des logs.
             $query = "INSERT INTO " . $logS->getTable()->getTableName() . " (ei_fonction_id, ei_log_id, ei_test_set_function_id, ei_test_set_id, ";
             $query .= "ei_scenario_id, ei_log_function_id, message, created_at, updated_at)";
             $query .= "VALUES (:fonction,:log,:tsfid,:tsid,:scid,:logfid,:message,NOW(),NOW())";
             /** @var Doctrine_Connection_Statement $stmt */
             $stmt = $dbh->prepare($query);
             $dbh->beginTransaction();
             foreach ($data->{"logs"} as $logSelenium) {
                 $stmt->bindValue("fonction", $test_set_function->getEiFonctionId());
                 $stmt->bindValue("log", $ei_log->getId());
                 $stmt->bindValue("tsfid", $test_set_function->getId());
                 $stmt->bindValue("tsid", $this->ei_test_set->getId());
                 $stmt->bindValue("scid", $this->ei_scenario->getId());
                 $stmt->bindValue("logfid", $log->getId());
                 $stmt->bindValue("message", $logSelenium);
                 $stmt->execute(array());
             }
             $dbh->commit();
             //**************************************************************************************//
             //*****     VERIFICATION FIN DE BLOCK POUR SYNCHRONISATION AVEC JEU DE DONNEES     *****//
             //**************************************************************************************//
             // Récupération du xpath et traitement en cas d'exception /Root.
             $xpathB = $test_set_function->getXpath() == "/Root" ? "/Root[1]" : $test_set_function->getXpath();
             $nbFonctionsExecuteesBlock = EiTestSetFunctionTable::getInstance()->findByEiTestSetIdAndXpath($test_set_function->getEiTestSetId(), $test_set_function->getXpath())->count();
             $this->logger->info("---   Synchronisation des paramètres en fin de block   ---");
             $this->logger->info("----------------------------------------------------------");
             $this->logger->info("---   NB fonctions exécutées : " . $nbFonctionsExecuteesBlock);
             /** @var EiTestSetBlockParam $testSetBlockParam */
             // On récupère le paramètre de block à mettre à jour relativement au xpath.
             $testSetBlockParam = EiTestSetBlockParamTable::getInstance()->findOneByEiTestSetIdAndPath($test_set_function->getEiTestSetId(), $xpathB);
             // On vérifie qu'il est bien non null et relatif à un élément de la structure de la version.
             if ($testSetBlockParam != null && $testSetBlockParam->getEiVersionStructure() != null) {
                 $this->logger->info("----------------------------------------------------------");
                 $this->logger->info("---   Matched : " . $xpathB);
                 // On récupère le nombre de fonctions que comporte le block.
                 $nbFonctionsBlock = $testSetBlockParam->getEiVersionStructure()->getNbFonctions();
                 $this->logger->info("----------------------------------------------------------");
                 $this->logger->info("---   NB FONCTIONS BLOCK " . $nbFonctionsBlock);
                 // SI même nombre, alors on synchronise.
                 if ($nbFonctionsBlock == $nbFonctionsExecuteesBlock) {
                     $this->logger->info("----------------------------------------------------------");
                     $this->logger->info("---   SYNCHRONISATION DE " . $testSetBlockParam->getName());
                     $testSetBlockParam->synchronizeWithDataSet();
                 }
             }
         }
         $ei_log->setStatus($ei_log_st);
         $ei_log->save();
         //*****************************************************//
         //*****      PARTIE GESTION STATUTS CAMPAGNES     *****//
         //*****************************************************//
         $this->logger->info("----------------------------------------------------------");
         $this->logger->info("---   MAJ CAMPAGNE");
         $this->logger->info("----------------------------------------------------------");
         // On regarde s'il s'agit du dernier block des logs.
         if (count($JSONArray) - 1 == $i) {
             $this->logger->info("----------------------------------------------------------");
             $this->logger->info("---   Dernier block des logs à la position (" . $data->{'position'} . ")");
             $this->logger->info("----------------------------------------------------------");
             // Puis on récupère le block à la position suivante.
             $nextTestSetFunction = Doctrine_Core::getTable('EiTestSetFunction')->findOneByPositionAndEiTestSetId($data->{'position'} + 1, $this->ei_test_set->getId());
             // S'il n'y a pas de block suivant et que la position est 1, on met à jour directement car block unique.
             if ($nextTestSetFunction == null && $data->{'position'} == 1) {
                 $this->logger->info("----------------------------------------------------------");
                 $this->logger->info("---   Pas de fonction après & position = 1");
                 $this->logger->info("----------------------------------------------------------");
                 // Mise à jour directe du statut du scénario.
                 $this->searchAndUpdateCampaignGraphState($request->getParameter("campagne"), $request->getParameter("campPosition"), $statutPlaying, $request->getParameter("execution_id"), $ei_log);
             } elseif ($nextTestSetFunction == null && $data->{'position'} > 1) {
                 $this->logger->info("----------------------------------------------------------");
                 $this->logger->info("---   Pas de fonction après & position > 1");
                 $this->logger->info("----------------------------------------------------------");
                 // Puis on récupère le block à la position suivante.
                 $nbBlockErrors = Doctrine_Core::getTable('EiTestSetFunction')->findByStatusAndEiTestSetId($statutKo, $this->ei_test_set->getId());
                 // Si nombre de blocks en erreur supérieur à 0, on indique le statut KO sinon OK.
                 $ei_log_st = $nbBlockErrors != null && $nbBlockErrors->count() > 0 ? $statutKo : $statutOk;
                 // Enfin, nous mettons à jour le statut du scénario.
                 $this->searchAndUpdateCampaignGraphState($request->getParameter("campagne"), $request->getParameter("campPosition"), $statutPlaying, $request->getParameter("execution_id"), $ei_log);
             } elseif ($request->getParameter("positionOnError") == "Stop" && $ei_log_st == $statutKo) {
                 $this->logger->info("----------------------------------------------------------");
                 $this->logger->info("---   Une fonction après & On Error Stop & statut KO");
                 $this->logger->info("----------------------------------------------------------");
                 $ei_log_st = $statutKo;
                 // Enfin, nous mettons à jour le statut du scénario.
                 $this->searchAndUpdateCampaignGraphState($request->getParameter("campagne"), $request->getParameter("campPosition"), $ei_log_st, $request->getParameter("execution_id"), $ei_log);
             }
         }
         if ($synchronized === true) {
             $JSONResponse = array("ok" => "Synchronized.", "xml" => $this->getController()->getPresentationFor("eitestset", "getFunctionsFromPosition"));
         } else {
             $JSONResponse = array("ok" => "Log saved.");
         }
     } catch (Exception $e) {
         $JSONResponse = array("error" => $e->getMessage());
     }
     return $this->renderText(json_encode($JSONResponse));
 }
 /**
  * @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;
     }
 }