Пример #1
0
 public function getFunctionByScenarioTestSetAndPosition($position, EiScenario $ei_scenario = null, EiTestSet $ei_test_set = null)
 {
     if ($position == null || $ei_scenario == null || $ei_test_set == null) {
         return null;
     }
     $q = Doctrine_Core::getTable('EiFonction')->createQuery('f')->where('EiTestSetFunction.ei_fonction_id=f.id And EiTestSetFunction.ei_test_set_id=? And EiTestSetFunction.position=?', array($ei_test_set->getId(), $position))->andWhere('EiTestSet.id=EiTestSetFunction.ei_test_set_id And EiTestSet.ei_scenario_id=?', array($ei_scenario->getId()))->execute();
     if (count($q) > 0) {
         return $q->getFirst();
     }
     return null;
 }
Пример #2
0
 /**
  * @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);
     }
 }
Пример #3
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;
 }
 /**
  * Méthode permettant de localiser la partie du JDD à lier à l'élément du block.
  *
  * TODO: Unifier les deux méthodes en une seule.
  * TODO: A vérifier
  *
  * Liée à EiTestSetBlockStack->getDataFromDataSet
  *
  * @param EiTestSet $testSet
  * @param EiVersionStructure $block
  * @param EiTestSetBlockStack $previousStack
  * @param EiTestSetBlockStack $parentStack
  * @return mixed|null
  */
 public function getDataFromDataSet(EiTestSet $testSet, EiVersionStructure $block, EiTestSetBlockStack $previousStack = null, EiTestSetBlockStack $parentStack = null)
 {
     /** @var EiTestSetDataSetTable $tableDSS */
     $tableDSS = Doctrine_Core::getTable("EiTestSetDataSet");
     $mapping = $block->getMappingDataSet(EiBlockDataSetMapping::$TYPE_IN);
     $dssStr = null;
     // Cas où il y a un mapping et que le parent est nul : On prend le premier élément que l'on trouve.
     if ($parentStack == null && $mapping != null) {
         $dssStr != null ? $tableDSS->getRelatedDataFromUniqueDataSetStructure($testSet->getId(), $mapping) : null;
     } elseif ($mapping != null) {
         // On vérifie que le block en question est une boucle.
         if ($block->isEiLoop()) {
             // On récupère le contexte du père.
             $contexte = $parentStack->getContext();
             $index = 1;
             //                var_dump("DataSet Père : " . $parentStack->getEiTestSetDatasetId());
             //                var_dump("Contexte DataSet Père : " . $contexte);
             // Si le block courant est de même nature que le block précédent
             if ($parentStack->getEiVersionStructureId() != $block->getId() && $block->getId() == $previousStack->getEiVersionStructureId()) {
                 //                    var_dump("DataSet Structure CAS 1");
                 // On vérifie s'il s'agit de la même boucle mais concerne une partie différente.
                 if ($previousStack->getPartIndex() < $previousStack->getPartsCount()) {
                     $index = $previousStack->getRepetitionIndex();
                     $contexte .= "-" . $index;
                 } else {
                     $index = $previousStack->getRepetitionIndex() + 1;
                     $contexte .= "-" . $index;
                 }
             } elseif ($parentStack->getEiVersionStructureId() != $block->getId()) {
                 //                    var_dump("DataSet Structure CAS 2");
                 $parentStr = $parentStack->getEiTestSetDataSet() != null ? $parentStack->getEiTestSetDataSet()->getEiDataSetStructure() : null;
                 if ($parentStr != null && $mapping->getEiDataSetStructureMapping()->getNode()->isDescendantOf($parentStr)) {
                     //                        var_dump("DataSet Structure CAS 2.1");
                     $parentMapping = $parentStr != null ? $parentStr->getId() : null;
                     $myMappingParent = $mapping->getEiDataSetStructureMapping()->getEiDatasetStructureParentId();
                     if ($parentMapping == null || $myMappingParent == $parentMapping) {
                         $contexte .= "-1";
                     } else {
                         if (preg_match("/([0-9]+)\$/", $contexte, $matched)) {
                             $length = strlen($matched[1]);
                         } else {
                             $length = 1;
                         }
                         $contexte = substr($contexte, 0, -$length) . 1;
                     }
                 } else {
                     //                        var_dump("DataSet Structure CAS 2.2");
                     $contexteArray = array();
                     for ($cpt = 0; $cpt <= $mapping->getEiDataSetStructureMapping()->getLevel(); $cpt++) {
                         $contexteArray[] = 1;
                     }
                     $contexte = implode("-", $contexteArray);
                     //                        var_dump("New context : " . $contexte);
                 }
             } else {
                 //                    var_dump("DataSet Structure CAS 3");
                 if (preg_match("/([0-9]+)\$/", $contexte, $matched)) {
                     $length = strlen($matched[1]);
                 } else {
                     $length = 1;
                 }
                 $contexte = substr($contexte, 0, -$length);
                 // On vérifie s'il s'agit de la même boucle mais concerne une partie différente.
                 if (!$parentStack->isComplete()) {
                     $index = $parentStack->getRepetitionIndex();
                 } else {
                     $index = $parentStack->getRepetitionIndex() + 1;
                 }
                 $contexte .= $index;
                 //                    var_dump($parentStack->getEiVersionStructureId(), $block->getId());
                 //                    var_dump($contexte);
             }
             $dssStr = $tableDSS->getDataFromContext($testSet->getId(), $mapping->getEiDatasetStructureId(), $contexte, $index);
         }
     }
     return $dssStr;
 }
 /**
  * @param EiTestSet $testSet
  * @param EiVersionStructure $block
  * @return mixed|null
  *
  * @createdAt 18/08/2015
  * @updatedAt 18/08/2015
  */
 public function getParentBlock($testSet, $block)
 {
     // Récupération de la connexion BDD.
     $conn = Doctrine_Manager::connection();
     try {
         // Définition requête SQL permettant de générer
         $searchSql = "\nSELECT id\nFROM " . $this->getTableName() . "\nWHERE ei_version_structure_id = " . $block->getId() . "\nAND ei_test_set_id = " . $testSet->getId() . "\nORDER BY lft DESC\nLIMIT 1;";
         // Récupération du block parent.
         $blockId = $conn->execute($searchSql)->fetch();
         if (!is_bool($blockId) && isset($blockId["id"])) {
             return $this->find($blockId["id"]);
         }
     } catch (Exception $exc) {
         return null;
     }
 }
