SuiteTestDeleteImpl.java :  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » api » api2ihm » suiteTest » Java Open Source

Java Open Source » Test Coverage » salome tmf 
salome tmf » org » objectweb » salome_tmf » api » api2ihm » suiteTest » SuiteTestDeleteImpl.java
/*
* SalomeTMF is a Test Management Framework
* Copyright (C) 2005 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @author Fayal SOUGRATI
*
* Contact: mikael.marche@rd.francetelecom.com
*/

package org.objectweb.salome_tmf.api.api2ihm.suiteTest;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties;

import org.objectweb.salome_tmf.api.api2db.DataBase;
import org.objectweb.salome_tmf.api.api2db.DataSet;
import org.objectweb.salome_tmf.api.api2ihm.Utile;

/**
 * Fonctions de suppression relatives  l'aire fonctionnelle "Suites de test"
 */
public class SuiteTestDeleteImpl implements SuiteTestDelete {

  /**
   * Base de donnees
   */
  DataBase database;
  
  /**
   * Fichier "properties" contenant les requetes SQL relatives aux suites de test
   */
  Properties prop;
  
  /**
   * ID du projet SalomeTMF dans lequel on se situe
   */
  int idProject;
  
  /**
   * Nom du projet SalomeTMF dans lequel on se situe
   */
  String nameProject;

    
    private boolean special_allow = false;

  /**
   * Constructeur
   * @param db
   * @param pr
   */
  public SuiteTestDeleteImpl(DataBase db, Properties pr) {
    database = db;
    prop = pr;    
  }
  
  /**
   * Fonction qui fixe le projet SalomeTMF dans lequel l'utilisateur travaille
   * @param projectName
   */
   public void setProject(String projectName) {
    nameProject = projectName;
    idProject = Utile.getIdProject(database,prop,projectName);
   }
  
