/** * Surcharge de la méthode save permettant de mettre à jour la table EiNode. * * @param Doctrine_Connection $conn */ public function save(Doctrine_Connection $conn = null) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT SAUVEGARDE TEMPLATE"); $isNew = $this->isNew(); /** @var EiNode $ei_node */ if ($isNew) { if ($this->getEiNode() == null) { $ei_node = new EiNode(); $this->setEiNode($ei_node); } else { $ei_node = $this->getEiNode(); } } parent::save($conn); if ($isNew) { $ei_node->setType(EiNode::$TYPE_DATASET_TEMPLATE); $ei_node->setObjId($this->getId()); $ei_node->setName($this->getName()); $ei_node->save($conn); } elseif (!$isNew) { $ei_node = $this->getEiNode(); $ei_node->setName($this->getName()); $ei_node->save($conn); } $this->updateCampaignGraphDataSet($conn); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- FIN SAUVEGARDE TEMPLATE"); }
/** * Action permettant de récupérer l'arbre des jeux de données. * * @param sfWebRequest $request */ public function execute($request) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT RECUPERATION ARBRE DATA SET"); $this->getResponse()->setContentType('application/json'); $this->setLayout(false); try { $this->getUser()->signIn($this->user, true); /** @var EiNodeTable $tableEiNode */ $tableEiNode = Doctrine_Core::getTable("EiNode"); // Récupération du noeud du scénario. $node = $this->scenario->getEiNode(); // Recherche de la structure des fichiers des jeux de données. $rootFolder = Doctrine_Core::getTable('EiNode')->findOneByRootIdAndType($node->getId(), 'EiDataSetFolder'); // On récupère ensuite la structure brute des dossiers. $structureBrute = $tableEiNode->getStructureDataSets($rootFolder); $structureBrute["root"]["name"] = "Root"; // Puis on la retravaille. // $structure = $this->getReorderedStructure(array(), $structureBrute); $response = json_encode(array("tree" => array($structureBrute))); } catch (Exception $e) { $response = array(); } return $this->renderText($response); }
/** * @param Doctrine_Connection $conn */ public function save(Doctrine_Connection $conn = null) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT SAUVEGARDE DATA SET"); $isNew = $this->isNew(); if ($isNew) { if ($this->getEiNode() == null) { $ei_node = new EiNode(); $this->setEiNode($ei_node); } else { $ei_node = $this->getEiNode(); } } parent::save($conn); if ($isNew) { $ei_node->setType('EiDataSet'); $ei_node->setObjId($this->getId()); $ei_node->setName($this->getName()); if ($this->getEiDataSetTemplate() != null) { $ei_node->setRootId($this->getEiDataSetTemplate()->getEiNode()->getId()); } $ei_node->save($conn); } else { $ei_node = $this->getEiNode(); $ei_node->setName($this->getName()); $ei_node->save($conn); } $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- FIN SAUVEGARDE DATA SET"); }
/** * Action permettant de récupérer l'arbre des jeux de données. * * @param sfWebRequest $request */ public function execute($request) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT RECUPERATION ARBRE DATA SET"); $this->getResponse()->setContentType('application/json'); $this->setLayout(false); $response = array("error" => "An error occured when we try to create your directory."); try { $this->getUser()->signIn($this->user, true); /** @var EiNodeTable $tableEiNode */ $tableEiNode = Doctrine_Core::getTable("EiNode"); // Récupération des données. $nom = $request->getPostParameter("name"); $parentNodeId = $request->getPostParameter("parent_node_id"); if ($nom == null || $parentNodeId == null) { $response["error"] = "You have to select a parent directory and type a valid directory name"; } else { /** @var EiNode $parentNode Récupération du noeud parent. */ $parentNode = $tableEiNode->find($parentNodeId); if ($parentNode != null && $parentNode->getId() != "" && $parentNode->getEiScenarioNode()->getObjId() == $this->scenario->getId()) { try { $folder = new EiNode(); $folder->setName($nom); $folder->setType(EiNode::$TYPE_DATASET_FOLDER); $folder->setProjectId($parentNode->getProjectId()); $folder->setProjectRef($parentNode->getProjectRef()); $folder->setRootId($parentNode->getId()); $folder->save(); unset($response["error"]); $response["id"] = $folder->getId(); } catch (Exception $exc) { $response["error"] = "An error occured when we tried to create directory : " . $exc->getMessage(); } } else { $response["error"] = "We are not able to accommodate your request."; } } } catch (Exception $e) { $response = array(); } return $this->renderText(json_encode($response)); }
/** * Méthode permettant de synchroniser les valeurs des paramètres du block dans le jeu de données du JDT. */ public function synchronizeWithDataSet() { $this->logger = sfContext::getInstance()->getLogger(); /** @var EiTestSetBlockParam[] $childs */ $childs = $this->getNode()->getDescendants(1); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- Parcours des " . count($childs) . " enfants."); if ($childs != null && (is_array($childs) || $childs instanceof Doctrine_Collection)) { // Parcourt des enfants du block. foreach ($childs as $child) { $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- Parcours de " . $child->getName() . "."); // On traite uniquement les paramètres à synchroniser. if ($child->getType() == EiVersionStructure::$TYPE_BLOCK_PARAM) { // On récupère les éléments mappés avec le paramètre. /** @var EiBlockDataSetMapping[] $mappings */ $mappings = $child->getEiVersionStructure()->getEiVersionStructureDataSetMapping(); if ($mappings->count() > 0) { $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- Mapping détecté."); /** @var EiBlockDataSetMapping $mapping */ foreach ($mappings as $mapping) { // On s'intéresse uniquement au cas où une synchronisation OUT a été définie. // Si tel est le cas, on récupère l'élément du jeu de données du JDT correspondant. if ($mapping->getType() == EiBlockDataSetMapping::$TYPE_OUT) { $structure = $this->getEiVersionStructure(); $mappingDs = $mapping->getEiDataSetStructureMapping(); $isForeach = $structure->getType() == EiVersionStructure::$TYPE_FOREACH; $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- Mapping out détecté avec " . $mappingDs . " dans Foreach ? " . ($isForeach ? "Oui" : "Non") . "."); if ($isForeach && !$mappingDs->getNode()->isDescendantOf($structure->getIteratorMapping()->getEiDataSetStructureMapping())) { /** @var EiTestSetDataSet $dataSetElement */ $dataSetElement = EiTestSetDataSetTable::getInstance()->findOneByEiDataSetStructureIdAndIndexRepetitionAndEiTestSetId($mapping->getEiDatasetStructureId(), 1, $this->getEiTestSetId()); } else { /** @var EiTestSetDataSet $dataSetElement */ $dataSetElement = EiTestSetDataSetTable::getInstance()->findOneByEiDataSetStructureIdAndParentIndexRepetitionAndEiTestSetId($mapping->getEiDatasetStructureId(), $this->getIndexRepetition(), $this->getEiTestSetId()); } if ($dataSetElement != null) { sfContext::getInstance()->getLogger()->info("----------------------------------------------------------"); sfContext::getInstance()->getLogger()->info("--- MATCHED SYNC WITH VALUE " . $child->getValue()); // Puis, on le met à jour avec la valeur du paramètre du block. $dataSetElement->setValue($child->getValue()); $dataSetElement->setIsModified(true); $dataSetElement->save(); } } } } else { $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- Pas de mapping détecté."); } } } } }
public function save($conn = null) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- SAVE DATA SET FORM"); parent::save($conn); if ($this->isNew()) { $file = $this->getValue('file'); if ($file != null) { $filename = 'uploaded_' . sha1($file->getOriginalName()); $extension = $file->getExtension($file->getOriginalExtension()); $fullName = sfConfig::get('sf_upload_dir') . '/' . $filename . $extension; $file->save($fullName); $this->getObject()->createDataLines($fullName); unlink($fullName); } else { $this->getObject()->createEmptyDataLines($conn, false); } } }
/** * @param $campagneId * @param $positionId * @param $ei_log_st * @param $execution_id * @param EiLog $ei_log * @return EiCampaignGraph|null */ private function searchAndUpdateCampaignGraphState($campagneId, $positionId, $ei_log_st, $execution_id, $ei_log = null) { $campagneGraph = null; /** @var EiTestSetTable $tableEiTestSet */ $tableEiTestSet = Doctrine_Core::getTable("EiTestSet"); /** @var EiCampaignExecutionGraph $executionGraph */ $executionGraph = $execution_id != null ? Doctrine_Core::getTable("EiCampaignExecutionGraph")->findOneByExecutionIdAndGraphId($execution_id, $positionId) : null; // Si les deux ne sont pas nuls, on tente une mise à jour du statut. if ($campagneId !== null && $positionId !== null) { /** @var EiCampaignGraph $campagneGraph */ $campagneGraph = Doctrine_Core::getTable("EiCampaignGraph")->getCampaignGraphStep($positionId); // Si une exécution est spécifiée, on met à jour l'élément de l'exécution. if ($executionGraph !== null || is_bool($executionGraph) && $executionGraph == true) { $graph = $executionGraph; $campagneIdG = $graph->getEiCampaignGraph()->getCampaignId(); } else { $graph = $campagneGraph; $campagneIdG = $graph->getCampaignId(); } if ($graph != null && $campagneIdG == intval($campagneId)) { // Mise à jour du statut en fonction des résultats des logs. if ($ei_log_st == null && $graph->getEiTestSetId() != "") { $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- CASE ST NULL & TEST SET NOT NULL"); $ts = $tableEiTestSet->findTestSet($graph->getEiTestSetId()); $ei_log_st = $ts->getStatusName() == StatusConst::STATUS_TEST_OK_DB ? StatusConst::STATUS_OK_DB : ($ts->getStatusName() == StatusConst::STATUS_TEST_KO_DB ? StatusConst::STATUS_KO_DB : StatusConst::STATUS_NA_DB); $this->logger->info("--- EI LOG ST : " . $ei_log_st . " / " . $ts->getStatusName()); $this->logger->info("----------------------------------------------------------"); } if ($ei_log_st != null && $ei_log_st == StatusConst::STATUS_OK_DB) { $graph->setState(sfConfig::get("app_campaigngraphstateok")); } elseif ($ei_log_st != null && $ei_log_st == StatusConst::STATUS_KO_DB) { $graph->setState(sfConfig::get("app_campaigngraphstateko")); } elseif ($ei_log_st != null && $ei_log_st == StatusConst::STATUS_PROCESSING_DB) { $graph->setState(sfConfig::get("app_campaigngraphstateprocessing")); } elseif ($ei_log_st != null && $ei_log_st == StatusConst::STATUS_NA_DB) { $graph->setState(sfConfig::get("app_campaigngraphstateaborted")); } else { $graph->setState(sfConfig::get("app_campaigngraphstateblank")); } if ($ei_log != null) { $graph->setEiTestSetId($ei_log->getEiTestSetId()); // Mise à jour du mode du JDT si <> Campagne if ($ei_log->getEiTestSet()->getMode() != EiTestSetModeConst::MODE_CAMPAGNE) { $ei_log->getEiTestSet()->setMode(EiTestSetModeConst::MODE_CAMPAGNE); $ei_log->getEiTestSet()->save(); } } $graph->save(); } } return $campagneGraph; }
/** * Action permettant de récupérer l'arbre des jeux de données. * * @param sfWebRequest $request */ public function execute($request) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT RECUPERATION ARBRE DATA SET"); $this->getResponse()->setContentType('application/json'); $this->setLayout(false); $response = array("error" => "An error occured when we try to delete your directory."); try { $this->getUser()->signIn($this->user, true); /** @var EiNodeTable $tableEiNode */ $tableEiNode = Doctrine_Core::getTable("EiNode"); // Récupération des données. $nodeId = $request->getPostParameter("node_id"); if ($nodeId == null) { $response["error"] = "You have to select a directory"; } else { /** @var EiNode $node Récupération du noeud à modifier. */ $node = $tableEiNode->find($nodeId); if ($node != null && $node->getId() != "" && $node->getEiScenarioNode()->getObjId() == $this->scenario->getId()) { try { if ($node->getNodes(true, true, true)->count() == 0) { unset($response["error"]); $node->delete(); $response["status"] = "OK"; } else { $response["error"] = "We are not able to accommodate your request because the directory is not empty."; } } catch (Exception $exc) { $response["error"] = "An error occured when we tried to delete directory : " . $exc->getMessage(); } } else { $response["error"] = "We are not able to accommodate your request."; } } } catch (Exception $e) { $response = array(); } return $this->renderText(json_encode($response)); }
/** * @param null $con * @param null $forms */ public function saveEmbeddedForms($con = null, $forms = null) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- SAVE EMBEDDED TEMPLATE FORM"); if ($this->isNew()) { foreach ($this->embeddedForms as $name => $form) { /** @var EiDataSet $object */ $object = $form->getObject(); /** @var EiDataSetTemplate $template */ $template = $this->getObject(); $object->setEiDataSetTemplate($this->getObject()); $object->setName($template->getName()); $node = $object->getEiNode(); $node->setProjectId($template->getEiNode()->getProjectId()); $node->setProjectRef($template->getEiNode()->getProjectRef()); $object->setRootStr($template->getRootStr()); $form->save($con); $template->setEiDataSet($object); $template->save($con); } } return parent::saveEmbeddedForms($con, $forms); }
/** * Action permettant de créer un data set. * * @param sfWebRequest $request */ public function execute($request) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT SAUVEGARDE DATA SET"); $this->setLayout(false); $this->getResponse()->setContentType('application/json'); $this->getUser()->signIn($this->user, true); // On récupère le noeud parent du scénario. $noeud_id = $this->scenario->getEiNode()->getId(); $noeud_parent = Doctrine_Core::getTable("EiNode")->findOneByRootIdAndType($noeud_id, "EiDataSetFolder"); $noeud_parent_id = $noeud_parent->getId(); // Récupération du nom & description. $nom = $request->getPostParameter("name"); $desc = $request->getPostParameter("description"); // On récupère le data set source (si enregistrement). $dataSetSourceId = $request->getPostParameter("jddSource"); // On récupère le data set template source (si enregistrement). $dataSetTemplateSourceId = $request->getPostParameter("jddTemplateSource"); // On récupère le dossier où enregistrer le JDD. $dataSetDirId = $request->getPostParameter("jddDir"); // On décode le fichier. $request->setParameter("file", str_replace("%3E", ">", str_replace("%3C", "<", $request->getParameter("file")))); // LOGS $this->logger->info("-- NOM : " . $nom); $this->logger->info("-- DESCRIPTION : " . $desc); $this->logger->info("-- JDD SOURCE ID : " . $dataSetSourceId); $this->logger->info("-- JDD TEMPLATE SOURCE ID : " . $dataSetTemplateSourceId); $this->logger->info("-- NOEUD ID PARENT : " . $noeud_parent_id); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- FIN SAUVEGARDE DATA SET"); $this->logger->info("----------------------------------------------------------"); $request->setParameter("ei_user", $this->user->getEiUser()); $request->setParameter("name", $nom); $request->setParameter("description", $desc); $request->setParameter("ei_node_parent_id", $noeud_parent_id); if ($dataSetSourceId != null && $dataSetSourceId != -1) { $request->setParameter("dataSetSource", $dataSetSourceId); } if ($dataSetTemplateSourceId != null && $dataSetTemplateSourceId != -1) { $request->setParameter("dataSetTemplateSource", $dataSetTemplateSourceId); } if ($dataSetDirId != null && $dataSetDirId != -1) { $oJddDir = Doctrine_Core::getTable("EiNode")->find($dataSetDirId); if ($oJddDir != null && $oJddDir->getObjId() != "") { $request->setParameter("dataSetDir", $dataSetDirId); $request->setParameter("ei_node_parent_id", $dataSetDirId); } } $this->logger->info("----------------------------------------------------------"); $chronometre = new Chronometre(); $chronometre->lancerChrono("PERFORMANCE CREATION JDD"); try { $content = $this->getController()->getPresentationFor("eidataset", "lightCreateFromXml"); } catch (Exception $exc) { $this->logger->info("--- ERREUR : " . $exc->getMessage() . " ---"); } // Fin mesure $chronometre->arreterEtAfficherChrono(); $this->logger->info("----------------------------------------------------------"); return $this->renderText($content); }
/** * Méthode permettant de modifier la version courante associée au template. * * @param sfWebRequest $request */ public function executeChangeCurrentVersion(sfWebRequest $request) { // Instanciation du logger. $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT MODIFICATION VERSION JDD TEMPLATE"); $this->logger->info("----------------------------------------------------------"); // On effectue les vérifications de base. $this->checkProject($request); $this->checkProfile($request, $this->ei_project); // On indique qu'aucun layout n'est utilisé. $this->setLayout(false); // Et le type de la réponse: Json. $this->getResponse()->setContentType('application/json'); // Puis on déclare le tableau contenant la réponse. $JSONResponse = array(); $valide = true; // Récupération des paramètres POST. $old_ei_data_set = $request->getPostParameter('oldVersionId'); $new_ei_data_set = $request->getPostParameter('newVersionId'); // Récupération du template id. $template_id = $request->getParameter('ei_data_set_template_id'); $this->logger->info("--- PARAMETRES POST"); $this->logger->info("OLD : " . $old_ei_data_set); $this->logger->info("NEW : " . $new_ei_data_set); $this->logger->info("--- TEMPLATE"); $this->logger->info("ID : " . $template_id); // On récupère le template. $ei_data_set_template = Doctrine_Core::getTable('EiDataSetTemplate')->find($template_id); // On récupère l'ancienne et la nouvelle version du jeu de données. /** @var EiDataSet $old_ei_data_set */ $old_ei_data_set = Doctrine_Core::getTable('EiDataSet')->find($old_ei_data_set); /** @var EiDataSet $new_ei_data_set */ $new_ei_data_set = Doctrine_Core::getTable('EiDataSet')->find($new_ei_data_set); // On vérifie que les objets existent bien. if ($ei_data_set_template != null && $old_ei_data_set != null && $old_ei_data_set->getId() != "" && $new_ei_data_set != null && $new_ei_data_set->getId() != "") { $this->logger->info("--- COMPARAISON TEMPLATE ASSOCIE A OLD & NEW"); $this->logger->info("OLD : " . $old_ei_data_set->getEiDataSetTemplateId()); $this->logger->info("NEW : " . $new_ei_data_set->getEiDataSetTemplateId()); if ($ei_data_set_template->getId() != $old_ei_data_set->getEiDataSetTemplateId()) { $valide = false; } } else { $this->logger->info("--- MAUVAISE RECUPERATION"); $valide = false; } // Puis, on vérifie qu'ils dépendent tous deux du même template. if ($valide && $old_ei_data_set->getEiDataSetTemplate()->getId() == $new_ei_data_set->getEiDataSetTemplate()->getId()) { // Si c'est le cas, on modifie la version courante. /** @var EiDataSetTemplate $template */ $template = $new_ei_data_set->getEiDataSetTemplate(); $template->setEiDataSetRefId($new_ei_data_set->getId()); $template->save(); $JSONResponse["success"] = true; $JSONResponse["title"] = "Success !"; $JSONResponse["message"] = "Data set master version has been changed successfully."; } else { $JSONResponse["success"] = false; $JSONResponse["title"] = "Error !"; $JSONResponse["message"] = "An error occured when we try to change Data set master version."; } $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- FIN MODIFICATION VERSION JDD TEMPLATE"); $this->logger->info("----------------------------------------------------------"); return $this->renderText(json_encode($JSONResponse)); }