Source Code Cross Referenced for AdminVTInsertImpl.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » api » api2ihm » adminVT » 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.api.api2ihm.adminVT 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SalomeTMF is a Test Management Framework
003:         * Copyright (C) 2005 France Telecom R&D
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2 of the License, or (at your option) any later version.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013:         * Lesser General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:         *
019:         * @author Fayçal SOUGRATI
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package org.objectweb.salome_tmf.api.api2ihm.adminVT;
025:
026:        import java.sql.Date;
027:        import java.sql.PreparedStatement;
028:        import java.sql.SQLException;
029:        import java.sql.Time;
030:        import java.util.Hashtable;
031:        import java.util.Properties;
032:
033:        import org.objectweb.salome_tmf.api.ApiConstants;
034:        import org.objectweb.salome_tmf.api.api2db.DataBase;
035:        import org.objectweb.salome_tmf.api.api2db.DataSet;
036:        import org.objectweb.salome_tmf.api.api2ihm.Utile;
037:        import org.objectweb.salome_tmf.api.api2ihm.suiteTest.STCommun;
038:
039:        /**
040:         * Fonctions d'insertion relatives e l'aire fonctionnelle "Administrer Voice Testing"
041:         * @author Fayeal SOUGRATI
042:         */
043:        public class AdminVTInsertImpl implements  AdminVTInsert, ApiConstants {
044:
045:            /**
046:             * Base de donnees Voice Testing
047:             */
048:            DataBase database;
049:
050:            /**
051:             * Fichier "properties" contenant les requetes SQL relatives a l'administration
052:             */
053:            Properties prop;
054:
055:            /**
056:             * Constructeur
057:             * @param db
058:             * @param pr
059:             */
060:            public AdminVTInsertImpl(DataBase db, Properties pr) {
061:                database = db;
062:                prop = pr;
063:            }
064:
065:            /**
066:             * Ajout d'un utilisateur SalomeTMF, en lui associant un administrateur ainsi que les groupes
067:             * d'utilisateurs par defaut (l'admin appartiendra au groupe par defaut "Administrateur")
068:             * @param name
069:             * @param description
070:             * @param loginAdmin
071:             */
072:            public void addProject(String name, String description,
073:                    String loginAdmin) {
074:                // Initialisation de la date actuelle
075:                Date dateActuelle = Utile.getCurrentDate();
076:
077:                int idProject = 0;
078:                int idAdmin = 0;
079:                int idAdminGroup = 0;
080:
081:                //org.objectweb.salome_tmf.api.Api.getInstanceOfBugzillaAPI().addProduct(name,description) ;
082:
083:                // Ajout du projet a la base VT
084:
085:                PreparedStatement prep = null;
086:                int _num = -1;
087:                try {
088:                    _num = org.objectweb.salome_tmf.api.Api.beginTrans();
089:
090:                    prep = database.prepareStatement(prop
091:                            .getProperty("addProject"));
092:                    prep.setString(1, name);
093:                    prep.setDate(2, dateActuelle);
094:                    prep.setString(3, description);
095:
096:                    prep.executeUpdate();
097:                }
098:
099:                catch (SQLException e) {
100:                    e.printStackTrace();
101:                    org.objectweb.salome_tmf.api.Api.addException("addProject",
102:                            null, e);
103:                } catch (Exception ex) {
104:                    ex.printStackTrace();
105:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
106:                            ex);
107:                }
108:
109:                // Ajout des groupes d'utilisateurs par defaut
110:                // Groupe "Administrateur"
111:                idProject = Utile.getIdProject(database, prop, name);
112:                try {
113:                    prep = database.prepareStatement(prop
114:                            .getProperty("addDefaultGroups"));
115:                    prep.setInt(1, idProject);
116:                    prep.setString(2, ADMINNAME);
117:                    prep.setString(3, ADMINDESC);
118:
119:                    prep.executeUpdate();
120:                } catch (SQLException e) {
121:                    e.printStackTrace();
122:                    org.objectweb.salome_tmf.api.Api.addException(
123:                            "addDefaultGroups", null, e);
124:                } catch (Exception ex) {
125:                    ex.printStackTrace();
126:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
127:                            ex);
128:                }
129:
130:                // Groupe "Developpeur"
131:                try {
132:                    prep.setString(2, DEVNAME);
133:                    prep.setString(3, DEVDESC);
134:
135:                    prep.executeUpdate();
136:                } catch (SQLException e) {
137:                    e.printStackTrace();
138:                    org.objectweb.salome_tmf.api.Api.addException(
139:                            "addDefaultGroups", null, e);
140:                } catch (Exception ex) {
141:                    ex.printStackTrace();
142:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
143:                            ex);
144:                }
145:
146:                // Groupe "Invite"
147:                try {
148:                    prep.setString(2, GUESTNAME);
149:                    prep.setString(3, GUESTDESC);
150:
151:                    prep.executeUpdate();
152:                } catch (SQLException e) {
153:                    e.printStackTrace();
154:                    org.objectweb.salome_tmf.api.Api.addException(
155:                            "addDefaultGroups", null, e);
156:                } catch (Exception ex) {
157:                    ex.printStackTrace();
158:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
159:                            ex);
160:                }
161:
162:                // On precise l'administrateur du projet:
163:                idAdmin = Utile.getIdPerson(database, prop, loginAdmin);
164:                idAdminGroup = Utile.getIdGroup(database, prop, idProject,
165:                        ADMINNAME);
166:
167:                try {
168:                    prep = database.prepareStatement(prop
169:                            .getProperty("addUserToGroup"));
170:                    prep.setInt(1, idAdmin);
171:                    prep.setInt(2, idAdminGroup);
172:
173:                    prep.executeUpdate();
174:                } catch (SQLException e) {
175:                    e.printStackTrace();
176:                    org.objectweb.salome_tmf.api.Api.addException(
177:                            "addUserToGroup", null, e);
178:                } catch (Exception ex) {
179:                    ex.printStackTrace();
180:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
181:                            ex);
182:                }
183:
184:                // Ajout de la famille de test par defaut
185:                /*
186:                try {
187:                    prep = database.prepareStatement(prop.getProperty("addFamily"));
188:                	prep.setString(1,DEFAULT_FAMILY_NAME);
189:                	prep.setInt(2,idProject);
190:                	prep.setString(3,DEFAULT_FAMILY_DESC);
191:
192:                	prep.executeUpdate();
193:                }
194:                catch (SQLException e) {
195:                    e.printStackTrace();
196:                    org.objectweb.salome_tmf.api.Api.addException("addFamily", null, e);
197:                }catch (Exception ex) {
198:                    ex.printStackTrace();
199:                    org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
200:                }*/
201:                org.objectweb.salome_tmf.api.Api.commitTrans(_num);
202:
203:            }
204:
205:            /**
206:             * 
207:             */
208:            public void addProject(String name, String description,
209:                    String loginAdmin, String fromProject, boolean suite,
210:                    boolean campagne, boolean users, boolean groupe) {
211:                addProject(name, description, loginAdmin);
212:                int personne_id = Utile.getIdPerson(database, prop, loginAdmin);
213:                int project_id_from = Utile.getIdProject(database, prop,
214:                        fromProject);
215:                int project_id_new = Utile.getIdProject(database, prop, name);
216:                int groupe_id = Utile.getIdGroup(database, prop,
217:                        project_id_new, DEVNAME);
218:                PreparedStatement prep, prep2;
219:                DataSet stmtRes = null;
220:                DataSet stmtRes2 = null;
221:                Hashtable mapGroupe = new Hashtable();
222:                Hashtable mapFamille = new Hashtable();
223:                Hashtable mapSuite = new Hashtable();
224:                Hashtable mapCas = new Hashtable();
225:                Hashtable mapAction = new Hashtable();
226:                Hashtable mapParam = new Hashtable();
227:                Hashtable mapCampagne = new Hashtable();
228:                Date dateActuelle = Utile.getCurrentDate();
229:                Time timeActuelle = Utile.getCurrentTime();
230:
231:                int _num = -1;
232:                try {
233:                    _num = org.objectweb.salome_tmf.api.Api.beginTrans();
234:                    if (groupe) {
235:
236:                        prep = database.prepareStatement(prop
237:                                .getProperty("selectGroupInfo"));
238:                        prep.setInt(1, project_id_from);
239:                        stmtRes = new DataSet(prep.executeQuery());
240:                        while (stmtRes.hasMoreElements()) {
241:                            int id_g = stmtRes.getResults().getInt("id_groupe");
242:                            String nom = stmtRes.getResults().getString(
243:                                    "nom_groupe");
244:                            String des = stmtRes.getResults().getString(
245:                                    "desc_groupe");
246:                            int perm = stmtRes.getResults()
247:                                    .getInt("permission");
248:                            if (!(nom.equals(ADMINNAME))
249:                                    && !(nom.equals(DEVNAME))
250:                                    && !(nom.equals(GUESTNAME))) {
251:                                prep2 = database.prepareStatement(prop
252:                                        .getProperty("addGroup"));
253:                                prep2.setInt(1, project_id_new);
254:                                prep2.setString(2, nom);
255:                                prep2.setString(3, des);
256:                                prep2.setInt(4, perm);
257:                                prep2.executeUpdate();
258:                            }
259:                            mapGroupe.put(new Integer(id_g), new Integer(Utile
260:                                    .getIdGroup(database, prop, project_id_new,
261:                                            nom)));
262:                        }
263:                    }
264:                    if (users) {
265:                        prep = database.prepareStatement(prop
266:                                .getProperty("selectUserGroupeInfo"));
267:                        prep.setInt(1, project_id_from);
268:                        stmtRes = new DataSet(prep.executeQuery());
269:                        while (stmtRes.hasMoreElements()) {
270:                            int id_personne = stmtRes.getResults().getInt(
271:                                    "PERSONNE_id_personne");
272:                            if (personne_id != id_personne) {
273:                                if (groupe) {
274:                                    groupe_id = stmtRes.getResults().getInt(
275:                                            "GROUPE_id_groupe");
276:                                    groupe_id = ((Integer) mapGroupe
277:                                            .get(new Integer(groupe_id)))
278:                                            .intValue();
279:                                }
280:                                prep2 = database.prepareStatement(prop
281:                                        .getProperty("addUserToGroup"));
282:                                prep2.setInt(1, id_personne);
283:                                prep2.setInt(2, groupe_id);
284:                                prep2.executeUpdate();
285:                            }
286:                        }
287:                    }
288:                    if (suite) {
289:                        // 1 Ajout des familles	
290:                        prep = database.prepareStatement(prop
291:                                .getProperty("selectFamilleInfo"));
292:                        prep.setInt(1, project_id_from);
293:                        stmtRes = new DataSet(prep.executeQuery());
294:                        while (stmtRes.hasMoreElements()) {
295:                            int id_fam = stmtRes.getResults().getInt(
296:                                    "id_famille");
297:                            String nom = stmtRes.getResults().getString(
298:                                    "nom_famille");
299:                            String des = stmtRes.getResults().getString(
300:                                    "description_famille");
301:                            int ordre = stmtRes.getResults().getInt(
302:                                    "ordre_famille");
303:                            if (!(nom.equals(DEFAULT_FAMILY_NAME))) {
304:
305:                                prep2 = database.prepareStatement(prop
306:                                        .getProperty("addFamily2"));
307:                                prep2.setString(1, nom);
308:                                prep2.setInt(2, project_id_new);
309:                                prep2.setString(3, des);
310:                                prep2.setInt(4, ordre);
311:                                prep2.executeUpdate();
312:                                org.objectweb.salome_tmf.api.Api
313:                                        .log("Add fammile " + nom);
314:                            }
315:
316:                            mapFamille.put(new Integer(id_fam), new Integer(
317:                                    Utile.getIdFamille(database, prop,
318:                                            project_id_new, nom)));
319:
320:                        }
321:                        System.out.println(mapFamille);
322:                        // 2 Ajout des suites
323:                        prep = database.prepareStatement(prop
324:                                .getProperty("selectSuiteInfo"));
325:                        prep.setInt(1, project_id_from);
326:                        stmtRes = new DataSet(prep.executeQuery());
327:                        while (stmtRes.hasMoreElements()) {
328:                            int id_suite = stmtRes.getResults().getInt(
329:                                    "id_suite");
330:                            int famille_id = stmtRes.getResults().getInt(
331:                                    "FAMILLE_TEST_id_famille");
332:                            String nom_suite = stmtRes.getResults().getString(
333:                                    "nom_suite");
334:                            String desc = stmtRes.getResults().getString(
335:                                    "description_suite");
336:                            int ordre = stmtRes.getResults().getInt(
337:                                    "ordre_suite");
338:                            prep2 = database.prepareStatement(prop
339:                                    .getProperty("addSuite"));
340:                            int new_famille_id = ((Integer) mapFamille
341:                                    .get(new Integer(famille_id))).intValue();
342:                            prep2.setInt(1, new_famille_id);
343:                            prep2.setString(2, nom_suite);
344:                            prep2.setString(3, desc);
345:                            prep2.setInt(4, ordre);
346:                            prep2.executeUpdate();
347:                            org.objectweb.salome_tmf.api.Api.log("Add suite "
348:                                    + nom_suite);
349:                            mapSuite.put(new Integer(id_suite), new Integer(
350:                                    Utile.getIdSuite(database, prop,
351:                                            project_id_new, new_famille_id,
352:                                            nom_suite)));
353:                        }
354:                        System.out.println(mapSuite);
355:
356:                        // 3 Ajout des Tests
357:                        prep = database.prepareStatement(prop
358:                                .getProperty("selectCasInfo"));
359:                        prep.setInt(1, project_id_from);
360:                        stmtRes = new DataSet(prep.executeQuery());
361:                        while (stmtRes.hasMoreElements()) {
362:                            int id_personne = personne_id;
363:                            int id_cas = stmtRes.getResults().getInt("id_cas");
364:                            if (users)
365:                                id_personne = stmtRes.getResults().getInt(
366:                                        "PERSONNE_id_personne");
367:
368:                            int id_suite = stmtRes.getResults().getInt(
369:                                    "SUITE_TEST_id_suite");
370:                            id_suite = ((Integer) mapSuite.get(new Integer(
371:                                    id_suite))).intValue();
372:
373:                            String nom_cas = stmtRes.getResults().getString(
374:                                    "nom_cas");
375:                            String type = stmtRes.getResults().getString(
376:                                    "type_cas");
377:                            String des = stmtRes.getResults().getString(
378:                                    "description_cas");
379:                            int ordre = stmtRes.getResults()
380:                                    .getInt("ordre_cas");
381:
382:                            prep2 = database.prepareStatement(prop
383:                                    .getProperty("addCas"));
384:                            prep2.setInt(1, id_personne);
385:                            prep2.setInt(2, id_suite);
386:                            prep2.setString(3, nom_cas);
387:                            prep2.setDate(4, dateActuelle);
388:                            prep2.setTime(5, timeActuelle);
389:                            prep2.setString(6, type);
390:                            prep2.setString(7, des);
391:                            prep2.setInt(8, ordre);
392:                            prep2.executeUpdate();
393:                            org.objectweb.salome_tmf.api.Api.log("Add cas "
394:                                    + nom_cas);
395:                            int new_id_cas = Utile.getIdCas(database, prop,
396:                                    id_suite, nom_cas);
397:                            mapCas.put(new Integer(id_cas), new Integer(
398:                                    new_id_cas));
399:
400:                            if (type.equals(AUTOMATIC)) {
401:                                int id_script = stmtRes.getResults().getInt(
402:                                        "SCRIPT_id_script");
403:                                prep2 = database.prepareStatement(prop
404:                                        .getProperty("selectScriptInfo"));
405:                                prep2.setInt(1, id_script);
406:                                stmtRes2 = new DataSet(prep2.executeQuery());
407:                                Properties prop2 = Utile
408:                                        .getPropertiesFile(SUITE_STMTS_FILE_PATH);
409:                                if (stmtRes2.getResults().next()) {
410:                                    String url = stmtRes2.getResults()
411:                                            .getString("url_script");
412:                                    String classe = stmtRes2.getResults()
413:                                            .getString("classe_autom_script");
414:                                    String classpath = stmtRes2.getResults()
415:                                            .getString("classpath_script");
416:                                    int id_attach = stmtRes2.getResults()
417:                                            .getInt("ATTACHEMENT_id_attach");
418:
419:                                    STCommun
420:                                            .addScriptToDB(database, prop2,
421:                                                    url, classe, classpath,
422:                                                    TEST_SCRIPT);
423:                                    int new_id_script = STCommun
424:                                            .getMaxIdScript(database, prop2);
425:
426:                                    java.io.File f = STCommun
427:                                            .getFileAttachFromDB(database,
428:                                                    prop2, id_attach);
429:                                    STCommun.addFileAttachToDB(database, prop2,
430:                                            f.getPath(), f.length(),
431:                                            dateActuelle, "");
432:                                    int new_id_attach = STCommun
433:                                            .getMaxIdAttach(database, prop2);
434:
435:                                    prep2 = database
436:                                            .prepareStatement(prop
437:                                                    .getProperty("addFileAttachToScript"));
438:                                    prep2.setInt(1, new_id_script);
439:                                    prep2.setInt(2, new_id_attach);
440:                                    prep2.executeUpdate();
441:
442:                                    prep2 = database.prepareStatement(prop
443:                                            .getProperty("attachScriptToTest"));
444:                                    prep2.setInt(1, new_id_script);
445:                                    prep2.setInt(2, new_id_cas);
446:                                    prep2.executeUpdate();
447:                                }
448:                            } else {
449:                                // 4 Ajout des actions
450:                                prep = database.prepareStatement(prop
451:                                        .getProperty("selectActionInfo"));
452:                                prep.setInt(1, id_cas);
453:                                stmtRes2 = new DataSet(prep.executeQuery());
454:                                while (stmtRes2.hasMoreElements()) {
455:                                    int id_action = stmtRes2.getResults()
456:                                            .getInt("id_action");
457:                                    String nom_action = stmtRes2.getResults()
458:                                            .getString("nom_action");
459:                                    String description_action = stmtRes2
460:                                            .getResults().getString(
461:                                                    "description_action");
462:                                    String res_attendu_action = stmtRes2
463:                                            .getResults().getString(
464:                                                    "res_attendu_action");
465:                                    int step = stmtRes2.getResults().getInt(
466:                                            "num_step_action");
467:
468:                                    prep2 = database.prepareStatement(prop
469:                                            .getProperty("addAction"));
470:                                    prep2.setInt(1, new_id_cas);
471:                                    prep2.setString(2, nom_action);
472:                                    prep2.setString(3, description_action);
473:                                    prep2.setString(4, res_attendu_action);
474:                                    prep2.setInt(5, step);
475:                                    prep2.executeUpdate();
476:
477:                                    mapAction.put(new Integer(id_action),
478:                                            new Integer(Utile.getIdAction(
479:                                                    database, prop, new_id_cas,
480:                                                    nom_action)));
481:                                }
482:
483:                            }
484:                        }
485:                        System.out.println("MapCas " + mapCas);
486:                        System.out.println("Map Action : " + mapAction);
487:                        // 5 Ajout des parametres
488:                        prep = database.prepareStatement(prop
489:                                .getProperty("selectParamInfo"));
490:                        prep.setInt(1, project_id_from);
491:                        stmtRes = new DataSet(prep.executeQuery());
492:                        while (stmtRes.hasMoreElements()) {
493:                            int id_param_test = stmtRes.getResults().getInt(
494:                                    "id_param_test");
495:                            String nom_param_test = stmtRes.getResults()
496:                                    .getString("nom_param_test");
497:                            String desc_param_test = stmtRes.getResults()
498:                                    .getString("desc_param_test");
499:
500:                            prep2 = database.prepareStatement(prop
501:                                    .getProperty("addParam"));
502:                            prep2.setInt(1, project_id_new);
503:                            prep2.setString(2, nom_param_test);
504:                            prep2.setString(3, desc_param_test);
505:                            prep2.executeUpdate();
506:
507:                            mapParam.put(new Integer(id_param_test),
508:                                    new Integer(Utile.getIdParam(database,
509:                                            prop, project_id_new,
510:                                            nom_param_test)));
511:                        }
512:                        System.out.println(mapParam);
513:                        // 6 Ajout de l'utilisation des paramatres aux tests
514:                        prep = database.prepareStatement(prop
515:                                .getProperty("selectParamTestUse"));
516:                        prep.setInt(1, project_id_from);
517:                        stmtRes = new DataSet(prep.executeQuery());
518:                        while (stmtRes.hasMoreElements()) {
519:                            int old_id_cas = stmtRes.getResults().getInt(
520:                                    "CAS_TEST_id_cas");
521:                            int old_id_param_test = stmtRes.getResults()
522:                                    .getInt("PARAM_TEST_id_param_test");
523:                            org.objectweb.salome_tmf.api.Api
524:                                    .log("Try to id for cas old cas "
525:                                            + old_id_cas);
526:                            org.objectweb.salome_tmf.api.Api
527:                                    .log("Try to id for parami ld parm "
528:                                            + old_id_param_test);
529:                            int new_id_cas = ((Integer) mapCas.get(new Integer(
530:                                    old_id_cas))).intValue();
531:                            int new_id_param_test = ((Integer) mapParam
532:                                    .get(new Integer(old_id_param_test)))
533:                                    .intValue();
534:                            org.objectweb.salome_tmf.api.Api
535:                                    .log("Addparam : cas " + old_id_cas
536:                                            + " <->" + new_id_cas + ", param"
537:                                            + old_id_param_test + "<->"
538:                                            + new_id_param_test);
539:                            prep2 = database.prepareStatement(prop
540:                                    .getProperty("addParamtoTest"));
541:                            prep2.setInt(1, new_id_cas);
542:                            prep2.setInt(2, new_id_param_test);
543:                            prep2.executeUpdate();
544:                        }
545:
546:                        // 7 Ajout de l'utilisation des paramatres aux actions
547:                        prep = database.prepareStatement(prop
548:                                .getProperty("selectParamActionUse"));
549:                        prep.setInt(1, project_id_from);
550:                        stmtRes = new DataSet(prep.executeQuery());
551:                        while (stmtRes.hasMoreElements()) {
552:                            int old_id_action = stmtRes.getResults().getInt(
553:                                    "ACTION_TEST_id_action");
554:                            int old_id_param_test = stmtRes.getResults()
555:                                    .getInt("PARAM_TEST_id_param_test");
556:
557:                            int new_id_action = ((Integer) mapAction
558:                                    .get(new Integer(old_id_action)))
559:                                    .intValue();
560:                            int new_id_param_test = ((Integer) mapParam
561:                                    .get(new Integer(old_id_param_test)))
562:                                    .intValue();
563:
564:                            prep2 = database.prepareStatement(prop
565:                                    .getProperty("addParamtoAction"));
566:                            prep2.setInt(1, new_id_action);
567:                            prep2.setInt(2, new_id_param_test);
568:                            prep2.executeUpdate();
569:                        }
570:
571:                    }
572:                    if (campagne && suite) {
573:                        prep = database.prepareStatement(prop
574:                                .getProperty("selectCampagneInfo"));
575:                        prep.setInt(1, project_id_from);
576:                        stmtRes = new DataSet(prep.executeQuery());
577:                        while (stmtRes.hasMoreElements()) {
578:                            int id_camp = stmtRes.getResults()
579:                                    .getInt("id_camp");
580:                            int id_personne = personne_id;
581:                            if (users)
582:                                id_personne = stmtRes.getResults().getInt(
583:                                        "PERSONNE_id_personne");
584:                            String nom_camp = stmtRes.getResults().getString(
585:                                    "nom_camp");
586:                            String description_camp = stmtRes.getResults()
587:                                    .getString("description_camp");
588:                            int ordre_camp = stmtRes.getResults().getInt(
589:                                    "ordre_camp");
590:
591:                            prep2 = database.prepareStatement(prop
592:                                    .getProperty("addCampagne"));
593:                            prep2.setInt(1, project_id_new);
594:                            prep2.setInt(2, id_personne);
595:                            prep2.setString(3, nom_camp);
596:                            prep2.setDate(4, dateActuelle);
597:                            prep2.setTime(5, timeActuelle);
598:                            prep2.setString(6, description_camp);
599:                            prep2.setInt(7, ordre_camp);
600:                            prep2.executeUpdate();
601:
602:                            mapCampagne.put(new Integer(id_camp), new Integer(
603:                                    Utile.getIdCampagne(database, prop,
604:                                            project_id_new, nom_camp)));
605:                        }
606:
607:                        // Ajout des test dans les campagnes
608:                        prep = database.prepareStatement(prop
609:                                .getProperty("selectCampagneCasInfo"));
610:                        prep.setInt(1, project_id_from);
611:                        stmtRes = new DataSet(prep.executeQuery());
612:                        while (stmtRes.hasMoreElements()) {
613:                            int old_id_camp = stmtRes.getResults().getInt(
614:                                    "CAMPAGNE_TEST_id_camp");
615:                            int old_id_cas = stmtRes.getResults().getInt(
616:                                    "CAS_TEST_id_cas");
617:                            int ordre = stmtRes.getResults().getInt(
618:                                    "ordre_cas_camp");
619:                            org.objectweb.salome_tmf.api.Api
620:                                    .log("Try to id for cas old cas "
621:                                            + old_id_cas);
622:                            int new_id_cas = ((Integer) mapCas.get(new Integer(
623:                                    old_id_cas))).intValue();
624:                            org.objectweb.salome_tmf.api.Api
625:                                    .log("Try to id for camp old cas "
626:                                            + old_id_camp);
627:                            int new_id_camp = ((Integer) mapCampagne
628:                                    .get(new Integer(old_id_camp))).intValue();
629:
630:                            prep2 = database.prepareStatement(prop
631:                                    .getProperty("addCasCampagne"));
632:                            prep2.setInt(1, new_id_camp);
633:                            prep2.setInt(2, new_id_cas);
634:                            prep2.setInt(3, ordre);
635:                            prep2.executeUpdate();
636:                        }
637:                    }
638:
639:                } catch (SQLException e) {
640:                    e.printStackTrace();
641:                    org.objectweb.salome_tmf.api.Api.addException("addFamily",
642:                            null, e);
643:                } catch (Exception ex) {
644:                    ex.printStackTrace();
645:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
646:                            ex);
647:                }
648:                org.objectweb.salome_tmf.api.Api.commitTrans(_num);
649:            }
650:
651:            /**
652:             * Ajout d'un utilisateur SalomeTMF
653:             * @param login
654:             * @param name
655:             * @param firstName
656:             * @param desc
657:             * @param email
658:             * @param tel
659:             * @param pwd
660:             */
661:            public void addPerson(String login, String name, String firstName,
662:                    String desc, String email, String tel, String pwd) {
663:
664:                // Initialisation de la date et heure actuelles
665:                Date dateActuelle = Utile.getCurrentDate();
666:                Time heureActuelle = Utile.getCurrentTime();
667:                int _num = -1;
668:                try {
669:                    _num = org.objectweb.salome_tmf.api.Api.beginTrans();
670:
671:                    PreparedStatement prep = database.prepareStatement(prop
672:                            .getProperty("addPerson"));
673:                    prep.setString(1, login);
674:                    prep.setString(2, name);
675:                    prep.setString(3, firstName);
676:                    prep.setString(4, desc);
677:                    prep.setString(5, email);
678:                    prep.setString(6, tel);
679:                    prep.setDate(7, dateActuelle);
680:                    prep.setTime(8, heureActuelle);
681:                    pwd = org.objectweb.salome_tmf.api.MD5paswd
682:                            .getEncodedPassword(pwd);
683:                    prep.setString(9, pwd);
684:                    prep.executeUpdate();
685:                } catch (SQLException e) {
686:                    e.printStackTrace();
687:                    org.objectweb.salome_tmf.api.Api.addException("addPerson",
688:                            null, e);
689:                } catch (Exception ex) {
690:                    ex.printStackTrace();
691:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
692:                            ex);
693:                }
694:                org.objectweb.salome_tmf.api.Api.commitTrans(_num);
695:            }
696:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.