Source Code Cross Referenced for SQLProject.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » databaseSQL » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Test Coverage » salome tmf » org.objectweb.salome_tmf.databaseSQL 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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 Marche Mikael
0020:         *
0021:         * Contact: mikael.marche@rd.francetelecom.com
0022:         */
0023:
0024:        package org.objectweb.salome_tmf.databaseSQL;
0025:
0026:        import java.net.URL;
0027:        import java.sql.Date;
0028:        import java.sql.PreparedStatement;
0029:        import java.sql.ResultSet;
0030:        import java.util.Hashtable;
0031:        import java.util.Vector;
0032:
0033:        import org.objectweb.salome_tmf.api.Api;
0034:        import org.objectweb.salome_tmf.api.ApiConstants;
0035:        import org.objectweb.salome_tmf.api.Permission;
0036:        import org.objectweb.salome_tmf.api.Util;
0037:        import org.objectweb.salome_tmf.api.data.ActionWrapper;
0038:        import org.objectweb.salome_tmf.api.data.AttachementWrapper;
0039:        import org.objectweb.salome_tmf.api.data.AutomaticTestWrapper;
0040:        import org.objectweb.salome_tmf.api.data.CampaignWrapper;
0041:        import org.objectweb.salome_tmf.api.data.EnvironmentWrapper;
0042:        import org.objectweb.salome_tmf.api.data.FamilyWrapper;
0043:        import org.objectweb.salome_tmf.api.data.FileAttachementWrapper;
0044:        import org.objectweb.salome_tmf.api.data.GroupWrapper;
0045:        import org.objectweb.salome_tmf.api.data.ManualTestWrapper;
0046:        import org.objectweb.salome_tmf.api.data.ParameterWrapper;
0047:        import org.objectweb.salome_tmf.api.data.ProjectWrapper;
0048:        import org.objectweb.salome_tmf.api.data.SalomeFileWrapper;
0049:        import org.objectweb.salome_tmf.api.data.ScriptWrapper;
0050:        import org.objectweb.salome_tmf.api.data.SuiteWrapper;
0051:        import org.objectweb.salome_tmf.api.data.TestCampWrapper;
0052:        import org.objectweb.salome_tmf.api.data.TestWrapper;
0053:        import org.objectweb.salome_tmf.api.data.UrlAttachementWrapper;
0054:        import org.objectweb.salome_tmf.api.data.UserWrapper;
0055:        import org.objectweb.salome_tmf.api.sql.ISQLProject;
0056:
0057:        public class SQLProject implements  ISQLProject {
0058:
0059:            /**
0060:             * Insert a project in the DB and create default group and permission for the project
0061:             * @param name
0062:             * @param description
0063:             * @return
0064:             * @throws Exception
0065:             */
0066:            public int insert(String name, String description, int idAdmin)
0067:                    throws Exception {
0068:                int id = -1;
0069:                int transNumber = -1;
0070:                if (idAdmin < 1) {
0071:                    throw new Exception("[SQLProject->insert] user have no id");
0072:                }
0073:                try {
0074:                    Date dateActuelle = Util.getCurrentDate();
0075:
0076:                    transNumber = SQLEngine.beginTransaction(0,
0077:                            ApiConstants.INSERT_PROJECT);
0078:                    Util.log("[SQLProject] add project " + name
0079:                            + ", admin id : " + idAdmin);
0080:                    PreparedStatement prep = SQLEngine
0081:                            .getSQLAddQuery("addProject"); //ok
0082:                    prep.setString(1, name);
0083:                    prep.setDate(2, dateActuelle);
0084:                    prep.setString(3, description);
0085:                    SQLEngine.runAddQuery(prep);
0086:
0087:                    ProjectWrapper pProject = getProject(name);
0088:                    id = pProject.getIdBDD();
0089:
0090:                    int perm = 0;
0091:                    SQLObjectFactory.getInstanceOfISQLGroup().insert(id,
0092:                            ApiConstants.GUESTNAME, ApiConstants.GUESTDESC,
0093:                            perm);
0094:
0095:                    perm |= Permission.ALLOW_CREATE_TEST;
0096:                    perm |= Permission.ALLOW_CREATE_CAMP;
0097:                    perm |= Permission.ALLOW_UPDATE_CAMP;
0098:                    perm |= Permission.ALLOW_UPDATE_TEST;
0099:                    perm |= Permission.ALLOW_EXECUT_CAMP;
0100:
0101:                    SQLObjectFactory.getInstanceOfISQLGroup().insert(id,
0102:                            ApiConstants.DEVNAME, ApiConstants.DEVDESC, perm);
0103:
0104:                    perm |= Permission.ALLOW_DELETE_CAMP;
0105:                    perm |= Permission.ALLOW_DELETE_TEST;
0106:                    int idGrpAdm = SQLObjectFactory.getInstanceOfISQLGroup()
0107:                            .insert(id, ApiConstants.ADMINNAME,
0108:                                    ApiConstants.ADMINDESC, perm);
0109:
0110:                    SQLObjectFactory.getInstanceOfISQLGroup().insertUser(
0111:                            idGrpAdm, idAdmin);
0112:
0113:                    SQLEngine.commitTrans(transNumber);
0114:                } catch (Exception e) {
0115:                    Util.log("[SQLProject->insert]" + e);
0116:                    if (Api.isDEBUG()) {
0117:                        e.printStackTrace();
0118:                    }
0119:                    SQLEngine.rollBackTrans(transNumber);
0120:                    throw e;
0121:                }
0122:                return id;
0123:            }
0124:
0125:            /**
0126:             * Create a project by copy information with an other project idFromProject
0127:             * @param name
0128:             * @param description : the description of the new project
0129:             * @param idAdmin : the administator of the  new project
0130:             * @param idFromProject : the project  where find the informations to create the new project
0131:             * @param suite : true for copy tests information
0132:             * @param campagne : true for copy campaigns information
0133:             * @param users : true for copy users information
0134:             * @param groupe : true for copy groups information
0135:             * @return
0136:             * @throws Exception
0137:             */
0138:            public int copyProject(String name, String description,
0139:                    int idAdmin, int idFromProject, boolean suite,
0140:                    boolean campagne, boolean users, boolean groupe)
0141:                    throws Exception {
0142:                int project_id_new = -1;
0143:                int transNumber = -1;
0144:                if (idAdmin < 1) {
0145:                    throw new Exception(
0146:                            "[SQLProject->copyProject] user have no id");
0147:                }
0148:                if (idFromProject < 1) {
0149:                    throw new Exception(
0150:                            "[SQLProject->copyProject] from project have no id");
0151:                }
0152:                try {
0153:                    Hashtable mapGroupe = new Hashtable();
0154:                    Hashtable mapFamille = new Hashtable();
0155:                    Hashtable mapSuite = new Hashtable();
0156:                    Hashtable mapCas = new Hashtable();
0157:                    Hashtable mapAction = new Hashtable();
0158:                    Hashtable mapParam = new Hashtable();
0159:                    //Hashtable mapCampagne = new Hashtable();
0160:
0161:                    project_id_new = insert(name, description, idAdmin);
0162:                    GroupWrapper[] projectGroups;
0163:                    projectGroups = SQLObjectFactory.getInstanceOfISQLGroup()
0164:                            .getGroupWrapperInProject(idFromProject);
0165:                    if (groupe) {
0166:                        for (int i = 0; i < projectGroups.length; i++) {
0167:                            GroupWrapper pGroupWrapper = projectGroups[i];
0168:                            int id_g = pGroupWrapper.getIdBDD();
0169:                            String nom = pGroupWrapper.getName();
0170:                            String des = pGroupWrapper.getDescription();
0171:                            int perm = pGroupWrapper.getPermission();
0172:                            if (!(nom.equals(ApiConstants.ADMINNAME))
0173:                                    && !(nom.equals(ApiConstants.DEVNAME))
0174:                                    && !(nom.equals(ApiConstants.GUESTNAME))) {
0175:                                int id_new_g = SQLObjectFactory
0176:                                        .getInstanceOfISQLGroup().insert(
0177:                                                project_id_new, nom, des, perm);
0178:                                mapGroupe.put(new Integer(id_g), new Integer(
0179:                                        id_new_g));
0180:                            }
0181:                        }
0182:                    }
0183:
0184:                    if (users) {
0185:                        for (int i = 0; i < projectGroups.length; i++) {
0186:                            GroupWrapper pGroupWrapper = projectGroups[i];
0187:                            int idGroupe = pGroupWrapper.getIdBDD();
0188:                            UserWrapper[] projectUsersGroup = SQLObjectFactory
0189:                                    .getInstanceOfISQLGroup()
0190:                                    .getUserWrappersInGroup(idGroupe);
0191:                            for (int j = 0; j < projectUsersGroup.length; j++) {
0192:                                UserWrapper pUserWrapper = (UserWrapper) projectUsersGroup[j];
0193:                                int idUser = pUserWrapper.getIdBDD();
0194:                                if (idAdmin != idUser) {
0195:                                    if (groupe) {
0196:                                        idGroupe = ((Integer) mapGroupe
0197:                                                .get(new Integer(idGroupe)))
0198:                                                .intValue();
0199:                                    } else {
0200:                                        idGroupe = SQLObjectFactory
0201:                                                .getInstanceOfISQLGroup()
0202:                                                .getID(project_id_new,
0203:                                                        ApiConstants.GUESTNAME);
0204:                                    }
0205:                                    SQLObjectFactory.getInstanceOfISQLGroup()
0206:                                            .insertUser(idGroupe, idUser);
0207:                                }
0208:                            }
0209:                        }
0210:                    }
0211:
0212:                    if (suite) {
0213:                        /* Ajout des parametres */
0214:                        ParameterWrapper[] listOfParam = getProjectParams(idFromProject);
0215:                        for (int i = 0; i < listOfParam.length; i++) {
0216:                            ParameterWrapper pParameterWrapper = listOfParam[i];
0217:                            String nom = pParameterWrapper.getName();
0218:                            String des = pParameterWrapper.getDescription();
0219:                            int id = pParameterWrapper.getIdBDD();
0220:                            int idNew_parm = SQLObjectFactory
0221:                                    .getInstanceOfISQLParameter().insert(
0222:                                            project_id_new, nom, des);
0223:                            mapParam.put(new Integer(id), new Integer(
0224:                                    idNew_parm));
0225:                        }
0226:
0227:                        /* Ajout des familles */
0228:                        FamilyWrapper[] listofFamily = getFamily(idFromProject);
0229:                        for (int i = 0; i < listofFamily.length; i++) {
0230:                            FamilyWrapper pFamilyWrapper = listofFamily[i];
0231:                            int id_fam = pFamilyWrapper.getIdBDD();
0232:                            String nom = pFamilyWrapper.getName();
0233:                            String des = pFamilyWrapper.getDescription();
0234:                            int idNew_fam = SQLObjectFactory
0235:                                    .getInstanceOfISQLFamily().insert(
0236:                                            project_id_new, nom, des);
0237:                            mapFamille.put(new Integer(id_fam), new Integer(
0238:                                    idNew_fam));
0239:
0240:                            /* Ajout des suites */
0241:                            SuiteWrapper[] listofSuite = SQLObjectFactory
0242:                                    .getInstanceOfISQLFamily().getTestList(
0243:                                            id_fam);
0244:                            for (int j = 0; j < listofSuite.length; j++) {
0245:                                SuiteWrapper pSuiteWrapper = listofSuite[j];
0246:                                int id_suite = pSuiteWrapper.getIdBDD();
0247:                                //int famille_id =  stmtRes.getResults().getInt("FAMILLE_TEST_id_famille");
0248:                                nom = pSuiteWrapper.getName();
0249:                                des = pSuiteWrapper.getDescription();
0250:                                int idNew_suite = SQLObjectFactory
0251:                                        .getInstanceOfISQLTestList().insert(
0252:                                                idNew_fam, nom, des);
0253:                                mapSuite.put(new Integer(id_suite),
0254:                                        new Integer(idNew_suite));
0255:
0256:                                /* Ajout des tests */
0257:                                TestWrapper[] listOfTest = SQLObjectFactory
0258:                                        .getInstanceOfISQLTestList()
0259:                                        .getTestsWrapper(id_suite);
0260:                                for (int k = 0; k < listOfTest.length; k++) {
0261:                                    TestWrapper pTestWrapper = listOfTest[k];
0262:                                    int id_cas = pTestWrapper.getIdBDD();
0263:                                    String conceptor = SQLObjectFactory
0264:                                            .getInstanceOfISQLPersonne()
0265:                                            .getLogin(idAdmin);
0266:                                    if (users) {
0267:                                        conceptor = pTestWrapper.getConceptor();
0268:                                        //id_personne = SQLObjectFactory.getInstanceOfISQLPersonne().getID(user);
0269:                                    }
0270:                                    nom = pTestWrapper.getName();
0271:                                    des = pTestWrapper.getDescription();
0272:                                    int idNewTest;
0273:                                    if (pTestWrapper.getType().equals(
0274:                                            ApiConstants.MANUAL)) {
0275:                                        idNewTest = SQLObjectFactory
0276:                                                .getInstanceOfISQLManualTest()
0277:                                                .insert(idNew_suite, nom, des,
0278:                                                        conceptor, "");
0279:
0280:                                    } else {
0281:                                        String ext = pTestWrapper
0282:                                                .getTestExtension();
0283:                                        idNewTest = SQLObjectFactory
0284:                                                .getInstanceOfISQLAutomaticTest()
0285:                                                .insert(idNew_suite, nom, des,
0286:                                                        conceptor, ext);
0287:                                    }
0288:                                    mapCas.put(new Integer(id_cas),
0289:                                            new Integer(idNewTest));
0290:                                    /* Ajout des parametres */
0291:                                    listOfParam = SQLObjectFactory
0292:                                            .getInstanceOfISQLTest()
0293:                                            .getAllUseParams(id_cas);
0294:                                    for (int l = 0; l < listOfParam.length; l++) {
0295:                                        ParameterWrapper pParameterWrapper = listOfParam[l];
0296:                                        int old_id_param_test = pParameterWrapper
0297:                                                .getIdBDD();
0298:                                        int new_id_param_test = ((Integer) mapParam
0299:                                                .get(new Integer(
0300:                                                        old_id_param_test)))
0301:                                                .intValue();
0302:                                        SQLObjectFactory
0303:                                                .getInstanceOfISQLTest()
0304:                                                .addUseParam(idNewTest,
0305:                                                        new_id_param_test);
0306:                                    }
0307:                                    if (pTestWrapper.getType().equals(
0308:                                            ApiConstants.MANUAL)) {
0309:                                        /* Ajout des Actions */
0310:                                        ActionWrapper[] listOfAction = SQLObjectFactory
0311:                                                .getInstanceOfISQLManualTest()
0312:                                                .getTestActions(id_cas);
0313:                                        for (int m = 0; m < listOfAction.length; m++) {
0314:                                            ActionWrapper pActionWrapper = listOfAction[m];
0315:                                            int id_action = pActionWrapper
0316:                                                    .getIdBDD();
0317:                                            nom = pActionWrapper.getName();
0318:                                            des = pActionWrapper
0319:                                                    .getDescription();
0320:                                            String res_attendu_action = pActionWrapper
0321:                                                    .getAwaitedResult();
0322:                                            int idNew_action = SQLObjectFactory
0323:                                                    .getInstanceOfISQLAction()
0324:                                                    .insert(idNewTest, nom,
0325:                                                            des,
0326:                                                            res_attendu_action);
0327:                                            mapAction.put(
0328:                                                    new Integer(id_action),
0329:                                                    new Integer(idNew_action));
0330:                                            listOfParam = SQLObjectFactory
0331:                                                    .getInstanceOfISQLAction()
0332:                                                    .getParamsUses(id_action);
0333:                                            for (int l = 0; l < listOfParam.length; l++) {
0334:                                                ParameterWrapper pParameterWrapper = listOfParam[l];
0335:                                                int old_id_param_test = pParameterWrapper
0336:                                                        .getIdBDD();
0337:                                                int new_id_param_test = ((Integer) mapParam
0338:                                                        .get(new Integer(
0339:                                                                old_id_param_test)))
0340:                                                        .intValue();
0341:                                                SQLObjectFactory
0342:                                                        .getInstanceOfISQLAction()
0343:                                                        .addUseParam(
0344:                                                                idNew_action,
0345:                                                                new_id_param_test);
0346:                                            }
0347:                                        }
0348:                                    } else {
0349:                                        /* Ajout des script */
0350:                                        ScriptWrapper pScriptWrapper = SQLObjectFactory
0351:                                                .getInstanceOfISQLAutomaticTest()
0352:                                                .getTestScript(id_cas);
0353:                                        des = pScriptWrapper.getDescription();
0354:                                        nom = pScriptWrapper.getName();
0355:                                        String arg = pScriptWrapper
0356:                                                .getPlugArg();
0357:                                        String ext = pScriptWrapper
0358:                                                .getScriptExtension();
0359:                                        SalomeFileWrapper f = SQLObjectFactory
0360:                                                .getInstanceOfISQLAutomaticTest()
0361:                                                .getTestScriptFile(id_cas);
0362:                                        SQLObjectFactory
0363:                                                .getInstanceOfISQLAutomaticTest()
0364:                                                .addScript(idNewTest, f, des,
0365:                                                        nom, ext, arg);
0366:                                    }
0367:
0368:                                }
0369:                            }
0370:                        }
0371:
0372:                    }
0373:
0374:                    if (campagne && suite) {
0375:                        CampaignWrapper[] listOfCampaign = getPrjectCampaigns(idFromProject);
0376:                        for (int i = 0; i < listOfCampaign.length; i++) {
0377:                            CampaignWrapper pCampaignWrapper = listOfCampaign[i];
0378:                            int idCamp = pCampaignWrapper.getIdBDD();
0379:                            String nom = pCampaignWrapper.getName();
0380:                            String des = pCampaignWrapper.getDescription();
0381:                            String conceptor = pCampaignWrapper.getConceptor();
0382:                            int idUser = idAdmin;
0383:                            if (users) {
0384:                                idUser = SQLObjectFactory
0385:                                        .getInstanceOfISQLPersonne().getID(
0386:                                                conceptor);
0387:                            }
0388:                            int idNew_Camp = SQLObjectFactory
0389:                                    .getInstanceOfISQLCampaign().insert(
0390:                                            project_id_new, nom, des, idUser);
0391:                            TestCampWrapper[] testInCamp = SQLObjectFactory
0392:                                    .getInstanceOfISQLCampaign()
0393:                                    .getTestsByOrder(idCamp);
0394:                            for (int j = 0; j < testInCamp.length; j++) {
0395:                                TestCampWrapper pTestCampWrapper = testInCamp[j];
0396:                                int idoldtest = pTestCampWrapper.getIdBDD();
0397:                                int idnewtest = ((Integer) mapCas
0398:                                        .get(new Integer(idoldtest)))
0399:                                        .intValue();
0400:                                SQLObjectFactory.getInstanceOfISQLCampaign()
0401:                                        .importTest(idNew_Camp, idnewtest,
0402:                                                idUser);
0403:                            }
0404:                        }
0405:
0406:                    }
0407:
0408:                    SQLEngine.commitTrans(transNumber);
0409:                } catch (Exception e) {
0410:                    Util.log("[SQLProject->copyProject]" + e);
0411:                    if (Api.isDEBUG()) {
0412:                        e.printStackTrace();
0413:                    }
0414:                    SQLEngine.rollBackTrans(transNumber);
0415:                    throw e;
0416:                }
0417:                return project_id_new;
0418:            }
0419:
0420:            /**
0421:             * Attach a file to the Project identified by idProject (Table  PROJET_VOICE_TESTING_ATTACHEMENT )
0422:             * @param idProject
0423:             * @param f the file
0424:             * @param description of the file
0425:             * @return the Id of the attachment in the table ATTACHEMENT
0426:             * @throws Exception
0427:             * @see ISQLFileAttachment.insert(File, String)
0428:             * no permission needed
0429:             */
0430:            public int addAttachFile(int idProject, SalomeFileWrapper f,
0431:                    String description) throws Exception {
0432:                if (idProject < 1 || f == null) {
0433:                    throw new Exception(
0434:                            "[SQLProject->addAttachFile] entry data are not valid");
0435:                }
0436:                int transNumber = -1;
0437:                int idAttach = -1;
0438:                try {
0439:                    transNumber = SQLEngine.beginTransaction(0,
0440:                            ApiConstants.INSERT_ATTACHMENT);
0441:                    idAttach = SQLObjectFactory
0442:                            .getInstanceOfISQLFileAttachment().insert(f,
0443:                                    description);
0444:
0445:                    PreparedStatement prep = SQLEngine
0446:                            .getSQLAddQuery("addAttachToProject"); //ok
0447:                    prep.setInt(1, idAttach);
0448:                    prep.setInt(2, idProject);
0449:                    SQLEngine.runAddQuery(prep);
0450:
0451:                    SQLEngine.commitTrans(transNumber);
0452:                } catch (Exception e) {
0453:                    Util.log("[SQLProject->addAttachFile]" + e);
0454:                    if (Api.isDEBUG()) {
0455:                        e.printStackTrace();
0456:                    }
0457:                    SQLEngine.rollBackTrans(transNumber);
0458:                    throw e;
0459:                }
0460:                return idAttach;
0461:            }
0462:
0463:            /**
0464:             * Attach an Url to the Project identified by idProject (Table  PROJET_VOICE_TESTING_ATTACHEMENT )
0465:             * @param idProject
0466:             * @param url
0467:             * @param description of the url
0468:             * @return the Id of the attachment in the table ATTACHEMENT
0469:             * @throws Exception
0470:             * @see ISQLUrlAttachment.insert(String, String)
0471:             * no permission needed
0472:             */
0473:            public int addAttachUrl(int idProject, String url,
0474:                    String description) throws Exception {
0475:                if (idProject < 1 || url == null) {
0476:                    throw new Exception(
0477:                            "[SQLProject->addAttachUrl] entry data are not valid");
0478:                }
0479:                int transNumber = -1;
0480:                int idAttach = -1;
0481:                try {
0482:                    transNumber = SQLEngine.beginTransaction(0,
0483:                            ApiConstants.INSERT_ATTACHMENT);
0484:                    idAttach = SQLObjectFactory
0485:                            .getInstanceOfISQLUrlAttachment().insert(url,
0486:                                    description);
0487:
0488:                    PreparedStatement prep = SQLEngine
0489:                            .getSQLAddQuery("addAttachToProject"); //ok
0490:                    prep.setInt(1, idAttach);
0491:                    prep.setInt(2, idProject);
0492:                    SQLEngine.runAddQuery(prep);
0493:
0494:                    SQLEngine.commitTrans(transNumber);
0495:                } catch (Exception e) {
0496:                    Util.log("[SQLProject->addAttachUrl]" + e);
0497:                    if (Api.isDEBUG()) {
0498:                        e.printStackTrace();
0499:                    }
0500:                    SQLEngine.rollBackTrans(transNumber);
0501:                    throw e;
0502:                }
0503:                return idAttach;
0504:            }
0505:
0506:            /**
0507:             * Update project name and description in the database for the project idProject
0508:             * @param idProject
0509:             * @param newName
0510:             * @param newDesc
0511:             * @throws Exception
0512:             * no permission needed
0513:             */
0514:            public void update(int idProject, String newName, String newDesc)
0515:                    throws Exception {
0516:                int transNumber = -1;
0517:                if (idProject < 1) {
0518:                    throw new Exception(
0519:                            "[SQLProject->update] project have no id");
0520:                }
0521:                try {
0522:                    transNumber = SQLEngine.beginTransaction(0,
0523:                            ApiConstants.UPDATE_PROJECT);
0524:                    PreparedStatement prep = SQLEngine
0525:                            .getSQLUpdateQuery("updateProject"); //ok
0526:
0527:                    prep.setString(1, newName);
0528:                    prep.setString(2, newDesc);
0529:                    prep.setInt(3, idProject);
0530:                    SQLEngine.runUpdateQuery(prep);
0531:
0532:                    SQLEngine.commitTrans(transNumber);
0533:                } catch (Exception e) {
0534:                    Util.log("[SQLProject->update]" + e);
0535:                    if (Api.isDEBUG()) {
0536:                        e.printStackTrace();
0537:                    }
0538:                    SQLEngine.rollBackTrans(transNumber);
0539:                    throw e;
0540:                }
0541:            }
0542:
0543:            /**
0544:             * Delete a project in the database
0545:             * the delete 
0546:             * @param idProject
0547:             * @param name
0548:             * @throws Exception
0549:             */
0550:            public void delete(int idProject, String name) throws Exception {
0551:                int transNumber = -1;
0552:                if (idProject < 1) {
0553:                    throw new Exception(
0554:                            "[SQLProject->delete] project have no id");
0555:                }
0556:                boolean dospecialAllow = false;
0557:                if (!SQLEngine.specialAllow) {
0558:                    dospecialAllow = true;
0559:                    SQLEngine.setSpecialAllow(true);
0560:                }
0561:
0562:                try {
0563:                    transNumber = SQLEngine.beginTransaction(111,
0564:                            ApiConstants.DELETE_PROJECT);
0565:
0566:                    GroupWrapper[] projectGroups;
0567:                    FamilyWrapper[] projectFamilies;
0568:                    CampaignWrapper[] projectCampaigns;
0569:                    EnvironmentWrapper[] projectEnv;
0570:                    ParameterWrapper[] projectParam;
0571:
0572:                    /* Suppression de toutes campagnes de test du projet */
0573:                    projectCampaigns = getPrjectCampaigns(idProject);
0574:                    for (int i = 0; i < projectCampaigns.length; i++) {
0575:                        CampaignWrapper pCampaignWrapper = projectCampaigns[i];
0576:                        SQLObjectFactory.getInstanceOfISQLCampaign().delete(
0577:                                pCampaignWrapper.getIdBDD(), false); //NOREORDER
0578:                    }
0579:
0580:                    /* Suppression de tous les environnements */
0581:                    projectEnv = getProjectEnvs(idProject);
0582:                    for (int i = 0; i < projectEnv.length; i++) {
0583:                        EnvironmentWrapper pEnvironmentWrapper = projectEnv[i];
0584:                        SQLObjectFactory.getInstanceOfISQLEnvironment().delete(
0585:                                pEnvironmentWrapper.getIdBDD());
0586:                    }
0587:
0588:                    /* Suppression de toutes les familles de test du projet */
0589:                    projectFamilies = getFamily(idProject);
0590:                    for (int i = 0; i < projectFamilies.length; i++) {
0591:                        FamilyWrapper pFamilyWrapper = projectFamilies[i];
0592:                        //SQLObjectFactory.getInstanceOfISQLFamily().delete(pFamilyWrapper.getIdBDD());
0593:                        SQLObjectFactory.getInstanceOfISQLFamily().delete(
0594:                                pFamilyWrapper.getIdBDD(), false); //NOREORDER
0595:                    }
0596:
0597:                    /* Suppression des parametres */
0598:                    projectParam = getProjectParams(idProject);
0599:                    for (int i = 0; i < projectParam.length; i++) {
0600:                        ParameterWrapper pParameterWrapper = projectParam[i];
0601:                        SQLObjectFactory.getInstanceOfISQLParameter().delete(
0602:                                pParameterWrapper.getIdBDD());
0603:                    }
0604:
0605:                    /* Suppression de tous les groupes d'utilisateurs du projet */
0606:                    projectGroups = getProjectGroups(idProject);
0607:                    for (int i = 0; i < projectGroups.length; i++) {
0608:                        GroupWrapper pGroupWrapper = projectGroups[i];
0609:                        SQLObjectFactory.getInstanceOfISQLGroup().delete(
0610:                                pGroupWrapper.getIdBDD());
0611:                    }
0612:
0613:                    /* Suppression des attachements */
0614:                    deleteAllAttach(idProject);
0615:
0616:                    /* Suppression du projet */
0617:                    PreparedStatement prep = SQLEngine
0618:                            .getSQLDeleteQuery("deleteProject");
0619:                    prep.setInt(1, idProject);
0620:                    SQLEngine.runDeleteQuery(prep);
0621:
0622:                    /* Suppression des config */
0623:                    try {
0624:                        if (Api.getLockMeth() == 0) {
0625:                            prep = SQLEngine
0626:                                    .getSQLCommonQuery("lockCONFIGWRITE");
0627:                            SQLEngine.runSelectQuery(prep);
0628:                        }
0629:                        SQLObjectFactory.getInstanceOfISQLConfig()
0630:                                .deleteAllProjectConf(idProject);
0631:                    } catch (Exception e1) {
0632:                        if (Api.isDEBUG()) {
0633:                            e1.printStackTrace();
0634:                        }
0635:                        /* WARNING */
0636:                    }
0637:                    /* Suppression des log d'action du projet *///et unlock ??
0638:                    /*prep = SQLEngine.getSQLCommonQuery("lockAction");
0639:                     SQLEngine.runSelectQuery(prep);
0640:                     */
0641:
0642:                    try {
0643:                        if (Api.getLockMeth() == 0) {
0644:                            prep = SQLEngine.getSQLCommonQuery("lockLDBAWRITE");
0645:                            SQLEngine.runSelectQuery(prep);
0646:                        }
0647:                        prep = SQLEngine.getSQLCommonQuery("deleteLastChange"); //ok
0648:                        prep.setString(1, name);
0649:                        SQLEngine.runDeleteQuery(prep);
0650:                    } catch (Exception e1) {
0651:                        if (Api.isDEBUG()) {
0652:                            e1.printStackTrace();
0653:                        }
0654:                        /* WARNING */
0655:                    }
0656:                    if (dospecialAllow) {
0657:                        SQLEngine.setSpecialAllow(false);
0658:                    }
0659:
0660:                    SQLEngine.commitTrans(transNumber);
0661:                    try {
0662:                        SQLObjectFactory.getInstanceOfISQLSalomeLock().delete(
0663:                                idProject);
0664:                    } catch (Exception e1) {
0665:
0666:                    }
0667:                } catch (Exception e) {
0668:                    if (dospecialAllow) {
0669:                        SQLEngine.setSpecialAllow(false);
0670:                    }
0671:                    Util.log("[SQLProject->delete]" + e);
0672:                    if (Api.isDEBUG()) {
0673:                        e.printStackTrace();
0674:                    }
0675:                    SQLEngine.rollBackTrans(transNumber);
0676:                    throw e;
0677:                }
0678:            }
0679:
0680:            /**
0681:             * Delete all attchements of the project identified by idProject
0682:             * @param idProject
0683:             * @throws Exception
0684:             * no permission needed
0685:             */
0686:            public void deleteAllAttach(int idProject) throws Exception {
0687:                if (idProject < 1) {
0688:                    throw new Exception(
0689:                            "[SQLProject->deleteAllAttach] entry data are not valid");
0690:                }
0691:                int transNumber = -1;
0692:                try {
0693:                    transNumber = SQLEngine.beginTransaction(0,
0694:                            ApiConstants.DELETE_ATTACHMENT);
0695:
0696:                    AttachementWrapper[] attachList = getAllAttachemnt(idProject);
0697:                    for (int i = 0; i < attachList.length; i++) {
0698:                        AttachementWrapper pAttachementWrapper = attachList[i];
0699:                        deleteAttach(idProject, pAttachementWrapper.getIdBDD());
0700:                    }
0701:
0702:                    SQLEngine.commitTrans(transNumber);
0703:                } catch (Exception e) {
0704:                    Util.log("[SQLProject->deleteAllAttach]" + e);
0705:                    if (Api.isDEBUG()) {
0706:                        e.printStackTrace();
0707:                    }
0708:                    SQLEngine.rollBackTrans(transNumber);
0709:                    throw e;
0710:                }
0711:            }
0712:
0713:            /**
0714:             * Delete an attchement idAttach of the project identified by idProject
0715:             * @param idProject
0716:             * @param idAttach
0717:             * @throws Exception
0718:             * @see ISQLAttachment.delete(int)
0719:             * no permission needed
0720:             */
0721:            public void deleteAttach(int idProject, int idAttach)
0722:                    throws Exception {
0723:                if (idProject < 1 || idAttach < 1) {
0724:                    throw new Exception(
0725:                            "[SQLProject->deleteAttach] entry data are not valid");
0726:                }
0727:                int transNumber = -1;
0728:                try {
0729:                    transNumber = SQLEngine.beginTransaction(0,
0730:                            ApiConstants.DELETE_ATTACHMENT);
0731:
0732:                    PreparedStatement prep = SQLEngine
0733:                            .getSQLDeleteQuery("deleteAttachFromProject"); //ok
0734:                    prep.setInt(1, idProject);
0735:                    prep.setInt(2, idAttach);
0736:                    SQLEngine.runDeleteQuery(prep);
0737:
0738:                    SQLObjectFactory.getInstanceOfISQLAttachment().delete(
0739:                            idAttach);
0740:
0741:                    SQLEngine.commitTrans(transNumber);
0742:                } catch (Exception e) {
0743:                    Util.log("[SQLProject->deleteAttach]" + e);
0744:                    if (Api.isDEBUG()) {
0745:                        e.printStackTrace();
0746:                    }
0747:                    SQLEngine.rollBackTrans(transNumber);
0748:                    throw e;
0749:                }
0750:            }
0751:
0752:            /**
0753:             * Get a Vector of AttachementWrapper (FileAttachementWrapper, UrlAttachementWrapper)
0754:             * for the project identified by idProject
0755:             * @param idProject : id of the project
0756:             * @return
0757:             * @throws Exception
0758:             */
0759:            public AttachementWrapper[] getAllAttachemnt(int idProject)
0760:                    throws Exception {
0761:                if (idProject < 1) {
0762:                    throw new Exception(
0763:                            "[SQLProject->getAllAttachemnt] entry data are not valid");
0764:                }
0765:                FileAttachementWrapper[] fileList = getAllAttachFiles(idProject);
0766:                UrlAttachementWrapper[] urlList = getAllAttachUrls(idProject);
0767:
0768:                AttachementWrapper[] result = new AttachementWrapper[fileList.length
0769:                        + urlList.length];
0770:
0771:                for (int i = 0; i < fileList.length; i++) {
0772:                    result[i] = fileList[i];
0773:                }
0774:                for (int i = 0; i < urlList.length; i++) {
0775:                    result[fileList.length + i] = urlList[i];
0776:                }
0777:
0778:                return result;
0779:            }
0780:
0781:            /**
0782:             * Get a Vector of FileAttachementWrapper for the project identified by idProject
0783:             * @param idProject : id of the project
0784:             * @return
0785:             * @throws Exception
0786:             */
0787:            public FileAttachementWrapper[] getAllAttachFiles(int idProject)
0788:                    throws Exception {
0789:                if (idProject < 1) {
0790:                    throw new Exception(
0791:                            "[SQLProject->getAllAttachFiles] entry data are not valid");
0792:                }
0793:                Vector result = new Vector();
0794:                PreparedStatement prep = SQLEngine
0795:                        .getSQLSelectQuery("selectProjectAttachFiles"); //ok
0796:                prep.setInt(1, idProject);
0797:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
0798:                while (stmtRes.next()) {
0799:                    FileAttachementWrapper fileAttach = new FileAttachementWrapper();
0800:                    fileAttach.setName(stmtRes.getString("nom_attach"));
0801:                    fileAttach.setLocalisation("");
0802:                    fileAttach.setDate(stmtRes.getDate("date_attachement"));
0803:                    fileAttach.setSize(new Long(stmtRes
0804:                            .getLong("taille_attachement")));
0805:                    fileAttach.setDescription(stmtRes
0806:                            .getString("description_attach"));
0807:                    fileAttach.setIdBDD(stmtRes.getInt("id_attach"));
0808:                    result.addElement(fileAttach);
0809:                }
0810:                FileAttachementWrapper[] fawArray = new FileAttachementWrapper[result
0811:                        .size()];
0812:                for (int i = 0; i < result.size(); i++) {
0813:                    fawArray[i] = (FileAttachementWrapper) result.get(i);
0814:                }
0815:                return fawArray;
0816:            }
0817:
0818:            /**
0819:             * Get a Vector of UrlAttachementWrapper for the project identified by idProject
0820:             * @param idProject : id of the project
0821:             * @return
0822:             * @throws Exception
0823:             */
0824:            public UrlAttachementWrapper[] getAllAttachUrls(int idProject)
0825:                    throws Exception {
0826:                if (idProject < 1) {
0827:                    throw new Exception(
0828:                            "[SQLProject->getAllAttachUrls] entry data are not valid");
0829:                }
0830:                Vector result = new Vector();
0831:                PreparedStatement prep = SQLEngine
0832:                        .getSQLSelectQuery("selectProjectAttachUrls"); //ok
0833:                prep.setInt(1, idProject);
0834:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
0835:                while (stmtRes.next()) {
0836:                    UrlAttachementWrapper pUrlAttachment = new UrlAttachementWrapper();
0837:                    String url = stmtRes.getString("url_attach");
0838:                    //			pUrlAttachment.setUrl(url);
0839:                    pUrlAttachment.setName(url);
0840:                    pUrlAttachment.setDescription(stmtRes
0841:                            .getString("description_attach"));
0842:                    ;
0843:                    pUrlAttachment.setIdBDD(stmtRes.getInt("id_attach"));
0844:                    result.addElement(pUrlAttachment);
0845:                }
0846:                UrlAttachementWrapper[] uawArray = new UrlAttachementWrapper[result
0847:                        .size()];
0848:                for (int i = 0; i < result.size(); i++) {
0849:                    uawArray[i] = (UrlAttachementWrapper) result.get(i);
0850:                }
0851:                return uawArray;
0852:            }
0853:
0854:            /**
0855:             * Get the number of family in the project identified by idProject
0856:             * @param idProject
0857:             * @throws Exception
0858:             */
0859:            public int getNumberOfFamily(int idProject) throws Exception {
0860:                if (idProject < 1) {
0861:                    throw new Exception(
0862:                            "[SQLProject->getNumberOfFamily] project have no id");
0863:                }
0864:                int result = 0;
0865:                PreparedStatement prep = SQLEngine
0866:                        .getSQLSelectQuery("selectProjectFamilies"); //ok
0867:                prep.setInt(1, idProject);
0868:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
0869:
0870:                while (stmtRes.next()) {
0871:                    result++;
0872:                }
0873:
0874:                return result;
0875:            }
0876:
0877:            /**
0878:             * Get a FamilyWrapper representing a family at order in the project identified by idProject
0879:             * @param idProject
0880:             * @param order
0881:             * @throws Exception
0882:             */
0883:            public FamilyWrapper getFamilyByOrder(int idProject, int order)
0884:                    throws Exception {
0885:                if (idProject < 1) {
0886:                    throw new Exception(
0887:                            "[SQLProject->getFamilyByOrder] project have no id");
0888:                }
0889:                FamilyWrapper pFamily = null;
0890:                PreparedStatement prep = SQLEngine
0891:                        .getSQLSelectQuery("selectFamilyByOrder"); //ok
0892:
0893:                prep.setInt(1, idProject);
0894:                prep.setInt(2, order);
0895:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
0896:
0897:                if (stmtRes.next()) {
0898:                    pFamily = new FamilyWrapper();
0899:                    pFamily.setName(stmtRes.getString("nom_famille"));
0900:                    pFamily.setDescription(stmtRes
0901:                            .getString("description_famille"));
0902:                    pFamily.setIdBDD(stmtRes.getInt("id_famille"));
0903:                    pFamily.setOrder(stmtRes.getInt("ordre_famille"));
0904:                    pFamily.setIdProject(idProject);
0905:                }
0906:                return pFamily;
0907:            }
0908:
0909:            /**
0910:             * Get a Vector of FamilyWrapper representing all family defined in the project idProject
0911:             * @param idProject
0912:             * @return
0913:             * @throws Exception
0914:             */
0915:            public FamilyWrapper[] getFamily(int idProject) throws Exception {
0916:                if (idProject < 1) {
0917:                    throw new Exception(
0918:                            "[SQLProject->getFamily] project have no id");
0919:                }
0920:                Vector result = new Vector();
0921:                PreparedStatement prep = SQLEngine
0922:                        .getSQLSelectQuery("selectProjectFamilies"); //ok
0923:                prep.setInt(1, idProject);
0924:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
0925:
0926:                while (stmtRes.next()) {
0927:                    FamilyWrapper pFamily = new FamilyWrapper();
0928:                    pFamily.setName(stmtRes.getString("nom_famille"));
0929:                    pFamily.setDescription(stmtRes
0930:                            .getString("description_famille"));
0931:                    pFamily.setIdBDD(stmtRes.getInt("id_famille"));
0932:                    pFamily.setOrder(stmtRes.getInt("ordre_famille"));
0933:                    result.addElement(pFamily);
0934:                }
0935:                FamilyWrapper[] fwArray = new FamilyWrapper[result.size()];
0936:                for (int i = 0; i < result.size(); i++) {
0937:                    fwArray[i] = (FamilyWrapper) result.get(i);
0938:                }
0939:                return fwArray;
0940:            }
0941:
0942:            /**
0943:             * Get a ProjectWrapper representing the project identified by name
0944:             * @param name
0945:             * @return
0946:             * @throws Exception
0947:             */
0948:            public ProjectWrapper getProject(String name) throws Exception {
0949:                ProjectWrapper pProjectWrapper = null;
0950:                int transNuber = -1;
0951:                try {
0952:                    transNuber = SQLEngine.beginTransaction(0,
0953:                            ApiConstants.LOADING);
0954:
0955:                    PreparedStatement prep = SQLEngine
0956:                            .getSQLSelectQuery("selectProjectByName"); //ok
0957:                    prep.setString(1, name);
0958:                    ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
0959:                    if (stmtRes.next()) {
0960:                        pProjectWrapper = new ProjectWrapper();
0961:                        pProjectWrapper.setIdBDD(stmtRes.getInt("id_projet"));
0962:                        pProjectWrapper
0963:                                .setName(stmtRes.getString("nom_projet"));
0964:                        pProjectWrapper.setDescription(stmtRes
0965:                                .getString("description_projet"));
0966:                        pProjectWrapper.setCreatedDate(stmtRes
0967:                                .getDate("date_creation_projet"));
0968:                    }
0969:                    SQLEngine.commitTrans(transNuber);
0970:                } catch (Exception e) {
0971:                    SQLEngine.rollBackTrans(transNuber);
0972:                    throw e;
0973:                }
0974:                return pProjectWrapper;
0975:            }
0976:
0977:            /**
0978:             * Get a Vector of ProjectWrapper representing all the project in the database
0979:             * @throws Exception
0980:             */
0981:            public ProjectWrapper[] getAllProjects() throws Exception {
0982:                Vector result = new Vector();
0983:                PreparedStatement prep = SQLEngine
0984:                        .getSQLSelectQuery("selectAllProjects"); //OK
0985:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
0986:
0987:                while (stmtRes.next()) {
0988:                    ProjectWrapper pProjectWrapper = new ProjectWrapper();
0989:                    pProjectWrapper.setIdBDD(stmtRes.getInt("id_projet"));
0990:                    pProjectWrapper.setName(stmtRes.getString("nom_projet"));
0991:                    pProjectWrapper.setDescription(stmtRes
0992:                            .getString("description_projet"));
0993:                    pProjectWrapper.setCreatedDate(stmtRes
0994:                            .getDate("date_creation_projet"));
0995:                    result.add(pProjectWrapper);
0996:                }
0997:                ProjectWrapper[] pwArray = new ProjectWrapper[result.size()];
0998:                for (int i = 0; i < result.size(); i++) {
0999:                    pwArray[i] = (ProjectWrapper) result.get(i);
1000:                }
1001:                return pwArray;
1002:            }
1003:
1004:            /**
1005:             * Return a Vector of UserWrapper representing all available User in Salome-TMF
1006:             * @return
1007:             * @throws Exception
1008:             */
1009:            public UserWrapper[] getAllUser() throws Exception {
1010:                Vector result = new Vector();
1011:                PreparedStatement prep = SQLEngine
1012:                        .getSQLSelectQuery("selectAllUsers"); //OK
1013:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
1014:
1015:                while (stmtRes.next()) {
1016:                    UserWrapper pUserWrapper = new UserWrapper();
1017:                    pUserWrapper.setIdBDD(stmtRes.getInt("id_personne"));
1018:                    pUserWrapper.setLogin(stmtRes.getString("login_personne"));
1019:                    pUserWrapper.setName(stmtRes.getString("nom_personne"));
1020:                    pUserWrapper
1021:                            .setPrenom(stmtRes.getString("prenom_personne"));
1022:                    pUserWrapper.setDescription(stmtRes
1023:                            .getString("desc_personne"));
1024:                    pUserWrapper.setEmail(stmtRes.getString("email_personne"));
1025:                    pUserWrapper.setTel(stmtRes.getString("tel_personne"));
1026:                    try {
1027:                        pUserWrapper.setCreateDate(stmtRes
1028:                                .getDate("date_creation_personne"));
1029:                    } catch (Exception e) {
1030:                        pUserWrapper.setCreateDate(Util.getCurrentDate());
1031:                    }
1032:                    pUserWrapper.setCreateTime(stmtRes.getTime(
1033:                            "heure_creation_personne").getTime());
1034:                    pUserWrapper.setPassword(stmtRes.getString("mot_de_passe"));
1035:                    result.add(pUserWrapper);
1036:                }
1037:                UserWrapper[] uwArray = new UserWrapper[result.size()];
1038:                for (int i = 0; i < result.size(); i++) {
1039:                    uwArray[i] = (UserWrapper) result.get(i);
1040:                }
1041:                return uwArray;
1042:            }
1043:
1044:            /**
1045:             * Get a Vector of UserWrapper representing all the Users in the project projectName
1046:             * @param projectName
1047:             * @throws Exception
1048:             */
1049:            public UserWrapper[] getUsersOfProject(String projectName)
1050:                    throws Exception {
1051:                Vector result = new Vector();
1052:                PreparedStatement prep = SQLEngine
1053:                        .getSQLSelectQuery("selectAllProjectUsers"); //ok
1054:                prep.setString(1, projectName);
1055:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
1056:
1057:                while (stmtRes.next()) {
1058:                    UserWrapper pUserWrapper = new UserWrapper();
1059:                    pUserWrapper.setIdBDD(stmtRes.getInt("id_personne"));
1060:                    pUserWrapper.setLogin(stmtRes.getString("login_personne"));
1061:                    pUserWrapper.setName(stmtRes.getString("nom_personne"));
1062:                    pUserWrapper
1063:                            .setPrenom(stmtRes.getString("prenom_personne"));
1064:                    pUserWrapper.setDescription(stmtRes
1065:                            .getString("desc_personne"));
1066:                    pUserWrapper.setEmail(stmtRes.getString("email_personne"));
1067:                    pUserWrapper.setTel(stmtRes.getString("tel_personne"));
1068:                    pUserWrapper.setCreateDate(stmtRes
1069:                            .getDate("date_creation_personne"));
1070:                    pUserWrapper.setCreateTime(stmtRes.getTime(
1071:                            "heure_creation_personne").getTime());
1072:                    pUserWrapper.setPassword(stmtRes.getString("mot_de_passe"));
1073:                    result.add(pUserWrapper);
1074:                }
1075:                UserWrapper[] uwArray = new UserWrapper[result.size()];
1076:                for (int i = 0; i < result.size(); i++) {
1077:                    uwArray[i] = (UserWrapper) result.get(i);
1078:                }
1079:                return uwArray;
1080:            }
1081:
1082:            /**
1083:             * Get a Vector of UserWrapper representing all admins in the project projectName
1084:             * @param idProject
1085:             * @throws Exception
1086:             */
1087:            public UserWrapper[] getAdminsOfProject(String projectName)
1088:                    throws Exception {
1089:                Vector result = new Vector();
1090:                PreparedStatement prep = SQLEngine
1091:                        .getSQLSelectQuery("selectAllProjectAdmin"); //ok
1092:                prep.setString(1, projectName);
1093:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
1094:
1095:                while (stmtRes.next()) {
1096:                    UserWrapper pUserWrapper = new UserWrapper();
1097:                    pUserWrapper.setIdBDD(stmtRes.getInt("id_personne"));
1098:                    pUserWrapper.setLogin(stmtRes.getString("login_personne"));
1099:                    pUserWrapper.setName(stmtRes.getString("nom_personne"));
1100:                    pUserWrapper
1101:                            .setPrenom(stmtRes.getString("prenom_personne"));
1102:                    pUserWrapper.setDescription(stmtRes
1103:                            .getString("desc_personne"));
1104:                    pUserWrapper.setEmail(stmtRes.getString("email_personne"));
1105:                    pUserWrapper.setTel(stmtRes.getString("tel_personne"));
1106:                    pUserWrapper.setCreateDate(stmtRes
1107:                            .getDate("date_creation_personne"));
1108:                    pUserWrapper.setCreateTime(stmtRes.getTime(
1109:                            "heure_creation_personne").getTime());
1110:                    pUserWrapper.setPassword(stmtRes.getString("mot_de_passe"));
1111:                    result.add(pUserWrapper);
1112:                }
1113:                UserWrapper[] uwArray = new UserWrapper[result.size()];
1114:                for (int i = 0; i < result.size(); i++) {
1115:                    uwArray[i] = (UserWrapper) result.get(i);
1116:                }
1117:                return uwArray;
1118:            }
1119:
1120:            /**
1121:             * Get a Vector of UserWrapper representing all user in groupName in the project projectName
1122:             * @param idProject
1123:             * @throws Exception
1124:             */
1125:            public UserWrapper[] getUserOfGroupInProject(String projectName,
1126:                    String groupName) throws Exception {
1127:                // A Supprimer afin d'utiliser celle de ISQLGroup
1128:                Vector result = new Vector();
1129:                PreparedStatement prep = SQLEngine
1130:                        .getSQLSelectQuery("selectGroupUsers"); //ok
1131:                prep.setString(1, groupName);
1132:                prep.setString(2, projectName);
1133:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
1134:
1135:                while (stmtRes.next()) {
1136:                    UserWrapper pUserWrapper = new UserWrapper();
1137:                    pUserWrapper.setIdBDD(stmtRes.getInt("id_personne"));
1138:                    pUserWrapper.setLogin(stmtRes.getString("login_personne"));
1139:                    pUserWrapper.setName(stmtRes.getString("nom_personne"));
1140:                    pUserWrapper
1141:                            .setPrenom(stmtRes.getString("prenom_personne"));
1142:                    pUserWrapper.setDescription(stmtRes
1143:                            .getString("desc_personne"));
1144:                    pUserWrapper.setEmail(stmtRes.getString("email_personne"));
1145:                    pUserWrapper.setTel(stmtRes.getString("tel_personne"));
1146:                    pUserWrapper.setCreateDate(stmtRes
1147:                            .getDate("date_creation_personne"));
1148:                    pUserWrapper.setCreateTime(stmtRes.getTime(
1149:                            "heure_creation_personne").getTime());
1150:                    pUserWrapper.setPassword(stmtRes.getString("mot_de_passe"));
1151:                    result.add(pUserWrapper);
1152:                }
1153:                UserWrapper[] uwArray = new UserWrapper[result.size()];
1154:                for (int i = 0; i < result.size(); i++) {
1155:                    uwArray[i] = (UserWrapper) result.get(i);
1156:                }
1157:                return uwArray;
1158:            }
1159:
1160:            /**
1161:             * Get a Vector of ParameterWrapper for the project idProject
1162:             * @param idProject
1163:             * @return
1164:             * @throws Exception
1165:             */
1166:            public ParameterWrapper[] getProjectParams(int idProject)
1167:                    throws Exception {
1168:                if (idProject < 1) {
1169:                    throw new Exception(
1170:                            "[SQLProject->getProjectParams] project have no id");
1171:                }
1172:                Vector result = new Vector();
1173:                PreparedStatement prep = SQLEngine
1174:                        .getSQLSelectQuery("selectProjectParams"); //ok
1175:                prep.setInt(1, idProject);
1176:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
1177:                while (stmtRes.next()) {
1178:                    ParameterWrapper pParameter = new ParameterWrapper();
1179:                    pParameter.setName(stmtRes.getString("nom_param_test"));
1180:                    pParameter.setDescription(stmtRes
1181:                            .getString("desc_param_test"));
1182:                    pParameter.setIdBDD(stmtRes.getInt("id_param_test"));
1183:                    result.addElement(pParameter);
1184:                }
1185:                ParameterWrapper[] pwArray = new ParameterWrapper[result.size()];
1186:                for (int i = 0; i < result.size(); i++) {
1187:                    pwArray[i] = (ParameterWrapper) result.get(i);
1188:                }
1189:                return pwArray;
1190:            }
1191:
1192:            /**
1193:             * Get a Vector of EnvironmentWrapper representing the environnment of the project idProject
1194:             * @param idProject
1195:             * @return
1196:             * @throws Exception
1197:             */
1198:            public EnvironmentWrapper[] getProjectEnvs(int idProject)
1199:                    throws Exception {
1200:                if (idProject < 1) {
1201:                    throw new Exception(
1202:                            "[SQLProject->getProjectEnvs] project have no id");
1203:                }
1204:                Vector result = new Vector();
1205:                PreparedStatement prep = SQLEngine
1206:                        .getSQLSelectQuery("selectProjectEnvs"); //ok
1207:                prep.setInt(1, idProject);
1208:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
1209:                while (stmtRes.next()) {
1210:                    EnvironmentWrapper env = new EnvironmentWrapper();
1211:                    env.setIdBDD(stmtRes.getInt("id_env"));
1212:                    env.setName(stmtRes.getString("nom_env"));
1213:                    env.setDescription(stmtRes.getString("description_env"));
1214:                    result.addElement(env);
1215:                }
1216:                EnvironmentWrapper[] ewArray = new EnvironmentWrapper[result
1217:                        .size()];
1218:                for (int i = 0; i < result.size(); i++) {
1219:                    ewArray[i] = (EnvironmentWrapper) result.get(i);
1220:                }
1221:                return ewArray;
1222:            }
1223:
1224:            /**
1225:             * Get a vector of CampaignWrapper representing the campaigns of the project idProject
1226:             * @param idProject
1227:             * @return
1228:             * @throws Exception
1229:             */
1230:            public CampaignWrapper[] getPrjectCampaigns(int idProject)
1231:                    throws Exception {
1232:                if (idProject < 1) {
1233:                    throw new Exception(
1234:                            "[SQLProject->getPrjectCampaigns] project have no id");
1235:                }
1236:                Vector result = new Vector();
1237:                PreparedStatement prep = SQLEngine
1238:                        .getSQLSelectQuery("selectProjectCampaigns"); //ok by CAMPAIGN
1239:                prep.setInt(1, idProject);
1240:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
1241:                while (stmtRes.next()) {
1242:                    CampaignWrapper pCampaign = new CampaignWrapper();
1243:                    pCampaign.setName(stmtRes.getString("nom_camp"));
1244:                    pCampaign.setIdBDD(stmtRes.getInt("id_camp"));
1245:                    pCampaign.setConceptor(SQLObjectFactory
1246:                            .getInstanceOfISQLPersonne().getLogin(
1247:                                    stmtRes.getInt("PERSONNE_id_personne")));
1248:                    pCampaign.setDescription(stmtRes
1249:                            .getString("description_camp"));
1250:                    pCampaign.setDate(stmtRes.getDate("date_creation_camp"));
1251:                    result.addElement(pCampaign);
1252:                }
1253:                CampaignWrapper[] cwArray = new CampaignWrapper[result.size()];
1254:                for (int i = 0; i < result.size(); i++) {
1255:                    cwArray[i] = (CampaignWrapper) result.get(i);
1256:                }
1257:                return cwArray;
1258:            }
1259:
1260:            /**
1261:             * Get a vector of GroupWrapper representing groups in the project idProject
1262:             * @param idProject
1263:             * @return
1264:             * @throws Exception
1265:             */
1266:            public GroupWrapper[] getProjectGroups(int idProject)
1267:                    throws Exception {
1268:                if (idProject < 1) {
1269:                    throw new Exception(
1270:                            "[SQLProject->getProjectGroups] project have no id");
1271:                }
1272:                Vector result = new Vector();
1273:                PreparedStatement prep = SQLEngine
1274:                        .getSQLSelectQuery("selectAllProjectGroups"); //ok
1275:                prep.setInt(1, idProject);
1276:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
1277:                while (stmtRes.next()) {
1278:                    GroupWrapper pGroupWrapper = new GroupWrapper();
1279:                    pGroupWrapper.setIdBDD(stmtRes.getInt("id_groupe"));
1280:                    pGroupWrapper.setIdProject(stmtRes
1281:                            .getInt("PROJET_VOICE_TESTING_id_projet"));
1282:                    pGroupWrapper.setName(stmtRes.getString("nom_groupe"));
1283:                    pGroupWrapper.setDescription(stmtRes
1284:                            .getString("desc_groupe"));
1285:                    pGroupWrapper.setPermission(stmtRes.getInt("permission"));
1286:                    result.addElement(pGroupWrapper);
1287:                }
1288:                GroupWrapper[] gwArray = new GroupWrapper[result.size()];
1289:                for (int i = 0; i < result.size(); i++) {
1290:                    gwArray[i] = (GroupWrapper) result.get(i);
1291:                }
1292:                return gwArray;
1293:
1294:            }
1295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.