/** * @param EiNodeDataSet $root * @return DOMDocument */ public static function createXML($root) { // Création du document XML. $documentXml = new DOMDocument("1.0", "UTF-8"); // Génération de la structure. $root->generateXML($documentXml, $documentXml); return $documentXml; }
/** * @param sfWebRequest $request */ public function executeSelectMapping(sfWebRequest $request) { $this->getContext()->getConfiguration()->loadHelpers(array('Url', 'I18N', 'Date', 'Tag', 'Number', 'Text', 'Partial')); // Appel AJAX requis. $this->forward404Unless($request->isXmlHttpRequest()); $this->setLayout(sfView::NONE); $this->getResponse()->setContentType('application/json'); // Vérifications du projet et du profil. $this->checkProject($request); $this->checkProfile($request, $this->ei_project); //************************************************************************************************************** // RECUPERATION ET VERIFICATIONS DES OBJETS : SCENARIO, NOEUD ROOT STRUCTURE, // CHEMIN DEPUIS SCENARIO. // Récupération & vérification du scénario. $this->ei_scenario = Doctrine_Core::getTable('EiScenario')->find($this->request->getParameter('ei_scenario_id')); $this->forward404Unless($this->ei_scenario); // Récupération & vérification du paramètre du block de la structure du scénario. $this->ei_block_param_id = $request->getParameter("ei_block_param_id"); $this->ei_block_param = Doctrine_Core::getTable("EiBlockParam")->find($this->ei_block_param_id); // On récupère la racine du scénario. $this->ei_root_node = Doctrine_Core::getTable("EiDataSetStructure")->getRoot($this->ei_scenario->getId()); $this->forward404Unless($this->ei_block_param); $this->forward404Unless($this->ei_root_node); /** @var TreeView $treeDisplay */ $treeDisplay = new TreeView($this->ei_root_node, new ModeSelectTreeStrategy(), array("id" => "datasetstructure_tree_select", "formats" => array("node" => EiNodeDataSet::getFormNameFormat(), "leaf" => EiLeafDataSet::getFormNameFormat()), "actions" => array("select" => array("route" => "eiblockdatasetmapping_do_select_mapping", "parameters" => array('project_id' => $this->project_id, 'project_ref' => $this->project_ref, 'ei_scenario_id' => $this->ei_scenario->getId(), 'profile_name' => $this->profile_name, 'profile_id' => $this->profile_id, 'profile_ref' => $this->profile_ref, 'ei_block_param_id' => $this->ei_block_param_id))))); return $this->renderText(json_encode(array("success" => true, "html" => $treeDisplay->render()))); }
/** * Composant permettant d'afficher les paramètres d'un bloc et de les mettre à jour. * * Comprend l'édition du bloc, l'édition des paramètres ainsi que le mapping avec les noeuds du jeu de données. * * @param sfWebRequest $request */ public function executeShowParams(sfWebRequest $request) { // On récupère le block parent. /** @var EiBlock $block */ $block = Doctrine_Core::getTable("EiVersionStructure")->findBlock($this->ei_version_structure_id); $blockParams = $block->getParams(); $scenarioId = $this->ei_scenario_id; $this->ei_block_parameters = $block->getJSONParameters($block->getAllAscendantsParams()); // Réupération de la structure du scénario. $structures = Doctrine_Core::getTable("EiDataSetStructure")->getTreeArrayForITree($scenarioId); // Création du TreeViewer. $treeViewer = new TreeViewer("EiDataSetStructure"); $treeViewer->import($structures); $selected = array(); /** @var EiBlockParam $param */ foreach ($blockParams as $key => $param) { /** @var EiBlockDataSetMapping $mapped */ $mapped = $param->getMapping(EiBlockDataSetMapping::$TYPE_IN); if ($mapped != null) { $selected[$key] = $mapped->getEiDatasetStructureId(); } } // TreeViewer pour le mapping. $this->treeDisplay = new TreeView($treeViewer, new ModeSelectTreeStrategy(), array("baseId" => "datasetstructure_tree_select_" . $block->getId(), "objects" => $blockParams, "selected" => $selected, "formats" => array("node" => EiNodeDataSet::getFormNameFormat(), "leaf" => EiLeafDataSet::getFormNameFormat()), "actions" => array("select" => array("route" => "eiblockdatasetmapping_select_mapping", "parameters" => array('project_id' => $this->project_id, 'project_ref' => $this->project_ref, 'ei_scenario_id' => $scenarioId, 'profile_name' => $this->profile_name, 'profile_id' => $this->profile_id, 'profile_ref' => $this->profile_ref, 'ei_block_param_id' => ':ei_block_param_id'), "target" => ":ei_block_param_id"), "doSelect" => array("route" => "eiblockdatasetmapping_do_select_mapping", "parameters" => array('project_id' => $this->project_id, 'project_ref' => $this->project_ref, 'ei_scenario_id' => $scenarioId, 'profile_name' => $this->profile_name, 'profile_id' => $this->profile_id, 'profile_ref' => $this->profile_ref, 'ei_block_param_id' => ':ei_block_param_id', 'type' => EiBlockDataSetMapping::$TYPE_IN), "target" => ":ei_block_param_id")))); $selected = array(); /** @var EiBlockParam $param */ foreach ($blockParams as $key => $param) { /** @var EiBlockDataSetMapping $mapped */ $mapped = $param->getMapping(EiBlockDataSetMapping::$TYPE_OUT); if ($mapped != null) { $selected[$key] = $mapped->getEiDatasetStructureId(); } } // TreeViewer pour le mapping. $this->treeDisplayOut = new TreeView($treeViewer, new ModeSelectTreeStrategy(), array("baseId" => "datasetstructure_tree_select_out_" . $block->getId(), "objects" => $blockParams, "selected" => $selected, "formats" => array("node" => EiNodeDataSet::getFormNameFormat(), "leaf" => EiLeafDataSet::getFormNameFormat()), "actions" => array("select" => array("route" => "eiblockdatasetmapping_select_mapping", "parameters" => array('project_id' => $this->project_id, 'project_ref' => $this->project_ref, 'ei_scenario_id' => $scenarioId, 'profile_name' => $this->profile_name, 'profile_id' => $this->profile_id, 'profile_ref' => $this->profile_ref, 'ei_block_param_id' => ':ei_block_param_id'), "target" => ":ei_block_param_id"), "doSelect" => array("route" => "eiblockdatasetmapping_do_select_mapping", "parameters" => array('project_id' => $this->project_id, 'project_ref' => $this->project_ref, 'ei_scenario_id' => $scenarioId, 'profile_name' => $this->profile_name, 'profile_id' => $this->profile_id, 'profile_ref' => $this->profile_ref, 'ei_block_param_id' => ':ei_block_param_id', 'type' => EiBlockDataSetMapping::$TYPE_OUT), "target" => ":ei_block_param_id")))); }
/** * @param EiNodeDataSet $parent * @return Doctrine_Collection */ public function getChildrenAccordingToParent($parent) { $query = Doctrine_Query::create()->select('node.*')->from('EiNodeDataSet node')->where('node.level = ?', $parent->getLevel() + 1)->andWhere('node.ei_dataset_structure_parent_id = ?', $parent->getId())->orderBy('node.lft'); return $query->execute(); }
public function save(Doctrine_Connection $conn = null, $is_clone = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $conn->beginTransaction(); if ($this->isNew()) { if ($this->project_id != null) { $this->nb_joue = 0; } //mise à jour du projet try { $ret = parent::save($conn); $ei_project = $this->updateProject($conn); if ($is_clone == null) { //Si ce n'est pas un clone alors on crée les versions par défaut $ei_version_id = $this->createDefaultVersion($this->getEiUserDefaultPackage(), $conn); $this->saveProfilsForVersions($ei_project, $ei_version_id, $conn); $this->createDefaultEiDataSetFolder($conn); // Création du bloc racine du jeu de données. $rootDataSetStructure = new EiNodeDataSet(); $rootDataSetStructure->setName("Root"); $rootDataSetStructure->setEiScenario($this); $rootDataSetStructure->setProjectId($this->project_id); $rootDataSetStructure->setProjectRef($this->project_ref); $rootDataSetStructure->save($conn); $treeObject = Doctrine_Core::getTable("EiDataSetStructure")->getTree(); $treeObject->createRoot($rootDataSetStructure); } $conn->commit(); } catch (Exception $e) { $conn->rollback(); throw $e; } } else { try { $ret = parent::save($conn); $node = $this->getNode(); $node->setName($this->getNomScenario()); $node->save($conn); $this->ei_node_id = $node->getId(); //$this->createDefaultEiDataSetFolder($conn); $conn->commit(); } catch (Exception $e) { $conn->rollback(); throw $e; } } return $ret; }
/** * TODO: Optimiser visionneuse de JDD. * * @param sfWebRequest $request */ public function executeManager(sfWebRequest $request) { $memoryLimit = ini_get("memory_limit"); ini_set("memory_limit", "-1"); /** @var EiDataSet $ei_data_set */ $ei_data_set = $this->ei_data_set->getEiDataSet(); $countLines = $ei_data_set->getCountOfLines(); if ($countLines < 1000) { // Réupération de la structure du jeu de données. $structures = $ei_data_set->getTreeArrayForITree(); // Création du TreeViewer. $treeViewer = new TreeViewer("EiDataSet"); $treeViewer->import($structures); $this->treeDisplay = new TreeView($treeViewer, new ModeEditTreeStrategy(), array("id" => "dataset_source_tree_" . time(), "formats" => array("node" => EiNodeDataSet::getFormNameFormat(), "leaf" => EiLeafDataSet::getFormNameFormat()), "types" => array("root" => array("icon" => TreeView::$TYPE_XML, "name" => "root"), "node" => array("icon" => TreeView::$TYPE_TAG, "name" => "node"), "attr" => array("icon" => TreeView::$TYPE_XSL_VALUE, "name" => "attribute"), "leaf" => array("icon" => TreeView::$TYPE_VALUE, "name" => "value")), "authorizations" => array("rename" => array("leaf"), "new" => array(), "remove" => array(), "dragndrop" => array()), "init" => array("openAll" => true), "styleMessageResultat" => 2, "styleMessageResultatObject" => '#ei_data_set_content', "actions" => array("rename" => array("route" => "eidataset_rename_value_dataline", "parameters" => array('project_id' => $this->project_id, 'project_ref' => $this->project_ref, 'ei_scenario_id' => $this->ei_scenario->getId(), 'profile_name' => $this->profile_name, 'profile_id' => $this->profile_id, 'profile_ref' => $this->profile_ref, 'ei_data_set_id' => $ei_data_set->getId(), 'ei_data_line_id' => 'ei_node_id'), "target" => "ei_node_id")))); } else { $this->treeDisplay = null; } ini_set("memory_limit", $memoryLimit); }
/** * Format les réponses JSON de succès. * * @param type $action * @param type $status * @return string */ private function createJSONResponse($action, $status, $type = "Node", $message = "") { if ($type == "Node") { /** @var EiNodeDataSet $objet */ $objet = $this->ei_node; } elseif ($type == "Leaf" || $type == "Attribute") { /** @var EiLeafDataSet $objet */ $objet = $this->ei_leaf; } else { $objet = new EiNodeDataSet(); } $JSONResponse['status'] = $status; $JSONResponse['success'] = $status == "error" ? false : true; $JSONResponse['message'] = $message == "" ? $type . " " . $objet->getName() . " has been {$action} successfully." : $message; return $JSONResponse; }