/** * Retourne le chemin complet vers l'élément. * * @return mixed */ public function getPath() { return ($this->parent != null ? $this->parent->getPath() : "") . "/" . $this->reference->getSlug() . "[" . $this->repeat_index . "]"; }
/** * 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); } }