Source Code Cross Referenced for StatRequirement.java in  » Test-Coverage » salome-tmf » salomeTMF_plug » requirements » ihm » 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.ihm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package salomeTMF_plug.requirements.ihm;
002:
003:        import java.sql.Date;
004:        import java.util.ArrayList;
005:        import java.util.Hashtable;
006:        import java.util.Vector;
007:
008:        import org.objectweb.salome_tmf.api.ApiConstants;
009:        import org.objectweb.salome_tmf.api.data.TestWrapper;
010:        import org.objectweb.salome_tmf.data.Campaign;
011:        import org.objectweb.salome_tmf.data.Execution;
012:        import org.objectweb.salome_tmf.data.ExecutionResult;
013:        import org.objectweb.salome_tmf.data.Test;
014:        import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
015:
016:        import salomeTMF_plug.requirements.ReqPlugin;
017:        import salomeTMF_plug.requirements.data.IReqFilter;
018:        import salomeTMF_plug.requirements.data.ReqFamily;
019:        import salomeTMF_plug.requirements.data.ReqLeaf;
020:        import salomeTMF_plug.requirements.data.Requirement;
021:
022:        public class StatRequirement {
023:
024:            Vector leafInCurrentFamily = new Vector(); //Vector of ReqFamily
025:            Hashtable allTestCovredByCurrentReq = new Hashtable(); //Hashtable Integer (id of test) -> Test
026:            Hashtable allTestCovredByReq = new Hashtable(); //Hashtable Integer (id of req) -> Vector of Test
027:            Hashtable allReqCovredByTest = new Hashtable(); // Hastable Integer (id of Test) -> Vector of Req
028:            Hashtable executedStatCovredByCurrentReq = new Hashtable(); //Hashtable Test->Vector[campain, Execution, {ExecResult}, nbP, nbF, nbU, lastExecRusult, lastResult, test]
029:
030:            Hashtable executedStatByCamp = new Hashtable();
031:            Hashtable executedStatByExec = new Hashtable();
032:            Hashtable executedStatByEnv = new Hashtable();
033:
034:            Requirement pCurrentReq = null;
035:
036:            /*UTIL*/
037:            //Project currentProject;
038:            /* CACHE*/
039:            private Hashtable testwrapper2model = new Hashtable();
040:
041:            public StatRequirement() {
042:                //currentProject = ReqPlugin.getProjectRef();
043:            }
044:
045:            //public void update(Requirement pRequirement, int filtre, boolean forceReload) throws Exception{
046:            public void update(Requirement pRequirement, IReqFilter filtre,
047:                    boolean forceReload) throws Exception {
048:                //System.out.println("Update State : "  + filtre);
049:                if (pRequirement == null) {
050:                    pCurrentReq = pRequirement;
051:                    clearStat(forceReload);
052:                    return;
053:                }
054:
055:                if (forceReload == false && pRequirement.equals(pCurrentReq)) {
056:                    return;
057:                }
058:
059:                pCurrentReq = pRequirement;
060:                clearStat(forceReload);
061:
062:                if (pRequirement.isFamilyReq()) {
063:
064:                    leafInCurrentFamily = ((ReqFamily) pCurrentReq)
065:                            .getAllLeaf(filtre);
066:
067:                    for (int j = 0; j < leafInCurrentFamily.size(); j++) {
068:                        Requirement pTmpRequirement = (Requirement) leafInCurrentFamily
069:                                .elementAt(j);
070:                        Vector testWraCoverTmp = pTmpRequirement
071:                                .getTestWrapperCoveredFromDB();
072:                        Vector coverdTest = new Vector();
073:                        for (int k = 0; k < testWraCoverTmp.size(); k++) {
074:                            try {
075:                                TestWrapper pTestWrapper = (TestWrapper) testWraCoverTmp
076:                                        .elementAt(k);
077:                                Test pTest = getTestFromWrapper(pTestWrapper);
078:                                Test oldTest = (Test) allTestCovredByCurrentReq
079:                                        .put(new Integer(pTestWrapper
080:                                                .getIdBDD()), pTest);
081:                                if (oldTest == null) {
082:                                    getExecutedStat(pTest);
083:                                }
084:                                coverdTest.add(pTest);
085:                                Vector coveredReq = (Vector) allReqCovredByTest
086:                                        .get(new Integer(pTestWrapper
087:                                                .getIdBDD()));
088:                                if (coveredReq == null) {
089:                                    coveredReq = new Vector();
090:                                    coveredReq.add(pTmpRequirement);
091:                                    allReqCovredByTest.put(new Integer(
092:                                            pTestWrapper.getIdBDD()),
093:                                            coveredReq);
094:                                } else {
095:                                    coveredReq.add(pTmpRequirement);
096:                                }
097:                            } catch (Exception e) {
098:
099:                            }
100:                        }
101:                        if (coverdTest.size() > 0) {
102:                            allTestCovredByReq.put(new Integer(pTmpRequirement
103:                                    .getIdBdd()), coverdTest);
104:                        }
105:                    }
106:                } else {
107:                    if (filtre.isFiltred(pRequirement)) {
108:                        //if ((((ReqLeaf)pRequirement).getPriorityFromModel()  | filtre) == filtre) {
109:
110:                        Vector testWraCoverTmp = pRequirement
111:                                .getTestWrapperCoveredFromDB();
112:                        Vector coverdTest = new Vector();
113:                        for (int k = 0; k < testWraCoverTmp.size(); k++) {
114:                            TestWrapper pTestWrapper = (TestWrapper) testWraCoverTmp
115:                                    .elementAt(k);
116:                            try {
117:                                Test pTest = getTestFromWrapper(pTestWrapper);
118:                                Test oldTest = (Test) allTestCovredByCurrentReq
119:                                        .put(new Integer(pTestWrapper
120:                                                .getIdBDD()), pTest);
121:                                if (oldTest == null) {
122:                                    getExecutedStat(pTest);
123:                                }
124:                                coverdTest.add(pTest);
125:                                Vector coveredReq = (Vector) allReqCovredByTest
126:                                        .get(new Integer(pTestWrapper
127:                                                .getIdBDD()));
128:                                if (coveredReq == null) {
129:                                    coveredReq = new Vector();
130:                                    coveredReq.add(pRequirement);
131:                                    allReqCovredByTest.put(new Integer(
132:                                            pTestWrapper.getIdBDD()),
133:                                            coveredReq);
134:                                } else {
135:                                    coveredReq.add(pRequirement);
136:                                }
137:                            } catch (Exception e) {
138:
139:                            }
140:                        }
141:                        if (coverdTest.size() > 0) {
142:                            allTestCovredByReq.put(new Integer(pRequirement
143:                                    .getIdBdd()), coverdTest);
144:                        }
145:                    }
146:                }
147:            }
148:
149:            public Hashtable getAllTestCovredByCurrentReq() {
150:                return allTestCovredByCurrentReq;
151:            }
152:
153:            public Hashtable getAllTestCovredByReq() {
154:                return allTestCovredByReq;
155:            }
156:
157:            public Hashtable getEexecutedStatCovredByCurrentReq() {
158:                return executedStatCovredByCurrentReq;
159:            }
160:
161:            public Hashtable getAllReqCovredByTest() {
162:                return allReqCovredByTest;
163:            }
164:
165:            public Vector getLeafInCurrentFamily() {
166:                return leafInCurrentFamily;
167:            }
168:
169:            public boolean isCovredTestIsExecuted(Test pTest) {
170:                if (executedStatCovredByCurrentReq.get(pTest) != null) {
171:                    return true;
172:                } else {
173:                    return false;
174:                }
175:            }
176:
177:            private Hashtable getExecutedStat(Test pTest) {
178:                //boolean executed = false;
179:                ArrayList campaignList = DataModel.getCurrentProject()
180:                        .getCampaignOfTest(pTest);
181:                Vector detailExec = new Vector();
182:                if (campaignList != null && campaignList.size() > 0) {
183:                    int i = 0;
184:                    int size = campaignList.size();
185:                    while (i < size /* && !executed */) {
186:                        Campaign pCampaign = (Campaign) campaignList.get(i);
187:
188:                        if (pCampaign.containsExecutionResultInModel()) {
189:                            //executed = true;
190:
191:                            ArrayList executionList = pCampaign
192:                                    .getExecutionListFromModel();
193:                            if (executionList != null
194:                                    && executionList.size() > 0) {
195:                                //Echec=Echec Inconclusif=Inconclusif Succ\u00E8s=Succ\u00E8s
196:                                int sizeExecutionList = executionList.size();
197:
198:                                for (int j = 0; j < sizeExecutionList; j++) {
199:                                    Execution pExec = (Execution) executionList
200:                                            .get(j);
201:                                    if (pExec != null
202:                                            && pExec
203:                                                    .getExecutionResultListFromModel() != null
204:                                            && pExec
205:                                                    .getExecutionResultListFromModel()
206:                                                    .size() > 0) {
207:                                        ArrayList executionResultList = pExec
208:                                                .getExecutionResultListFromModel();
209:                                        int sizeExecutionResList = executionResultList
210:                                                .size();
211:
212:                                        Vector listOfExecResult = new Vector();
213:                                        ExecutionResult lastExecutionResult = null;
214:                                        String lastResult = ApiConstants.UNKNOWN;
215:                                        int nbFail = 0;
216:                                        int nbPass = 0;
217:                                        int nbUnknow = 0;
218:
219:                                        for (int k = 0; k < sizeExecutionResList; k++) {
220:
221:                                            ExecutionResult pExecutionResult = (ExecutionResult) executionResultList
222:                                                    .get(k);
223:                                            listOfExecResult
224:                                                    .add(pExecutionResult);
225:                                            if (lastExecutionResult != null) {
226:                                                Date pDate = pExecutionResult
227:                                                        .getExecutionDateFromModel();
228:                                                Date currentDate = lastExecutionResult
229:                                                        .getExecutionDateFromModel();
230:                                                if (pDate.after(currentDate)) {
231:                                                    lastExecutionResult = pExecutionResult;
232:                                                }
233:                                            } else {
234:                                                lastExecutionResult = pExecutionResult;
235:                                            }
236:                                            String status;
237:                                            if (lastExecutionResult != pExecutionResult) {
238:                                                lastResult = lastExecutionResult
239:                                                        .getTestResultStatusFromModel(pTest);
240:                                                status = pExecutionResult
241:                                                        .getTestResultStatusFromModel(pTest);
242:
243:                                            } else {
244:                                                status = pExecutionResult
245:                                                        .getTestResultStatusFromModel(pTest);
246:                                                lastResult = status;
247:                                            }
248:
249:                                            if (status
250:                                                    .equals(ApiConstants.UNKNOWN)) {
251:                                                nbUnknow++;
252:                                            } else if (status
253:                                                    .equals(ApiConstants.FAIL)) {
254:                                                nbFail++;
255:                                            } else if (status
256:                                                    .equals(ApiConstants.SUCCESS)) {
257:                                                nbPass++;
258:                                            }
259:                                        }// End For ExecutionResult
260:                                        if (listOfExecResult.size() > 0) {
261:                                            Vector data = new Vector();
262:                                            data.add(pCampaign);
263:                                            data.add(pExec);
264:                                            data.add(listOfExecResult);
265:                                            data.add(new Integer(nbPass));
266:                                            data.add(new Integer(nbFail));
267:                                            data.add(new Integer(nbUnknow));
268:                                            data.add(lastExecutionResult);
269:                                            data.add(lastResult);
270:                                            data.add(pTest);
271:                                            Vector statByCamp = (Vector) executedStatByCamp
272:                                                    .get(pCampaign);
273:                                            if (statByCamp == null) {
274:                                                statByCamp = new Vector();
275:                                            }
276:                                            statByCamp.add(data);
277:                                            executedStatByCamp.put(pCampaign,
278:                                                    statByCamp);
279:
280:                                            Vector statByExec = (Vector) executedStatByExec
281:                                                    .get(pExec);
282:                                            if (statByExec == null) {
283:                                                statByExec = new Vector();
284:                                            }
285:                                            statByExec.add(data);
286:                                            executedStatByExec.put(pExec,
287:                                                    statByExec);
288:
289:                                            Vector statByEnv = (Vector) executedStatByEnv
290:                                                    .get(pExec
291:                                                            .getEnvironmentFromModel());
292:                                            if (statByEnv == null) {
293:                                                statByEnv = new Vector();
294:                                            }
295:                                            statByEnv.add(data);
296:                                            executedStatByEnv.put(pExec
297:                                                    .getEnvironmentFromModel(),
298:                                                    statByEnv);
299:
300:                                            detailExec.add(data);
301:                                        }
302:                                    } // End If have Execresult
303:                                } //End For Execution
304:                            }
305:                        }// End if Campaign contain exec with result
306:                        i++;
307:                    }// End while Campaign
308:                    if (detailExec.size() > 0) {
309:                        executedStatCovredByCurrentReq.put(pTest, detailExec);
310:                    }
311:                }// End if have campaign
312:                return executedStatCovredByCurrentReq;
313:            }
314:
315:            private Test getTestFromWrapper(TestWrapper pTestWrapper)
316:                    throws Exception {
317:                Test pTest;
318:                pTest = (Test) testwrapper2model.get(new Integer(pTestWrapper
319:                        .getIdBDD()));
320:                if (pTest != null) {
321:                    return pTest;
322:                }
323:                pTest = DataModel.getCurrentProject().getTestFromModel(
324:                        pTestWrapper.getIdBDD());
325:                if (pTest == null && !ReqPlugin.isGlobalProject()) {
326:                    if (ReqPlugin.getProjectRef().getIdBdd() == DataModel
327:                            .getCurrentProject().getIdBdd()) {
328:                        DataModel.reloadFromBase(true);
329:                        pTest = DataModel.getCurrentProject().getTestFromModel(
330:                                pTestWrapper.getIdBDD());
331:                    }
332:                    if (pTest == null) {
333:                        throw new Exception(
334:                                "No test found in model representing "
335:                                        + pTestWrapper.getName() + ", id="
336:                                        + pTestWrapper.getIdBDD());
337:                    }
338:                }
339:                testwrapper2model.put(new Integer(pTestWrapper.getIdBDD()),
340:                        pTest);
341:                return pTest;
342:            }
343:
344:            public void clearStat(boolean clearCache) {
345:                leafInCurrentFamily.clear();
346:                allTestCovredByCurrentReq.clear();
347:                allTestCovredByReq.clear();
348:                executedStatCovredByCurrentReq.clear();
349:                executedStatByCamp.clear();
350:                executedStatByEnv.clear();
351:                executedStatByExec.clear();
352:                allReqCovredByTest.clear();
353:
354:                if (clearCache) {
355:                    testwrapper2model.clear();
356:                }
357:            }
358:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.