/** * ADD block to stack. * * @param EiTestSetBlockStack $parentStack * @return EiTestSetBlockStack */ public function addToStack(EiTestSetBlockStack $parentStack = null) { $dataSetStr = null; $position = 1; if ($parentStack != null) { $position = $parentStack->getPosition() + 1; $dataSetStr = $this->getTable()->getDataFromDataSet($this, $parentStack); } else { $dataSetStr = $this->getTable()->getDataFromDataSet($this); } $stack = new EiTestSetBlockStack(); $stack->setEiTestSet($this->getEiTestSet()); $stack->setEiVersionStructure($this->getEiVersionStructure()); $stack->setEiTestSetBlockParam($this); $stack->setEiTestSetDataSet($dataSetStr); $stack->setPath($this->getPath()); $stack->setPosition($position); $stack->save(); return $stack; }
/** * 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; }