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


001:        package org.objectweb.salome_tmf.data;
002:
003:        import java.util.ArrayList;
004:
005:        import org.objectweb.salome_tmf.api.Api;
006:        import org.objectweb.salome_tmf.api.ApiConstants;
007:
008:        public class CampaignData implements  ApiConstants {
009:            /**
010:             * Liste des campagnes
011:             */
012:            static private ArrayList campaignList = new ArrayList();;
013:
014:            //static private ArrayList execResultList = new ArrayList();;
015:
016:            /***********************************************************************************/
017:            static void clearData() {
018:                campaignList.clear();
019:                //execResultList.clear();
020:            }
021:
022:            /***********************************************************************************/
023:            // Ancien truc
024:            /*public static void addResultToExec(ExecutionResult result) {
025:            	execResultList.add(result);
026:            }
027:            
028:            public static ArrayList getResultToExec() {
029:            	return execResultList;
030:            }*/
031:            /**
032:             * Retourne la liste ordonnée des objets <code>Campagne</code>
033:             * @return la liste ordonnée des objets <code>Campagne</code>
034:             */
035:            public static ArrayList getCampaignList() {
036:                return campaignList;
037:            } // Fin de la méthode getCampaignList/0
038:
039:            /**
040:             * Retourne la campagne dont le nom est passé en paramètre
041:             * @param campaignName un nom
042:             * @return Retourne la campagne dont le nom est passé en paramètre, <code>null</code>
043:             * si le nom n'est pas celui d'une campagne
044:             */
045:            public static Campaign getCampaign(String campaignName) {
046:                for (int i = 0; i < campaignList.size(); i++) {
047:                    if (((Campaign) campaignList.get(i)).getName().equals(
048:                            campaignName)) {
049:                        return (Campaign) campaignList.get(i);
050:                    }
051:                }
052:                return null;
053:            } // Fin de la méthode getCampaign/1
054:
055:            /**
056:             * Retourne la campagne dont le nom est passé en paramètre
057:             * @param id de la campagne
058:             * @return Retourne la campagne dont le nom est passé en paramètre, <code>null</code>
059:             * si le nom n'est pas celui d'une campagne
060:             */
061:            public static Campaign getCampaign(int id) {
062:                for (int i = 0; i < campaignList.size(); i++) {
063:                    if (((Campaign) campaignList.get(i)).getIdBdd() == id) {
064:                        return (Campaign) campaignList.get(i);
065:                    }
066:                }
067:                return null;
068:            } // Fin de la méthode getCampaign/1
069:
070:            /**
071:             * Retourne la liste des campagnes qui contiennent le test passé en 
072:             * paramètre
073:             * @param test un test
074:             * @return la liste des campagnes qui contiennent le test passé en 
075:             * paramètre
076:             */
077:            public static ArrayList getCampaignOfTest(Test test) {
078:                ArrayList result = new ArrayList();
079:                for (int i = 0; i < campaignList.size(); i++) {
080:                    if (((Campaign) campaignList.get(i)).containsTest(test)) {
081:                        result.add(campaignList.get(i));
082:                    }
083:                }
084:                return result;
085:            } // Fin de la méthode getCampaignOfTest/1
086:
087:            public static ArrayList getCampaignOfTestList(TestList testList) {
088:                ArrayList result = new ArrayList();
089:                for (int i = 0; i < campaignList.size(); i++) {
090:                    if (((Campaign) campaignList.get(i))
091:                            .containsTestList(testList)) {
092:                        result.add(campaignList.get(i));
093:                    }
094:                }
095:                return result;
096:            }
097:
098:            public static ArrayList getCampaignOfFamily(Family family) {
099:                ArrayList result = new ArrayList();
100:                for (int i = 0; i < campaignList.size(); i++) {
101:                    if (((Campaign) campaignList.get(i)).containsFamily(family)) {
102:                        result.add(campaignList.get(i));
103:                    }
104:                }
105:                return result;
106:            }
107:
108:            /**
109:             * 
110:             * @param envName
111:             * @return
112:             */
113:            public static ArrayList getExecutionOfEnvironment(String envName) {
114:                ArrayList result = new ArrayList();
115:                for (int i = 0; i < getCampaignList().size(); i++) {
116:                    for (int j = 0; j < ((Campaign) getCampaignList().get(i))
117:                            .getExecutionList().size(); j++) {
118:                        if (((Execution) ((Campaign) getCampaignList().get(i))
119:                                .getExecutionList().get(j)).getEnvironment()
120:                                .getName().equals(envName)) {
121:                            result.add((((Campaign) getCampaignList().get(i))
122:                                    .getExecutionList().get(j)));
123:                        }
124:                    }
125:                }
126:                return result;
127:            }
128:
129:            public static ArrayList getExecutionsOfDataSetInCamp(Campaign camp,
130:                    String dataSetName) {
131:                ArrayList result = new ArrayList();
132:                for (int j = 0; j < camp.getExecutionList().size(); j++) {
133:                    if (((Execution) camp.getExecutionList().get(j))
134:                            .getDataSet().getName().equals(dataSetName)) {
135:                        result.add((camp.getExecutionList().get(j)));
136:                    }
137:                }
138:
139:                return result;
140:            }
141:
142:            /**
143:             * Retourne une chaine contenant toutes les campagnes qui ont des r?sultats
144:             * d'exécution et qui contiennent le test passé en paramètre
145:             * @param test un test
146:             * @return une chaine contenant toutes les campagnes qui ont des r?sultats
147:             * d'exécution et qui contiennent le test passé en paramètre
148:             */
149:            public static String getCampaignWithExecResultWhereTestIsUse(
150:                    Test test) {
151:                String message = "";
152:                for (int i = 0; i < getCampaignList().size(); i++) {
153:                    Campaign camp = (Campaign) getCampaignList().get(i);
154:                    if (camp.containsTest(test)
155:                            && camp.containsExecutionResult())
156:                        message = message + "* " + camp.getName() + "\n";
157:                }
158:                return message;
159:            }
160:
161:            /**************** Operations d'ajout dans le modele de données **********************************/
162:
163:            /**
164:             * Ajoute un test dans une campagne de tests
165:             * @param test un test 
166:             * @param campagne une campagne
167:             */
168:            static void addTestInCampaignInModel(Test test, Campaign campaign) {
169:                campaign.addTest(test);
170:            } // Fin de la méthode addTestInCampaign/2
171:
172:            public static ArrayList addTestInCampaignInBddAndModel(Test pTest,
173:                    Campaign pCampain) throws Exception {
174:                boolean newDataSetCreated = false;
175:                ArrayList datasetsCreated = new ArrayList();
176:                ArrayList dataSets = pCampain.getDataSetList();
177:                //BDD
178:                int transNumber = -1;
179:                try {
180:                    // BDD
181:                    transNumber = Api
182:                            .beginTransaction(Api.INSERT_TEST_INTO_CAMPAIGN);
183:
184:                    pCampain.importTestInDB(pTest.getIdBDD());
185:                    for (int i = 0; i < pTest.getParameterList().size(); i++) {
186:                        if (dataSets != null) {
187:                            if ((dataSets.size() == 0) && (!newDataSetCreated)
188:                                    && pCampain.getExecutionList().size() != 0) {
189:                                newDataSetCreated = true;
190:                                for (int k = 0; k < pCampain.getExecutionList()
191:                                        .size(); k++) {
192:                                    Execution pExecution = pCampain
193:                                            .getExecution(k);
194:                                    DataSet newDataSet = new DataSet();
195:                                    newDataSet.setName("dataSet_" + k);
196:                                    newDataSet.setDescription(DEFAULT_DATA_SET);
197:                                    newDataSet.add2DB(pCampain);
198:
199:                                    Parameter param = (Parameter) pTest
200:                                            .getParameterList().get(i);
201:                                    Environment env = pExecution
202:                                            .getEnvironment();
203:
204:                                    if (env.getParameter(param.getName()) != null) {
205:                                        newDataSet.addParamValue2DB(env
206:                                                .getParameterValue(param),
207:                                                param);
208:                                    } else {
209:                                        newDataSet.addParamValue2DB("", param);
210:                                    }
211:
212:                                    pExecution.updateDatasetInDB(newDataSet
213:                                            .getIdBdd());
214:                                    datasetsCreated.add(i, newDataSet);
215:                                }
216:                            } else {
217:                                for (int k = 0; k < dataSets.size(); k++) {
218:                                    DataSet dataSet = (DataSet) dataSets.get(k);
219:                                    if (!dataSet.getParametersHashMap()
220:                                            .containsKey(
221:                                                    ((Parameter) pTest
222:                                                            .getParameterList()
223:                                                            .get(i)).getName())) {
224:                                        Parameter param = (Parameter) pTest
225:                                                .getParameterList().get(i);
226:                                        dataSet.addParamValue2DB("", param);
227:                                    }
228:                                }
229:                            }
230:                        }
231:                    }
232:                    Api.commitTrans(transNumber);
233:                } catch (Exception e) {
234:
235:                }
236:                //Model
237:                for (int i = 0; i < pTest.getParameterList().size(); i++) {
238:                    Parameter param = (Parameter) pTest.getParameterList().get(
239:                            i);
240:                    if (dataSets != null) {
241:                        if (newDataSetCreated) {
242:                            for (int ind = 0; ind < datasetsCreated.size(); ind++) {
243:                                DataSet dataset = (DataSet) datasetsCreated
244:                                        .get(ind);
245:                                pCampain.addDataSet(dataset);
246:                                //dataset.addParameter(param.getName(), "");
247:                            }
248:                            for (int k = 0; k < pCampain.getExecutionList()
249:                                    .size(); k++) {
250:                                Execution pExecution = pCampain.getExecution(k);
251:                                Environment env = pExecution.getEnvironment();
252:                                String paramValue = "";
253:                                if (env.getParameter(param.getName()) != null) {
254:                                    paramValue = env.getParameterValue(param);
255:                                }
256:                                ((DataSet) datasetsCreated.get(k))
257:                                        .addParameter(param.getName(),
258:                                                paramValue);
259:                                pExecution.setDataSet((DataSet) datasetsCreated
260:                                        .get(k));
261:                                //executionTableModel.setValueAt(((DataSet)datasetsCreated.get(k)).getName(),k,3);
262:                            }
263:                        } else {
264:                            for (int k = 0; k < dataSets.size(); k++) {
265:                                DataSet dataSet = (DataSet) dataSets.get(k);
266:                                if (!dataSet.getParametersHashMap()
267:                                        .containsKey(
268:                                                ((Parameter) pTest
269:                                                        .getParameterList()
270:                                                        .get(i)).getName())) {
271:                                    dataSet.addParameter(param.getName(), "");
272:                                }
273:                            }
274:                        }
275:                    }
276:                }
277:
278:                addTestInCampaignInModel(pTest, pCampain);
279:                return datasetsCreated;
280:            }
281:
282:            /**
283:             * Ajoute une campagne
284:             * @param campagne
285:             */
286:            static void addCampaignInModel(Campaign campaign) {
287:                campaignList.add(campaign);
288:            } // Fin de la méthode addcampaign/1
289:
290:            /* Return True if model need refresh */
291:            public static boolean addCampaignInBDDandModel(Campaign campaign)
292:                    throws Exception {
293:                boolean refresh = false;
294:                //BDD
295:                refresh = campaign.add2DB(getCampaignList().size());
296:
297:                //Model
298:                addCampaignInModel(campaign);
299:
300:                return refresh;
301:            } // Fin de la méthode addcampaign/1
302:
303:            /**************** Operations de suppression dans données **********************************/
304:
305:            /**
306:             * Supprime une campagne en mettant à jour le model
307:             * @param campagne une campagne
308:             */
309:            static void deleteCampaignInModel(Campaign pCampaign) {
310:                campaignList.remove(pCampaign);
311:            } // Fin de la méthode deleteCampaign/1
312:
313:            public static void deleteCampaignFromBDDandModel(Campaign pCampaign)
314:                    throws Exception {
315:                //BDD
316:                pCampaign.deleteFromDB(true);
317:
318:                //Model
319:                deleteCampaignInModel(pCampaign);
320:
321:            } // Fin de la méthode deleteCampaign/1
322:
323:            /**
324:             * Supprime un test d'une campagne en mettan à jour l'ensemble du model
325:             * @param test un test
326:             * @param campagne une campagne
327:             * @return vrai si la campagne est vide
328:             */
329:            static boolean deleteTestFromCampaignInModel(Test test,
330:                    Campaign campaign) {
331:                return campaign.removeTest(test);
332:
333:            } // Fin de la méthode deleteTestFromCampaign/2
334:
335:            static public boolean deleteTestFromCampaignInBDDandModel(
336:                    Test pTest, Campaign pCampaign) throws Exception {
337:                //BDD
338:                pCampaign.deleteTestFromCampInDB(pTest.getIdBDD(), true);
339:                //Model
340:                return deleteTestFromCampaignInModel(pTest, pCampaign);
341:
342:            } // Fin de la méthode deleteTestFromCampaign/2
343:
344:            /**
345:             * 
346:             * @param testName
347:             * @param testListName
348:             * @param familyName
349:             * @param campaign
350:             */
351:            //static void deleteTestFromCampaign(String testName, String testListName, String familyName, Campaign campaign) {
352:            //	campaign.removeTest(TestPlanData.getTest(familyName, testListName, testName));
353:            //}
354:            /**
355:             * Supprime une suite de tests d'une campagne en mettan à jour l'ensemble du model
356:             * @param list une suite de tests
357:             * @param campagne une campagne
358:             * @return vrai si la campgne est vide
359:             */
360:            static boolean deleteTestListFromCampaignInModel(
361:                    TestList pTestList, Campaign campaign) {
362:                return campaign.removeTestList(pTestList);
363:            } // Fin de la méthode deleteTestListFromCampaign/2
364:
365:            static public boolean deleteTestListFromCampaignInBDDandModel(
366:                    TestList pTestList, Campaign campaign) throws Exception {
367:                //BDD
368:                int transNumber = -1;
369:                ArrayList pListofTest = campaign.getTestList();
370:                try {
371:                    transNumber = Api
372:                            .beginTransaction(Api.DELETE_TEST_FROM_CAMPAIGN);
373:                    for (int i = 0; i < pListofTest.size(); i++) {
374:                        Test pTest = (Test) pListofTest.get(i);
375:                        if (pTestList.getTest(pTest.getIdBDD()) != null) {
376:                            campaign.deleteTestFromCampInDB(pTest.getIdBDD(),
377:                                    true);
378:                        }
379:                    }
380:                } catch (Exception e) {
381:                    Api.forceRollBackTrans(transNumber);
382:                    throw e;
383:                }
384:                //Model
385:                return deleteTestListFromCampaignInModel(pTestList, campaign);
386:            } // Fin de la méthode deleteTestListFromCampaign/2
387:
388:            /**
389:             * Supprime une famille d'une campagne en mettan à jour l'ensemble du model
390:             * @param family une famille
391:             * @param campagne une campagne
392:             * @return vrai si la campgne est vide
393:             */
394:            static boolean deleteFamilyFromCampaignFromModel(Family family,
395:                    Campaign campaign) {
396:                return campaign.removeFamily(family);
397:            } // Fin de la méthode deleteFamilyFromCampaign/2
398:
399:            static public boolean deleteFamilyFromCampaignInBDDandModel(
400:                    Family family, Campaign campaign) throws Exception {
401:                //BDD
402:                int transNumber = -1;
403:                ArrayList pListofTest = campaign.getTestList();
404:                try {
405:                    transNumber = Api
406:                            .beginTransaction(Api.DELETE_TEST_FROM_CAMPAIGN);
407:                    for (int i = 0; i < pListofTest.size(); i++) {
408:                        Test pTest = (Test) pListofTest.get(i);
409:                        if (family.isContainTest(pTest)) {
410:                            campaign.deleteTestFromCampInDB(pTest.getIdBDD(),
411:                                    true);
412:                        }
413:                    }
414:                    Api.commitTrans(transNumber);
415:                } catch (Exception e) {
416:                    Api.forceRollBackTrans(transNumber);
417:                    throw e;
418:                }
419:
420:                //Model
421:                return deleteFamilyFromCampaignFromModel(family, campaign);
422:            } // Fin de la méthode deleteFamilyFromCampaign/2
423:
424:            /******************************************************************************************************************/
425:
426:            /**
427:             * Rend vrai si le nom passé en paramètre correspond au nom d'une campagne 
428:             * @param campagneName un nom 
429:             * @return Rend vrai si le nom passé en paramètre correspond au nom d'une 
430:             * campagne, faux sinon.
431:             */
432:            public static boolean containsCampaign(String campaignName) {
433:                for (int i = 0; i < campaignList.size(); i++) {
434:                    if (((Campaign) campaignList.get(i)).getName().equals(
435:                            campaignName)) {
436:                        return true;
437:                    }
438:                }
439:                return false;
440:            } // Fin de la méthode containsCampaign/1
441:
442:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.