0001: /*
0002: * SalomeTMF is a Test Management Framework
0003: * Copyright (C) 2005 France Telecom R&D
0004: *
0005: * This library is free software; you can redistribute it and/or
0006: * modify it under the terms of the GNU Lesser General Public
0007: * License as published by the Free Software Foundation; either
0008: * version 2 of the License, or (at your option) any later version.
0009: *
0010: * This library is distributed in the hope that it will be useful,
0011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013: * Lesser General Public License for more details.
0014: *
0015: * You should have received a copy of the GNU Lesser General Public
0016: * License along with this library; if not, write to the Free Software
0017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0018: *
0019: * @author Fayçal SOUGRATI
0020: *
0021: * Contact: mikael.marche@rd.francetelecom.com
0022: */
0023:
0024: package org.objectweb.salome_tmf.api.api2ihm.adminProject;
0025:
0026: import java.sql.PreparedStatement;
0027: import java.sql.SQLException;
0028: import java.util.Properties;
0029: import java.util.Vector;
0030:
0031: import org.objectweb.salome_tmf.api.api2db.DataBase;
0032: import org.objectweb.salome_tmf.api.api2db.DataSet;
0033: import org.objectweb.salome_tmf.api.api2ihm.Utile;
0034: import org.objectweb.salome_tmf.api.wrapper.EnvironmentWrapper;
0035: import org.objectweb.salome_tmf.api.wrapper.ParameterWrapper;
0036:
0037: //import org.objectweb.salome_tmf.data.Parameter;
0038:
0039: /**
0040: * Fonctions de selection relatives e l'aire fonctionnelle "Administrer un projet"
0041: */
0042: public class AdminProjectSelectImpl implements AdminProjectSelect {
0043: /**
0044: * Base de donnees
0045: */
0046: DataBase database;
0047:
0048: /**
0049: * Fichier "properties" contenant les requetes SQL relatives aux suites de test
0050: */
0051: Properties prop;
0052:
0053: /**
0054: * ID du projet SalomeTMF dans lequel on se situe
0055: */
0056: int idProject;
0057:
0058: /**
0059: * Nom du projet SalomeTMF dans lequel on se situe
0060: */
0061: String nameProject;
0062:
0063: /**
0064: * Constructeur
0065: * @param db
0066: * @param pr
0067: */
0068: public AdminProjectSelectImpl(DataBase db, Properties pr) {
0069: database = db;
0070: prop = pr;
0071: }
0072:
0073: /**
0074: * Fonction qui fixe le projet SalomeTMF dans lequel l'utilisateur travaille
0075: * @param projectName
0076: */
0077: public void setProject(String projectName) {
0078: org.objectweb.salome_tmf.api.Api
0079: .log("Try to connect to the project : " + projectName);
0080: nameProject = projectName;
0081: idProject = Utile.getIdProject(database, prop, projectName);
0082: //org.objectweb.salome_tmf.api.Api.getInstanceOfBugzillaAPI().init(projectName);
0083: }
0084:
0085: /**
0086: * Selection des noms de tous les groupes d'utilisateurs appartenant a un projet
0087: * @return
0088: */
0089: public Vector getAllProjectGroupsName() {
0090: Vector result = new Vector();
0091: DataSet stmtRes = null;
0092:
0093: try {
0094: // On execute la requete
0095: PreparedStatement prep = database.prepareStatement(prop
0096: .getProperty("selectAllProjectGroupsName"));
0097: prep.setInt(1, idProject);
0098: stmtRes = new DataSet(prep.executeQuery());
0099: // Ajoute les element un par un au resultat
0100: while (stmtRes.hasMoreElements()) {
0101: result.addElement(stmtRes.getResults().getString(
0102: "nom_groupe"));
0103: }
0104: } catch (SQLException e) {
0105: e.printStackTrace();
0106: org.objectweb.salome_tmf.api.Api.addException(
0107: "selectAllProjectGroupsName", null, e);
0108: } catch (Exception ex) {
0109: ex.printStackTrace();
0110: org.objectweb.salome_tmf.api.Api.addException(null, null,
0111: ex);
0112: }
0113:
0114: // On retourne le resultat
0115: return result;
0116: }
0117:
0118: /**
0119: * Selection des descriptions de tous les groupes d'utilisateurs appartenant a un projet
0120: * @return
0121: */
0122: public Vector getAllProjectGroupsDesc() {
0123: Vector result = new Vector();
0124: DataSet stmtRes = null;
0125:
0126: try {
0127: // On execute la requete
0128: PreparedStatement prep = database.prepareStatement(prop
0129: .getProperty("selectAllProjectGroupsDesc"));
0130: prep.setInt(1, idProject);
0131: stmtRes = new DataSet(prep.executeQuery());
0132: // Ajoute les element un par un au resultat
0133: while (stmtRes.hasMoreElements()) {
0134: result.addElement(stmtRes.getResults().getString(
0135: "desc_groupe"));
0136: }
0137: } catch (SQLException e) {
0138: e.printStackTrace();
0139: org.objectweb.salome_tmf.api.Api.addException(
0140: "selectAllProjectGroupsDesc", null, e);
0141: } catch (Exception ex) {
0142: ex.printStackTrace();
0143: org.objectweb.salome_tmf.api.Api.addException(null, null,
0144: ex);
0145: }
0146:
0147: // On retourne le resultat
0148: return result;
0149: }
0150:
0151: /**
0152: * Selection des logins de tous les utilisateurs d'un projet
0153: * @return
0154: */
0155: public Vector getAllProjectUsersLogin() {
0156: Vector result = new Vector();
0157: DataSet stmtRes = null;
0158:
0159: try {
0160: // On execute la requete
0161: PreparedStatement prep = database.prepareStatement(prop
0162: .getProperty("selectAllProjectUsers"));
0163: prep.setInt(1, idProject);
0164: stmtRes = new DataSet(prep.executeQuery());
0165: // Ajoute les element un par un au resultat
0166: while (stmtRes.hasMoreElements()) {
0167: result.addElement(stmtRes.getResults().getString(
0168: "login_personne"));
0169: }
0170: } catch (SQLException e) {
0171: e.printStackTrace();
0172: org.objectweb.salome_tmf.api.Api.addException(
0173: "selectAllProjectUsers", null, e);
0174: } catch (Exception ex) {
0175: ex.printStackTrace();
0176: org.objectweb.salome_tmf.api.Api.addException(null, null,
0177: ex);
0178: }
0179:
0180: // On retourne le resultat
0181: return result;
0182: }
0183:
0184: /**
0185: * Selection des logins d'utilisateurs ne faisant pas partie du projet
0186: * @return
0187: */
0188: public Vector getOtherUsersForProject() {
0189: // Resultat de la fonction
0190: Vector result = new Vector();
0191: DataSet stmtRes = null;
0192: String sql = null;
0193: try {
0194: // On recupere la liste de tous les utilisateurs SalomeTMF
0195: sql = "selectAllVTUsersLogin";
0196: PreparedStatement prep = database.prepareStatement(prop
0197: .getProperty("selectAllVTUsersLogin"));
0198: stmtRes = new DataSet(prep.executeQuery());
0199: while (stmtRes.hasMoreElements()) {
0200: result.addElement(stmtRes.getResults().getString(
0201: "login_personne"));
0202: }
0203: sql = "selectAllProjectUsers";
0204: // On enleve les utilisateurs appartenant au projet
0205: prep = database.prepareStatement(prop
0206: .getProperty("selectAllProjectUsers"));
0207: prep.setInt(1, idProject);
0208: stmtRes = new DataSet(prep.executeQuery());
0209: while (stmtRes.hasMoreElements()) {
0210: result.removeElement(stmtRes.getResults().getString(
0211: "login_personne"));
0212: }
0213: } catch (SQLException e) {
0214: e.printStackTrace();
0215: org.objectweb.salome_tmf.api.Api.addException(sql, null, e);
0216: } catch (Exception ex) {
0217: ex.printStackTrace();
0218: org.objectweb.salome_tmf.api.Api.addException(null, null,
0219: ex);
0220: }
0221:
0222: // On retourne le resultat
0223: return result;
0224: }
0225:
0226: /**
0227: * Selection des noms complets (nom+prenom) de tous les utilisateurs d'un projet
0228: * @return
0229: */
0230: public Vector getAllProjectUsersCompleteName() {
0231: Vector result = new Vector();
0232: DataSet stmtRes = null;
0233:
0234: try {
0235: // On execute la requete
0236: PreparedStatement prep = database.prepareStatement(prop
0237: .getProperty("selectAllProjectUsers"));
0238: prep.setInt(1, idProject);
0239: stmtRes = new DataSet(prep.executeQuery());
0240: // Ajoute les element un par un au resultat
0241: while (stmtRes.hasMoreElements()) {
0242: result.addElement(stmtRes.getResults().getString(
0243: "nom_personne")
0244: + " "
0245: + stmtRes.getResults().getString(
0246: "prenom_personne"));
0247: }
0248: } catch (SQLException e) {
0249: e.printStackTrace();
0250: org.objectweb.salome_tmf.api.Api.addException(
0251: "selectAllProjectUsers", null, e);
0252: } catch (Exception ex) {
0253: ex.printStackTrace();
0254: org.objectweb.salome_tmf.api.Api.addException(null, null,
0255: ex);
0256: }
0257:
0258: // On retourne le resultat
0259: return result;
0260: }
0261:
0262: /**
0263: * Selection du mail d'un utilisateur
0264: * @param userLogin
0265: * @return
0266: */
0267: public String getMailsOfUser(String userLogin) {
0268: DataSet stmtRes = null;
0269: String result = null;
0270: try {
0271: PreparedStatement prep = database.prepareStatement(prop
0272: .getProperty("selectUserInfoFromLogin"));
0273: prep.setString(1, userLogin);
0274: stmtRes = new DataSet(prep.executeQuery());
0275: // Ajoute les element un par un au resultat
0276: if (stmtRes.hasMoreElements()) {
0277: result = stmtRes.getResults().getString(
0278: "email_personne");
0279: }
0280:
0281: } catch (SQLException e) {
0282: e.printStackTrace();
0283: org.objectweb.salome_tmf.api.Api.addException(
0284: "selectUserInfoFromLogin", null, e);
0285: } catch (Exception ex) {
0286: ex.printStackTrace();
0287: org.objectweb.salome_tmf.api.Api.addException(null, null,
0288: ex);
0289: }
0290:
0291: // On retourne le resultat
0292: return result;
0293: }
0294:
0295: /**
0296: * Selection des groupes auquels appartient l'utilisateur dont on donne le login
0297: * @param userLogin
0298: * @return
0299: */
0300: public Vector getGroupsForUser(String userLogin) {
0301: Vector result = new Vector();
0302: DataSet stmtRes = null;
0303:
0304: try {
0305: // On execute la requete
0306: PreparedStatement prep = database.prepareStatement(prop
0307: .getProperty("selectGroupsForUser"));
0308: prep.setInt(1, idProject);
0309: prep.setString(2, userLogin);
0310: stmtRes = new DataSet(prep.executeQuery());
0311: // Ajoute les element un par un au resultat
0312: while (stmtRes.hasMoreElements()) {
0313: result.addElement(stmtRes.getResults().getString(
0314: "nom_groupe"));
0315: }
0316: } catch (SQLException e) {
0317: e.printStackTrace();
0318: org.objectweb.salome_tmf.api.Api.addException(
0319: "selectGroupsForUser", null, e);
0320: } catch (Exception ex) {
0321: ex.printStackTrace();
0322: org.objectweb.salome_tmf.api.Api.addException(null, null,
0323: ex);
0324: }
0325:
0326: // On retourne le resultat
0327: return result;
0328: }
0329:
0330: /**
0331: * Selection des groupes auquels N'appartient PAS l'utilisateur dont on donne le login
0332: * @param userLogin
0333: * @return
0334: */
0335: public Vector getOtherGoupsForUser(String userLogin) {
0336: // Resultat de la fonction
0337: Vector result = new Vector();
0338: DataSet stmtRes = null;
0339: String sql = null;
0340: try {
0341: // On recupere la liste de tous les groupes du projet
0342: sql = "selectAllProjectGroupsName";
0343: PreparedStatement prep = database.prepareStatement(prop
0344: .getProperty("selectAllProjectGroupsName"));
0345: prep.setInt(1, idProject);
0346: stmtRes = new DataSet(prep.executeQuery());
0347: while (stmtRes.hasMoreElements()) {
0348: result.addElement(stmtRes.getResults().getString(
0349: "nom_groupe"));
0350: }
0351:
0352: sql = "selectGroupsForUser";
0353: // On enleve les groupes auquels appartient l'utilisateur
0354: prep = database.prepareStatement(prop
0355: .getProperty("selectGroupsForUser"));
0356: prep.setInt(1, idProject);
0357: prep.setString(2, userLogin);
0358: stmtRes = new DataSet(prep.executeQuery());
0359: while (stmtRes.hasMoreElements()) {
0360: result.removeElement(stmtRes.getResults().getString(
0361: "nom_groupe"));
0362: }
0363: } catch (SQLException e) {
0364: e.printStackTrace();
0365: org.objectweb.salome_tmf.api.Api.addException(sql, null, e);
0366: } catch (Exception ex) {
0367: ex.printStackTrace();
0368: org.objectweb.salome_tmf.api.Api.addException(null, null,
0369: ex);
0370: }
0371:
0372: // On retourne le resultat
0373: return result;
0374: }
0375:
0376: /**
0377: * Selection des logins des utilisateurs d'un groupe
0378: * @param groupName
0379: * @return
0380: */
0381: public Vector getGroupUsers(String groupName) {
0382: Vector result = new Vector();
0383: DataSet stmtRes = null;
0384:
0385: try {
0386: //On execute la requete
0387: PreparedStatement prep = database.prepareStatement(prop
0388: .getProperty("selectGroupUsers"));
0389: prep.setInt(1, idProject);
0390: prep.setString(2, groupName);
0391: stmtRes = new DataSet(prep.executeQuery());
0392: // Ajoute les element un par un au resultat
0393: while (stmtRes.hasMoreElements()) {
0394: result.addElement(stmtRes.getResults().getString(
0395: "login_personne"));
0396: }
0397: } catch (SQLException e) {
0398: e.printStackTrace();
0399: org.objectweb.salome_tmf.api.Api.addException(
0400: "selectGroupUsers", null, e);
0401: } catch (Exception ex) {
0402: ex.printStackTrace();
0403: org.objectweb.salome_tmf.api.Api.addException(null, null,
0404: ex);
0405: }
0406:
0407: // On retourne le resultat
0408: return result;
0409: }
0410:
0411: /**
0412: * Selection des noms des utilisateurs d'un groupe
0413: * @param groupName
0414: * @return
0415: */
0416: public Vector getGroupLastNameUsers(String groupName) {
0417: Vector result = new Vector();
0418: DataSet stmtRes = null;
0419:
0420: try {
0421: //On execute la requete
0422: PreparedStatement prep = database.prepareStatement(prop
0423: .getProperty("selectGroupLastNameUsers"));
0424: prep.setInt(1, idProject);
0425: prep.setString(2, groupName);
0426: stmtRes = new DataSet(prep.executeQuery());
0427: // Ajoute les element un par un au resultat
0428: while (stmtRes.hasMoreElements()) {
0429: result.addElement(stmtRes.getResults().getString(
0430: "nom_personne"));
0431: }
0432: } catch (SQLException e) {
0433: e.printStackTrace();
0434: org.objectweb.salome_tmf.api.Api.addException(
0435: "selectGroupLastNameUsers", null, e);
0436: } catch (Exception ex) {
0437: ex.printStackTrace();
0438: org.objectweb.salome_tmf.api.Api.addException(null, null,
0439: ex);
0440: }
0441:
0442: // On retourne le resultat
0443: return result;
0444: }
0445:
0446: /**
0447: * Selection des prenoms des utilisateurs d'un groupe
0448: * @param groupName
0449: * @return
0450: */
0451: public Vector getGroupFirstNameUsers(String groupName) {
0452: Vector result = new Vector();
0453: DataSet stmtRes = null;
0454:
0455: try {
0456: //On execute la requete
0457: PreparedStatement prep = database.prepareStatement(prop
0458: .getProperty("selectGroupFirstNameUsers"));
0459: prep.setInt(1, idProject);
0460: prep.setString(2, groupName);
0461: stmtRes = new DataSet(prep.executeQuery());
0462: // Ajoute les element un par un au resultat
0463: while (stmtRes.hasMoreElements()) {
0464: result.addElement(stmtRes.getResults().getString(
0465: "prenom_personne"));
0466: }
0467: } catch (SQLException e) {
0468: e.printStackTrace();
0469: org.objectweb.salome_tmf.api.Api.addException(
0470: "selectGroupFirstNameUsers", null, e);
0471: } catch (Exception ex) {
0472: ex.printStackTrace();
0473: org.objectweb.salome_tmf.api.Api.addException(null, null,
0474: ex);
0475: }
0476:
0477: // On retourne le resultat
0478: return result;
0479: }
0480:
0481: /**
0482: * Selection des descriptions des utilisateurs d'un groupe
0483: * @param groupName
0484: * @return
0485: */
0486: public Vector getGroupDescUsers(String groupName) {
0487: Vector result = new Vector();
0488: DataSet stmtRes = null;
0489:
0490: try {
0491: //On execute la requete
0492: PreparedStatement prep = database.prepareStatement(prop
0493: .getProperty("selectGroupDescUsers"));
0494: prep.setInt(1, idProject);
0495: prep.setString(2, groupName);
0496: stmtRes = new DataSet(prep.executeQuery());
0497: // Ajoute les element un par un au resultat
0498: while (stmtRes.hasMoreElements()) {
0499: result.addElement(stmtRes.getResults().getString(
0500: "desc_personne"));
0501: }
0502: } catch (SQLException e) {
0503: e.printStackTrace();
0504: org.objectweb.salome_tmf.api.Api.addException(
0505: "selectGroupDescUsers", null, e);
0506: } catch (Exception ex) {
0507: ex.printStackTrace();
0508: org.objectweb.salome_tmf.api.Api.addException(null, null,
0509: ex);
0510: }
0511:
0512: // On retourne le resultat
0513: return result;
0514: }
0515:
0516: /**
0517: * Selection des emails des utilisateurs d'un groupe
0518: * @param groupName
0519: * @return
0520: */
0521: public Vector getGroupEmailUsers(String groupName) {
0522: Vector result = new Vector();
0523: DataSet stmtRes = null;
0524:
0525: try {
0526: //On execute la requete
0527: PreparedStatement prep = database.prepareStatement(prop
0528: .getProperty("selectGroupEmailUsers"));
0529: prep.setInt(1, idProject);
0530: prep.setString(2, groupName);
0531: stmtRes = new DataSet(prep.executeQuery());
0532: // Ajoute les element un par un au resultat
0533: while (stmtRes.hasMoreElements()) {
0534: result.addElement(stmtRes.getResults().getString(
0535: "email_personne"));
0536: }
0537: } catch (SQLException e) {
0538: e.printStackTrace();
0539: org.objectweb.salome_tmf.api.Api.addException(
0540: "selectGroupEmailUsers", null, e);
0541: } catch (Exception ex) {
0542: ex.printStackTrace();
0543: org.objectweb.salome_tmf.api.Api.addException(null, null,
0544: ex);
0545: }
0546:
0547: // On retourne le resultat
0548: return result;
0549: }
0550:
0551: /**
0552: * Selection des numeros de telephone des utilisateurs d'un groupe
0553: * @param groupName
0554: * @return
0555: */
0556: public Vector getGroupTelUsers(String groupName) {
0557: Vector result = new Vector();
0558: DataSet stmtRes = null;
0559:
0560: try {
0561: //On execute la requete
0562: PreparedStatement prep = database.prepareStatement(prop
0563: .getProperty("selectGroupTelUsers"));
0564: prep.setInt(1, idProject);
0565: prep.setString(2, groupName);
0566: stmtRes = new DataSet(prep.executeQuery());
0567: // Ajoute les element un par un au resultat
0568: while (stmtRes.hasMoreElements()) {
0569: result.addElement(stmtRes.getResults().getString(
0570: "tel_personne"));
0571: }
0572: } catch (SQLException e) {
0573: e.printStackTrace();
0574: org.objectweb.salome_tmf.api.Api.addException(
0575: "selectGroupTelUsers", null, e);
0576: } catch (Exception ex) {
0577: ex.printStackTrace();
0578: org.objectweb.salome_tmf.api.Api.addException(null, null,
0579: ex);
0580: }
0581:
0582: // On retourne le resultat
0583: return result;
0584: }
0585:
0586: /**
0587: * Selection des dates de creation des utilisateurs d'un groupe
0588: * @param groupName
0589: * @return
0590: */
0591: public Vector getGroupDateUsers(String groupName) {
0592: Vector result = new Vector();
0593: DataSet stmtRes = null;
0594:
0595: try {
0596: //On execute la requete
0597: PreparedStatement prep = database.prepareStatement(prop
0598: .getProperty("selectGroupDateUsers"));
0599: prep.setInt(1, idProject);
0600: prep.setString(2, groupName);
0601: stmtRes = new DataSet(prep.executeQuery());
0602: // Ajoute les element un par un au resultat
0603: while (stmtRes.hasMoreElements()) {
0604: result.addElement(stmtRes.getResults().getString(
0605: "date_creation_personne"));
0606: }
0607: } catch (SQLException e) {
0608: e.printStackTrace();
0609: org.objectweb.salome_tmf.api.Api.addException(
0610: "selectGroupDateUsers", null, e);
0611: } catch (Exception ex) {
0612: ex.printStackTrace();
0613: org.objectweb.salome_tmf.api.Api.addException(null, null,
0614: ex);
0615: }
0616:
0617: // On retourne le resultat
0618: return result;
0619: }
0620:
0621: /**
0622: * Selection des logins des utilisateurs N'appartenant PAS au groupe
0623: * @param groupName
0624: * @return
0625: */
0626: public Vector getUsersOfOtherGroups(String groupName) {
0627: // Resultat de la fonction
0628: Vector result = new Vector();
0629: DataSet stmtRes = null;
0630: String sql = null;
0631: try {
0632: sql = "selectAllProjectUsers";
0633: // On recupere la liste des logins de tous les utilisateurs du projet
0634: PreparedStatement prep = database.prepareStatement(prop
0635: .getProperty("selectAllProjectUsers"));
0636: prep.setInt(1, idProject);
0637: stmtRes = new DataSet(prep.executeQuery());
0638: while (stmtRes.hasMoreElements()) {
0639: result.addElement(stmtRes.getResults().getString(
0640: "login_personne"));
0641: }
0642:
0643: sql = "selectGroupUsers";
0644: // On enleve les utilisateurs qui appartiennent au groupe
0645: prep = database.prepareStatement(prop
0646: .getProperty("selectGroupUsers"));
0647: prep.setInt(1, idProject);
0648: prep.setString(2, groupName);
0649: stmtRes = new DataSet(prep.executeQuery());
0650: while (stmtRes.hasMoreElements()) {
0651: result.removeElement(stmtRes.getResults().getString(
0652: "login_personne"));
0653: }
0654: } catch (SQLException e) {
0655: e.printStackTrace();
0656: org.objectweb.salome_tmf.api.Api.addException(sql, null, e);
0657: } catch (Exception ex) {
0658: ex.printStackTrace();
0659: org.objectweb.salome_tmf.api.Api.addException(null, null,
0660: ex);
0661: }
0662:
0663: // On retourne le resultat
0664: return result;
0665: }
0666:
0667: /**
0668: *
0669: * @param login
0670: * @param pwd
0671: * @return
0672: */
0673: public boolean isUserOfThisProject(String login, String pwd) {
0674: boolean result = false;
0675: DataSet stmtRes = null;
0676:
0677: try {
0678: // On execute la requete
0679: //PreparedStatement prep = database.prepareStatement(prop.getProperty("selectProjectUsersAndPwd"));
0680: PreparedStatement prep = database.prepareStatement(prop
0681: .getProperty("selectUserPwdProject"));
0682: prep.setInt(1, idProject);
0683: prep.setString(2, login);
0684: stmtRes = new DataSet(prep.executeQuery());
0685: /*while (stmtRes.hasMoreElements() && !result) {
0686: result = (stmtRes.getResults().getString("mot_de_passe").equals(pwd) && stmtRes.getResults().getString("login_personne").equals(login));
0687: }*/
0688: if (stmtRes.hasMoreElements()) {
0689: String pwd2 = stmtRes.getResults().getString(
0690: "mot_de_passe");
0691: result = org.objectweb.salome_tmf.api.MD5paswd
0692: .testPassword(pwd, pwd2);
0693: } else {
0694: return false;
0695: }
0696:
0697: } catch (SQLException e) {
0698: e.printStackTrace();
0699: org.objectweb.salome_tmf.api.Api.addException(
0700: "selectProjectUsersAndPwd", null, e);
0701: return false;
0702: } catch (Exception ex) {
0703: ex.printStackTrace();
0704: org.objectweb.salome_tmf.api.Api.addException(null, null,
0705: ex);
0706: return false;
0707: }
0708:
0709: return result;
0710: } // Fin de la methode isUserOfThisProject/2
0711:
0712: /**
0713: * Selection des permissions d'un groupe
0714: * @param groupName
0715: * @return
0716: */
0717: public int getPermissionOfGroups(String groupName) {
0718: try {
0719: DataSet stmtRes = null;
0720: int res = -1;
0721: PreparedStatement prep = database.prepareStatement(prop
0722: .getProperty("selectAllowGroup"));
0723: prep.setInt(1, idProject);
0724: prep.setString(2, groupName);
0725: stmtRes = new DataSet(prep.executeQuery());
0726: if (stmtRes.hasMoreElements()) {
0727: res = stmtRes.getResults().getInt("permission");
0728: }
0729: return res;
0730:
0731: } catch (SQLException e) {
0732: e.printStackTrace();
0733: org.objectweb.salome_tmf.api.Api.addException(
0734: "selectAllowGroup", null, e);
0735: return -1;
0736: } catch (Exception ex) {
0737: ex.printStackTrace();
0738: org.objectweb.salome_tmf.api.Api.addException(null, null,
0739: ex);
0740: return -1;
0741: }
0742:
0743: }
0744:
0745: /**
0746: * Selection des permissions d'un utilisateur
0747: * @param groupName
0748: * @return
0749: */
0750: public int getPermissionOfUser(String userLogin) {
0751: try {
0752: Vector groupe_List = getGroupsForUser(userLogin);
0753: int res = -1;
0754: if (!(groupe_List.isEmpty())) {
0755: res = 0;
0756: for (int i = 0; i < groupe_List.size(); i++) {
0757: res |= getPermissionOfGroups((String) groupe_List
0758: .elementAt(i));
0759: }
0760: }
0761: return res;
0762:
0763: } catch (Exception ex) {
0764: ex.printStackTrace();
0765: org.objectweb.salome_tmf.api.Api.addException(null, null,
0766: ex);
0767: return -1;
0768: }
0769:
0770: }
0771:
0772: /**
0773: * Selection de la description du role d'un user dans un groupe
0774: * @param groupName
0775: * @return
0776: */
0777: public String getUserDescInGroupe(String userLogin, String groupName) {
0778: String res = "";
0779: try {
0780:
0781: DataSet stmtRes = null;
0782: // On execute la requete
0783: PreparedStatement prep = database.prepareStatement(prop
0784: .getProperty("selectUserDescInGroupe"));
0785: prep.setInt(1, idProject);
0786: prep.setString(2, groupName);
0787: prep.setString(3, userLogin);
0788: stmtRes = new DataSet(prep.executeQuery());
0789: if (stmtRes.hasMoreElements()) {
0790: res = stmtRes.getResults().getString("description");
0791: }
0792: } catch (SQLException e) {
0793: e.printStackTrace();
0794: org.objectweb.salome_tmf.api.Api.addException(
0795: "selectUserDescInGroupe", null, e);
0796: } catch (Exception ex) {
0797: ex.printStackTrace();
0798: org.objectweb.salome_tmf.api.Api.addException(null, null,
0799: ex);
0800: }
0801:
0802: // On retourne le resultat
0803: return res;
0804: }
0805:
0806: /**** TO REMOVE *******/
0807:
0808: /**
0809: * Selection des noms des parametres lies a un projet
0810: * @return
0811: */
0812: public Vector getProjectParamsName() {
0813: // Resultat de la fonction
0814: Vector result = new Vector();
0815: DataSet stmtRes = null;
0816:
0817: try {
0818: // On appelle la requete a executer
0819: PreparedStatement prep = database.prepareStatement(prop
0820: .getProperty("selectProjectParams"));
0821: prep.setInt(1, idProject);
0822: stmtRes = new DataSet(prep.executeQuery());
0823: while (stmtRes.hasMoreElements()) {
0824: result.addElement(stmtRes.getResults().getString(
0825: "nom_param_test"));
0826: }
0827: } catch (SQLException e) {
0828: e.printStackTrace();
0829: org.objectweb.salome_tmf.api.Api.addException(
0830: "selectProjectParams", null, e);
0831: } catch (Exception ex) {
0832: ex.printStackTrace();
0833: org.objectweb.salome_tmf.api.Api.addException(null, null,
0834: ex);
0835: }
0836:
0837: // On retourne le resultat
0838: return result;
0839: }
0840:
0841: /**
0842: * Selection des descriptions des parametres lies a un projet
0843: * @return
0844: */
0845: public Vector getProjectParamsDesc() {
0846: // Resultat de la fonction
0847: Vector result = new Vector();
0848: DataSet stmtRes = null;
0849:
0850: try {
0851: // On appelle la requete a executer
0852: PreparedStatement prep = database.prepareStatement(prop
0853: .getProperty("selectProjectParams"));
0854: prep.setInt(1, idProject);
0855: stmtRes = new DataSet(prep.executeQuery());
0856: while (stmtRes.hasMoreElements()) {
0857: result.addElement(stmtRes.getResults().getString(
0858: "desc_param_test"));
0859: }
0860: } catch (SQLException e) {
0861: e.printStackTrace();
0862: org.objectweb.salome_tmf.api.Api.addException(
0863: "selectProjectParams", null, e);
0864: } catch (Exception ex) {
0865: ex.printStackTrace();
0866: org.objectweb.salome_tmf.api.Api.addException(null, null,
0867: ex);
0868: }
0869:
0870: // On retourne le resultat
0871: return result;
0872: }
0873:
0874: /**
0875: * Selection des noms des parametres valorises dans un environnement
0876: * @param envName
0877: * @return
0878: */
0879: public Vector getEnvParamsName(String envName) {
0880: Vector result = new Vector();
0881: DataSet stmtRes = null;
0882:
0883: try {
0884: // On execute la requete
0885: PreparedStatement prep = database.prepareStatement(prop
0886: .getProperty("selectEnvParams"));
0887: prep.setInt(1, idProject);
0888: prep.setString(2, envName);
0889: stmtRes = new DataSet(prep.executeQuery());
0890: // Ajoute les element un par un au resultat
0891: while (stmtRes.hasMoreElements()) {
0892: result.addElement(stmtRes.getResults().getString(
0893: "nom_param_test"));
0894: }
0895: } catch (SQLException e) {
0896: e.printStackTrace();
0897: org.objectweb.salome_tmf.api.Api.addException(
0898: "selectEnvParams", null, e);
0899: } catch (Exception ex) {
0900: ex.printStackTrace();
0901: org.objectweb.salome_tmf.api.Api.addException(null, null,
0902: ex);
0903: }
0904:
0905: // On retourne le resultat
0906: return result;
0907: }
0908:
0909: /**
0910: * Selection des valeurs des parametres valorises dans un environnement
0911: * @param envName
0912: * @return
0913: */
0914: public Vector getEnvParamsValue(String envName) {
0915: Vector result = new Vector();
0916: DataSet stmtRes = null;
0917:
0918: try {
0919: // On execute la requete
0920: PreparedStatement prep = database.prepareStatement(prop
0921: .getProperty("selectEnvParams"));
0922: prep.setInt(1, idProject);
0923: prep.setString(2, envName);
0924: stmtRes = new DataSet(prep.executeQuery());
0925: // Ajoute les element un par un au resultat
0926: while (stmtRes.hasMoreElements()) {
0927: result.addElement(stmtRes.getResults().getString(
0928: "valeur"));
0929: }
0930: } catch (SQLException e) {
0931: e.printStackTrace();
0932: org.objectweb.salome_tmf.api.Api.addException(
0933: "selectEnvParams", null, e);
0934: } catch (Exception ex) {
0935: ex.printStackTrace();
0936: org.objectweb.salome_tmf.api.Api.addException(null, null,
0937: ex);
0938: }
0939:
0940: // On retourne le resultat
0941: return result;
0942: }
0943:
0944: /**
0945: * Selection des id des parametres valorises dans un environnement
0946: * @param envName
0947: * @return
0948: */
0949: public Vector getEnvParamsId(String envName) {
0950: Vector result = new Vector();
0951: DataSet stmtRes = null;
0952:
0953: try {
0954: // On execute la requete
0955: PreparedStatement prep = database.prepareStatement(prop
0956: .getProperty("selectEnvParams"));
0957: prep.setInt(1, idProject);
0958: prep.setString(2, envName);
0959: stmtRes = new DataSet(prep.executeQuery());
0960: // Ajoute les element un par un au resultat
0961: while (stmtRes.hasMoreElements()) {
0962: result.addElement(stmtRes.getResults().getString(
0963: "id_param_test"));
0964: }
0965: } catch (SQLException e) {
0966: e.printStackTrace();
0967: org.objectweb.salome_tmf.api.Api.addException(
0968: "selectEnvParams", null, e);
0969: } catch (Exception ex) {
0970: ex.printStackTrace();
0971: org.objectweb.salome_tmf.api.Api.addException(null, null,
0972: ex);
0973: }
0974:
0975: // On retourne le resultat
0976: return result;
0977: }
0978:
0979: /**
0980: * Selection des descriptions des parametres valorises dans un environnement
0981: * @param envName
0982: * @return
0983: */
0984: public Vector getEnvParamsDesc(String envName) {
0985: Vector result = new Vector();
0986: DataSet stmtRes = null;
0987:
0988: try {
0989: // On execute la requete
0990: PreparedStatement prep = database.prepareStatement(prop
0991: .getProperty("selectEnvParams"));
0992: prep.setInt(1, idProject);
0993: prep.setString(2, envName);
0994: stmtRes = new DataSet(prep.executeQuery());
0995: // Ajoute les element un par un au resultat
0996: while (stmtRes.hasMoreElements()) {
0997: result.addElement(stmtRes.getResults().getString(
0998: "desc_param_test"));
0999: }
1000: } catch (SQLException e) {
1001: e.printStackTrace();
1002: org.objectweb.salome_tmf.api.Api.addException(
1003: "selectEnvParams", null, e);
1004: } catch (Exception ex) {
1005: ex.printStackTrace();
1006: org.objectweb.salome_tmf.api.Api.addException(null, null,
1007: ex);
1008: }
1009:
1010: // On retourne le resultat
1011: return result;
1012: }
1013:
1014: /**
1015: * Selection des noms des environnements appartenant e un projet
1016: * @return
1017: */
1018: public Vector getProjectEnvsName() {
1019: Vector result = new Vector();
1020: DataSet stmtRes = null;
1021:
1022: try {
1023: // On execute la requete
1024: PreparedStatement prep = database.prepareStatement(prop
1025: .getProperty("selectProjectEnvs"));
1026: prep.setInt(1, idProject);
1027: stmtRes = new DataSet(prep.executeQuery());
1028: // Ajoute les element un par un au resultat
1029: while (stmtRes.hasMoreElements()) {
1030: result.addElement(stmtRes.getResults().getString(
1031: "nom_env"));
1032: }
1033: } catch (SQLException e) {
1034: e.printStackTrace();
1035: org.objectweb.salome_tmf.api.Api.addException(
1036: "selectProjectEnvs", null, e);
1037: } catch (Exception ex) {
1038: ex.printStackTrace();
1039: org.objectweb.salome_tmf.api.Api.addException(null, null,
1040: ex);
1041: }
1042:
1043: // On retourne le resultat
1044: return result;
1045: }
1046:
1047: /**
1048: * Selection des descriptions des environnements appartenant e un projet
1049: * @return
1050: */
1051: public Vector getProjectEnvsDesc() {
1052: Vector result = new Vector();
1053: DataSet stmtRes = null;
1054:
1055: try {
1056: // On execute la requete
1057: PreparedStatement prep = database.prepareStatement(prop
1058: .getProperty("selectProjectEnvs"));
1059: prep.setInt(1, idProject);
1060: stmtRes = new DataSet(prep.executeQuery());
1061: // Ajoute les element un par un au resultat
1062: while (stmtRes.hasMoreElements()) {
1063: result.addElement(stmtRes.getResults().getString(
1064: "description_env"));
1065: }
1066: } catch (SQLException e) {
1067: e.printStackTrace();
1068: org.objectweb.salome_tmf.api.Api.addException(
1069: "selectProjectEnvs", null, e);
1070: } catch (Exception ex) {
1071: ex.printStackTrace();
1072: org.objectweb.salome_tmf.api.Api.addException(null, null,
1073: ex);
1074: }
1075:
1076: // On retourne le resultat
1077: return result;
1078: }
1079:
1080: /**
1081: * Donne la valeur associee e un parametre dans un environnement
1082: * @param envName
1083: * @param paramName
1084: * @return
1085: */
1086: public String getParamValueInEnv(String envName, String paramName) {
1087: String result = null;
1088: DataSet stmtRes = null;
1089:
1090: try {
1091: // On execute la requete
1092: PreparedStatement prep = database.prepareStatement(prop
1093: .getProperty("selectParamValueInEnv"));
1094: prep.setInt(1, idProject);
1095: prep.setString(2, envName);
1096: prep.setString(3, paramName);
1097: stmtRes = new DataSet(prep.executeQuery());
1098: if (stmtRes.getResults().next()) {
1099: result = stmtRes.getResults().getString("valeur");
1100: }
1101: } catch (SQLException e) {
1102: e.printStackTrace();
1103: org.objectweb.salome_tmf.api.Api.addException(
1104: "selectParamValueInEnv", null, e);
1105: } catch (Exception ex) {
1106: ex.printStackTrace();
1107: org.objectweb.salome_tmf.api.Api.addException(null, null,
1108: ex);
1109: }
1110:
1111: // On retourne le resultat
1112: return result;
1113: }
1114:
1115: /**
1116: * Retourne la description d'un groupe
1117: * @param groupName le nom d'un groupe
1118: */
1119: public String getGroupDescription(String groupName) {
1120: String result = null;
1121: DataSet stmtRes = null;
1122:
1123: try {
1124: // On execute la requete
1125: PreparedStatement prep = database.prepareStatement(prop
1126: .getProperty("selectGroupDescription"));
1127: prep.setInt(1, idProject);
1128: prep.setString(2, groupName);
1129: stmtRes = new DataSet(prep.executeQuery());
1130: if (stmtRes.getResults().next()) {
1131: result = stmtRes.getResults().getString("desc_groupe");
1132: }
1133: } catch (SQLException e) {
1134: e.printStackTrace();
1135: org.objectweb.salome_tmf.api.Api.addException(
1136: "selectGroupDescription", null, e);
1137: } catch (Exception ex) {
1138: ex.printStackTrace();
1139: org.objectweb.salome_tmf.api.Api.addException(null, null,
1140: ex);
1141: }
1142:
1143: // On retourne le resultat
1144: return result;
1145:
1146: }
1147:
1148: public Vector getProjectEnvs() {
1149: Vector result = new Vector();
1150: DataSet stmtRes = null;
1151: try {
1152: // On execute la requete
1153: PreparedStatement prep = database.prepareStatement(prop
1154: .getProperty("selectProjectEnvs"));
1155: prep.setInt(1, idProject);
1156: stmtRes = new DataSet(prep.executeQuery());
1157: // Ajoute les element un par un au resultat
1158: while (stmtRes.hasMoreElements()) {
1159: /*Environment env = new Environment();
1160: env.setIdBdd(stmtRes.getResults().getInt("id_env"));
1161: env.setName(stmtRes.getResults().getString("nom_env"));
1162: env.setDescription(stmtRes.getResults().getString("description_env"));
1163: result.addElement(env);*/
1164: EnvironmentWrapper env = new EnvironmentWrapper();
1165: env.setIdBDD(stmtRes.getResults().getInt("id_env"));
1166: env.setName(stmtRes.getResults().getString("nom_env"));
1167: env.setDescription(stmtRes.getResults().getString(
1168: "description_env"));
1169: result.addElement(env);
1170: //result.addElement(stmtRes.getResults().getString("nom_env"));
1171: }
1172: } catch (SQLException e) {
1173: e.printStackTrace();
1174: org.objectweb.salome_tmf.api.Api.addException(
1175: "selectProjectEnvs", null, e);
1176: } catch (Exception ex) {
1177: ex.printStackTrace();
1178: org.objectweb.salome_tmf.api.Api.addException(null, null,
1179: ex);
1180: }
1181:
1182: // On retourne le resultat
1183: return result;
1184: }
1185:
1186: public Vector getProjectParams() {
1187: // Resultat de la fonction
1188: Vector result = new Vector();
1189: DataSet stmtRes = null;
1190:
1191: try {
1192: // On appelle la requete a executer
1193: PreparedStatement prep = database.prepareStatement(prop
1194: .getProperty("selectProjectParams"));
1195: prep.setInt(1, idProject);
1196: stmtRes = new DataSet(prep.executeQuery());
1197: while (stmtRes.hasMoreElements()) {
1198: /*Parameter pParameter = new Parameter();
1199: pParameter.setName(stmtRes.getResults().getString("nom_param_test"));
1200: pParameter.setDescription(stmtRes.getResults().getString("desc_param_test"));
1201: pParameter.setIdBdd(stmtRes.getResults().getInt("id_param_test")); */
1202: ParameterWrapper pParameter = new ParameterWrapper();
1203: pParameter.setName(stmtRes.getResults().getString(
1204: "nom_param_test"));
1205: pParameter.setDescription(stmtRes.getResults()
1206: .getString("desc_param_test"));
1207: pParameter.setIdBDD(stmtRes.getResults().getInt(
1208: "id_param_test"));
1209: result.addElement(pParameter);
1210: //result.addElement(stmtRes.getResults().getString("desc_param_test"));
1211: }
1212: } catch (SQLException e) {
1213: e.printStackTrace();
1214: org.objectweb.salome_tmf.api.Api.addException(
1215: "selectProjectParams", null, e);
1216: } catch (Exception ex) {
1217: ex.printStackTrace();
1218: org.objectweb.salome_tmf.api.Api.addException(null, null,
1219: ex);
1220: }
1221:
1222: // On retourne le resultat
1223: return result;
1224: }
1225:
1226: }
|