Source Code Cross Referenced for SQLExecutionTestResult.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) 


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 Marche Mikael
020:         *
021:         * Contact: mikael.marche@rd.francetelecom.com
022:         */
023:
024:        package org.objectweb.salome_tmf.databaseSQL;
025:
026:        import java.net.URL;
027:        import java.sql.PreparedStatement;
028:        import java.sql.ResultSet;
029:        import java.util.Vector;
030:
031:        import org.objectweb.salome_tmf.api.Api;
032:        import org.objectweb.salome_tmf.api.ApiConstants;
033:        import org.objectweb.salome_tmf.api.Permission;
034:        import org.objectweb.salome_tmf.api.Util;
035:        import org.objectweb.salome_tmf.api.data.AttachementWrapper;
036:        import org.objectweb.salome_tmf.api.data.DataUpToDateException;
037:        import org.objectweb.salome_tmf.api.data.ExecutionResultTestWrapper;
038:        import org.objectweb.salome_tmf.api.data.FileAttachementWrapper;
039:        import org.objectweb.salome_tmf.api.data.SalomeFileWrapper;
040:        import org.objectweb.salome_tmf.api.data.UrlAttachementWrapper;
041:        import org.objectweb.salome_tmf.api.sql.ISQLExecutionTestResult;
042:
043:        public class SQLExecutionTestResult implements  ISQLExecutionTestResult {
044:
045:            /**
046:             * Insert an execution test result (table EXEC_CAS) for the execution result idExecRes and test idTest
047:             * @param idExecRes
048:             * @param idTest
049:             * @param result ('PASSED', 'FAILED', 'INCONCLUSIF'  @see ApiConstants)  	
050:             * @return the id of the execution test result in the table EXEC_CAS
051:             * @throws Exception
052:             * need permission canExecutCamp
053:             */
054:            public int insert(int idExecRes, int idTest, String result)
055:                    throws Exception {
056:                if (idExecRes < 1 || idTest < 1) {
057:                    throw new Exception(
058:                            "[SQLExecutionTestResult->insert] entry data are not valid");
059:                }
060:                int idRestestExec = -1;
061:                int transNumber = -1;
062:                if (!SQLEngine.specialAllow) {
063:                    if (!(Permission.canExecutCamp())) {
064:                        throw new SecurityException(
065:                                "[SQLExecutionTestResult : insert -> canExecutCamp]");
066:                    }
067:                }
068:                if (SQLObjectFactory.getInstanceOfISQLExecutionResult()
069:                        .getWrapper(idExecRes) == null) {
070:                    throw new DataUpToDateException();
071:                }
072:                if (SQLObjectFactory.getInstanceOfISQLTest().getTest(idTest) == null) {
073:                    throw new DataUpToDateException();
074:                }
075:                try {
076:                    transNumber = SQLEngine.beginTransaction(110,
077:                            ApiConstants.INSERT_EXECUTION_TEST_RESULT);
078:
079:                    PreparedStatement prep = SQLEngine
080:                            .getSQLAddQuery("addResExecCas"); //ok
081:                    prep.setInt(1, idExecRes);
082:                    prep.setInt(2, idTest);
083:                    prep.setString(3, result);
084:                    SQLEngine.runAddQuery(prep);
085:
086:                    idRestestExec = getID(idExecRes, idTest);
087:                    SQLEngine.commitTrans(transNumber);
088:                } catch (Exception e) {
089:                    Util.log("[SQLExecutionTestResult->insert]" + e);
090:                    if (Api.isDEBUG()) {
091:                        e.printStackTrace();
092:                    }
093:                    SQLEngine.rollBackTrans(transNumber);
094:                    throw e;
095:                }
096:                return idRestestExec;
097:            }
098:
099:            /**
100:             * Attach an url to the execution test result  identified by idExecRes and idTest(table EXEC_CAS_ATTACH)
101:             * @param idExecRes
102:             * @param idTest
103:             * @param url
104:             * @param description
105:             * @return the Id of the attachment in the table ATTACHEMENT
106:             * @throws Exception
107:             * @see ISQLUrlAttachment.insert(String, String)
108:             * no permission needed
109:             */
110:            public int addAttachUrl(int idExecRes, int idTest, String url,
111:                    String description) throws Exception {
112:                int idAttach = -1;
113:                int idRestestExec = getID(idExecRes, idTest);
114:                if (idRestestExec != -1) {
115:                    idAttach = addAttachUrl(idRestestExec, url, description);
116:                }
117:                return idAttach;
118:            }
119:
120:            /**
121:             * Attach an url to the execution test result identified by idRestestExec (table EXEC_CAS_ATTACH)
122:             * @param idRestestExec
123:             * @param url
124:             * @param description
125:             * @return the Id of the attachment in the table ATTACHEMENT
126:             * @throws Exception
127:             * @see ISQLUrlAttachment.insert(String, String)
128:             * no permission needed
129:             */
130:            public int addAttachUrl(int idRestestExec, String url,
131:                    String description) throws Exception {
132:                if (idRestestExec < 1 || url == null) {
133:                    throw new Exception(
134:                            "[SQLExecutionTestResult->addAttachUrl] entry data are not valid");
135:                }
136:                int transNumber = -1;
137:                int idAttach = -1;
138:                if (getWrapper(idRestestExec) == null) {
139:                    throw new DataUpToDateException();
140:                }
141:                try {
142:                    transNumber = SQLEngine.beginTransaction(10,
143:                            ApiConstants.INSERT_ATTACHMENT);
144:                    idAttach = SQLObjectFactory
145:                            .getInstanceOfISQLUrlAttachment().insert(url,
146:                                    description);
147:
148:                    PreparedStatement prep = SQLEngine
149:                            .getSQLAddQuery("addUrlAttachToExecTestResult"); //ok
150:                    prep.setInt(1, idRestestExec);
151:                    prep.setInt(2, idAttach);
152:                    SQLEngine.runAddQuery(prep);
153:
154:                    SQLEngine.commitTrans(transNumber);
155:                } catch (Exception e) {
156:                    Util.log("[SQLExecutionTestResult->addAttachUrl]" + e);
157:                    if (Api.isDEBUG()) {
158:                        e.printStackTrace();
159:                    }
160:                    SQLEngine.rollBackTrans(transNumber);
161:                    throw e;
162:                }
163:
164:                return idAttach;
165:            }
166:
167:            /**
168:             * Attach a file to the execution test result identified by idExecRes and idTest (table EXEC_CAS_ATTACH)
169:             * @param idExecRes
170:             * @param idTest
171:             * @param file
172:             * @param description
173:             * @return the Id of the attachment in the table ATTACHEMENT
174:             * @throws Exception
175:             * @see ISQLFileAttachment.insert(File, String)
176:             * no permission needed
177:             */
178:            public int addAttachFile(int idExecRes, int idTest,
179:                    SalomeFileWrapper file, String description)
180:                    throws Exception {
181:                int idAttach = -1;
182:                int idRestestExec = getID(idExecRes, idTest);
183:                if (idRestestExec != -1) {
184:                    idAttach = addAttachFile(idRestestExec, file, description);
185:                }
186:                return idAttach;
187:            }
188:
189:            /**
190:             * Attach a file to the execution test result identified by idRestestExec (table EXEC_CAS_ATTACH)
191:             * @param idRestestExec
192:             * @param file
193:             * @param description
194:             * @return the Id of the attachment in the table ATTACHEMENT
195:             * @throws Exception
196:             * @see ISQLFileAttachment.insert(File, String)
197:             * no permission needed
198:             */
199:            public int addAttachFile(int idRestestExec, SalomeFileWrapper file,
200:                    String description) throws Exception {
201:                if (idRestestExec < 1 || file == null) {
202:                    throw new Exception(
203:                            "[SQLExecutionTestResult->addAttachFile] entry data are not valid "
204:                                    + idRestestExec + ", " + file);
205:                }
206:                int transNumber = -1;
207:                int idAttach = -1;
208:                if (getWrapper(idRestestExec) == null) {
209:                    throw new DataUpToDateException();
210:                }
211:                try {
212:                    transNumber = SQLEngine.beginTransaction(10,
213:                            ApiConstants.INSERT_ATTACHMENT);
214:                    idAttach = SQLObjectFactory
215:                            .getInstanceOfISQLFileAttachment().insert(file,
216:                                    description);
217:
218:                    PreparedStatement prep = SQLEngine
219:                            .getSQLAddQuery("addFileAttachToExecTestResult"); //ok
220:                    prep.setInt(1, idRestestExec);
221:                    prep.setInt(2, idAttach);
222:                    SQLEngine.runAddQuery(prep);
223:
224:                    SQLEngine.commitTrans(transNumber);
225:                } catch (Exception e) {
226:                    Util.log("[SQLExecutionTestResult->addAttachFile]" + e);
227:                    if (Api.isDEBUG()) {
228:                        e.printStackTrace();
229:                    }
230:                    SQLEngine.rollBackTrans(transNumber);
231:                    throw e;
232:                }
233:                return idAttach;
234:            }
235:
236:            /**
237:             * Update the result of an execution test result identified by idExecRes and idTest 
238:             * @param idExecRes
239:             * @param idTest
240:             * @param result
241:             * @throws Exception
242:             * need permission canExecutCamp
243:             */
244:            public void update(int idExecRes, int idTest, String result)
245:                    throws Exception {
246:                int idRestestExec = getID(idExecRes, idTest);
247:                if (idRestestExec != -1) {
248:                    update(idRestestExec, result);
249:                }
250:            }
251:
252:            /**
253:             * Update the result of an execution test result identified by idRestestExec
254:             * @param idRestestExec
255:             * @param result
256:             * @throws Exception
257:             * need permission canExecutCamp
258:             */
259:            public void update(int idRestestExec, String result)
260:                    throws Exception {
261:                if (idRestestExec < 1) {
262:                    throw new Exception(
263:                            "[SQLExecutionTestResult->update] entry data are not valid");
264:                }
265:                int transNumber = -1;
266:                if (!SQLEngine.specialAllow) {
267:                    if (!(Permission.canExecutCamp())) {
268:                        throw new SecurityException(
269:                                "[SQLExecutionTestResult : insert -> canExecutCamp]");
270:                    }
271:                }
272:                try {
273:                    transNumber = SQLEngine.beginTransaction(10,
274:                            ApiConstants.UPDATE_EXECUTION_TEST_RESULT);
275:
276:                    PreparedStatement prep = SQLEngine
277:                            .getSQLUpdateQuery("updateTestStatusForExecResult2"); //ok
278:                    prep.setString(1, result);
279:                    prep.setInt(2, idRestestExec);
280:                    SQLEngine.runUpdateQuery(prep);
281:
282:                    SQLEngine.commitTrans(transNumber);
283:                } catch (Exception e) {
284:                    Util.log("[SQLExecutionTestResult->update]" + e);
285:                    if (Api.isDEBUG()) {
286:                        e.printStackTrace();
287:                    }
288:                    SQLEngine.rollBackTrans(transNumber);
289:                    throw e;
290:                }
291:            }
292:
293:            /**
294:             * Delete the referenced execution test result identified by idExecRes and idTest
295:             * @param idResExec
296:             * @param idTest
297:             * @throws Exception
298:             * @see delete(int)
299:             * need permission canExecutCamp
300:             */
301:            public void delete(int idResExec, int idTest) throws Exception {
302:                if (!SQLEngine.specialAllow) {
303:                    if (!(Permission.canExecutCamp())) {
304:                        throw new SecurityException(
305:                                "[SQLExecutionTestResult : delete -> canExecutCamp]");
306:                    }
307:                }
308:                int idRestestExec = getID(idResExec, idTest);
309:                if (idRestestExec != -1) {
310:                    delete(idRestestExec);
311:                }
312:            }
313:
314:            /**
315:             * Delete all referenced execution test result for the execution result idExecRes
316:             * @param idExecRes
317:             * @throws Exception
318:             * @see delete(int)
319:             * need permission canExecutCamp
320:             */
321:            public void deleteAllFrom(int idExecRes) throws Exception {
322:                if (idExecRes < 1) {
323:                    throw new Exception(
324:                            "[SQLExecutionTestResult->deleteAllFrom] entry data are not valid");
325:                }
326:                int transNumber = -1;
327:                if (!SQLEngine.specialAllow) {
328:                    if (!(Permission.canExecutCamp())) {
329:                        throw new SecurityException(
330:                                "[SQLExecutionTestResult : deleteAllFrom -> canExecutCamp]");
331:                    }
332:                }
333:                try {
334:                    transNumber = SQLEngine.beginTransaction(10,
335:                            ApiConstants.DELETE_EXECUTION_TEST_RESULT);
336:
337:                    PreparedStatement prep = SQLEngine
338:                            .getSQLSelectQuery("selectResExecCampTests"); //ok
339:                    prep.setInt(1, idExecRes);
340:                    ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
341:
342:                    while (stmtRes.next()) {
343:                        int idRestestExec = stmtRes.getInt("id_exec_cas");
344:                        delete(idRestestExec);
345:                    }
346:
347:                    SQLEngine.commitTrans(transNumber);
348:                } catch (Exception e) {
349:                    Util.log("[SQLExecutionTestResult->deleteAllFrom]" + e);
350:                    if (Api.isDEBUG()) {
351:                        e.printStackTrace();
352:                    }
353:                    SQLEngine.rollBackTrans(transNumber);
354:                    throw e;
355:                }
356:
357:            }
358:
359:            /**
360:             * Delete the execution test result identified by idRestestExec
361:             * Then delete all the attachements and Action results.
362:             * @param idRestestExec
363:             * @throws Exception
364:             * @see ISQLExecutionActionResult.deleteAll(int)
365:             * need permission canExecutCamp
366:             */
367:            public void delete(int idRestestExec) throws Exception {
368:                if (idRestestExec < 1) {
369:                    throw new Exception(
370:                            "[SQLExecutionTestResult->delete] entry data are not valid");
371:                }
372:                int transNumber = -1;
373:                if (!SQLEngine.specialAllow) {
374:                    if (!(Permission.canExecutCamp())) {
375:                        throw new SecurityException(
376:                                "[SQLExecutionTestResult : delete -> canExecutCamp]");
377:                    }
378:                }
379:                try {
380:                    transNumber = SQLEngine.beginTransaction(10,
381:                            ApiConstants.DELETE_EXECUTION_TEST_RESULT);
382:
383:                    //Delete Action results
384:                    SQLObjectFactory.getInstanceOfISQLExecutionActionResult()
385:                            .deleteAll(idRestestExec);
386:
387:                    //DeleteAttachs
388:                    deleteAllAttach(idRestestExec);
389:
390:                    PreparedStatement prep = SQLEngine
391:                            .getSQLDeleteQuery("deleteResExecTest"); //ok
392:                    prep.setInt(1, idRestestExec);
393:                    SQLEngine.runDeleteQuery(prep);
394:
395:                    SQLEngine.commitTrans(transNumber);
396:                } catch (Exception e) {
397:                    Util.log("[SQLExecutionTestResult->delete]" + e);
398:                    if (Api.isDEBUG()) {
399:                        e.printStackTrace();
400:                    }
401:                    SQLEngine.rollBackTrans(transNumber);
402:                    throw e;
403:                }
404:            }
405:
406:            /**
407:             * Delete all attchements of the execution test result identified by idRestestExec
408:             * @param idRestestExec
409:             * @throws Exception
410:             * no permission needed
411:             */
412:            public void deleteAllAttach(int idRestestExec) throws Exception {
413:                if (idRestestExec < 1) {
414:                    throw new Exception(
415:                            "[SQLExecutionTestResult->deleteAllAttach] entry data are not valid");
416:                }
417:                int transNumber = -1;
418:                try {
419:                    transNumber = SQLEngine.beginTransaction(10,
420:                            ApiConstants.DELETE_ATTACHMENT);
421:
422:                    AttachementWrapper[] attachList = getAttachs(idRestestExec);
423:                    for (int i = 0; i < attachList.length; i++) {
424:                        AttachementWrapper pAttachementWrapper = attachList[i];
425:                        deleteAttach(idRestestExec, pAttachementWrapper
426:                                .getIdBDD());
427:                    }
428:
429:                    SQLEngine.commitTrans(transNumber);
430:                } catch (Exception e) {
431:                    Util.log("[SQLExecutionTestResult->deleteAllAttach]" + e);
432:                    if (Api.isDEBUG()) {
433:                        e.printStackTrace();
434:                    }
435:                    SQLEngine.rollBackTrans(transNumber);
436:                    throw e;
437:                }
438:            }
439:
440:            /**
441:             * Delete an attchement idAttach of the execution test result identified by idResExec and idTest
442:             * @param idResExec
443:             * @param idTest
444:             * @param idAttach
445:             * @throws Exception
446:             */
447:            public void deleteAttach(int idResExec, int idTest, int idAttach)
448:                    throws Exception {
449:                if (idResExec < 1 || idTest < 1 || idAttach < 1) {
450:                    throw new Exception(
451:                            "[SQLExecutionTestResult->deleteAttach] entry data are not valid");
452:                }
453:                int idRestestExec = getID(idResExec, idTest);
454:                if (idRestestExec != -1) {
455:                    deleteAttach(idRestestExec, idAttach);
456:                }
457:            }
458:
459:            /**
460:             * Delete an attchement idAttach of the execution test result identified by idRestestExec
461:             * @param idRestestExec
462:             * @param idAttach
463:             * @throws Exception
464:             */
465:            public void deleteAttach(int idRestestExec, int idAttach)
466:                    throws Exception {
467:                if (idRestestExec < 1 || idAttach < 1) {
468:                    throw new Exception(
469:                            "[SQLExecutionTestResult->deleteAttach] entry data are not valid");
470:                }
471:                int transNumber = -1;
472:                try {
473:                    transNumber = SQLEngine.beginTransaction(10,
474:                            ApiConstants.DELETE_ATTACHMENT);
475:
476:                    PreparedStatement prep = SQLEngine
477:                            .getSQLDeleteQuery("deleteAttachFromExecTestResult"); //ok
478:                    prep.setInt(1, idAttach);
479:                    prep.setInt(2, idRestestExec);
480:                    SQLEngine.runDeleteQuery(prep);
481:
482:                    SQLObjectFactory.getInstanceOfISQLAttachment().delete(
483:                            idAttach);
484:
485:                    SQLEngine.commitTrans(transNumber);
486:                } catch (Exception e) {
487:                    Util.log("[SQLExecutionTestResult->deleteAttach]" + e);
488:                    if (Api.isDEBUG()) {
489:                        e.printStackTrace();
490:                    }
491:                    SQLEngine.rollBackTrans(transNumber);
492:                    throw e;
493:                }
494:            }
495:
496:            /**
497:             * Get a vector of FileAttachementWrapper representing the files attachment
498:             * execution test result identified by idResExec and idTest
499:             * @param idResExec
500:             * @param idTest
501:             * @return
502:             * @throws Exception
503:             */
504:            public FileAttachementWrapper[] getAttachFiles(int idResExec,
505:                    int idTest) throws Exception {
506:                if (idResExec < 1 || idTest < 1) {
507:                    throw new Exception(
508:                            "[SQLExecutionTestResult->getAttachFiles] entry data are not valid");
509:                }
510:                int idRestestExec = getID(idResExec, idTest);
511:                return getAttachFiles(idRestestExec);
512:            }
513:
514:            /**
515:             * Get a vector of FileAttachementWrapper representing the files attachment 
516:             * of the execution test result identified by idRestestExec
517:             * @param idRestestExec
518:             * @return
519:             * @throws Exception
520:             */
521:            public FileAttachementWrapper[] getAttachFiles(int idRestestExec)
522:                    throws Exception {
523:                if (idRestestExec < 1) {
524:                    throw new Exception(
525:                            "[SQLExecutionTestResult->getAttachFiles] entry data are not valid");
526:                }
527:                Vector result = new Vector();
528:                PreparedStatement prep = SQLEngine
529:                        .getSQLSelectQuery("selectAllExecTestResultAttchFile"); //ok
530:                prep.setInt(1, idRestestExec);
531:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
532:
533:                while (stmtRes.next()) {
534:                    FileAttachementWrapper fileAttach = new FileAttachementWrapper();
535:                    fileAttach.setName(stmtRes.getString("nom_attach"));
536:                    fileAttach.setLocalisation("");
537:                    fileAttach.setDate(stmtRes.getDate("date_attachement"));
538:                    fileAttach.setSize(new Long(stmtRes
539:                            .getLong("taille_attachement")));
540:                    fileAttach.setDescription(stmtRes
541:                            .getString("description_attach"));
542:                    fileAttach.setIdBDD(stmtRes.getInt("id_attach"));
543:                    result.addElement(fileAttach);
544:                }
545:
546:                FileAttachementWrapper[] fawArray = new FileAttachementWrapper[result
547:                        .size()];
548:                for (int i = 0; i < result.size(); i++) {
549:                    fawArray[i] = (FileAttachementWrapper) result.get(i);
550:                }
551:                return fawArray;
552:            }
553:
554:            /**
555:             * Get a vector of UrlAttachementWrapper representing the Urls attachment 
556:             * of the execution test result identified by idResExec and idTest
557:             * @param idResExec
558:             * @param idTest
559:             * @return
560:             * @throws Exception
561:             */
562:            public UrlAttachementWrapper[] getAttachUrls(int idResExec,
563:                    int idTest) throws Exception {
564:                if (idResExec < 1 || idTest < 1) {
565:                    throw new Exception(
566:                            "[SQLExecutionTestResult->getAttachUrls] entry data are not valid");
567:                }
568:                int idRestestExec = getID(idResExec, idTest);
569:                return getAttachUrls(idRestestExec);
570:            }
571:
572:            /**
573:             * Get a vector of UrlAttachementWrapper representing the Urls attachment 
574:             * of the execution test result identified by idRestestExec
575:             * @param idRestestExec
576:             * @return
577:             * @throws Exception
578:             */
579:            public UrlAttachementWrapper[] getAttachUrls(int idRestestExec)
580:                    throws Exception {
581:                if (idRestestExec < 1) {
582:                    throw new Exception(
583:                            "[SQLExecutionTestResult->getAttachUrls] entry data are not valid");
584:                }
585:                Vector result = new Vector();
586:                PreparedStatement prep = SQLEngine
587:                        .getSQLSelectQuery("selectAllExecTestResultAttchURL"); //ok
588:                prep.setInt(1, idRestestExec);
589:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
590:
591:                while (stmtRes.next()) {
592:                    UrlAttachementWrapper pUrlAttachment = new UrlAttachementWrapper();
593:                    String url = stmtRes.getString("url_attach");
594:                    //			pUrlAttachment.setUrl(url);
595:                    pUrlAttachment.setName(url);
596:                    pUrlAttachment.setDescription(stmtRes
597:                            .getString("description_attach"));
598:                    ;
599:                    pUrlAttachment.setIdBDD(stmtRes.getInt("id_attach"));
600:                    result.addElement(pUrlAttachment);
601:                }
602:                UrlAttachementWrapper[] uawArray = new UrlAttachementWrapper[result
603:                        .size()];
604:                for (int i = 0; i < result.size(); i++) {
605:                    uawArray[i] = (UrlAttachementWrapper) result.get(i);
606:                }
607:
608:                return uawArray;
609:            }
610:
611:            /**
612:             * Get a vector of all attachments (AttachementWrapper, File or Url) 
613:             * of the execution test result identified by idResExec and idTest
614:             * @param idResExec
615:             * @param idTest
616:             * @return
617:             * @throws Exception
618:             */
619:            public AttachementWrapper[] getAttachs(int idResExec, int idTest)
620:                    throws Exception {
621:                if (idResExec < 1 || idTest < 1) {
622:                    throw new Exception(
623:                            "[SQLExecutionTestResult->getAttachs] entry data are not valid");
624:                }
625:                int idRestestExec = getID(idResExec, idTest);
626:                return getAttachs(idRestestExec);
627:            }
628:
629:            /**
630:             * Get a vector of all attachments (AttachementWrapper, File or Url) 
631:             * of the execution test result identified by idRestestExec
632:             * @param idRestestExec
633:             * @return
634:             * @throws Exception
635:             */
636:            public AttachementWrapper[] getAttachs(int idRestestExec)
637:                    throws Exception {
638:                if (idRestestExec < 1) {
639:                    throw new Exception(
640:                            "[SQLExecutionTestResult->getAttachs] entry data are not valid");
641:                }
642:
643:                FileAttachementWrapper[] fileList = getAttachFiles(idRestestExec);
644:                UrlAttachementWrapper[] urlList = getAttachUrls(idRestestExec);
645:
646:                AttachementWrapper[] result = new AttachementWrapper[fileList.length
647:                        + urlList.length];
648:
649:                for (int i = 0; i < fileList.length; i++) {
650:                    result[i] = fileList[i];
651:                }
652:                for (int i = 0; i < urlList.length; i++) {
653:                    result[fileList.length + i] = urlList[i];
654:                }
655:
656:                return result;
657:            }
658:
659:            /**
660:             * Get the id * of the execution test result identified by idResExec and idTest
661:             * @param idResExec
662:             * @param idTest
663:             * @return
664:             * @throws Exception
665:             */
666:            public int getID(int idResExec, int idTest) throws Exception {
667:                if (idResExec < 1 || idTest < 1) {
668:                    throw new Exception(
669:                            "[SQLExecutionTestResult->getID] entry data are not valid");
670:                }
671:                int idRestestExec = -1;
672:                PreparedStatement prep = SQLEngine
673:                        .getSQLSelectQuery("selectResExecTest"); //ok from execution result
674:                prep.setInt(1, idResExec);
675:                prep.setInt(2, idTest);
676:                ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
677:
678:                if (stmtRes.next()) {
679:                    idRestestExec = stmtRes.getInt("id_exec_cas");
680:                }
681:                return idRestestExec;
682:            }
683:
684:            ExecutionResultTestWrapper getWrapper(int idResExecTest)
685:                    throws Exception {
686:                if (idResExecTest < 1) {
687:                    throw new Exception(
688:                            "[SQLExecutionTestResult->getWrapper] entry data are not valid");
689:                }
690:                ExecutionResultTestWrapper pExcutionResultTestWrapper = null;
691:                int transNuber = -1;
692:                try {
693:                    transNuber = SQLEngine.beginTransaction(10,
694:                            ApiConstants.LOADING);
695:
696:                    PreparedStatement prep = SQLEngine
697:                            .getSQLSelectQuery("selectResExecTestByID"); //ok
698:                    prep.setInt(1, idResExecTest);
699:                    ResultSet stmtRes = SQLEngine.runSelectQuery(prep);
700:
701:                    if (stmtRes.next()) {
702:                        pExcutionResultTestWrapper = new ExecutionResultTestWrapper();
703:                        pExcutionResultTestWrapper.setIdBDD(idResExecTest);
704:                        pExcutionResultTestWrapper.setOrder(stmtRes
705:                                .getInt("ordre_exec_cas"));
706:                        pExcutionResultTestWrapper.setIdResExec(stmtRes
707:                                .getInt("RES_EXEC_CAMP_id_res_exec_camp"));
708:                        pExcutionResultTestWrapper.setStatus(stmtRes
709:                                .getString("res_exec_cas"));
710:                    }
711:
712:                    SQLEngine.commitTrans(transNuber);
713:                } catch (Exception e) {
714:                    SQLEngine.rollBackTrans(transNuber);
715:                    throw e;
716:                }
717:                return pExcutionResultTestWrapper;
718:            }
719:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.