/** * @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); } }