Ejemplo n.º 1
0
 public function createRootFolderIfNew(Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     try {
         $conn->beginTransaction();
         $root_folder = new EiFolder();
         $root_folder->setProjectId($this->getProjectId());
         $root_folder->setProjectRef($this->getRefId());
         $root_folder->setName('Root');
         $root_folder->save($conn);
         $root_node = new EiNode();
         $root_node->setProjectId($this->getProjectId());
         $root_node->setProjectRef($this->getRefId());
         $root_node->setObjId($root_folder->getId());
         $root_node->setName('Root');
         $root_node->setType('EiFolder');
         $root_node->setPosition(1);
         $root_node->setIsRoot(true);
         $root_node->setIsShortcut(false);
         $root_node->setRootId(Null);
         $root_node->save($conn);
         $conn->commit();
     } catch (Exception $e) {
         $conn->rollback();
         throw $e;
     }
 }
Ejemplo n.º 2
0
 public function configure()
 {
     unset($this['created_at'], $this['updated_at'], $this['nb_joue'], $this['ei_node_id'], $this['ei_version_structure_id']);
     $this->widgetSchema['project_id'] = new sfWidgetFormInputHidden();
     $this->widgetSchema['project_ref'] = new sfWidgetFormInputHidden();
     //Modification des labels
     $this->widgetSchema->setLabels(array('nom_scenario' => 'Libelle'));
     if (!$this->isNew()) {
         $this->widgetSchema['nom_scenario']->setAttribute('class', 'nom_scenario form-control');
     } else {
         $this->widgetSchema['nom_scenario']->setAttribute('class', 'libelle form-control');
     }
     $this->widgetSchema['nom_scenario']->setAttribute('placeholder', 'Enter test suite name ...');
     $this->widgetSchema['description']->setAttribute('placeholder', 'Enter a description for test suite ...');
     $this->widgetSchema['description']->setAttribute('class', 'description_scenario form-control');
     //Imbrication du formulaire pour le noeud parent
     $root_id = $this->getOption('root_id');
     if (isset($root_id) && $root_id != null) {
         $ei_node = new EiNode();
         $ei_node->setIsRoot(false);
         $ei_node->setProjectId($this->getObject()->getProjectId());
         $ei_node->setProjectRef($this->getObject()->getProjectRef());
         $ei_node->setObjId($this->getObject()->getId());
         $ei_node->setPosition(Doctrine_Core::getTable('EiNode')->getLastPositionInNode($this->getObject()->getProjectId(), $this->getObject()->getProjectRef(), $root_id));
         $ei_node->setType('EiScenario');
         $ei_node->setRootId($root_id);
         $this->getObject()->setEiNode($ei_node);
         //on imbrique le sous formulaire au formulaire de creation d'un scénario
         $this->embedForm('ei_node', new EiNodeForm($ei_node));
     }
     /* On vérifie à la validation que l'utilisateur possède un package par défaut */
     $this->validatorSchema->setPostValidator(new sfValidatorCallback(array('callback' => array($this, 'checkIfDefaultPackageExist'))));
 }
 /**
  * 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));
 }
Ejemplo n.º 4
0
 public function configure()
 {
     unset($this['created_at'], $this['updated_at']);
     $this->widgetSchema["project_ref"] = new sfWidgetFormInputHidden();
     $this->widgetSchema["project_id"] = new sfWidgetFormInputHidden();
     $this->widgetSchema['name']->setAttributes(array('class' => '  form-control'));
     //Imbrication du formulaire pour le noeud parent
     $root_id = $this->getOption('root_id');
     if (isset($root_id) && $root_id != null) {
         $ei_node = new EiNode();
         $ei_node->setIsRoot(false);
         $ei_node->setProjectId($this->getObject()->getProjectId());
         $ei_node->setProjectRef($this->getObject()->getProjectRef());
         $ei_node->setObjId($this->getObject()->getId());
         $ei_node->setPosition(Doctrine_Core::getTable('EiNode')->getLastPositionInNode($this->getObject()->getProjectId(), $this->getObject()->getProjectRef(), $root_id));
         $ei_node->setType('EiFolder');
         $ei_node->setRootId($root_id);
         //on imbrique le sous formulaire au formulaire de creation d'un dossier
         $this->embedForm('ei_node', new EiNodeForm($ei_node));
     }
 }
Ejemplo n.º 5
0
function createAndSaveScenario(EiProjet $ei_project, EiNode $root_node)
{
    //On crée le noeud du scénario avant de créer le scénario en soit
    $ei_node = new EiNode();
    $ei_scenario = new EiScenario();
    $ei_node->setIsRoot(false);
    $ei_node->setProjectId($ei_project->getProjectId());
    $ei_node->setProjectRef($ei_project->getRefId());
    $ei_node->setName('testNomScenario');
    $ei_node->setPosition(Doctrine_Core::getTable('EiNode')->getLastPositionInNode($ei_project->getProjectId(), $ei_project->getRefId(), $root_node->getId()));
    $ei_node->setType('EiScenario');
    $ei_node->setRootId($root_node->getId());
    $ei_scenario->project_id = $ei_project->getProjectId();
    $ei_scenario->project_ref = $ei_project->getRefId();
    $ei_scenario->setNomScenario('testNomScenario');
    $ei_scenario->setEiNode($ei_node);
    $ei_scenario->save();
    $ei_node->setObjId($ei_scenario->getId());
    $ei_node->save();
    return $ei_scenario;
}
Ejemplo n.º 6
0
 /**
  * Copie le noeud du scenario.
  * @param EiScenario $copie
  * @param type $conn
  * @throws Exception
  */
 private function createNodeCopie(EiScenario $copie, $conn)
 {
     try {
         $root_folder = $this->getNode();
         $ei_node = new EiNode();
         $ei_node->setProjectId($this->getProjectId());
         $ei_node->setProjectRef($this->getProjectRef());
         $ei_node->setName($copie->getNomScenario());
         $ei_node->setPosition(Doctrine_Core::getTable('EiNode')->getLastPositionInNode($this->getProjectId(), $this->getProjectRef(), $root_folder->getRootId()));
         $ei_node->setIsRoot(false);
         $ei_node->setIsShortcut(false);
         $ei_node->setRootId($root_folder->getRootId());
         $ei_node->setType("EiScenario");
         $copie->setEiNode($ei_node);
         $copie->save($conn, true);
         //$copie->createDefaultEiDataSetFolder($conn);
         $ei_node->setObjId($copie->getId());
         $copie->save($conn, true);
     } catch (Exception $e) {
         throw $e;
     }
 }