/** * @param EiTestSet $testSet * @param EiProjet $project */ public function searchRelatedEiExecutionStackAndTaggedIt(EiTestSet $testSet, EiProjet $project) { /** @var EiExecutionStack $executionStack */ $executionStack = Doctrine_Core::getTable("EiExecutionStack")->search($testSet->getEiScenarioId(), $testSet->getEiDataSetId(), $testSet->getProfileRef(), $testSet->getProfileId(), $project->getRefId(), $project->getProjectId(), $testSet->getSfGuardUser()->getId()); if ($executionStack != null && $executionStack->getId() != "") { $executionStack->setEiTestSetId($testSet->getId()); $executionStack->save(); } }
/** * @param EiTestSet $testSet * @param int $position * * @updated 18/08/2015 */ private function generateTestSetFunctionFromPosition(EiTestSet $testSet, $position = 1, EiIteration $iteration = null) { // Si la fonction n'a pas encore été chargée dans le jeu de test, on le fait. if ($testSet->getFunctionAt($position) === null) { // Récupération de la version de la structure. /** @var EiProfilScenario $profilScenario */ $profilScenario = Doctrine_Core::getTable("EiProfilScenario")->findOneByEiScenarioIdAndProfileIdAndProfileRef($testSet->getEiScenarioId(), $testSet->getProfileId(), $testSet->getProfileRef()); /** @var EiVersion $version */ $version = $profilScenario->getEiVersion(); /** @var EiVersionStructure $rootStructure */ $rootStructure = Doctrine_Core::getTable("EiVersionStructure")->getEiVersionStructureRootId($version->getId()); $chrono = new Chronometre(); $globalCh = $chrono->lancerChrono("Génération de la fonction à la position " . $position, true); if ($rootStructure !== null) { $conn = Doctrine_Manager::connection(); //************************************************************// //***** CREATION DES PARAMETRES DU BLOCK SUIVANT *****// //************************************************************// $start = $chrono->lancerChrono("RECHERCHE PROCHAIN BLOCK", true); // Récupération de l'instance de la table EiTestSetBlockParam /** @var EiTestSetBlockParamTable $tableJDTBP */ $tableJDTBP = Doctrine_Core::getTable("EiTestSetBlockParam"); // Récupération de la table de gestion de la pile. /** @var EiTestSetBlockStackTable $tableJDTS */ $tableJDTS = Doctrine_Core::getTable("EiTestSetBlockStack"); try { $conn->beginTransaction(); // Récupération de la dernière fonction exécutée. /** @var EiTestSetFunction $lastFunc */ $lastFunc = Doctrine_Core::getTable("EiTestSetFunction")->findOneByPositionAndEiTestSetId($position - 1, $testSet->getId()); // Récupération du block dans la stack. $path = $lastFunc == null ? EiTestSetFunction::getDefaultPath() : $lastFunc->getPath(); $blockStack = $tableJDTS->getLastElementFromPath($testSet->getId(), $path); do { // var_dump("------------- BEGIN -------------"); // if( $blockStack != null ) // var_dump($blockStack->toArray(false)); // Récupération du block suivant à la position -1. $nextBlock = $testSet->getNextBlock(is_bool($lastFunc) ? null : $lastFunc, is_bool($blockStack) ? null : $blockStack, $conn); // if ($nextBlock != null){ // var_dump($nextBlock->toArray(false)); // var_dump("First fragment is a function ? " . ($nextBlock->firstFragmentElementIsFunction() ? 1:0)); // } if ($nextBlock != null) { $start2 = $chrono->lancerChrono("GENERATION DES PARAMETRES DE BLOCKS", true); // Génération de ses paramètres dans le JDT. /** @var EiTestSetBlockParam $blockParam */ $tableJDTBP->generate($testSet, $nextBlock, $conn); $chrono->arreterEtAfficherChrono("GENERATION DES PARAMETRES DE BLOCKS", $start2); } // var_dump("------------- END -------------"); } while ($nextBlock != null && !$nextBlock->firstFragmentElementIsFunction() && ($blockStack = $nextBlock)); // var_dump($nextBlock->toArray(false)); // var_dump($nextBlock->getEiTestSetBlockStackParent()->toArray(false)); // exit; $chrono->arreterEtAfficherChrono("RECHERCHE PROCHAIN BLOCK", $start); //*****************************************************// //***** GENERATION DES FICHIERS XML & XSL *****// //*****************************************************// $start = $chrono->lancerChrono("Génération XML Mapping Data Set METHODE 1", true); // On génére les paramètres de blocks à partir de la branche du block. if ($nextBlock != null) { $xml = $nextBlock->generateBlockParametersXML(); } else { $xml = $testSet->generateBlockParametersXML(); } $chrono->arreterEtAfficherChrono("Génération XML Mapping Data Set METHODE 1", $start); // echo $xml; $start = $chrono->lancerChrono("Génération XSL Test Set", true); // Récupération de la liste des fonctions du fragment. $functionsList = $nextBlock != null ? $nextBlock->getFragmentsFunctions() : array(); // var_dump($functionsList); // Si block if ($nextBlock != null && $nextBlock->getPartIndex() != $nextBlock->getPartsCount()) { $xsl = $nextBlock->generateXSLForTestSet($functionsList); } elseif ($nextBlock != null) { $xsl = $nextBlock->generateXSLForTestSet($functionsList); } else { $xsl = $testSet->getEiVersion()->generateXSLForTestSet(); } $chrono->arreterEtAfficherChrono("Génération XSL Test Set", $start); // echo $xsl; //exit; $start = $chrono->lancerChrono("Génération XML Test Set", true); if ($nextBlock != null) { $testSet->generateFromXML($xsl, $xml, $position, $iteration); } $chrono->arreterEtAfficherChrono("Génération XML Test Set", $start); $testSet->save($conn); // Validation des éléments. $tableJDTS->validateStackElements($testSet->getId(), $conn); $conn->commit(); } catch (Exception $exc) { // TODO : à supprimer var_dump($exc->getMessage(), $exc->getTraceAsString()); $conn->rollback(); } } $chrono->arreterEtAfficherChrono("Génération de la fonction à la position " . $position, $globalCh); } }
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); }