Source Code Cross Referenced for CTCommun.java in  » Test-Coverage » salome-tmf » org » objectweb » salome_tmf » api » api2ihm » campTest » 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.campTest 
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 Fayçal SOUGRATI
0020:         *
0021:         * Contact: mikael.marche@rd.francetelecom.com
0022:         */
0023:
0024:        package org.objectweb.salome_tmf.api.api2ihm.campTest;
0025:
0026:        import java.sql.PreparedStatement;
0027:        import java.sql.SQLException;
0028:        import java.util.Properties;
0029:
0030:        import org.objectweb.salome_tmf.api.api2db.DataBase;
0031:        import org.objectweb.salome_tmf.api.api2db.DataSet;
0032:
0033:        /**
0034:         * CTCommun : Classes contenant les fonctions communes aux differentes classes relatives a l'aire
0035:         * fonctionnelle "Campagnes de test"
0036:         */
0037:        public class CTCommun {
0038:
0039:            /**
0040:             * Fonction qui donne l'ID d'une campagne de test à partir de son nom
0041:             * @param database
0042:             * @param prop
0043:             * @param idProject
0044:             * @param campName
0045:             * @return
0046:             */
0047:            public static int getIdCamp(DataBase database, Properties prop,
0048:                    int idProject, String campName) {
0049:                int campId = -1;
0050:                int num = -1;
0051:                try {
0052:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0053:
0054:                    PreparedStatement prep = database.prepareStatement(prop
0055:                            .getProperty("selectCampId"));
0056:                    prep.setString(1, campName);
0057:                    prep.setInt(2, idProject);
0058:                    DataSet DS = new DataSet(prep.executeQuery());
0059:
0060:                    if (DS.hasMoreElements()) {
0061:                        campId = DS.getResults().getInt("id_camp");
0062:                    } else {
0063:                        org.objectweb.salome_tmf.api.Api
0064:                                .addException(new Exception("id not exist"));
0065:                    }
0066:                } catch (SQLException e) {
0067:                    e.printStackTrace();
0068:                    org.objectweb.salome_tmf.api.Api.addException(
0069:                            "selectCampId", null, e);
0070:                } catch (Exception E) {
0071:                    E.printStackTrace();
0072:                    org.objectweb.salome_tmf.api.Api
0073:                            .addException(null, null, E);
0074:                }
0075:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0076:
0077:                return campId;
0078:            }
0079:
0080:            /**
0081:             * Fonction qui donne l'ID d'un environnement sous test à partir de son nom
0082:             * @param database
0083:             * @param prop
0084:             * @param idProject
0085:             * @param envName
0086:             * @return
0087:             */
0088:            public static int getIdEnv(DataBase database, Properties prop,
0089:                    int idProject, String envName) {
0090:                int envId = -1;
0091:                int num = -1;
0092:                try {
0093:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0094:
0095:                    PreparedStatement prep = database.prepareStatement(prop
0096:                            .getProperty("selectEnvId"));
0097:                    prep.setString(1, envName);
0098:                    prep.setInt(2, idProject);
0099:                    DataSet DS = new DataSet(prep.executeQuery());
0100:
0101:                    if (DS.hasMoreElements()) {
0102:                        envId = DS.getResults().getInt("id_env");
0103:                    } else {
0104:                        org.objectweb.salome_tmf.api.Api
0105:                                .addException(new Exception("id not exist"));
0106:                    }
0107:                } catch (SQLException e) {
0108:                    e.printStackTrace();
0109:                    org.objectweb.salome_tmf.api.Api.addException(
0110:                            "selectEnvId", null, e);
0111:                } catch (Exception E) {
0112:                    E.printStackTrace();
0113:                    org.objectweb.salome_tmf.api.Api
0114:                            .addException(null, null, E);
0115:                }
0116:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0117:
0118:                return envId;
0119:            }
0120:
0121:            /**
0122:             * Fonction qui donne l'ID d'une execution de campagne de test a partir de son nom et du nom de la
0123:             * campagne de test a laquelle elle est liée
0124:             * @param database
0125:             * @param prop
0126:             * @param idProject
0127:             * @param campName
0128:             * @param execCampName
0129:             * @return
0130:             */
0131:            public static int getIdExecCamp(DataBase database, Properties prop,
0132:                    int idProject, String campName, String execCampName) {
0133:                int execCampId = -1;
0134:                int num = -1;
0135:                try {
0136:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0137:
0138:                    PreparedStatement prep = database.prepareStatement(prop
0139:                            .getProperty("selectExecCampId"));
0140:                    prep.setString(1, campName);
0141:                    prep.setString(2, execCampName);
0142:                    prep.setInt(3, idProject);
0143:                    DataSet DS = new DataSet(prep.executeQuery());
0144:
0145:                    if (DS.hasMoreElements()) {
0146:                        execCampId = DS.getResults().getInt("id_exec_camp");
0147:                    } else {
0148:                        org.objectweb.salome_tmf.api.Api
0149:                                .addException(new Exception("id not exist"));
0150:                    }
0151:                } catch (SQLException e) {
0152:                    e.printStackTrace();
0153:                    org.objectweb.salome_tmf.api.Api.addException(
0154:                            "selectExecCampId", null, e);
0155:                } catch (Exception E) {
0156:                    E.printStackTrace();
0157:                    org.objectweb.salome_tmf.api.Api
0158:                            .addException(null, null, E);
0159:                }
0160:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0161:
0162:                return execCampId;
0163:            }
0164:
0165:            /**
0166:             * Selection de l'ID du resultat de l'execution d'une campagne de test
0167:             * @param database
0168:             * @param prop
0169:             * @param idProject
0170:             * @param campName
0171:             * @param execCampName
0172:             * @param resExecCampName
0173:             * @return
0174:             */
0175:            public static int getIdResExecCamp(DataBase database,
0176:                    Properties prop, int idProject, String campName,
0177:                    String execCampName, String resExecCampName) {
0178:                int resExecCampId = -1;
0179:                int num = -1;
0180:                try {
0181:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0182:
0183:                    PreparedStatement prep = database.prepareStatement(prop
0184:                            .getProperty("selectResExecCampId"));
0185:                    prep.setString(1, campName);
0186:                    prep.setString(2, execCampName);
0187:                    prep.setString(3, resExecCampName);
0188:                    prep.setInt(4, idProject);
0189:                    DataSet DS = new DataSet(prep.executeQuery());
0190:
0191:                    if (DS.hasMoreElements()) {
0192:                        resExecCampId = DS.getResults().getInt(
0193:                                "id_res_exec_camp");
0194:                    } else {
0195:                        org.objectweb.salome_tmf.api.Api
0196:                                .addException(new Exception("id not exist"));
0197:                    }
0198:
0199:                } catch (SQLException e) {
0200:                    e.printStackTrace();
0201:                    org.objectweb.salome_tmf.api.Api.addException(
0202:                            "selectResExecCampId", null, e);
0203:                } catch (Exception E) {
0204:                    E.printStackTrace();
0205:                    org.objectweb.salome_tmf.api.Api
0206:                            .addException(null, null, E);
0207:                }
0208:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0209:
0210:                return resExecCampId;
0211:            }
0212:
0213:            /**
0214:             * Selection de l'ID d'un resultat d'execution de campagne de test
0215:             * @param database
0216:             * @param prop
0217:             * @param idProject
0218:             * @param campName
0219:             * @param execCampName
0220:             * @param resExecCampName
0221:             * @param testId
0222:             * @return
0223:             */
0224:            public static int getIdResExecCas(DataBase database,
0225:                    Properties prop, int idProject, String campName,
0226:                    String execCampName, String resExecCampName, int testId) {
0227:                int resExecCasId = -1;
0228:                int num = -1;
0229:                try {
0230:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0231:
0232:                    PreparedStatement prep = database.prepareStatement(prop
0233:                            .getProperty("selectResExecCasId"));
0234:                    prep.setString(1, campName);
0235:                    prep.setString(2, execCampName);
0236:                    prep.setString(3, resExecCampName);
0237:                    prep.setInt(4, testId);
0238:                    prep.setInt(5, idProject);
0239:                    DataSet DS = new DataSet(prep.executeQuery());
0240:
0241:                    if (DS.hasMoreElements()) {
0242:                        resExecCasId = DS.getResults().getInt("id_exec_cas");
0243:                    } else {
0244:                        org.objectweb.salome_tmf.api.Api
0245:                                .addException(new Exception("id not exist"));
0246:                    }
0247:
0248:                } catch (SQLException e) {
0249:                    e.printStackTrace();
0250:                    org.objectweb.salome_tmf.api.Api.addException(
0251:                            "selectResExecCasId", null, e);
0252:                } catch (Exception ex) {
0253:                    ex.printStackTrace();
0254:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0255:                            ex);
0256:                }
0257:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0258:
0259:                return resExecCasId;
0260:            }
0261:
0262:            /**
0263:             * Selection de l'ID d'un resultat d'execution de campagne de test
0264:             * @param database
0265:             * @param prop
0266:             * @param idProject
0267:             * @param resExecCampId
0268:             * @param testId
0269:             * @return
0270:             */
0271:            public static int getIdResExecCasUsingID(DataBase database,
0272:                    Properties prop, int resExecCampId, int testId) {
0273:                int resExecCasId = -1;
0274:                int num = -1;
0275:                try {
0276:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0277:
0278:                    PreparedStatement prep = database.prepareStatement(prop
0279:                            .getProperty("selectResExecCasIdUsingID"));
0280:                    prep.setInt(1, resExecCampId);
0281:                    prep.setInt(2, testId);
0282:                    DataSet DS = new DataSet(prep.executeQuery());
0283:
0284:                    if (DS.hasMoreElements()) {
0285:                        resExecCasId = DS.getResults().getInt("id_exec_cas");
0286:                    } else {
0287:                        org.objectweb.salome_tmf.api.Api
0288:                                .addException(new Exception("id not exist"));
0289:                    }
0290:
0291:                } catch (SQLException e) {
0292:                    e.printStackTrace();
0293:                    org.objectweb.salome_tmf.api.Api.addException(
0294:                            "selectResExecCasId", null, e);
0295:                } catch (Exception ex) {
0296:                    ex.printStackTrace();
0297:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0298:                            ex);
0299:                }
0300:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0301:
0302:                return resExecCasId;
0303:            }
0304:
0305:            /**
0306:             * Selection de l'ID d'un parametre de test a partir de son nom et du projet auquel il appartient
0307:             * @param database
0308:             * @param prop
0309:             * @param nameParam
0310:             * @param idProject
0311:             * @return
0312:             */
0313:            public static int getIdParam(DataBase database, Properties prop,
0314:                    String nameParam, int idProject) {
0315:                int idParam = -1;
0316:                int _num = -1;
0317:                try {
0318:                    _num = org.objectweb.salome_tmf.api.Api.beginTrans();
0319:
0320:                    PreparedStatement prep = database.prepareStatement(prop
0321:                            .getProperty("selectIdParam"));
0322:                    prep.setString(1, nameParam);
0323:                    prep.setInt(2, idProject);
0324:                    DataSet DS = new DataSet(prep.executeQuery());
0325:
0326:                    if (DS.hasMoreElements()) {
0327:                        idParam = DS.getResults().getInt("id_param_test");
0328:                    } else {
0329:                        org.objectweb.salome_tmf.api.Api
0330:                                .addException(new Exception("id not exist"));
0331:                    }
0332:
0333:                } catch (SQLException e) {
0334:                    e.printStackTrace();
0335:                    org.objectweb.salome_tmf.api.Api.addException(
0336:                            "selectIdParam", null, e);
0337:                } catch (Exception ex) {
0338:                    ex.printStackTrace();
0339:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0340:                            ex);
0341:                }
0342:                org.objectweb.salome_tmf.api.Api.commitTrans(_num);
0343:                return idParam;
0344:            }
0345:
0346:            /**
0347:             * Calcul du nombre de tests d'un resultat d'execution de campagne de test 
0348:             * @param resExecCamp
0349:             * @return
0350:             */
0351:            public static int getNbResExecCampTests(DataBase database,
0352:                    Properties prop, int resExecCampId) {
0353:                int nbTests = -1;
0354:                int num = -1;
0355:                try {
0356:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0357:
0358:                    PreparedStatement prep = database.prepareStatement(prop
0359:                            .getProperty("selectResExecCampTests"));
0360:                    prep.setInt(1, resExecCampId);
0361:
0362:                    DataSet DS = new DataSet(prep.executeQuery());
0363:
0364:                    while (DS.hasMoreElements()) {
0365:                        nbTests++;
0366:                    }
0367:                } catch (SQLException e) {
0368:                    e.printStackTrace();
0369:                    org.objectweb.salome_tmf.api.Api.addException(
0370:                            "selectResExecCampTests", null, e);
0371:                } catch (Exception ex) {
0372:                    ex.printStackTrace();
0373:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0374:                            ex);
0375:                }
0376:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0377:
0378:                return nbTests;
0379:            }
0380:
0381:            public static int getIdJeuDonnees(DataBase database,
0382:                    Properties prop, int idProject, String campName,
0383:                    String jeuDonneesName) {
0384:                int idJeuDonnees = -1;
0385:                int num = -1;
0386:                try {
0387:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0388:
0389:                    PreparedStatement prep = database.prepareStatement(prop
0390:                            .getProperty("selectIdJeuDonnees"));
0391:                    prep.setString(1, campName);
0392:                    prep.setString(2, jeuDonneesName);
0393:                    prep.setInt(3, idProject);
0394:                    DataSet DS = new DataSet(prep.executeQuery());
0395:
0396:                    if (DS.hasMoreElements()) {
0397:                        idJeuDonnees = DS.getResults().getInt("id_jeu_donnees");
0398:                    } else {
0399:                        org.objectweb.salome_tmf.api.Api
0400:                                .addException(new Exception("id not exist"));
0401:                    }
0402:
0403:                } catch (SQLException e) {
0404:                    e.printStackTrace();
0405:                    org.objectweb.salome_tmf.api.Api.addException(
0406:                            "selectIdJeuDonnees", null, e);
0407:                } catch (Exception ex) {
0408:                    ex.printStackTrace();
0409:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0410:                            ex);
0411:                }
0412:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0413:
0414:                return idJeuDonnees;
0415:            }
0416:
0417:            /**
0418:             * Selection de l'Id d'un fichier attaché à une campagne
0419:             * @param database
0420:             * @param prop
0421:             * @param campaignId
0422:             * @param fileName
0423:             * @return
0424:             */
0425:            public static int getCampaignAttachFileId(DataBase database,
0426:                    Properties prop, int campaignId, String fileName) {
0427:                int fileAttachId = -1;
0428:                int num = -1;
0429:                try {
0430:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0431:
0432:                    PreparedStatement prep = database.prepareStatement(prop
0433:                            .getProperty("selectCampaignAttachFile"));
0434:                    prep.setInt(1, campaignId);
0435:                    prep.setString(2, fileName);
0436:                    DataSet DS = new DataSet(prep.executeQuery());
0437:
0438:                    if (DS.hasMoreElements()) {
0439:                        fileAttachId = DS.getResults().getInt("id_attach");
0440:                    } else {
0441:                        org.objectweb.salome_tmf.api.Api
0442:                                .addException(new Exception("id not exist"));
0443:                    }
0444:
0445:                } catch (SQLException e) {
0446:                    e.printStackTrace();
0447:                    org.objectweb.salome_tmf.api.Api.addException(
0448:                            "selectCampaignAttachFile", null, e);
0449:                } catch (Exception ex) {
0450:                    ex.printStackTrace();
0451:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0452:                            ex);
0453:                }
0454:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0455:
0456:                return fileAttachId;
0457:            }
0458:
0459:            /**
0460:             * Selection de l'Id d'une URL attachée à une campagne
0461:             * @param database
0462:             * @param prop
0463:             * @param campaignId
0464:             * @param fileName
0465:             * @return
0466:             */
0467:            public static int getCampaignAttachUrlId(DataBase database,
0468:                    Properties prop, int campaignId, String url) {
0469:                int urlAttachId = -1;
0470:                int num = -1;
0471:                try {
0472:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0473:
0474:                    PreparedStatement prep = database.prepareStatement(prop
0475:                            .getProperty("selectCampaignAttachUrl"));
0476:                    prep.setInt(1, campaignId);
0477:                    prep.setString(2, url);
0478:                    DataSet DS = new DataSet(prep.executeQuery());
0479:
0480:                    if (DS.hasMoreElements()) {
0481:                        urlAttachId = DS.getResults().getInt("id_attach");
0482:                    } else {
0483:                        org.objectweb.salome_tmf.api.Api
0484:                                .addException(new Exception("id not exist"));
0485:                    }
0486:
0487:                } catch (SQLException e) {
0488:                    e.printStackTrace();
0489:                    org.objectweb.salome_tmf.api.Api.addException(
0490:                            "selectCampaignAttachUrl", null, e);
0491:                } catch (Exception ex) {
0492:                    ex.printStackTrace();
0493:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0494:                            ex);
0495:                }
0496:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0497:
0498:                return urlAttachId;
0499:            }
0500:
0501:            /**
0502:             * Selection de l'Id d'un fichier attaché à un environnement
0503:             * @param database
0504:             * @param prop
0505:             * @param envId
0506:             * @param fileName
0507:             * @return
0508:             */
0509:            public static int getEnvAttachFileId(DataBase database,
0510:                    Properties prop, int envId, String fileName) {
0511:                int fileAttachId = -1;
0512:                int num = -1;
0513:                try {
0514:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0515:
0516:                    PreparedStatement prep = database.prepareStatement(prop
0517:                            .getProperty("selectEnvAttachFile"));
0518:                    prep.setInt(1, envId);
0519:                    prep.setString(2, fileName);
0520:                    DataSet DS = new DataSet(prep.executeQuery());
0521:
0522:                    if (DS.hasMoreElements()) {
0523:                        fileAttachId = DS.getResults().getInt("id_attach");
0524:                    } else {
0525:                        org.objectweb.salome_tmf.api.Api
0526:                                .addException(new Exception("id not exist"));
0527:                    }
0528:
0529:                } catch (SQLException e) {
0530:                    e.printStackTrace();
0531:                    org.objectweb.salome_tmf.api.Api.addException(
0532:                            "selectEnvAttachFile", null, e);
0533:                } catch (Exception ex) {
0534:                    ex.printStackTrace();
0535:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0536:                            ex);
0537:                }
0538:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0539:
0540:                return fileAttachId;
0541:            }
0542:
0543:            /**
0544:             * Selection de l'Id d'une URL attachée à un environnement
0545:             * @param database
0546:             * @param prop
0547:             * @param envId
0548:             * @param fileName
0549:             * @return
0550:             */
0551:            public static int getEnvAttachUrlId(DataBase database,
0552:                    Properties prop, int envId, String url) {
0553:                int urlAttachId = -1;
0554:                int num = -1;
0555:                try {
0556:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0557:
0558:                    PreparedStatement prep = database.prepareStatement(prop
0559:                            .getProperty("selectEnvAttachUrl"));
0560:                    prep.setInt(1, envId);
0561:                    prep.setString(2, url);
0562:                    DataSet DS = new DataSet(prep.executeQuery());
0563:
0564:                    if (DS.hasMoreElements()) {
0565:                        urlAttachId = DS.getResults().getInt("id_attach");
0566:                    } else {
0567:                        org.objectweb.salome_tmf.api.Api
0568:                                .addException(new Exception("id not exist"));
0569:                    }
0570:
0571:                } catch (SQLException e) {
0572:                    e.printStackTrace();
0573:                    org.objectweb.salome_tmf.api.Api.addException(
0574:                            "selectEnvAttachUrl", null, e);
0575:                } catch (Exception ex) {
0576:                    ex.printStackTrace();
0577:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0578:                            ex);
0579:                }
0580:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0581:
0582:                return urlAttachId;
0583:            }
0584:
0585:            /**
0586:             * Selection de l'Id d'un fichier attaché à une exécution
0587:             * @param database
0588:             * @param prop
0589:             * @param execId
0590:             * @param fileName
0591:             * @return
0592:             */
0593:            public static int getExecAttachFileId(DataBase database,
0594:                    Properties prop, int execId, String fileName) {
0595:                int fileAttachId = -1;
0596:                int num = -1;
0597:                try {
0598:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0599:
0600:                    PreparedStatement prep = database.prepareStatement(prop
0601:                            .getProperty("selectExecAttachFile"));
0602:                    prep.setInt(1, execId);
0603:                    prep.setString(2, fileName);
0604:                    DataSet DS = new DataSet(prep.executeQuery());
0605:
0606:                    if (DS.hasMoreElements()) {
0607:                        fileAttachId = DS.getResults().getInt("id_attach");
0608:                    } else {
0609:                        org.objectweb.salome_tmf.api.Api
0610:                                .addException(new Exception("id not exist"));
0611:                    }
0612:
0613:                } catch (SQLException e) {
0614:                    e.printStackTrace();
0615:                    org.objectweb.salome_tmf.api.Api.addException(
0616:                            "selectExecAttachFile", null, e);
0617:                } catch (Exception ex) {
0618:                    ex.printStackTrace();
0619:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0620:                            ex);
0621:                }
0622:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0623:
0624:                return fileAttachId;
0625:            }
0626:
0627:            /**
0628:             * Selection de l'Id d'une URL attachée à une exécution
0629:             * @param database
0630:             * @param prop
0631:             * @param execId
0632:             * @param fileName
0633:             * @return
0634:             */
0635:            public static int getExecAttachUrlId(DataBase database,
0636:                    Properties prop, int execId, String url) {
0637:                int urlAttachId = -1;
0638:                int num = -1;
0639:                try {
0640:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0641:
0642:                    PreparedStatement prep = database.prepareStatement(prop
0643:                            .getProperty("selectExecAttachUrl"));
0644:                    prep.setInt(1, execId);
0645:                    prep.setString(2, url);
0646:                    DataSet DS = new DataSet(prep.executeQuery());
0647:
0648:                    if (DS.hasMoreElements()) {
0649:                        urlAttachId = DS.getResults().getInt("id_attach");
0650:                    } else {
0651:                        org.objectweb.salome_tmf.api.Api
0652:                                .addException(new Exception("id not exist"));
0653:                    }
0654:
0655:                } catch (SQLException e) {
0656:                    e.printStackTrace();
0657:                    org.objectweb.salome_tmf.api.Api.addException(
0658:                            "selectExecAttachUrl", null, e);
0659:                } catch (Exception ex) {
0660:                    ex.printStackTrace();
0661:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0662:                            ex);
0663:                }
0664:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0665:
0666:                return urlAttachId;
0667:            }
0668:
0669:            /**
0670:             * Sélection de l'ID d'un fichier attaché à un résultat d'exécution
0671:             * @param database
0672:             * @param prop
0673:             * @param execResultId
0674:             * @param fileName
0675:             * @return
0676:             */
0677:            public static int getExecResultAttachFileId(DataBase database,
0678:                    Properties prop, int execResultId, String fileName) {
0679:                int fileAttachId = -1;
0680:                int num = -1;
0681:                try {
0682:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0683:
0684:                    PreparedStatement prep = database.prepareStatement(prop
0685:                            .getProperty("selectExecResultAttachFile"));
0686:                    prep.setInt(1, execResultId);
0687:                    prep.setString(2, fileName);
0688:                    DataSet DS = new DataSet(prep.executeQuery());
0689:
0690:                    if (DS.hasMoreElements()) {
0691:                        fileAttachId = DS.getResults().getInt("id_attach");
0692:                    } else {
0693:                        org.objectweb.salome_tmf.api.Api
0694:                                .addException(new Exception("id not exist"));
0695:                    }
0696:
0697:                } catch (SQLException e) {
0698:                    e.printStackTrace();
0699:                    org.objectweb.salome_tmf.api.Api.addException(
0700:                            "selectExecResultAttachFile", null, e);
0701:                } catch (Exception ex) {
0702:                    ex.printStackTrace();
0703:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0704:                            ex);
0705:                }
0706:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0707:
0708:                return fileAttachId;
0709:            }
0710:
0711:            /**
0712:             * Selection de l'Id d'une URL attachée à une exécution
0713:             * @param database
0714:             * @param prop
0715:             * @param execResultId
0716:             * @param fileName
0717:             * @return
0718:             */
0719:            public static int getExecResultAttachUrlId(DataBase database,
0720:                    Properties prop, int execResultId, String url) {
0721:                int urlAttachId = -1;
0722:                int num = -1;
0723:                try {
0724:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0725:
0726:                    PreparedStatement prep = database.prepareStatement(prop
0727:                            .getProperty("selectExecResultAttachUrl"));
0728:                    prep.setInt(1, execResultId);
0729:                    prep.setString(2, url);
0730:                    DataSet DS = new DataSet(prep.executeQuery());
0731:
0732:                    if (DS.hasMoreElements()) {
0733:                        urlAttachId = DS.getResults().getInt("id_attach");
0734:                    } else {
0735:                        org.objectweb.salome_tmf.api.Api
0736:                                .addException(new Exception("id not exist"));
0737:                    }
0738:
0739:                } catch (SQLException e) {
0740:                    e.printStackTrace();
0741:                    org.objectweb.salome_tmf.api.Api.addException(
0742:                            "selectExecResultAttachUrl", null, e);
0743:                } catch (Exception ex) {
0744:                    ex.printStackTrace();
0745:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0746:                            ex);
0747:                }
0748:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0749:
0750:                return urlAttachId;
0751:            }
0752:
0753:            /**
0754:             * 
0755:             * @param database
0756:             * @param prop
0757:             * @param execTestResultId
0758:             * @param fileName
0759:             * @return
0760:             */
0761:            public static int getExecTestResultAttachFileId(DataBase database,
0762:                    Properties prop, int execTestResultId, String fileName) {
0763:                int fileAttachId = -1;
0764:                int num = -1;
0765:                try {
0766:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0767:
0768:                    PreparedStatement prep = database.prepareStatement(prop
0769:                            .getProperty("selectExecTestResultAttachFile"));
0770:                    prep.setInt(1, execTestResultId);
0771:                    prep.setString(2, fileName);
0772:                    DataSet DS = new DataSet(prep.executeQuery());
0773:
0774:                    if (DS.hasMoreElements()) {
0775:                        fileAttachId = DS.getResults().getInt("id_attach");
0776:                    } else {
0777:                        org.objectweb.salome_tmf.api.Api
0778:                                .addException(new Exception("id not exist"));
0779:                    }
0780:
0781:                } catch (SQLException e) {
0782:                    e.printStackTrace();
0783:                    org.objectweb.salome_tmf.api.Api.addException(
0784:                            "selectExecTestResultAttachFile", null, e);
0785:                } catch (Exception ex) {
0786:                    ex.printStackTrace();
0787:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0788:                            ex);
0789:                }
0790:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0791:
0792:                return fileAttachId;
0793:            }
0794:
0795:            /**
0796:             * Selection de l'Id d'une URL attachée à une exécution
0797:             * @param database
0798:             * @param prop
0799:             * @param execTestResultId
0800:             * @param fileName
0801:             * @return
0802:             */
0803:            public static int getExecTestResultAttachUrlId(DataBase database,
0804:                    Properties prop, int execTestResultId, String url) {
0805:                int urlAttachId = -1;
0806:                int num = -1;
0807:                try {
0808:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0809:
0810:                    PreparedStatement prep = database.prepareStatement(prop
0811:                            .getProperty("selectExecTestResultAttachUrl"));
0812:                    prep.setInt(1, execTestResultId);
0813:                    prep.setString(2, url);
0814:                    DataSet DS = new DataSet(prep.executeQuery());
0815:
0816:                    if (DS.hasMoreElements()) {
0817:                        urlAttachId = DS.getResults().getInt("id_attach");
0818:                    } else {
0819:                        org.objectweb.salome_tmf.api.Api
0820:                                .addException(new Exception("id not exist"));
0821:                    }
0822:
0823:                } catch (SQLException e) {
0824:                    e.printStackTrace();
0825:                    org.objectweb.salome_tmf.api.Api.addException(
0826:                            "selectExecTestResultAttachUrl", null, e);
0827:                } catch (Exception ex) {
0828:                    ex.printStackTrace();
0829:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0830:                            ex);
0831:                }
0832:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0833:
0834:                return urlAttachId;
0835:            }
0836:
0837:            /**
0838:             * Fonction qui retourne le max des ID uniques des attachements présents dans la base SalomeTMF
0839:             * @param database
0840:             * @param prop
0841:             * @return
0842:             */
0843:            public static int getMaxIdScript(DataBase database, Properties prop) {
0844:                int maxIdScript = -1;
0845:                int num = -1;
0846:                try {
0847:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0848:
0849:                    PreparedStatement prep = database.prepareStatement(prop
0850:                            .getProperty("selectMaxIdScript"));
0851:                    DataSet DS = new DataSet(prep.executeQuery());
0852:
0853:                    if (DS.hasMoreElements()) {
0854:                        maxIdScript = DS.getResults().getInt("max_id_script");
0855:                    } else {
0856:                        org.objectweb.salome_tmf.api.Api
0857:                                .addException(new Exception("id not exist"));
0858:                    }
0859:
0860:                } catch (SQLException sqle) {
0861:                    sqle.printStackTrace();
0862:                    org.objectweb.salome_tmf.api.Api.addException(
0863:                            "selectMaxIdScript", null, sqle);
0864:                } catch (Exception ex) {
0865:                    ex.printStackTrace();
0866:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0867:                            ex);
0868:                }
0869:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0870:
0871:                return maxIdScript;
0872:            }
0873:
0874:            /**
0875:             * 
0876:             * @param database
0877:             * @param prop
0878:             * @param idTest
0879:             * @param scriptName
0880:             * @return
0881:             */
0882:            public static int getIdScriptExecution(DataBase database,
0883:                    Properties prop, int idExec, String scriptName, String type) {
0884:                int scriptId = -1;
0885:                int num = -1;
0886:                try {
0887:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0888:
0889:                    PreparedStatement prep = database.prepareStatement(prop
0890:                            .getProperty("selectIdScriptOfExec"));
0891:                    prep.setInt(1, idExec);
0892:                    prep.setString(2, scriptName);
0893:                    prep.setString(3, type);
0894:                    DataSet DS = new DataSet(prep.executeQuery());
0895:
0896:                    if (DS.hasMoreElements()) {
0897:                        scriptId = DS.getResults().getInt("id_script");
0898:                    } else {
0899:                        org.objectweb.salome_tmf.api.Api
0900:                                .addException(new Exception("id not exist"));
0901:                    }
0902:
0903:                } catch (SQLException e) {
0904:                    e.printStackTrace();
0905:                    org.objectweb.salome_tmf.api.Api.addException(
0906:                            "selectIdScriptOfExec", null, e);
0907:                } catch (Exception ex) {
0908:                    ex.printStackTrace();
0909:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0910:                            ex);
0911:                }
0912:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0913:
0914:                return scriptId;
0915:            }
0916:
0917:            /**
0918:             * 
0919:             * @param database
0920:             * @param prop
0921:             * @param idTest
0922:             * @param scriptName
0923:             * @return
0924:             */
0925:            public static int getIdScriptEnvironment(DataBase database,
0926:                    Properties prop, int idEnv, String scriptName) {
0927:                int scriptId = -1;
0928:                int num = -1;
0929:                try {
0930:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0931:
0932:                    PreparedStatement prep = database.prepareStatement(prop
0933:                            .getProperty("selectIdScriptOfEnvironment"));
0934:                    prep.setInt(1, idEnv);
0935:                    prep.setString(2, scriptName);
0936:                    DataSet DS = new DataSet(prep.executeQuery());
0937:
0938:                    if (DS.hasMoreElements()) {
0939:                        scriptId = DS.getResults().getInt("id_script");
0940:                    } else {
0941:                        org.objectweb.salome_tmf.api.Api
0942:                                .addException(new Exception("id not exist"));
0943:                    }
0944:
0945:                } catch (SQLException e) {
0946:                    e.printStackTrace();
0947:                    org.objectweb.salome_tmf.api.Api.addException(
0948:                            "selectIdScriptOfEnvironment", null, e);
0949:                } catch (Exception ex) {
0950:                    ex.printStackTrace();
0951:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0952:                            ex);
0953:                }
0954:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0955:
0956:                return scriptId;
0957:            }
0958:
0959:            /**
0960:             * 
0961:             * @param database
0962:             * @param prop
0963:             * @param scriptId
0964:             * @param scriptName
0965:             * @return
0966:             */
0967:            public static int getAttachIdScript(DataBase database,
0968:                    Properties prop, int scriptId, String scriptName) {
0969:                int scriptAttachId = -1;
0970:                int num = -1;
0971:                try {
0972:                    num = org.objectweb.salome_tmf.api.Api.beginTrans();
0973:
0974:                    PreparedStatement prep = database.prepareStatement(prop
0975:                            .getProperty("selectScriptAttachId"));
0976:                    prep.setInt(1, scriptId);
0977:                    DataSet DS = new DataSet(prep.executeQuery());
0978:
0979:                    if (DS.hasMoreElements()) {
0980:                        scriptAttachId = DS.getResults().getInt(
0981:                                "ATTACHEMENT_id_attach");
0982:                    } else {
0983:                        org.objectweb.salome_tmf.api.Api
0984:                                .addException(new Exception("id not exist"));
0985:                    }
0986:
0987:                } catch (SQLException e) {
0988:                    e.printStackTrace();
0989:                    org.objectweb.salome_tmf.api.Api.addException(
0990:                            "selectScriptAttachId", null, e);
0991:                } catch (Exception ex) {
0992:                    ex.printStackTrace();
0993:                    org.objectweb.salome_tmf.api.Api.addException(null, null,
0994:                            ex);
0995:                }
0996:                org.objectweb.salome_tmf.api.Api.commitTrans(num);
0997:
0998:                return scriptAttachId;
0999:            }
1000:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.