  /**
   * Suppression d'une suite de test
   * @param nameFamily
   * @param nameSuite
   */
  public void deleteSuite(String nameFamily, String nameSuite) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteSuite NOT ALLOW");
        try {
      throw new Exception("deleteSuite NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      
      int idFamily = -1;
      int idSuite = -1;
      //String sql = null;
      int _num = -1;
      try {
    _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      // Initialisation de l'ID de la famille de test
      idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
            
      // Suppression de tous les tests de la suite de test
    
      
      idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      org.objectweb.salome_tmf.api.Api.log("Suppression de tous les tests de la suite de test " + nameSuite + " d'id " + idSuite);
      String testName = null;
      DataSet DS = STCommun.selectSuiteTests(database,prop,idSuite);
      while (DS.getResults().next()) {
        testName = DS.getResults().getString("nom_cas");
        org.objectweb.salome_tmf.api.Api.log("Suppression du test du test " + testName);
        deleteTest(nameFamily,nameSuite,testName);
      }

      // Suppression des attachements de la suite
      org.objectweb.salome_tmf.api.Api.log("Suppression de tous les attachements de la suite de test " + nameSuite + " d'id " + idSuite);
      deleteAllAttachFromSuite(idSuite);
      
      // Suppression de la suite de test
      org.objectweb.salome_tmf.api.Api.log("Suppression de la suite " + nameSuite + " d'id " + idSuite);
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteSuite"));
      prep.setString(1, nameSuite);
      prep.setInt(2, idFamily);
      prep.executeUpdate();
      
    }
    catch(SQLException E) {
      E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException("deleteSuite", null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
      org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
        
      /**
   * Suppression d'une suite de test
   * @param suiteId
   */
  public void deleteSuiteUsingID(int suiteId) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteSuite NOT ALLOW");
        try {
      throw new Exception("deleteSuite NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      
      int _num = -1;
      try {
    _num = org.objectweb.salome_tmf.api.Api.beginTrans();
            
    // Suppression de tous les tests de la suite de test
    
                org.objectweb.salome_tmf.api.Api.log("Suppression de tous les tests de la suite d'id " + suiteId);
                DataSet DS = STCommun.selectSuiteTests(database,prop,suiteId);
                while (DS.getResults().next()) {
                        int testId = DS.getResults().getInt("id_cas");
                        org.objectweb.salome_tmf.api.Api.log("Suppression du test d'id " + testId);
                        deleteTestUsingID(testId);
                }

                // Suppression des attachements de la suite
                org.objectweb.salome_tmf.api.Api.log("Suppression de tous les attachements de la suite de test d'id " + suiteId);
                deleteAllAttachFromSuite(suiteId);

                // Suppression de la suite de test
                org.objectweb.salome_tmf.api.Api.log("Suppression de la suite d'id " + suiteId);
                PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteSuiteUsingID"));
                prep.setInt(1, suiteId);
                prep.executeUpdate();
      
    }
    catch(SQLException E) {
      E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException("deleteSuite", null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
      org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
  
    public void deleteFamily(int idFamily, String name){
  special_allow = true;
  int _num = -1;
  try {
      _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      // Suppression de toutes les suite de test appartenant a la famille
      String suiteName = null;
      DataSet DS = STCommun.selectFamilySuites(database,prop,idFamily);
      while (DS.getResults().next()) {
    suiteName = DS.getResults().getString("nom_suite");
    deleteSuite(name,suiteName);
      }
      
      // Suppression de la famille de test
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteFamily"));
      prep.setString(1, name);
      prep.setInt(2, idProject);
      prep.executeUpdate();
      special_allow = false;
      
  }
  catch(SQLException E) {
      special_allow = false;
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException("deleteFamily", null, E);
  }catch (Exception ex) {
      ex.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
  }
  org.objectweb.salome_tmf.api.Api.commitTrans(_num);
    }
  /**
   * Suppression d'une famille de test
   * @param name
   */
  public void deleteFamily(String name){
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteFamily NOT ALLOW");
        try {
      throw new Exception("deleteFamily NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
    int idFamily = 0;
    int _num =-1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      // Initialisation de l'ID de la famille de test
      idFamily = STCommun.getIdFamily(database,prop,idProject, name);
      
      // Suppression de toutes les suite de test appartenant a la famille
      String suiteName = null;
      DataSet DS = STCommun.selectFamilySuites(database,prop,idFamily);
      while (DS.getResults().next()) {
        suiteName = DS.getResults().getString("nom_suite");
        deleteSuite(name,suiteName);
      }

      // Suppression de la famille de test
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteFamily"));
      prep.setString(1, name);
      prep.setInt(2, idProject);
      prep.executeUpdate();
      
    }
    catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException("deleteFamily", null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
        
        /**
   * Suppression d'une famille de test
   * @param familyId
   */
  public void deleteFamilyUsingID(int familyId){
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteFamily NOT ALLOW");
        try {
      throw new Exception("deleteFamily NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
            
            int _num =-1;
            try {
                _num = org.objectweb.salome_tmf.api.Api.beginTrans();
                
                // Suppression de toutes les suite de test appartenant a la famille
                DataSet DS = STCommun.selectFamilySuites(database,prop,familyId);
                while (DS.getResults().next()) {
                        int suiteId = DS.getResults().getInt("id_suite");
                        deleteSuiteUsingID(suiteId);
                }

                // Suppression de la famille de test
                PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteFamilyUsingID"));
                prep.setInt(1, familyId);
                prep.executeUpdate();

            }
            catch(SQLException E) {
                    E.printStackTrace();
                    org.objectweb.salome_tmf.api.Api.addException("deleteFamily", null, E);
            }catch (Exception ex) {
                ex.printStackTrace();
                org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
            }
            org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
  
  /**
   * Suppression d'un test d'une suite de test
   * @param nameFamily
   * @param nameSuite
   * @param nameTest
   */
  public void deleteTest(String nameFamily, String nameSuite, String nameTest) {
       if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteTest NOT ALLOW");
        try {
      throw new Exception("deleteTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
       }
    int idFamily = -1;
    int idSuite = -1;
    int idTest = -1;
    int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Initialisation de l'ID de la famille de test
      idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      
      // Initialisation de l'ID de la suite de test
      idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      
      // Initialisation de l'ID du test
      idTest = STCommun.getIdTest(database,prop,nameTest,idSuite);
      
      //  Suppression de toutes les action de test si c'est un test manuel
      org.objectweb.salome_tmf.api.Api.log("Suppression de toutes les action de test si c'est un test manuel");
      String actionName = null;
      DataSet DS = STCommun.selectTestActions(database,prop,idTest);
      while (DS.getResults().next()) {
          actionName = DS.getResults().getString("nom_action");
          deleteAction(nameFamily,nameSuite,nameTest,actionName);
      }
       
      // Supression des parametres
      org.objectweb.salome_tmf.api.Api.log("Supression des parametres du test");
      deleteAllParamFromTest(idTest);
      
      // Suppression des attachments du test
      org.objectweb.salome_tmf.api.Api.log("Suppression des attachments du test");
      deleteAllAttachFromTest(idTest);
      
      //Supprssion du scprit de test, si test automatique
      org.objectweb.salome_tmf.api.Api.log("Supprssion du scprit de test, si test automatique");
      deleteScriptFromTest(idTest);
      
      // Supprsion du test dans les campagnes de tests
      org.objectweb.salome_tmf.api.Api.log("Supprsion du test dans les campagnes de tests");
      org.objectweb.salome_tmf.api.api2ihm.campTest.CampTestDelete ct_d =   org.objectweb.salome_tmf.api.Api.getInstanceOfCampTest().getCampTestDelete();
      ct_d.setProject(nameProject);
      ct_d.purgeTestFromAllCampaigns(idTest);

      // Suppression du test
      org.objectweb.salome_tmf.api.Api.log("Suppression du test");
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteTest"));
      prep.setInt(1, idSuite);
      prep.setString(2, nameTest);
      prep.executeUpdate();
      
    }
    catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException("deleteTest", null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
        
        /**
   * Suppression d'un test d'une suite de test
   * @param testId
   */
  public void deleteTestUsingID(int testId) {
       if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteTest NOT ALLOW");
        try {
      throw new Exception("deleteTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
       }
    int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      //  Suppression de toutes les action de test si c'est un test manuel
      org.objectweb.salome_tmf.api.Api.log("Suppression de toutes les action de test si c'est un test manuel");
      DataSet DS = STCommun.selectTestActions(database,prop,testId);
      while (DS.getResults().next()) {
          int actionId = DS.getResults().getInt("id_action");
          deleteActionUsingID(actionId);
      }
       
      // Supression des parametres
      org.objectweb.salome_tmf.api.Api.log("Supression des parametres du test");
      deleteAllParamFromTest(testId);
      
      // Suppression des attachments du test
      org.objectweb.salome_tmf.api.Api.log("Suppression des attachments du test");
      deleteAllAttachFromTest(testId);
      
      //Supprssion du scprit de test, si test automatique
      org.objectweb.salome_tmf.api.Api.log("Supprssion du scprit de test, si test automatique");
      deleteScriptFromTest(testId);
      
      // Supprsion du test dans les campagnes de tests
      org.objectweb.salome_tmf.api.Api.log("Supprsion du test dans les campagnes de tests");
      org.objectweb.salome_tmf.api.api2ihm.campTest.CampTestDelete ct_d =   org.objectweb.salome_tmf.api.Api.getInstanceOfCampTest().getCampTestDelete();
      ct_d.setProject(nameProject);
      ct_d.purgeTestFromAllCampaigns(testId);

      // Suppression du test
      org.objectweb.salome_tmf.api.Api.log("Suppression du test");
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteTestUsingID"));
      prep.setInt(1, testId);
      prep.executeUpdate();
      
    }
    catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException("deleteTest", null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
  
  /**
   * Suppression d'une action d'un test manuel
   * @param nameFamily
   * @param nameSuite
   * @param nameTest
   * @param nameAction
   */
  public void deleteAction(String nameFamily, String nameSuite, String nameTest, String nameAction) {
       if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAction NOT ALLOW");
        try {
      throw new Exception("deleteAction NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
       }
    int idFamily = -1;
    int idSuite = -1;
    int idTest = -1;
    int idAction = -1;
    String sql = null;
    DataSet stmtRes = null;
    int _num = -1;
    try {
      _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      
             // Initialisation de l'ID de la famille de test
      idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      
      // Initialisation de l'ID de la suite de test
      idSuite = STCommun.getIdSuite(database,prop,idProject, nameSuite,idFamily);
      
      // Initialisation de l'ID du test manuel
      idTest = STCommun.getIdTest(database,prop,nameTest, idSuite);
  
      idAction = STCommun.getIdAction(database, prop, nameAction, idTest);
      

      //Supprssion des attachments
      deleteAllAttachFromTestAction(idAction);
      
      //Supprssion des paramatres de l'action
      sql = "selectActionParams";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("selectActionParams"));
      prep.setInt(1,idAction);
      stmtRes = new DataSet(prep.executeQuery());
      while  (stmtRes.hasMoreElements()) {
          prep = database.prepareStatement(prop.getProperty("deleteParamFromAction"));
          int idParam = stmtRes.getResults().getInt("PARAM_TEST_id_param_test");
          prep.setInt(1, idAction);
          prep.setInt(2, idParam);
          prep.executeUpdate();
            }
      
      // Supprssion de l'action
      sql = "deleteAction";
      prep = database.prepareStatement(prop.getProperty("deleteAction"));
      prep.setInt(1, idTest);
      prep.setString(2, nameAction);
      prep.executeUpdate();
    }
    catch(SQLException E) {
      E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
        
  /**
   * Suppression d'une action d'un test manuel
   * @param actionId
   */
  public void deleteActionUsingID(int actionId) {
       if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAction NOT ALLOW");
        try {
      throw new Exception("deleteAction NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
       }
    String sql = null;
    DataSet stmtRes = null;
    int _num = -1;
    try {
      _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      
             //Supprssion des attachments
      deleteAllAttachFromTestAction(actionId);
      
      //Supprssion des paramatres de l'action
      sql = "selectActionParams";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("selectActionParams"));
      prep.setInt(1,actionId);
      stmtRes = new DataSet(prep.executeQuery());
      while  (stmtRes.hasMoreElements()) {
          prep = database.prepareStatement(prop.getProperty("deleteParamFromAction"));
          int idParam = stmtRes.getResults().getInt("PARAM_TEST_id_param_test");
          prep.setInt(1, actionId);
          prep.setInt(2, idParam);
          prep.executeUpdate();
            }
      
      // Supprssion de l'action
      sql = "deleteAction";
      prep = database.prepareStatement(prop.getProperty("deleteActionUsingID"));
      prep.setInt(1, actionId);
      prep.executeUpdate();
    }
    catch(SQLException E) {
      E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }

    
  /**
   * Suppression des parametres d'un test : N'entraine PAS la suppression du parametre de test du projet
   * @param idTest
   */
  public void deleteAllParamFromTest(int idTest) {
       if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAllParamFromTest NOT ALLOW");
        try {
      throw new Exception("deleteAllParamFromTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
       }
    int idParam = -1;
    DataSet stmtRes = null;
    DataSet stmtRes2 = null;
    String sql = null;
    int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
        sql = "selectTestParams";
        PreparedStatement prep = database.prepareStatement(prop.getProperty("selectTestParams"));
        prep.setInt(1, idTest);
        stmtRes = new DataSet(prep.executeQuery());
        while  (stmtRes.hasMoreElements()) {
      // Supprsion du paramtre du tests
      idParam = stmtRes.getResults().getInt("PARAM_TEST_id_param_test"); //ou id_param_test 
      
      sql = "selectAllIdAction";
      prep = database.prepareStatement(prop.getProperty("selectAllIdAction"));
      prep.setInt(1, idTest);
      stmtRes2 = new DataSet(prep.executeQuery());
      while  (stmtRes2.hasMoreElements()) {
          int id_action = stmtRes2.getResults().getInt("id_action");
          org.objectweb.salome_tmf.api.Api.log("Supprsion du paramtre "+ idParam +" du tests" + idTest + " dans l'action : " + id_action);
          sql = "deleteParamFromAction";
          prep = database.prepareStatement(prop.getProperty("deleteParamFromAction"));
          prep.setInt(1, id_action);
          prep.setInt(2, idParam);
          prep.executeUpdate();
      }
      
      org.objectweb.salome_tmf.api.Api.log("Supprsion du paramtre "+ idParam +" du tests" + idTest);
      sql = "deleteParamFromTest";
      prep = database.prepareStatement(prop.getProperty("deleteParamFromTest"));
      
      prep.setInt(1, idTest);
      prep.setInt(2, idParam);
      prep.executeUpdate();
      
        }
    }
    catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }    
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }




  /**
   * Suppression d'un parametre d'un test : N'entraine PAS la suppression du parametre de test du projet
   * @param nameFamily  
   * @param nameSuite
   * @param nameTest
   * @param nameParam
   */
  public void deleteParamFromTest(String nameFamily, String nameSuite,String nameTest, String nameParam) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteParamFromTest NOT ALLOW");
        try {
      throw new Exception("deleteParamFromTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
    int idFamily = -1;
    int idSuite = -1;
    int idTest = -1;
    int idParam = -1;
    String sql = null;
    DataSet stmtRes = null;
    int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Initialisation de l'ID de la famille de test
      idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      // Initialisation de l'ID de la suite de test
      idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      // Initialisation de l'ID du test manuel
      idTest = STCommun.getIdTest(database,prop,nameTest, idSuite);
      // Initialisation de l'ID du parametre de test
      idParam = STCommun.getIdParam(database,prop,nameParam,idProject);
      
      sql = "selectAllIdAction";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("selectAllIdAction"));
      prep.setInt(1, idTest);
      stmtRes = new DataSet(prep.executeQuery());
      while  (stmtRes.hasMoreElements()) {
          int id_action = stmtRes.getResults().getInt("id_action");
          org.objectweb.salome_tmf.api.Api.log("Supprsion du paramtre "+ idParam +" du tests" + idTest + " dans l'action : " + id_action);
          sql = "deleteParamFromAction";
          prep = database.prepareStatement(prop.getProperty("deleteParamFromAction"));
          prep.setInt(1, id_action);
          prep.setInt(2, idParam);
          prep.executeUpdate();
      }

      // Appel de la requete a executer
      sql = "deleteParamFromTest";
      prep = database.prepareStatement(prop.getProperty("deleteParamFromTest"));
  
      prep.setInt(1, idTest);
      prep.setInt(2, idParam);
      prep.executeUpdate();
    }
    catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);  
  }
        
          /**
   * Suppression d'un parametre d'un test : N'entraine PAS la suppression du parametre de test du projet
   * @param testId
   * @param paramId
   */
  public void deleteParamFromTestUsingID(int testId, int paramId) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteParamFromTest NOT ALLOW");
        try {
      throw new Exception("deleteParamFromTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
    
    String sql = null;
    DataSet stmtRes = null;
    int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      sql = "selectAllIdAction";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("selectAllIdAction"));
      prep.setInt(1, testId);
      stmtRes = new DataSet(prep.executeQuery());
      while  (stmtRes.hasMoreElements()) {
          int id_action = stmtRes.getResults().getInt("id_action");
          org.objectweb.salome_tmf.api.Api.log("Supprsion du paramtre "+ paramId +" du test " + testId + " dans l'action : " + id_action);
          sql = "deleteParamFromAction";
          prep = database.prepareStatement(prop.getProperty("deleteParamFromAction"));
          prep.setInt(1, id_action);
          prep.setInt(2, paramId);
          prep.executeUpdate();
      }

      // Appel de la requete a executer
      sql = "deleteParamFromTest";
      prep = database.prepareStatement(prop.getProperty("deleteParamFromTest"));
  
      prep.setInt(1, testId);
      prep.setInt(2, paramId);
      prep.executeUpdate();
    }
    catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);  
  }
  
  /**
   * Suppression d'un parametre d'une action de test : N'entraine PAS la suppression du parametre de test du projet
   * @param nameFamily
   * @param nameSuite
   * @param nameTest
   * @param nameAction
   * @param nameParam
   */
  public void deleteParamFromAction(String nameFamily, String nameSuite,String nameTest, String nameAction, String nameParam) {
       if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteParamFromAction NOT ALLOW");
        try {
      throw new Exception("deleteParamFromAction NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
       }
    int idFamily = -1;
    int idSuite = -1;
    int idTest = -1;
    int idAction = -1;
    int idParam = -1;
    int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Initialisation de l'ID de la famille de test
      idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      // Initialisation de l'ID de la suite de test
      idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      // Initialisation de l'ID du test manuel
      idTest = STCommun.getIdTest(database,prop,nameTest, idSuite);
      // Idem pour l'action de test
      idAction = STCommun.getIdAction(database,prop,nameAction,idTest);
      // Initialisation de l'ID du parametre de test
      idParam = STCommun.getIdParam(database,prop,nameParam,idProject);
      
      // Appel de la requete a executer
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteParamFromAction"));
  
      prep.setInt(1, idAction);
      prep.setInt(2, idParam);
      prep.executeUpdate();
    }
    catch(SQLException E) {
        E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException("deleteParamFromAction", null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
        
        /**
   * Suppression d'un parametre d'une action de test : N'entraine PAS la suppression du parametre de test du projet
   * @param actionId
   * @param paramId
   */
  public void deleteParamFromActionUsingID(int actionId, int paramId) {
       if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteParamFromAction NOT ALLOW");
        try {
      throw new Exception("deleteParamFromAction NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
       }
    
    int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Appel de la requete a executer
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteParamFromAction"));
  
      prep.setInt(1, actionId);
      prep.setInt(2, paramId);
      prep.executeUpdate();
    }
    catch(SQLException E) {
        E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException("deleteParamFromAction", null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
  
    /**
     * Suppression des fichiers attachs  une suite de test
     * @param idSuite
     */
    public void deleteAllAttachFromSuite(int idSuite) {
  if (!special_allow) {
      if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest()) ){
    org.objectweb.salome_tmf.api.Api.log("deleteAllAttachFromSuite NOT ALLOW");
    try {
        throw new Exception("deleteAllAttachFromSuite NOT ALLOW");
    }catch (Exception e) {
        e.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException(e);
    }
    return;
      }
  }
  DataSet stmtRes = null;
  int _num =-1;
  try {
      _num = org.objectweb.salome_tmf.api.Api.beginTrans();
    
      org.objectweb.salome_tmf.api.Api.log("Selection des attachements de la suite " + idSuite);
      PreparedStatement prep = database.prepareStatement(prop.getProperty("selectSuiteAttachs"));
      prep.setInt(1, idSuite);
      stmtRes = new DataSet(prep.executeQuery());
      while  (stmtRes.hasMoreElements()) {
    int idAttachFile = stmtRes.getResults().getInt("ATTACHEMENT_id_attach");
    deleteAttachFromSuite(idSuite, idAttachFile);
      }
  }catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException("selectSuiteAttachs", null, E);
  }catch (Exception ex) {
      ex.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
  }
  org.objectweb.salome_tmf.api.Api.commitTrans(_num);
    }

    /**
     * Suppression d'un fichier attach  une suite de test
     * @param idSuite
     * @param idAttachFile
     */
    public void deleteAttachFromSuite(int idSuite, int idAttachFile) {
  if (!special_allow) {
      if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
    org.objectweb.salome_tmf.api.Api.log("deleteAttachFromSuite NOT ALLOW");
    try {
     throw new Exception("deleteAttachFromSuite NOT ALLOW");
    }catch (Exception e) {
        e.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException(e);
    }
    return;
      }
  }
  String sql = null;
  int _num = -1;
  try {
      _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      
      // Suppression de l'attachement de la suite de test
      org.objectweb.salome_tmf.api.Api.log("Suppression de l'attachement "+ idAttachFile +" de la suite de test" + idSuite);
      sql = "deleteAttachFromSuite";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteAttachFromSuite"));
      prep.setInt(1, idSuite);
      prep.setInt(2, idAttachFile);
      prep.executeUpdate();
      
      // Suppression de l'attachement de la BdD
      org.objectweb.salome_tmf.api.Api.log("Suppression de l'attachement "+ idAttachFile +"dans la BDD");
      sql = "deleteAttachFromDB";
      prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
      prep.setInt(1, idAttachFile);
      prep.executeUpdate();
  } catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
  org.objectweb.salome_tmf.api.Api.commitTrans(_num);
    }
  /**
   * Suppression d'un fichier attach  une suite de test
   * @param nameFamily
   * @param nameSuite
   * @param fileName
   */
  public void deleteAttachFileFromSuite(String nameFamily, String nameSuite, String fileName) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAttachFileFromSuite NOT ALLOW");
        try {
      throw new Exception("deleteAttachFileFromSuite NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
    int idFamily = 0;
    int idSuite = 0;
    int idAttachFile = 0;
    int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Initialisation de l'ID de la famille de test
      idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      // Initialisation de l'ID de la suite de test
      idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      // Idem pour l'attachement
      idAttachFile = STCommun.getSuiteAttachFileId(database,prop,idSuite,fileName);
      
      deleteAttachFromSuite(idSuite, idAttachFile);

      
      
    }
    catch(Exception E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException( null, null, E);
    }    
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
  
  /**
   * Suppression d'une URL attache  une suite de test
   * @param nameFamily
   * @param nameSuite
   * @param url
   */
  public void deleteAttachUrlFromSuite(String nameFamily, String nameSuite, String url) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAttachUrlFromSuite NOT ALLOW");
        try {
      throw new Exception("deleteAttachUrlFromSuite NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
    int idFamily = 0;
    int idSuite = 0;
    int idAttachUrl = 0;
    int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Initialisation de l'ID de la famille de test
      idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      // Initialisation de l'ID de la suite de test
      idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      // Idem pour l'attachement
      idAttachUrl = STCommun.getSuiteAttachUrlId(database,prop,idSuite,url);
      
      deleteAttachFromSuite(idSuite, idAttachUrl);  
      /*
      // Suppression de l'attachement de la suite de test
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteAttachFromSuite"));
      prep.setInt(1, idSuite);
      prep.setInt(2, idAttachUrl);
      prep.executeUpdate();
      
      // Suppression de l'attachement de la BdD
      prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
      prep.setInt(1, idAttachUrl);
      prep.executeUpdate();
      */
    }
    catch(Exception E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException( null, null, E);
    }    
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
        
        /**
   * Suppression d'une URL attache  une suite de test
   * @param suiteId
   * @param AttachId
   * @see org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest()
   */
  public void deleteAttachFromSuiteUsingID(int suiteId, int attachId) {
            deleteAttachFromSuite(suiteId,attachId);
        }
  
  /**
   * Suppression d'un fichier attach  un test
   * @param nameFamily
   * @param nameSuite
   * @param testName
   * @param fileName
   */
  public void deleteAttachFileFromTest(String nameFamily, String nameSuite, String testName, String fileName) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAttachFileFromTest NOT ALLOW");
        try {
      throw new Exception("deleteAttachFileFromTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      String sql = null;
      int _num = -1;
      try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Initialisation de l'ID de la famille de test
      int idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      // Initialisation de l'ID de la suite de test
      int idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      // Initialisation de l'ID du test
      int idTest = STCommun.getIdTest(database, prop, testName, idSuite);
      // Idem pour l'attachement
      int idAttachFile = STCommun.getTestAttachFileId(database,prop,idTest,fileName);
      
      // Suppression de l'attachement de la suite de test
      sql = "deleteAttachFromTest";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteAttachFromTest"));
      prep.setInt(1, idTest);
      prep.setInt(2, idAttachFile);
      prep.executeUpdate();
      
      // Suppression de l'attachement de la BdD
      sql = "deleteAttachFromDB";
      prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
      prep.setInt(1, idAttachFile);
      prep.executeUpdate();
      
    }
    catch(SQLException E) {
      E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }  
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);  
  }
    /**
     * Suppression des fichiers attachs une action
     * @param idTest
     */
  
    private void deleteAllAttachFromTestAction(int idAction) {
  if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAllAttachFromTestAction NOT ALLOW");
        try {
      throw new Exception("deleteAllAttachFromTestAction NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
  }
  String sql = null;
  int _num = -1;
  try {
      _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      
      DataSet stmtRes = null;
      int idAttachFile;
      sql = "selectTestAllAttachAction";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("selectTestAllAttachAction"));
      prep.setInt(1, idAction);
      stmtRes = new DataSet(prep.executeQuery());
      
      while  (stmtRes.hasMoreElements()) {
    idAttachFile = stmtRes.getResults().getInt("ATTACHEMENT_id_attach");
    // Suppression de l'attachement de la suite de test
    org.objectweb.salome_tmf.api.Api.log("Suppression de l'attachement "+ idAttachFile +" de l'action" + idAction);
    sql = "deleteAttachFromAction";
    prep = database.prepareStatement(prop.getProperty("deleteAttachFromAction"));
    prep.setInt(1, idAction);
    prep.setInt(2, idAttachFile);
    prep.executeUpdate();
    
    // Suppression de l'attachement de la BdD
    sql = "deleteAttachFromDB";
    prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
    prep.setInt(1, idAttachFile);
    prep.executeUpdate();
      }
      
  }
  catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
  }catch (Exception ex) {
      ex.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
  }  
  org.objectweb.salome_tmf.api.Api.commitTrans(_num);
    }
  
    /**
     * Suppression des fichiers attachs  un test
     * @param idTest
     */
  
    private void deleteAllAttachFromTest(int idTest) {

  String sql = null;
  int _num = -1;
  try {
      _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      
      DataSet stmtRes = null;
      int idAttachFile;
      sql = "selectTestAllAttachFiles";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("selectTestAllAttachFiles"));
      prep.setInt(1, idTest);
      stmtRes = new DataSet(prep.executeQuery());
      
      while  (stmtRes.hasMoreElements()) {
    idAttachFile = stmtRes.getResults().getInt("ATTACHEMENT_id_attach");
    // Suppression de l'attachement de la suite de test
    org.objectweb.salome_tmf.api.Api.log("Suppression de l'attachement " + idAttachFile + " du test " + idTest);
    sql = "deleteAttachFromTest";
    prep = database.prepareStatement(prop.getProperty("deleteAttachFromTest"));
    prep.setInt(1, idTest);
    prep.setInt(2, idAttachFile);
    prep.executeUpdate();
    
    // Suppression de l'attachement de la BdD
    sql = "deleteAttachFromDB";
    prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
    prep.setInt(1, idAttachFile);
    prep.executeUpdate();
      }
      
  }
  catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
  }catch (Exception ex) {
      ex.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
  }    
  org.objectweb.salome_tmf.api.Api.commitTrans(_num);
    }
  
  /**
   * Suppression d'une URL attache  une action
   * @param nameFamily
   * @param nameSuite
   * @param testName
   * @param url
   */
  public void deleteAttachUrlFromTest(String nameFamily, String nameSuite, String testName, String url) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAttachUrlFromTest NOT ALLOW");
        try {
      throw new Exception("deleteAttachUrlFromTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      String sql = null;
      int _num = -1;
      try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Initialisation de l'ID de la famille de test
      int idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      // Initialisation de l'ID de la suite de test
      int idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      // Initialisation de l'ID du test
      int idTest = STCommun.getIdTest(database, prop, testName, idSuite);
      // Idem pour l'attachement
      int idAttachUrl = STCommun.getTestAttachUrlId(database,prop,idTest,url);
      
      // Suppression de l'attachement de la suite de test
      sql = "deleteAttachFromTest";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteAttachFromTest"));
      prep.setInt(1, idTest);
      prep.setInt(2, idAttachUrl);
      prep.executeUpdate();
      
      // Suppression de l'attachement de la BdD
      sql = "deleteAttachFromDB";
      prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
      prep.setInt(1, idAttachUrl);
      prep.executeUpdate();
      
    }
    catch(SQLException E) {
        E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }    
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
        
        /**
   * Suppression d'une URL attache  un test
   * @param testId
   * @param attachId
   * @see org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest()
   */
  public void deleteAttachFromTestUsingID(int testId, int attachId) {
            if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAttachUrlFromTest NOT ALLOW");
        try {
      throw new Exception("deleteAttachUrlFromTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      String sql = null;
      int _num = -1;
      try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
                    // Suppression de l'attachement de la suite de test
                    sql = "deleteAttachFromTest";
                    PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteAttachFromTest"));
                    prep.setInt(1, testId);
                    prep.setInt(2, attachId);
                    prep.executeUpdate();

                    // Suppression de l'attachement de la BdD
                    sql = "deleteAttachFromDB";
                    prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
                    prep.setInt(1, attachId);
                    prep.executeUpdate();
      
    }
    catch(SQLException E) {
        E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }    
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
        }

  /**
   * Suppression d'un fichier attach  un test
   * @param nameFamily
   * @param nameSuite
   * @param testName
   * @param actionName
   * @param fileName
   */
  public void deleteAttachFileFromAction(String nameFamily, String nameSuite, String testName, String actionName, String fileName) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAttachFileFromAction NOT ALLOW");
        try {
      throw new Exception("deleteAttachFileFromAction NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      String sql = null;
      int _num = -1;
      try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Initialisation de l'ID de la famille de test
      int idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      // Initialisation de l'ID de la suite de test
      int idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      // Initialisation de l'ID du test
      int idTest = STCommun.getIdTest(database, prop, testName, idSuite);
      // Initialisation de l'ID de l'action
      int idAction = STCommun.getIdAction(database, prop, actionName, idTest);
      // Idem pour l'attachement
      int idAttachFile = STCommun.getActionAttachFileId(database,prop,idAction,fileName);
      
      // Suppression de l'attachement de la suite de test
      sql = "deleteAttachFromAction";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteAttachFromAction"));
      prep.setInt(1, idAction);
      prep.setInt(2, idAttachFile);
      prep.executeUpdate();
      
      // Suppression de l'attachement de la BdD
      sql = "deleteAttachFromDB";
      prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
      prep.setInt(1, idAttachFile);
      prep.executeUpdate();
      
    }
    catch(SQLException E) {
        E.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }    
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
  
  /**
   * Suppression d'une URL attache  une action
   * @param nameFamily
   * @param nameSuite
   * @param testName
   * @param actionName
   * @param url
   */
  public void deleteAttachUrlFromAction(String nameFamily, String nameSuite, String testName, String actionName, String url) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAttachUrlFromAction NOT ALLOW");
        try {
      throw new Exception("deleteAttachUrlFromAction NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      String sql = null;
      int _num =-1;
      try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
      // Initialisation de l'ID de la famille de test
      int idFamily = STCommun.getIdFamily(database,prop,idProject,nameFamily);
      // Initialisation de l'ID de la suite de test
      int idSuite = STCommun.getIdSuite(database,prop,idProject,nameSuite,idFamily);
      // Initialisation de l'ID du test
      int idTest = STCommun.getIdTest(database, prop, testName, idSuite);
      // Initialisation de l'ID de l'action
      int idAction = STCommun.getIdAction(database, prop, actionName, idTest);
      // Idem pour l'attachement
      int idAttachUrl = STCommun.getActionAttachUrlId(database,prop,idAction,url);
      
      // Suppression de l'attachement de la suite de test
      sql = "deleteAttachFromAction";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteAttachFromAction"));
      prep.setInt(1, idAction);
      prep.setInt(2, idAttachUrl);
      prep.executeUpdate();
      
      // Suppression de l'attachement de la BdD
      sql = "deleteAttachFromDB";
      prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
      prep.setInt(1, idAttachUrl);
      prep.executeUpdate();
      
    }
    catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }  
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
        
        /**
   * Suppression d'une URL attache  un test
   * @param actionId
   * @param attachId
   * @see org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest()
   */
  public void deleteAttachFromActionUsingID(int actionId, int attachId) {
            if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteAttachUrlFromAction NOT ALLOW");
        try {
      throw new Exception("deleteAttachUrlFromAction NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      String sql = null;
      int _num =-1;
      try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
        
                    // Suppression de l'attachement de la suite de test
                    sql = "deleteAttachFromAction";
                    PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteAttachFromAction"));
                    prep.setInt(1, actionId);
                    prep.setInt(2, attachId);
                    prep.executeUpdate();

                    // Suppression de l'attachement de la BdD
                    sql = "deleteAttachFromDB";
                    prep = database.prepareStatement(prop.getProperty("deleteAttachFromDB"));
                    prep.setInt(1, attachId);
                    prep.executeUpdate();
      
    }
    catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }  
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
        }

    

    /**
   * Supprime les scripts d'un test
   * @param idTest
   */
    public void deleteScriptFromTest(int idTest) {
   if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteScriptFromTes NOT ALLOW");
        try {
      throw new Exception("deleteScriptFromTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
   }
  DataSet stmtRes = null;
  int scriptId = -1;
  int attachId = -1;
  String sql = null;
  int _num = -1;
  try {
      _num = org.objectweb.salome_tmf.api.Api.beginTrans();
    
      sql = "selectScriptAttchOfTest";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("selectScriptAttchOfTest"));
      prep.setInt(1,idTest);
      stmtRes = new DataSet(prep.executeQuery());
      
      if (stmtRes.getResults().next()) {
    scriptId = stmtRes.getResults().getInt("SCRIPT_id_script");
    attachId = stmtRes.getResults().getInt("ATTACHEMENT_id_attach");

    // Suppression de l'attachement de la suite de test
    sql = "deleteAttachFromScript";
    prep = database.prepareStatement(prop.getProperty("deleteAttachFromScript"));
    prep.setInt(1, scriptId);
    prep.setInt(2, attachId);
    prep.executeUpdate();
    
    // Suppression de l'attachement de la BdD
    sql = "deleteScriptFileFromDB";
    prep = database.prepareStatement(prop.getProperty("deleteScriptFileFromDB"));
    prep.setInt(1, attachId);
    prep.executeUpdate();
    
    // Suppression de l'attachement de la BdD
    sql = "deleteScriptFromDB";
    prep = database.prepareStatement(prop.getProperty("deleteScriptFromDB"));
    prep.setInt(1, scriptId);
    prep.executeUpdate();
    
    
    // Suppression de l'attachement de la suite de test
    sql = "deleteScriptFromTest";
    prep = database.prepareStatement(prop.getProperty("deleteScriptFromTest"));
    prep.setInt(1, idTest);
    prep.executeUpdate();
      }
  }
  catch(SQLException E) {
      E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(sql, null, E);
  }catch (Exception ex) {
      ex.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
  }
  org.objectweb.salome_tmf.api.Api.commitTrans(_num);
    }
    
    
    /**
   * Supprime un script d'un test
   * @param familyName
   * @param suiteName
   * @param testName
   * @param scriptName
   */
  public void deleteScriptFromTest(String familyName, String suiteName, String testName, String scriptName) {
      if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteScriptFromTest NOT ALLOW");
        try {
      throw new Exception("deleteScriptFromTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      // Initialisation de l'ID de la famille de test
      int idFamily = STCommun.getIdFamily(database,prop,idProject,familyName);
      // Initialisation de l'ID de la suite de test
      int idSuite = STCommun.getIdSuite(database,prop,idProject,suiteName,idFamily);
      // Initialisation de l'ID du test
      int idTest = STCommun.getIdTest(database, prop, testName, idSuite);
    
      // Suppression du script de la BdD
      deleteScript(scriptName, idTest);    
  
      // Suppression de l'attachement de la suite de test
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteScriptFromTest"));
      prep.setInt(1, idTest);
      prep.executeUpdate();
      
    }
    catch(SQLException E) {
        E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException("deleteScriptFromTest", null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }
        
        /**
   * Supprime un script d'un test
   * @param testId
   * @param scriptName
   * @see org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest()
   */
  public void deleteScriptFromTestUsingID(int testId, String scriptName) {
            if (!special_allow) {
    if (!(org.objectweb.salome_tmf.api.api2ihm.AdminProject.canDeleteTest())){
        org.objectweb.salome_tmf.api.Api.log("deleteScriptFromTest NOT ALLOW");
        try {
      throw new Exception("deleteScriptFromTest NOT ALLOW");
        }catch (Exception e) {
      e.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException(e);
        }
        return;
    }
      }
      int _num = -1;
    try {
        _num = org.objectweb.salome_tmf.api.Api.beginTrans();
      
                    // Suppression du script de la BdD
                    deleteScript(scriptName, testId);    

                    // Suppression de l'attachement de la suite de test
                    PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteScriptFromTest"));
                    prep.setInt(1, testId);
                    prep.executeUpdate();
      
    }
    catch(SQLException E) {
        E.printStackTrace();
      org.objectweb.salome_tmf.api.Api.addException("deleteScriptFromTest", null, E);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
    org.objectweb.salome_tmf.api.Api.commitTrans(_num);
        }

  public void deleteScript(String scriptName, int idTest) {
      String sql = null;
      int _num = -1;
      try {
    _num = org.objectweb.salome_tmf.api.Api.beginTrans();
    // Initialisation de l'ID de la famille de test
    int scriptId = STCommun.getIdScript(database,prop,idTest,scriptName);
    // Initialisation de l'ID du fichier attach
      int attachId = STCommun.getAttachIdScript(database, prop, scriptId, scriptName);
      
      // Suppression de l'attachement de la suite de test
      sql = "deleteAttachFromScript";
      PreparedStatement prep = database.prepareStatement(prop.getProperty("deleteAttachFromScript"));
      prep.setInt(1, scriptId);
      prep.setInt(2, attachId);
      prep.executeUpdate();
  
      // Suppression de l'attachement de la BdD
      sql = "deleteScriptFileFromDB";
      prep = database.prepareStatement(prop.getProperty("deleteScriptFileFromDB"));
      prep.setInt(1, attachId);
      prep.executeUpdate();

      // Suppression de l'attachement de la BdD
      sql = "deleteScriptFromDB";
      prep = database.prepareStatement(prop.getProperty("deleteScriptFromDB"));
      prep.setInt(1, scriptId);
      prep.executeUpdate();

    } catch (SQLException e) {
        e.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException(sql, null, e);
    }catch (Exception ex) {
        ex.printStackTrace();
        org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
    }
      org.objectweb.salome_tmf.api.Api.commitTrans(_num);
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.