Source Code Cross Referenced for Requirement.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » requirements » data » 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 » salomeTMF_plug.requirements.data 
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 salomeTMF_plug.requirements.data;
025:
026:        import java.io.File;
027:        import java.util.ArrayList;
028:        import java.util.Enumeration;
029:        import java.util.Hashtable;
030:        import java.util.Vector;
031:
032:        import org.jfree.chart.ChartFactory;
033:        import org.jfree.chart.ChartUtilities;
034:        import org.jfree.chart.JFreeChart;
035:        import org.jfree.data.general.DefaultPieDataset;
036:        import org.objectweb.salome_tmf.api.ApiConstants;
037:        import org.objectweb.salome_tmf.api.data.FileAttachementWrapper;
038:        import org.objectweb.salome_tmf.api.data.SalomeFileWrapper;
039:        import org.objectweb.salome_tmf.api.data.TestWrapper;
040:        import org.objectweb.salome_tmf.api.data.UrlAttachementWrapper;
041:        import org.objectweb.salome_tmf.data.Attachment;
042:        import org.objectweb.salome_tmf.data.Campaign;
043:        import org.objectweb.salome_tmf.data.ExecutionResult;
044:        import org.objectweb.salome_tmf.data.FileAttachment;
045:        import org.objectweb.salome_tmf.data.Test;
046:        import org.objectweb.salome_tmf.data.UrlAttachment;
047:        import org.objectweb.salome_tmf.data.WithAttachment;
048:        import org.objectweb.salome_tmf.ihm.languages.Language;
049:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
050:
051:        import salomeTMF_plug.requirements.ReqPlugin;
052:        import salomeTMF_plug.requirements.sqlWrapper.HistoryWrapper;
053:        import salomeTMF_plug.requirements.sqlWrapper.ISQLRequirement;
054:        import salomeTMF_plug.requirements.sqlWrapper.ReqWrapper;
055:        import salomeTMF_plug.requirements.sqlWrapper.SQLWrapper;
056:
057:        public abstract class Requirement extends WithAttachment {
058:
059:            protected Requirement m_parent;
060:            static ISQLRequirement pSQLRequirement;
061:
062:            public static boolean coverChange = true;
063:
064:            public Requirement(String name, String description,
065:                    Requirement parent) {
066:                super (name, description);
067:                m_parent = parent;
068:                if (pSQLRequirement == null) {
069:                    pSQLRequirement = SQLWrapper.getSQLRequirement();
070:                }
071:            }
072:
073:            /*public Requirement(String name, String description){
074:            	super(name, description, null);
075:            }*/
076:
077:            public Requirement getParent() {
078:                return m_parent;
079:            }
080:
081:            public void setParent(Requirement parent) {
082:                m_parent = parent;
083:            }
084:
085:            public abstract boolean isFamilyReq();
086:
087:            public abstract String getLongName();
088:
089:            /******************** Basic Operation *************************/
090:            abstract public Requirement getCopie(ReqFamily pReqFamily);
091:
092:            abstract public void addInDB() throws Exception;
093:
094:            abstract public void addTestCoverInDB(int idTest, boolean verifie)
095:                    throws Exception;
096:
097:            public void updateDescriptionInModel(String _description) {
098:                description = _description;
099:            }
100:
101:            public void updateDescriptionInDB(String _description)
102:                    throws Exception {
103:                if (!isInBase()) {
104:                    throw new Exception(
105:                            "[Requirement->updateDescriptionInDB] requirement is not in DB");
106:                }
107:                pSQLRequirement.updateDescription(idBdd, _description);
108:            }
109:
110:            public void updateDescriptionInDBAndModel(String _description)
111:                    throws Exception {
112:                if (_description.trim().equals(description.trim())) {
113:                    return;
114:                }
115:                updateDescriptionInDB(_description);
116:                updateDescriptionInModel(_description);
117:            }
118:
119:            public void updateNameInModel(String _name) {
120:                name = _name;
121:            }
122:
123:            public void updateNameInDB(String _name) throws Exception {
124:                if (!isInBase()) {
125:                    throw new Exception(
126:                            "[Requirement->updateDescriptionInDB] requirement is not in DB");
127:                }
128:                pSQLRequirement.updateName(idBdd, _name, m_parent.getIdBdd(),
129:                        ReqPlugin.getProjectRef().getIdBdd());
130:            }
131:
132:            public void updateNameInDBAndModel(String _name) throws Exception {
133:                if (_name.trim().equals(name.trim())) {
134:                    return;
135:                }
136:                updateNameInDB(_name);
137:                updateNameInModel(_name);
138:            }
139:
140:            public void updateInDBAndModel(String newName, String newDesc)
141:                    throws Exception {
142:                updateNameInDBAndModel(newName);
143:                updateDescriptionInDBAndModel(newDesc);
144:            }
145:
146:            public void updateParentInDB(ReqFamily _parent) throws Exception {
147:                if (!isInBase()) {
148:                    throw new Exception(
149:                            "[Requirement->updateParentInDB] requirement is not in DB");
150:                }
151:                int idParent = _parent.getIdBdd();
152:
153:                String tmpName = name;
154:                boolean trouve = false;
155:                int j = 0;
156:                while (!trouve) {
157:                    ReqWrapper pReqWrapper = pSQLRequirement.getReq(
158:                            getNameFromModel(), _parent.getIdBdd(), ReqPlugin
159:                                    .getProjectRef().getIdBdd());
160:                    if (pReqWrapper == null) {
161:                        trouve = true;
162:                    } else {
163:                        updateNameInModel("copy_" + j + "_" + tmpName);
164:                        j++;
165:                    }
166:                }
167:                if (j > 0) {
168:                    updateNameInDB(name);
169:                }
170:                pSQLRequirement.updateParent(idBdd, idParent);
171:            }
172:
173:            public void updateParentInModel(ReqFamily _parent) {
174:                ((ReqFamily) m_parent).removeRequirment(this );
175:                _parent.addRequirement(this );
176:                m_parent = _parent;
177:            }
178:
179:            public void updateParentInDBAndModel(ReqFamily _parent)
180:                    throws Exception {
181:
182:                updateParentInDB(_parent);
183:                updateParentInModel(_parent);
184:            }
185:
186:            public void deleteInDBAndModel() throws Exception {
187:                deleteInDB();
188:                deleteInModel();
189:            }
190:
191:            void deleteInDB() throws Exception {
192:                pSQLRequirement.deleteReq(idBdd);
193:                coverChange = true;
194:            }
195:
196:            abstract void deleteInModel();
197:
198:            public void deleteCoverForTest(int idTest) throws Exception {
199:                if (!isInBase()) {
200:                    throw new Exception("Requirement " + name
201:                            + " is not in BDD");
202:                }
203:                pSQLRequirement.deleteCover(idBdd, idTest);
204:                coverChange = true;
205:            }
206:
207:            static public void deleteAllCoverForTest(int idTest)
208:                    throws Exception {
209:                pSQLRequirement.deleteAllTestCover(idTest);
210:                coverChange = true;
211:            }
212:
213:            public Vector getTestWrapperCoveredFromDB() throws Exception {
214:                Vector tmpVector = new Vector();
215:                TestWrapper[] tmpArray = pSQLRequirement
216:                        .getTestCoveredForReq(idBdd);
217:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
218:                    tmpVector.add(tmpArray[tmpI]);
219:                }
220:                return tmpVector;
221:            }
222:
223:            public static Vector getTestWrapperCoveredFromDB(int idBdd)
224:                    throws Exception {
225:                Vector tmpVector = new Vector();
226:                TestWrapper[] tmpArray = pSQLRequirement
227:                        .getTestCoveredForReq(idBdd);
228:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
229:                    tmpVector.add(tmpArray[tmpI]);
230:                }
231:                return tmpVector;
232:            }
233:
234:            public static Vector getReqWrapperCoveredByTest(int idTest)
235:                    throws Exception {
236:                Vector tmpVector = new Vector();
237:                ReqWrapper[] tmpArray = pSQLRequirement
238:                        .getReqCoveredByTest(idTest);
239:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
240:                    tmpVector.add(tmpArray[tmpI]);
241:                }
242:                return tmpVector;
243:            }
244:
245:            public static Vector getReqWrapperCoveredByCamp(int idCamp)
246:                    throws Exception {
247:                Vector tmpVector = new Vector();
248:                ReqWrapper[] tmpArray = pSQLRequirement
249:                        .getReqWrapperCoveredByCamp(idCamp);
250:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
251:                    tmpVector.add(tmpArray[tmpI]);
252:                }
253:                return tmpVector;
254:            }
255:
256:            public static Vector getReqWrapperCovered() throws Exception {
257:                Vector tmpVector = new Vector();
258:                //ReqWrapper[] tmpArray = pSQLRequirement.getCoveredReq(ReqPlugin.getProjectRef().getIdBdd());
259:                ReqWrapper[] tmpArray = pSQLRequirement.getCoveredReq(DataModel
260:                        .getCurrentProject().getIdBdd());
261:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
262:                    tmpVector.add(tmpArray[tmpI]);
263:                }
264:                return tmpVector;
265:            }
266:
267:            public static Vector getReqWrapperInCurrentProject()
268:                    throws Exception {
269:                Vector tmpVector = new Vector();
270:                ReqWrapper[] tmpArray = pSQLRequirement
271:                        .getProjectRequirements(ReqPlugin.getProjectRef()
272:                                .getIdBdd());
273:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
274:                    tmpVector.add(tmpArray[tmpI]);
275:                }
276:                return tmpVector;
277:            }
278:
279:            public static Vector getReqWrapperLeafInCurrentProject()
280:                    throws Exception {
281:                Vector tmpVector = new Vector();
282:                ReqWrapper[] tmpArray = pSQLRequirement
283:                        .getProjectRequirementByType(ReqPlugin.getProjectRef()
284:                                .getIdBdd(), 1);
285:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
286:                    tmpVector.add(tmpArray[tmpI]);
287:                }
288:                return tmpVector;
289:            }
290:
291:            public static Vector getReqWrapperFamilyInCurrentProject()
292:                    throws Exception {
293:                Vector tmpVector = new Vector();
294:                ReqWrapper[] tmpArray = pSQLRequirement
295:                        .getProjectRequirementByType(ReqPlugin.getProjectRef()
296:                                .getIdBdd(), 0);
297:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
298:                    tmpVector.add(tmpArray[tmpI]);
299:                }
300:                return tmpVector;
301:            }
302:
303:            public static Vector getReqWrapperInExecByStatus(int ideExec,
304:                    String status) throws Exception {
305:                Vector tmpVector = new Vector();
306:                ReqWrapper[] tmpArray = pSQLRequirement
307:                        .getReqCoveredByResExecAndStatus(ideExec, status);
308:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
309:                    tmpVector.add(tmpArray[tmpI]);
310:                }
311:                return tmpVector;
312:            }
313:
314:            /******************** Attachements ****************************/
315:
316:            public void addAttachementInDB(Attachment attach) throws Exception {
317:                if (attach instanceof  FileAttachment) {
318:                    addAttachFileInDB((FileAttachment) attach);
319:                } else {
320:                    addAttachUrlInDB((UrlAttachment) attach);
321:                }
322:            }
323:
324:            void addAttachFileInDB(FileAttachment file) throws Exception {
325:                if (!isInBase()) {
326:                    throw new Exception("Requirement " + name
327:                            + " is not in BDD");
328:                }
329:                //SalomeFileWrapper f = file.getLocalFile();
330:                File f = file.getLocalFile();
331:                SalomeFileWrapper pFileWra = new SalomeFileWrapper(f);
332:                int id = pSQLRequirement.addAttachFile(idBdd, pFileWra, file
333:                        .getDescriptionFromModel());
334:                file.setIdBdd(id);
335:
336:            }
337:
338:            void addAttachUrlInDB(UrlAttachment url) throws Exception {
339:                if (!isInBase()) {
340:                    throw new Exception("Requirement " + name
341:                            + " is not in BDD");
342:                }
343:                int id = pSQLRequirement.addAttachUrl(idBdd, url
344:                        .getNameFromModel(), url.getDescriptionFromModel());
345:                url.setIdBdd(id);
346:            }
347:
348:            public void addAttachInDBAndModel(Attachment attach)
349:                    throws Exception {
350:                if (attach instanceof  FileAttachment) {
351:                    addAttachFileInDB((FileAttachment) attach);
352:                } else {
353:                    addAttachUrlInDB((UrlAttachment) attach);
354:                }
355:                addAttachementInModel(attach);
356:            }
357:
358:            public void deleteAttachementInDBAndModel(Attachment attach)
359:                    throws Exception {
360:                deleteAttachementInDB(attach.getIdBdd());
361:
362:                deleteAttachmentInModel(attach);
363:            }
364:
365:            protected void deleteAttachementInDB(int attachId) throws Exception {
366:                if (!isInBase()) {
367:                    throw new Exception("Requirement " + name
368:                            + " is not in BDD");
369:                }
370:                pSQLRequirement.deleteAttach(idBdd, attachId);
371:            }
372:
373:            public Vector getAttachFilesFromDB() throws Exception {
374:                if (!isInBase()) {
375:                    throw new Exception("Requirement " + name
376:                            + " is not in BDD");
377:                }
378:                Vector tmpVector = new Vector();
379:                FileAttachementWrapper[] tmpArray = pSQLRequirement
380:                        .getAllAttachFiles(idBdd);
381:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
382:                    tmpVector.add(tmpArray[tmpI]);
383:                }
384:                return tmpVector;
385:            }
386:
387:            public Vector getAttachUrlsFromDB() throws Exception {
388:                if (!isInBase()) {
389:                    throw new Exception("Requirement " + name
390:                            + " is not in BDD");
391:                }
392:                Vector tmpVector = new Vector();
393:                UrlAttachementWrapper[] tmpArray = pSQLRequirement
394:                        .getAllAttachUrls(idBdd);
395:                for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
396:                    tmpVector.add(tmpArray[tmpI]);
397:                }
398:                return tmpVector;
399:            }
400:
401:            /**************************************************************************************/
402:
403:            static public void writeCampaingChart(Campaign pCamp,
404:                    String filePath) {
405:                try {
406:                    Vector reqCoveredWrapper;
407:                    Vector reqCovered = new Vector();
408:                    ArrayList pTestList = pCamp.getTestListFromModel();
409:                    int nbTest = pTestList.size();
410:                    for (int i = 0; i < nbTest; i++) {
411:                        Test pTest = (Test) pTestList.get(i);
412:                        reqCoveredWrapper = Requirement
413:                                .getReqWrapperCoveredByTest(pTest.getIdBdd());
414:                        int size = reqCoveredWrapper.size();
415:                        for (int j = 0; j < size; j++) {
416:                            ReqWrapper pReqWrapper = (ReqWrapper) reqCoveredWrapper
417:                                    .elementAt(j);
418:                            if (!reqCovered.contains(pReqWrapper)) {
419:                                reqCovered.add(pReqWrapper);
420:                            }
421:                        }
422:                    }
423:                    writeCampaingChart(reqCovered, filePath);
424:
425:                } catch (Exception e) {
426:
427:                }
428:            }
429:
430:            static public void writeCampaingChart(Vector reqCovered,
431:                    String filePath) {
432:                try {
433:                    int nbReqCovered = reqCovered.size();
434:                    int nbReqTotal = 0;
435:
436:                    try {
437:                        nbReqTotal = Requirement
438:                                .getReqWrapperLeafInCurrentProject().size();
439:                    } catch (Exception e) {
440:                        nbReqTotal = 0;
441:                    }
442:
443:                    DefaultPieDataset dataset = new DefaultPieDataset();
444:                    if (nbReqTotal > 0) {
445:                        Double nbCovered = new Double((nbReqCovered * 100)
446:                                / nbReqTotal);
447:                        Double nbNotCovered = new Double(100
448:                                - (nbReqCovered * 100) / nbReqTotal);
449:                        dataset.setValue(Language.getInstance().getText(
450:                                "Exigence_non_couverte"), nbNotCovered);
451:                        dataset.setValue(Language.getInstance().getText(
452:                                "Exigence_couverte"), nbCovered);
453:                    }
454:
455:                    JFreeChart chart = ChartFactory.createPieChart3D(Language
456:                            .getInstance().getText("Exigence_couverte"), // chart title
457:                            dataset, // data
458:                            true, // include legend
459:                            true, false);
460:
461:                    ChartUtilities.saveChartAsJPEG(new java.io.File(filePath),
462:                            chart, 500, 300);
463:
464:                } catch (Exception e) {
465:
466:                }
467:
468:            }
469:
470:            static public void writeReqCoverChart(String filePath) {
471:                try {
472:                    int nbTotalReq = Requirement
473:                            .getReqWrapperLeafInCurrentProject().size();
474:                    int nbCoveredReq = Requirement.getReqWrapperCovered()
475:                            .size();
476:                    DefaultPieDataset dataset = new DefaultPieDataset();
477:                    if (nbTotalReq > 0) {
478:                        Double nbCovered = new Double((nbCoveredReq * 100)
479:                                / nbTotalReq);
480:                        Double nbNotCovered = new Double(100
481:                                - (nbCoveredReq * 100) / nbTotalReq);
482:                        dataset.setValue(Language.getInstance().getText(
483:                                "Exigence_non_couverte"), nbNotCovered);
484:                        dataset.setValue(Language.getInstance().getText(
485:                                "Exigence_couverte"), nbCovered);
486:
487:                    }
488:                    JFreeChart chart = ChartFactory.createPieChart3D(Language
489:                            .getInstance().getText("Exigence_couverte"), // chart title
490:                            dataset, // data
491:                            true, // include legend
492:                            true, false);
493:
494:                    ChartUtilities.saveChartAsJPEG(new java.io.File(filePath),
495:                            chart, 500, 300);
496:                } catch (Exception e) {
497:
498:                }
499:            }
500:
501:            static public void writeResExecChart(
502:                    ExecutionResult executionResult, String filePath) {
503:                int nbFail = 0;
504:                int nbPass = 0;
505:                int nbInco = 0;
506:                try {
507:                    Vector reqPass = Requirement.getReqWrapperInExecByStatus(
508:                            executionResult.getIdBdd(), ApiConstants.SUCCESS);
509:                    Vector reqFail = Requirement.getReqWrapperInExecByStatus(
510:                            executionResult.getIdBdd(), ApiConstants.FAIL);
511:                    Vector reqInco = Requirement.getReqWrapperInExecByStatus(
512:                            executionResult.getIdBdd(), ApiConstants.UNKNOWN);
513:                    int sizePass = reqPass.size();
514:                    int sizeFail = reqFail.size();
515:                    int sizeInco = reqInco.size();
516:
517:                    Hashtable allReq = new Hashtable();
518:                    for (int i = 0; i < sizePass; i++) {
519:                        ReqWrapper pReqWrapper = (ReqWrapper) reqPass
520:                                .elementAt(i);
521:                        allReq.put(pReqWrapper, ApiConstants.SUCCESS);
522:                    }
523:                    for (int i = 0; i < sizeInco; i++) {
524:                        ReqWrapper pReqWrapper = (ReqWrapper) reqInco
525:                                .elementAt(i);
526:                        allReq.put(pReqWrapper, ApiConstants.UNKNOWN);
527:                    }
528:                    for (int i = 0; i < sizeFail; i++) {
529:                        ReqWrapper pReqWrapper = (ReqWrapper) reqFail
530:                                .elementAt(i);
531:                        allReq.put(pReqWrapper, ApiConstants.FAIL);
532:                    }
533:
534:                    Enumeration enumReq = allReq.keys();
535:                    while (enumReq.hasMoreElements()) {
536:                        ReqWrapper pReqWrapper = (ReqWrapper) enumReq
537:                                .nextElement();
538:                        String status = (String) allReq.get(pReqWrapper);
539:                        if (status.equals(ApiConstants.SUCCESS)) {
540:                            nbPass++;
541:                        } else if (status.equals(ApiConstants.FAIL)) {
542:                            nbFail++;
543:                        } else {
544:                            nbInco++;
545:                        }
546:                    }
547:                    int nbReqTotal = nbFail + nbPass + nbInco;
548:
549:                    DefaultPieDataset dataset = new DefaultPieDataset();
550:                    if (nbReqTotal > 0) {
551:                        Double percentPass = new Double((nbPass * 100)
552:                                / nbReqTotal);
553:                        Double percentFail = new Double((nbFail * 100)
554:                                / nbReqTotal);
555:                        Double percentInco = new Double((nbInco * 100)
556:                                / nbReqTotal);
557:                        dataset.setValue(Language.getInstance().getText(
558:                                "Exigence_Fail"), percentFail);
559:                        dataset.setValue(Language.getInstance().getText(
560:                                "Exigence_Inco"), percentInco);
561:                        dataset.setValue(Language.getInstance().getText(
562:                                "Exigence_Pass"), percentPass);
563:                    }
564:                    JFreeChart chart = ChartFactory.createPieChart3D(Language
565:                            .getInstance().getText("Exigence_couverte"), // chart title
566:                            dataset, // data
567:                            true, // include legend
568:                            true, false);
569:
570:                    ChartUtilities.saveChartAsJPEG(new java.io.File(filePath),
571:                            chart, 500, 300);
572:                } catch (Exception e) {
573:
574:                }
575:            }
576:
577:            public int hashCode() {
578:                if (isInBase()) {
579:                    return idBdd;
580:                } else {
581:                    return super .hashCode();
582:                }
583:            }
584:
585:            public boolean equals(Object o) {
586:                if (o instanceof  Requirement) {
587:                    Requirement toTest = (Requirement) o;
588:                    if (isInBase() && toTest.isInBase()) {
589:                        return idBdd == toTest.getIdBdd();
590:                    } else {
591:                        return getNameFromModel() == toTest.getNameFromModel();
592:                    }
593:                } else {
594:                    return false;
595:                }
596:            }
597:
598:            public boolean existeInBase() throws Exception {
599:                if (!isInBase()) {
600:                    return false;
601:                }
602:                return pSQLRequirement.getReqById(idBdd) != null;
603:            }
604:
605:            /*********************************** History ****************************************/
606:            public HistoryWrapper[] getHistory() throws Exception {
607:                if (!isInBase()) {
608:                    return null;
609:                }
610:                return pSQLRequirement.getHistory(idBdd);
611:            }
612:
613:            static public String getStringCodeValue(int code) {
614:                String res = "";
615:                if (code == ISQLRequirement.HIST_CREATE_REQ) {
616:                    res = "Creation";
617:                } else if (code == ISQLRequirement.HIST_ADD_REQLEAF) {
618:                    res = "Add Requiement";
619:                } else if (code == ISQLRequirement.HIST_ADD_REQFAM) {
620:                    res = "Add Requiement family";
621:                } else if (code == ISQLRequirement.HIST_ADD_ATTACH) {
622:                    res = "Add Requiement Attachement";
623:                } else if (code == ISQLRequirement.HIST_ADD_COVER) {
624:                    res = "Add Requiement Test Cover";
625:                } else if (code == ISQLRequirement.HIST_ADD_LINK) {
626:                    res = "Add Requiement Link";
627:                } else if (code == ISQLRequirement.HIST_DEL_REQ) {
628:                    res = "Delete Requiement";
629:                } else if (code == ISQLRequirement.HIST_DEL_ATTACH) {
630:                    res = "Delete Attachement";
631:                } else if (code == ISQLRequirement.HIST_DEL_COVER) {
632:                    res = "Delete Test Cover";
633:                } else if (code == ISQLRequirement.HIST_DEL_LINK) {
634:                    res = "Delete Requiement Link";
635:                } else if (code == ISQLRequirement.HIST_UPDATE_NAME) {
636:                    res = "Update Name";
637:                } else if (code == ISQLRequirement.HIST_UPDATE_DESCRIPTION) {
638:                    res = "Update Description";
639:                } else if (code == ISQLRequirement.HIST_UPDATE_VERSION) {
640:                    res = "Update Version";
641:                } else if (code == ISQLRequirement.HIST_UPDATE_REFERENCE) {
642:                    res = "Update Reference";
643:                } else if (code == ISQLRequirement.HIST_UPDATE_INFO) {
644:                    res = "Update Information";
645:                } else if (code == ISQLRequirement.HIST_UPDATE_PRIORITY) {
646:                    res = "Update Priority";
647:                } else if (code == ISQLRequirement.HIST_UPDATE_CATEGORY) {
648:                    res = "Update Category";
649:                } else if (code == ISQLRequirement.HIST_UPDATE_COMPLEXITY) {
650:                    res = "Update Complexity";
651:                } else if (code == ISQLRequirement.HIST_UPDATE_ORIGINE) {
652:                    res = "Update Origine";
653:                } else if (code == ISQLRequirement.HIST_UPDATE_SATE) {
654:                    res = "Update Sate";
655:                } else if (code == ISQLRequirement.HIST_UPDATE_VERIFWAY) {
656:                    res = "Update Verification Way";
657:                } else if (code == ISQLRequirement.HIST_UPDATE_PARENT) {
658:                    res = "Update Requirement Parent";
659:                }
660:                return res;
661:            }
662:
663:            static public boolean isTestIdValeur(int code) {
664:                if (code == ISQLRequirement.HIST_DEL_COVER) {
665:                    return true;
666:                } else if (code == ISQLRequirement.HIST_ADD_COVER) {
667:                    return true;
668:                }
669:
670:                return false;
671:            }
672:
673:            static public boolean isStateValeur(int code) {
674:                if (code == ISQLRequirement.HIST_UPDATE_SATE) {
675:                    return true;
676:                }
677:                return false;
678:            }
679:
680:            static public boolean isPriorityValeur(int code) {
681:                if (code == ISQLRequirement.HIST_UPDATE_PRIORITY) {
682:                    return true;
683:                }
684:                return false;
685:            }
686:
687:            static public boolean isComplexityValeur(int code) {
688:                if (code == ISQLRequirement.HIST_UPDATE_COMPLEXITY) {
689:                    return true;
690:                }
691:                return false;
692:            }
693:
694:            static public boolean isCategoryValeur(int code) {
695:                if (code == ISQLRequirement.HIST_UPDATE_CATEGORY) {
696:                    return true;
697:                }
698:                return false;
699:            }
700:
701:            static public boolean isDescriptionValeur(int code) {
702:                if (code == ISQLRequirement.HIST_UPDATE_DESCRIPTION) {
703:                    return true;
704:                }
705:                return false;
706:            }
707:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.