001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Fayçal SOUGRATI
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023: package org.objectweb.salome_tmf.api.api2ihm.adminProject;
024:
025: import java.sql.PreparedStatement;
026: import java.sql.SQLException;
027:
028: import java.util.Properties;
029:
030: import org.objectweb.salome_tmf.api.api2db.DataBase; //import org.objectweb.salome_tmf.api.api2db.DataSet;
031: import org.objectweb.salome_tmf.api.api2ihm.Utile;
032:
033: /**
034: * Fonctions de mise a jour relatives e l'aire fonctionnelle "Administrer un projet"
035: */
036:
037: public class AdminProjectUpdateImpl implements AdminProjectUpdate {
038: /**
039: * Base de donnees
040: */
041: DataBase database;
042:
043: /**
044: * Fichier "properties" contenant les requetes SQL relatives aux suites de test
045: */
046: Properties prop;
047:
048: /**
049: * ID du projet SalomeTMF dans lequel on se situe
050: */
051: int idProject;
052:
053: /**
054: * Nom du projet SalomeTMF dans lequel on se situe
055: */
056: String nameProject;
057:
058: /**
059: * Constructeur
060: * @param db
061: * @param pr
062: */
063: public AdminProjectUpdateImpl(DataBase db, Properties pr) {
064: database = db;
065: prop = pr;
066: }
067:
068: /**
069: * Fonction qui fixe le projet SalomeTMF dans lequel l'utilisateur travaille
070: * @param projectName
071: */
072: public void setProject(String projectName) {
073: nameProject = projectName;
074: idProject = Utile.getIdProject(database, prop, projectName);
075: }
076:
077: /**
078: * Mise a jour des permissions dans un groupe
079: *
080: * @param groupName
081: * @param permission
082: */
083: public void updatePermission(String groupName, int permission) {
084: int _num = -1;
085: try {
086: _num = org.objectweb.salome_tmf.api.Api.beginTrans();
087: //DataSet stmtRes = null;
088: PreparedStatement prep = database.prepareStatement(prop
089: .getProperty("updateAllowGroup"));
090: prep.setInt(1, permission);
091: prep.setInt(2, idProject);
092: prep.setString(3, groupName);
093: prep.executeUpdate();
094: } catch (SQLException e) {
095: e.printStackTrace();
096: org.objectweb.salome_tmf.api.Api.addException(
097: "updateAllowGroup", null, e);
098: } catch (Exception ex) {
099: ex.printStackTrace();
100: org.objectweb.salome_tmf.api.Api.addException(null, null,
101: ex);
102: }
103: org.objectweb.salome_tmf.api.Api.commitTrans(_num);
104: }
105:
106: /**
107: * Mise a jour de la description du role d'un user dans un groupe
108: *
109: * @param userLogin
110: * @param groupName
111: * @param description
112: */
113: public void updateUserDescInGroupe(String userLogin,
114: String groupName, String description) {
115: int _num = -1;
116: try {
117: _num = org.objectweb.salome_tmf.api.Api.beginTrans();
118:
119: //DataSet stmtRes = null;
120: PreparedStatement prep = database.prepareStatement(prop
121: .getProperty("updateUserDescInGroupe"));
122: prep.setString(1, description);
123: prep.setInt(2, idProject);
124: prep.setString(3, groupName);
125: prep.setString(4, userLogin);
126:
127: prep.executeUpdate();
128: } catch (SQLException E) {
129: E.printStackTrace();
130: org.objectweb.salome_tmf.api.Api.addException(
131: "updateUserDescInGroupe", null, E);
132: } catch (Exception ex) {
133: ex.printStackTrace();
134: org.objectweb.salome_tmf.api.Api.addException(null, null,
135: ex);
136: }
137: org.objectweb.salome_tmf.api.Api.commitTrans(_num);
138: }
139:
140: /**
141: * Mise a jour du nom et de la description d'un groupe
142: * @param oldGroupName
143: * @param newGroupName
144: * @param newDescription
145: */
146: public void updateGroup(String oldGroupName, String newGroupName,
147: String newDescription) {
148: int _num = -1;
149: try {
150: _num = org.objectweb.salome_tmf.api.Api.beginTrans();
151:
152: //DataSet stmtRes = null;
153: PreparedStatement prep = database.prepareStatement(prop
154: .getProperty("updateGroup"));
155: prep.setString(1, newGroupName);
156: prep.setString(2, newDescription);
157: prep.setInt(3, idProject);
158: prep.setString(4, oldGroupName);
159: prep.executeUpdate();
160: } catch (SQLException E) {
161: E.printStackTrace();
162: org.objectweb.salome_tmf.api.Api.addException(
163: "updateGroup", null, E);
164: } catch (Exception ex) {
165: ex.printStackTrace();
166: org.objectweb.salome_tmf.api.Api.addException(null, null,
167: ex);
168: }
169: org.objectweb.salome_tmf.api.Api.commitTrans(_num);
170:
171: }
172: }
|