Пример #6
0
 /**
  * @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();
     }
 }
Пример #7
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;
     }
 }
 /**
  * Génère, à partir de l'arbre ITreeExplorer l'arborescence du jeu de données pour le JDT.
  *
  * @param ITreeExplorerItem $element
  */
 private function generate(ITreeExplorerItem $element, $isParentRoot = false)
 {
     $elt = null;
     try {
         // On parcourt toutes les occurences de l'élément de la structure.
         foreach ($element->getOccurrences() as $occurrence) {
             $pid = $occurrence->getParent() != null ? $occurrence->getParent()->getId() : null;
             $pIndex = $occurrence->getParent() != null ? $occurrence->getParent()->getRepeatIndex() : $occurrence->getRepeatIndex();
             // On crée l'objet.
             $elt = new EiTestSetDataSet();
             // Puis, on lui affecte les quelques éléments en notre possession.
             $elt->setEiTestSetId($this->testSet->getId());
             $elt->setEiDataSetStructureId($element->getId());
             $elt->setIndexRepetition($occurrence->getRepeatIndex());
             $elt->setParentIndexRepetition($pIndex);
             $elt->setType($element->getType() == "root" || $element->getType() == "node" ? EiDataSetStructure::$TYPE_NODE : EiDataSetStructure::$TYPE_LEAF);
             $elt->setName($element->getName());
             $elt->setSlug($element->getSlug());
             $elt->setValue($occurrence->getValue() != null ? $occurrence->getValue() : "");
             if ($occurrence->getParent() != null && isset($this->registered[$occurrence->getParent()->getId()])) {
                 $elt->setParentId($this->registered[$occurrence->getParent()->getId()]->getId());
             } elseif (!(is_bool($isParentRoot) && $isParentRoot == false)) {
                 $elt->setParentId($isParentRoot->getId());
             }
             if ($element->getType() == "root") {
                 $elt->setLft(1);
                 $elt->setRgt(2);
                 $elt->setLevel(0);
                 $elt->save();
                 $elt->setRootId($elt->getId());
                 $elt->save();
                 $this->root_id = $elt->getId();
                 $this->root = $elt;
             } elseif (($pid != null || $pid == 0) && isset($this->registered[$pid])) {
                 if ($element->getType() == "leaf") {
                     $occurrence->setLeft($occurrence->getLeft() + ($pIndex - 1) * $occurrence->getRightNode());
                     $occurrence->setRight($occurrence->getRight() + ($pIndex - 1) * $occurrence->getRightNode());
                     if ($occurrence->getRight() > $this->maxRight) {
                         $this->maxRight = $occurrence->getRight();
                     }
                 }
                 $elt->setLft($occurrence->getLeft());
                 $elt->setRgt($occurrence->getRight());
                 $elt->setLevel($occurrence->getLevel());
                 $elt->setRootId($this->root_id);
                 $elt->save();
                 if (!isset($this->registeredChildren[$pid])) {
                     $this->registeredChildren[$pid] = array();
                     $this->registeredChildren[$pid][] = $elt;
                 } else {
                     $this->registeredChildren[$pid][] = $elt;
                 }
             }
             $this->registered[$occurrence->getId()] = $elt;
         }
         /** @var ITreeExplorerItem $child */
         foreach ($element->getChildren() as $child) {
             $this->generate($child, $elt != null && $element->getType() == "root" ? $elt : false);
         }
     } catch (Exception $exc) {
         print_r($exc);
     }
 }
 public function getTestSetParam(EiTestSet $ei_test_set)
 {
     $conn = Doctrine_Manager::connection();
     $q = "\n         \n         SELECT p.*, f.* , fp.name\n\n         FROM  ei_test_set_param p\n        LEFT   JOIN ei_test_set_function f\n             ON f.id = p.ei_test_set_function_id\n             AND f.ei_test_set_id =p.ei_test_set_id\n        \n        LEFT   JOIN ei_function_has_param fp\n             ON fp.param_id = p.param_id\n        \n        WHERE p.ei_test_set_id= " . $ei_test_set->getId() . "\n        \n        ORDER BY f.position     \n        ";
     return $conn->fetchAll($q);
 }