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


0001:        /*
0002:         * Created on 6 juin 2005
0003:         * SalomeTMF is a Test Managment Framework
0004:         * Copyright (C) 2005 France Telecom R&D
0005:         *
0006:         * This library is free software; you can redistribute it and/or
0007:         * modify it under the terms of the GNU Lesser General Public
0008:         * License as published by the Free Software Foundation; either
0009:         * version 2 of the License, or (at your option) any later version.
0010:         *
0011:         * This library is distributed in the hope that it will be useful,
0012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014:         * Lesser General Public License for more details.
0015:         *
0016:         * You should have received a copy of the GNU Lesser General Public
0017:         * License along with this library; if not, write to the Free Software
0018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0019:         *
0020:         * Contact: mikael.marche@rd.francetelecom.com
0021:         */
0022:        package org.objectweb.salome_tmf.data;
0023:
0024:        import java.net.URL;
0025:        import java.util.ArrayList;
0026:        import java.util.HashMap;
0027:        import java.util.Vector;
0028:
0029:        import org.objectweb.salome_tmf.api.Api;
0030:        import org.objectweb.salome_tmf.api.ApiConstants;
0031:        import org.objectweb.salome_tmf.api.api2ihm.AdminProject;
0032:        import org.objectweb.salome_tmf.api.api2ihm.AdminVT;
0033:        import org.objectweb.salome_tmf.api.api2ihm.CampTest;
0034:        import org.objectweb.salome_tmf.api.api2ihm.SuiteTest;
0035:        import org.objectweb.salome_tmf.api.api2ihm.campTest.TestSuiteFamily;
0036:        import org.objectweb.salome_tmf.api.wrapper.ActionWrapper;
0037:        import org.objectweb.salome_tmf.api.wrapper.AutomaticTestWrapper;
0038:        import org.objectweb.salome_tmf.api.wrapper.CampaignWrapper;
0039:        import org.objectweb.salome_tmf.api.wrapper.DataSetWrapper;
0040:        import org.objectweb.salome_tmf.api.wrapper.EnvironmentWrapper;
0041:        import org.objectweb.salome_tmf.api.wrapper.ExecutionResultWrapper;
0042:        import org.objectweb.salome_tmf.api.wrapper.ExecutionWrapper;
0043:        import org.objectweb.salome_tmf.api.wrapper.FamilyWrapper;
0044:        import org.objectweb.salome_tmf.api.wrapper.FileAttachementWrapper;
0045:        import org.objectweb.salome_tmf.api.wrapper.ManualTestWrapper;
0046:        import org.objectweb.salome_tmf.api.wrapper.ParameterWrapper;
0047:        import org.objectweb.salome_tmf.api.wrapper.ScriptWrapper;
0048:        import org.objectweb.salome_tmf.api.wrapper.SuiteWrapper;
0049:        import org.objectweb.salome_tmf.api.wrapper.TestWrapper;
0050:        import org.objectweb.salome_tmf.api.wrapper.UrlAttachementWrapper;
0051:
0052:        //import org.objectweb.salome_tmf.ihm.languages.Language;
0053:
0054:        /**
0055:         * @author marchemi
0056:         *  
0057:         */
0058:        public class ProjectData implements  ApiConstants {
0059:
0060:            /* Donnné d'un projet */
0061:
0062:            /**
0063:             * Nom des éléments vides
0064:             */
0065:            //static final public String EMPTY_NAME = Language.getInstance().getText("Aucun");
0066:            /**
0067:             * La clé est un nom de jeu de données et la valeur le jeu de données correspondant.
0068:             */
0069:            //static HashMap dataSetHashMap = new HashMap();;
0070:
0071:            /* Environnement vide */
0072:            static private Environment emptyEnvironment;
0073:
0074:            /* Jeu de données vide */
0075:            static private DataSet emptyDataSet;
0076:
0077:            /* Wrapper to IHM */
0078:            static private DataModelWrapper pDataModelWrapper = null;
0079:            static private Project currentProject;
0080:            static private User currentUser;
0081:
0082:            /* Constructeur */
0083:            public ProjectData(DataModelWrapper pDataModelWrapper) {
0084:                this .pDataModelWrapper = pDataModelWrapper;
0085:            }
0086:
0087:            /**************************************************************************/
0088:            /**							METHODES D'ACCES AUX DONNES				    ***/
0089:            /**************************************************************************/
0090:
0091:            public static void setDataModelWrapper(
0092:                    DataModelWrapper ptrDataModelWrapper) {
0093:                pDataModelWrapper = ptrDataModelWrapper;
0094:            }
0095:
0096:            /**
0097:             * Retourne le jeu de données associé au nom passé en paramètre
0098:             * @return un jeu de données
0099:             */
0100:            /*public static DataSet getDataSet(String dataSetName) {
0101:            	return (DataSet)dataSetHashMap.get(dataSetName);
0102:            } // Fin de la méthode getDataSet/1
0103:             */
0104:            /**
0105:             * @return
0106:             */
0107:            public static DataSet getEmptyDataSet() {
0108:                if (emptyDataSet == null) {
0109:                    emptyDataSet = new DataSet();
0110:                    emptyDataSet.setName(EMPTY_NAME);
0111:                }
0112:                return emptyDataSet;
0113:            }
0114:
0115:            /**
0116:             * @return
0117:             */
0118:            public static Environment getEmptyEnvironment() {
0119:                if (emptyEnvironment == null) {
0120:                    emptyEnvironment = new Environment();
0121:                    emptyEnvironment.setName(EMPTY_NAME);
0122:                }
0123:                return emptyEnvironment;
0124:            }
0125:
0126:            /**
0127:             * @return l'utilisateur courant
0128:             */
0129:            public static User getCurrentUser() {
0130:                return currentUser;
0131:            } // Fin de la méthode getCurrentUser/0
0132:
0133:            /**
0134:             * @return le projet en cours de traitement
0135:             */
0136:            public static Project getCurrentProject() {
0137:                return currentProject;
0138:            } // Fin de la méthode getCurrentProject/0
0139:
0140:            //****************** Open Connection  to BDD DATA ********************/
0141:
0142:            public static boolean dataConnected() {
0143:                return ConnectionData.isConnected();
0144:            }
0145:
0146:            private static void openConnections(String userLogin,
0147:                    java.net.URL url_applet) {
0148:                //Api.openConnection(url_applet);
0149:                AdminVT adminVT = Api.getInstanceOfAdminVT();
0150:                ConnectionData.setAdminVTSelect(adminVT.getAdminVTSelect());
0151:                ConnectionData.setAdminVTUpdate(adminVT.getAdminVTUpdate());
0152:
0153:                AdminProject adminProject = Api.getInstanceOfAdminProject();
0154:                ConnectionData.setAdminProject(adminProject);
0155:                ConnectionData.setAdminProjectSelect(adminProject
0156:                        .getAdminProjectSelect());
0157:                ConnectionData.getAdminProjectSelect().setProject(
0158:                        currentProject.getName());
0159:                User user = new User();
0160:                user.setLogin(userLogin);
0161:                user.setFirstName(ConnectionData.getAdminVTSelect()
0162:                        .getUserFirstName(userLogin));
0163:                user.setLastName(ConnectionData.getAdminVTSelect().getUserName(
0164:                        userLogin));
0165:                user.setEmail(ConnectionData.getAdminVTSelect().getUserEmail(
0166:                        userLogin));
0167:                user.setPhoneNumber(ConnectionData.getAdminVTSelect()
0168:                        .getUserTel(userLogin));
0169:                currentUser = user;
0170:
0171:                adminProject.setUser(currentUser.getLogin());
0172:
0173:                ConnectionData.setAdminProjectInsert(adminProject
0174:                        .getAdminProjectInsert());
0175:                ConnectionData.getAdminProjectInsert().setProject(
0176:                        currentProject.getName());
0177:                ConnectionData.setAdminProjectDelete(adminProject
0178:                        .getAdminProjectDelete());
0179:                ConnectionData.getAdminProjectDelete().setProject(
0180:                        currentProject.getName());
0181:
0182:                // Les suites de tests
0183:
0184:                SuiteTest suiteTest = Api.getInstanceOfSuiteTest();
0185:                ConnectionData.setSuiteTestSelect(suiteTest
0186:                        .getSuiteTestSelect());
0187:                ConnectionData.getSuiteTestSelect().setProject(
0188:                        currentProject.getName());
0189:                ConnectionData.setSuiteTestDelete(suiteTest
0190:                        .getSuiteTestDelete());
0191:                ConnectionData.getSuiteTestDelete().setProject(
0192:                        currentProject.getName());
0193:                ConnectionData.setSuiteTestInsert(suiteTest
0194:                        .getSuiteTestInsert());
0195:                ConnectionData.getSuiteTestInsert().setProject(
0196:                        currentProject.getName());
0197:                ConnectionData.setSuiteTestUpdate(suiteTest
0198:                        .getSuiteTestUpdate());
0199:                ConnectionData.getSuiteTestUpdate().setProject(
0200:                        currentProject.getName());
0201:
0202:                // Les campagnes de tests
0203:
0204:                CampTest campTest = Api.getInstanceOfCampTest();
0205:                ConnectionData.setCampTest(campTest);
0206:                ConnectionData.setCampTestInsert(campTest.getCampTestInsert());
0207:                ConnectionData.getCampTestInsert().setProject(
0208:                        currentProject.getName());
0209:                ConnectionData.setCampTestDelete(campTest.getCampTestDelete());
0210:                ConnectionData.getCampTestDelete().setProject(
0211:                        currentProject.getName());
0212:                ConnectionData.setCampTestSelect(campTest.getCampTestSelect());
0213:                ConnectionData.getCampTestSelect().setProject(
0214:                        currentProject.getName());
0215:                ConnectionData.setCampTestUpdate(campTest.getCampTestUpdate());
0216:                ConnectionData.getCampTestUpdate().setProject(
0217:                        currentProject.getName());
0218:
0219:            }
0220:
0221:            /**************** Chargement des données ********************************/
0222:
0223:            public static void clearData() {
0224:                clearTestPlanData();
0225:                clearCampainData();
0226:            }
0227:
0228:            public static void clearTestPlanData() {
0229:                TestPlanData.clearData();
0230:            }
0231:
0232:            public static void clearCampainData() {
0233:                CampaignData.clearData();
0234:            }
0235:
0236:            public static void loadData(String p, String userLogin, URL url)
0237:                    throws Exception {
0238:                try {
0239:                    if (ConnectionData.isConnected()) {
0240:                        Project project = new Project();
0241:                        project.setName(p);
0242:                        currentProject = project;
0243:                        // Ouverture des connection à la base
0244:                        openConnections(userLogin, url);
0245:                        int transNumber = -1;
0246:                        try {
0247:                            transNumber = Api.beginTransaction(Api.LOADING);
0248:                            loadParametersData(true);
0249:                            loadEnvironmentData(true);
0250:                            loadTestData(true);
0251:                            loadCampaignData(true);
0252:                            Api.commitTrans(transNumber);
0253:                        } catch (Exception exception) {
0254:                            Api.forceRollBackTrans(transNumber);
0255:                            throw exception;
0256:                        }
0257:                    }
0258:                } catch (Exception e) {
0259:                    e.printStackTrace();
0260:                    ConnectionData.setConnected(false);
0261:                    throw e;
0262:                }
0263:            } // Fin de la méthode initDataTests
0264:
0265:            private static void loadParametersData(boolean forinit) {
0266:                boolean newParameter = false;
0267:                Vector projectParam = ConnectionData.getAdminProjectSelect()
0268:                        .getProjectParams();
0269:                if (pDataModelWrapper != null) {
0270:                    pDataModelWrapper.clearParameterToModel();
0271:                }
0272:                for (int m = 0; m < projectParam.size(); m++) {
0273:                    ParameterWrapper paramBdd = (ParameterWrapper) projectParam
0274:                            .get(m);
0275:                    Parameter param = null;
0276:                    if (!forinit)
0277:                        param = currentProject
0278:                                .getParameter(paramBdd.getIdBDD());
0279:
0280:                    if (param != null) {
0281:                        newParameter = false;
0282:                    } else {
0283:                        param = new Parameter(paramBdd);
0284:                        newParameter = true;
0285:                    }
0286:                    if (newParameter) {
0287:                        currentProject.addParameterToModel(param);
0288:                    }
0289:                    ArrayList data = new ArrayList();
0290:                    data.add(param.getName());
0291:                    data.add(param.getDescription());
0292:
0293:                    if (pDataModelWrapper != null)
0294:                        pDataModelWrapper.addParameterToModel(data);
0295:
0296:                }
0297:            }
0298:
0299:            public static void reloadData(boolean clear) {
0300:                if (clear) {
0301:                    clearTestPlanData();
0302:                }
0303:                clearCampainData();
0304:                if (ConnectionData.isConnected()) {
0305:                    loadParametersData(clear);
0306:                    loadEnvironmentData(clear);
0307:                    loadTestData(clear);
0308:                    loadCampaignData(false);
0309:                }
0310:            }
0311:
0312:            /* ancien refresh refreshAllTestData*/
0313:            public static void realoadTestData() {
0314:                if (ConnectionData.isConnected()) {
0315:                    loadTestData(false);
0316:                }
0317:            }
0318:
0319:            /* ancien refresh refreshAllCampaignData*/
0320:            public static void reloadCampaignData() {
0321:                if (ConnectionData.isConnected()) {
0322:                    loadCampaignData(false);
0323:                }
0324:            }
0325:
0326:            /* ancien refresh refreshEnvironmentAndParameter */
0327:            public static void reloadEnvironmentAndParameterData() {
0328:                if (ConnectionData.isConnected()) {
0329:                    loadParametersData(false);
0330:                    loadEnvironmentData(false);
0331:                }
0332:            }
0333:
0334:            public static void refreshTestData(Test test) {
0335:                ArrayList oldTestList = test.getTestList().getTestList();
0336:                Vector testVector = ConnectionData.getSuiteTestSelect()
0337:                        .getSuiteTests(test.getTestList().getName(),
0338:                                test.getTestList().getFamily().getName());
0339:                //initTestList(test.getTestList(), SalomeTMF.getTestDynamicTree().findRemoveTestListNode(test.getTestList().getName(), test.getTestList().getFamily().getName(),false), false );
0340:                if (pDataModelWrapper != null)
0341:                    pDataModelWrapper.clearTestListToModel(test.getTestList());
0342:                loadTestListData(test.getTestList(), false);
0343:                if (oldTestList != null && oldTestList.size() > 0) {
0344:                    for (int i = oldTestList.size() - 1; i >= 0; i--) {
0345:                        if (!testVector.contains(((Test) oldTestList.get(i))
0346:                                .getName())) {
0347:                            TestPlanData.deleteTestInModel((Test) oldTestList
0348:                                    .get(i));
0349:                            if (pDataModelWrapper != null)
0350:                                pDataModelWrapper
0351:                                        .clearTestToModel((Test) oldTestList
0352:                                                .get(i));
0353:                            //SalomeTMF.getTestDynamicTree().findRemoveTestNode(((Test)oldTestList.get(i)).getName(), ((Test)oldTestList.get(i)).getTestList().getName(),((Test)oldTestList.get(i)).getTestList().getFamily().getName(), true);
0354:                        }
0355:                    }
0356:                }
0357:
0358:            } // Fin de la méthode refreshTest/1
0359:
0360:            /**
0361:             * 
0362:             * @param testList
0363:             */
0364:            public static void refreshTestListData(TestList testList) {
0365:                ArrayList oldTestListList = testList.getFamily()
0366:                        .getTestListList();
0367:                Vector testListVector = ConnectionData.getSuiteTestSelect()
0368:                        .getFamilySuites(testList.getFamily().getName());
0369:                //SalomeTMF.getTestDynamicTree().findRemoveFamilyNode(testList.getFamily().getName(), false),
0370:                if (pDataModelWrapper != null)
0371:                    pDataModelWrapper.clearFamilyToModel(testList.getFamily());
0372:                loadFamilyData(testList.getFamily(), false);
0373:                if (oldTestListList != null && oldTestListList.size() > 0) {
0374:                    for (int i = oldTestListList.size() - 1; i >= 0; i--) {
0375:                        if (!testListVector
0376:                                .contains(((TestList) oldTestListList.get(i))
0377:                                        .getName())) {
0378:                            TestPlanData
0379:                                    .deleteTestListInModel((TestList) oldTestListList
0380:                                            .get(i));
0381:                            if (pDataModelWrapper != null)
0382:                                pDataModelWrapper
0383:                                        .clearTestListToModel((TestList) oldTestListList
0384:                                                .get(i));
0385:                            //SalomeTMF.getTestDynamicTree().findRemoveTestListNode(((TestList)oldTestListList.get(i)).getName(), ((TestList)oldTestListList.get(i)).getFamily().getName(), true);
0386:                        }
0387:                    }
0388:                }
0389:            } // Fin de la méthode refreshTestList/1
0390:
0391:            private static void loadEnvironmentData(boolean forinit) {
0392:                boolean newEnvironment = false;
0393:                Vector environmentOfProject = ConnectionData
0394:                        .getAdminProjectSelect().getProjectEnvs();
0395:                for (int m = 0; m < environmentOfProject.size(); m++) {
0396:                    EnvironmentWrapper envDB = (EnvironmentWrapper) environmentOfProject
0397:                            .get(m);
0398:                    Environment env = null;
0399:                    if (!forinit)
0400:                        env = currentProject.getEnvironment(envDB.getIdBDD());
0401:                    if (env != null) {
0402:                        newEnvironment = false;
0403:                    } else {
0404:                        env = new Environment(envDB);
0405:                        newEnvironment = true;
0406:                    }
0407:                    Vector paramNameVector = ConnectionData
0408:                            .getAdminProjectSelect().getEnvParamsName(
0409:                                    env.getName());
0410:                    for (int n = 0; n < paramNameVector.size(); n++) {
0411:                        String value = ConnectionData.getAdminProjectSelect()
0412:                                .getParamValueInEnv(env.getName(),
0413:                                        (String) paramNameVector.get(n));
0414:                        env.addParameter(currentProject
0415:                                .getParameter((String) paramNameVector.get(n)),
0416:                                value);
0417:                    }
0418:                    //String scriptName = ConnectionData.getCampTestSelect().getEnvironmentScriptName(env.getName());
0419:                    ScriptWrapper script = ConnectionData.getCampTestSelect()
0420:                            .getEnvironmentScript(env.getIdBdd());
0421:                    if (script != null) {
0422:                        env.setInitScript(new Script(script));
0423:                    }
0424:
0425:                    if (newEnvironment) {
0426:                        currentProject.addEnvironmentInModel(env);
0427:                    }
0428:
0429:                    ArrayList data = new ArrayList();
0430:                    data.add(env.getName());
0431:                    if (env.getInitScript() != null) {
0432:                        data.add(env.getInitScript().getName());
0433:                    } else {
0434:                        data.add("");
0435:                    }
0436:                    data.add(env.getParametersHashTable());
0437:                    data.add(env.getDescription());
0438:                    if (pDataModelWrapper != null)
0439:                        pDataModelWrapper.addEnvToModel(data);
0440:
0441:                    Vector envFileNameAttachVector = ConnectionData
0442:                            .getCampTestSelect().getEnvAttachFiles(
0443:                                    env.getIdBdd());
0444:                    Vector envUrlAttachVector = ConnectionData
0445:                            .getCampTestSelect().getEnvAttachUrls(
0446:                                    env.getIdBdd());
0447:                    loadAttachmentData(env, envFileNameAttachVector,
0448:                            envUrlAttachVector);
0449:                }
0450:
0451:            }
0452:
0453:            private static void loadFamilyData(Family family, boolean forinit) {
0454:                // Pour savoir si la suite est nouvelle
0455:                boolean newTestList = false;
0456:                Vector testListVector = ConnectionData.getSuiteTestSelect()
0457:                        .getFamilySuites(family.getIdBdd());
0458:                for (int j = 0; j < testListVector.size(); j++) {
0459:                    SuiteWrapper testListBdd = (SuiteWrapper) testListVector
0460:                            .get(j);
0461:                    TestList testList = null;
0462:                    if (!forinit)
0463:                        testList = family.getTestList(testListBdd.getIdBDD());
0464:
0465:                    if (testList != null) {
0466:                        //La suite est déjà présente
0467:                        testList.getAttachmentMap().clear();
0468:                        newTestList = false;
0469:                    } else {
0470:                        // La suite n'existe pas encore
0471:                        testList = new TestList(testListBdd);
0472:                        newTestList = true;
0473:                    }
0474:
0475:                    testList.setFamily(family);
0476:                    //DefaultMutableTreeNode testListNode;
0477:                    if (newTestList) {
0478:                        //testListNode = SalomeTMF.getTestDynamicTree().addObject(familyNode,testList,false);
0479:                        family.addTestList(testList);
0480:                        if (pDataModelWrapper != null)
0481:                            pDataModelWrapper.addTestListToModel(family,
0482:                                    testList);
0483:                    } else {
0484:                        if (pDataModelWrapper != null)
0485:                            pDataModelWrapper.updateTestListToModel(testList);
0486:                        //testListNode = SalomeTMF.getTestDynamicTree().findRemoveTestListNode(testList.getName(), testList.getFamily().getName(), false);
0487:                    }
0488:                    Vector fileNameAttachVector = ConnectionData
0489:                            .getSuiteTestSelect().getSuiteAttachFile(
0490:                                    testList.getIdBdd());
0491:                    Vector urlAttachVector = ConnectionData
0492:                            .getSuiteTestSelect().getSuiteAttachUrls(
0493:                                    testList.getIdBdd());
0494:                    loadAttachmentData(testList, fileNameAttachVector,
0495:                            urlAttachVector);
0496:
0497:                    //family.addTestList(testList);
0498:                    loadTestListData(testList, forinit);
0499:
0500:                    if (pDataModelWrapper != null)
0501:                        pDataModelWrapper.refreshTestListToModel(testList);
0502:
0503:                }
0504:            } // Fin de la méthode initFamily/2
0505:
0506:            private static void loadTestListData(TestList testList,
0507:                    boolean forinit) {
0508:                boolean newTest = false;
0509:                Vector testVector = ConnectionData.getSuiteTestSelect()
0510:                        .getSuiteTests(testList.getIdBdd());
0511:
0512:                for (int k = 0; k < testVector.size(); k++) {
0513:                    TestWrapper testBdd = (TestWrapper) testVector.get(k);
0514:                    Test test = null;
0515:                    if (!forinit)
0516:                        test = testList.getTest(testBdd.getIdBDD());
0517:
0518:                    if (test != null) {
0519:                        test.getAttachmentMap().clear();
0520:                        test.getParameterList().clear();
0521:                        if (test instanceof  ManualTest) {
0522:                            ((ManualTest) test).getActionList().clear();
0523:                        }
0524:                        newTest = false;
0525:                    } else {
0526:                        if (testBdd instanceof  ManualTestWrapper) {
0527:                            test = new ManualTest((ManualTestWrapper) testBdd);
0528:                        } else {
0529:                            test = new AutomaticTest(
0530:                                    (AutomaticTestWrapper) testBdd);
0531:                        }
0532:
0533:                        newTest = true;
0534:                    }
0535:                    Vector testParamNameVector = ConnectionData
0536:                            .getSuiteTestSelect().getTestParamsName(
0537:                                    test.getIdBDD());
0538:
0539:                    for (int g = 0; g < testParamNameVector.size(); g++) {
0540:                        test.addParameter(currentProject
0541:                                .getParameter((String) testParamNameVector
0542:                                        .get(g)));
0543:                    }
0544:
0545:                    if (test instanceof  ManualTest) {
0546:                        Vector actionVector = ConnectionData
0547:                                .getSuiteTestSelect().getAllTestActions(
0548:                                        test.getIdBDD());
0549:                        for (int h = 0; h < actionVector.size(); h++) {
0550:                            Action action = new Action(
0551:                                    (ActionWrapper) actionVector.get(h), test);
0552:
0553:                            Vector actionFileNameAttachVector = ConnectionData
0554:                                    .getSuiteTestSelect().getActionAttachFile(
0555:                                            action.getIdBdd());
0556:                            Vector actionUrlAttachVector = ConnectionData
0557:                                    .getSuiteTestSelect().getActionAttachUrls(
0558:                                            action.getIdBdd());
0559:
0560:                            loadAttachmentData(action,
0561:                                    actionFileNameAttachVector,
0562:                                    actionUrlAttachVector);
0563:                            // Paramètres de l'action
0564:                            Vector paramActionVector = ConnectionData
0565:                                    .getSuiteTestSelect().getActionParamsName(
0566:                                            testList.getFamily().getName(),
0567:                                            testList.getName(), test.getName(),
0568:                                            action.getName());
0569:                            for (int g = 0; g < paramActionVector.size(); g++) {
0570:                                action
0571:                                        .addParameter(currentProject
0572:                                                .getParameter((String) paramActionVector
0573:                                                        .get(g)));
0574:                            }
0575:                            ((ManualTest) test).addAction(action);
0576:                        }
0577:                    } else {
0578:                        ScriptWrapper script = ConnectionData
0579:                                .getSuiteTestSelect().getTestScript(
0580:                                        test.getIdBDD());
0581:                        if (script != null) {
0582:                            ((AutomaticTest) test)
0583:                                    .setScript(new Script(script));
0584:                        }
0585:                    }
0586:
0587:                    Vector fileNameAttachVector = ConnectionData
0588:                            .getSuiteTestSelect().getTestAttachFiles(
0589:                                    test.getIdBDD());
0590:                    Vector urlAttachVector = ConnectionData
0591:                            .getSuiteTestSelect().getTestAttachUrls(
0592:                                    test.getIdBDD());
0593:                    loadAttachmentData(test, fileNameAttachVector,
0594:                            urlAttachVector);
0595:
0596:                    test.setTestList(testList);
0597:                    //testList.addTest(test);
0598:                    if (newTest) {
0599:                        // Le nouveau test est ajouté dans l'arbre
0600:                        //            	DefaultMutableTreeNode testListNode,
0601:                        //SalomeTMF.getTestDynamicTree().addObject(testListNode,test,false);
0602:                        testList.addTest(test);
0603:                        if (pDataModelWrapper != null)
0604:                            pDataModelWrapper.addTestToModel(testList, test);
0605:                    } else {
0606:                        if (pDataModelWrapper != null) {
0607:                            pDataModelWrapper.updateTestToModel(testList, test);
0608:                            pDataModelWrapper.refreshTestToModel(test);
0609:                        }
0610:
0611:                    }
0612:                }
0613:
0614:            } // Fin de la méthode refreshTestList/2
0615:
0616:            private static void loadTestData(boolean forinit) {
0617:                boolean newFamily = false;
0618:                Vector familyVector = ConnectionData.getSuiteTestSelect()
0619:                        .getAllProjectFamilies();
0620:                for (int i = 0; i < familyVector.size(); i++) {
0621:                    FamilyWrapper familyBdd = (FamilyWrapper) familyVector
0622:                            .get(i);
0623:                    //Family family = getFamily((String)familyVector.get(i));
0624:                    Family family = null;
0625:                    if (!forinit)
0626:                        family = TestPlanData.getFamily(familyBdd.getIdBDD());
0627:
0628:                    if (family != null) {
0629:                        newFamily = false;
0630:                    } else {
0631:                        // La famille n'existe pas encore
0632:                        family = new Family(familyBdd);
0633:                        newFamily = true;
0634:                    }
0635:
0636:                    //DefaultMutableTreeNode familyNode; 
0637:                    if (newFamily) {
0638:                        TestPlanData.addFamilyInModel(family);
0639:                        //familyNode = SalomeTMF.getTestDynamicTree().addObject(null,family,true);
0640:                        if (pDataModelWrapper != null)
0641:                            pDataModelWrapper.addFamilyToModel(family);
0642:                    } else {
0643:                        if (pDataModelWrapper != null)
0644:                            pDataModelWrapper.updateFamilyToModel(family);
0645:                        //familyNode = SalomeTMF.getTestDynamicTree().findRemoveFamilyNode(family.getName(), false);
0646:                    }
0647:                    //TestPlanData.addFamilyInModel(family); 
0648:                    loadFamilyData(family, forinit);
0649:
0650:                    if (pDataModelWrapper != null)
0651:                        pDataModelWrapper.refreshFamilyToModel(family);
0652:                }
0653:            }
0654:
0655:            private static void loadCampaignData(boolean forinit) {
0656:                boolean newCampaign = false;
0657:                Vector campaignVector = ConnectionData.getCampTestSelect()
0658:                        .getAllProjectCampaigns();
0659:                for (int i = 0; i < campaignVector.size(); i++) {
0660:                    CampaignWrapper campaignBdd = (CampaignWrapper) campaignVector
0661:                            .get(i);
0662:                    Campaign campaign = null;
0663:                    if (!forinit)
0664:                        campaign = CampaignData.getCampaign(campaignBdd
0665:                                .getIdBDD());
0666:
0667:                    if (campaign != null) {
0668:                        newCampaign = false;
0669:                    } else {
0670:                        campaign = new Campaign(campaignBdd);
0671:                        newCampaign = true;
0672:                    }
0673:
0674:                    //DefaultMutableTreeNode campaignNode;
0675:                    if (newCampaign) {
0676:                        //campaignNode = SalomeTMF.getCampaignDynamicTree().addObject(null,campaign,true);
0677:                        if (pDataModelWrapper != null)
0678:                            pDataModelWrapper.addCampaignToModel(campaign);
0679:                    } else {
0680:                        //campaignNode = SalomeTMF.getCampaignDynamicTree().findRemoveCampaignNode(campaign.getName(), false);
0681:                        if (pDataModelWrapper != null)
0682:                            pDataModelWrapper.upadateCampaignToModel(campaign);
0683:                    }
0684:
0685:                    Vector campaignDataVector = ConnectionData
0686:                            .getCampTestSelect().getCampaignTests(
0687:                                    campaign.getName());
0688:                    for (int j = 0; j < campaignDataVector.size(); j++) {
0689:                        TestSuiteFamily tsf = (TestSuiteFamily) campaignDataVector
0690:                                .get(j);
0691:                        Family family = null;
0692:                        family = campaign.containsFamily(tsf.getFamilyName());
0693:                        //DefaultMutableTreeNode familyNode;
0694:
0695:                        if (family == null) {
0696:                            family = TestPlanData
0697:                                    .getFamily(tsf.getFamilyName());
0698:                            campaign.addFamily(family);
0699:                            //familyNode = SalomeTMF.getCampaignDynamicTree().addObject(campaignNode, family, false);
0700:                            if (pDataModelWrapper != null)
0701:                                pDataModelWrapper.addCampaignFamilyToModel(
0702:                                        campaign, family);
0703:                        } else {
0704:                            //familyNode = SalomeTMF.getCampaignDynamicTree().findRemoveFamilyNodeInCampagneTree(tsf.getFamilyName(), campaign.getName(), false);
0705:                            if (pDataModelWrapper != null)
0706:                                pDataModelWrapper.upadateCampaignFamilyToModel(
0707:                                        campaign, family);
0708:                        }
0709:
0710:                        //DefaultMutableTreeNode testListNode = SalomeTMF.getCampaignDynamicTree().findRemoveTestListNodeInCampagneTree(tsf.getSuiteName(), tsf.getFamilyName(), campaign.getName(), false);
0711:                        TestList testList;
0712:                        testList = campaign
0713:                                .containsTestList(tsf.getSuiteName());
0714:                        //if (testListNode == null) {
0715:                        if (testList == null) {
0716:                            testList = TestPlanData.getTestList(family
0717:                                    .getName(), tsf.getSuiteName());
0718:                            campaign.addOnlyTestList(testList);
0719:                            //testListNode = SalomeTMF.getCampaignDynamicTree().addObject(familyNode, testList, false);
0720:                            if (pDataModelWrapper != null)
0721:                                pDataModelWrapper.addCampaignTestListToModel(
0722:                                        family, testList);
0723:                        } else {
0724:                            //testList = (TestList)testListNode.getUserObject();
0725:                            //testListNode = SalomeTMF.getCampaignDynamicTree().findRemoveTestListNodeInCampagneTree(tsf.getSuiteName(), tsf.getFamilyName(), campaign.getName(), false);
0726:                            if (pDataModelWrapper != null)
0727:                                pDataModelWrapper
0728:                                        .upadateCampaignTestListToModel(
0729:                                                campaign, family, testList);
0730:                        }
0731:                        //Test test = (AutomaticTest)TestPlanData.getTest(family.getName(), testList.getName(), tsf.getTestName());
0732:                        Test test = TestPlanData.getTest(family.getName(),
0733:                                testList.getName(), tsf.getTestName());
0734:                        if (!campaign.containsTest(tsf.getTestName())) {
0735:                            if (pDataModelWrapper != null)
0736:                                pDataModelWrapper.addCampaignTestToModel(
0737:                                        testList, test);
0738:                            //SalomeTMF.getCampaignDynamicTree().addObject(testListNode, test, false);
0739:                        }
0740:                        campaign.addTest(test);
0741:
0742:                        /*if (ConnectionData.getSuiteTestSelect().getTestType(tsf.getTestName(), tsf.getSuiteName(), tsf.getFamilyName()).equalsIgnoreCase(MANUAL)) {
0743:                        	
0744:                        	ManualTest test = (ManualTest)getTest(family.getName(), testList.getName(), tsf.getTestName());
0745:                        	if (!campaign.containsTest(tsf.getTestName())) {
0746:                        		SalomeTMF.getCampaignDynamicTree().addObject(testListNode, test, false);
0747:                        	}
0748:                        	campaign.addTest(test);
0749:
0750:                        } else {
0751:                        	AutomaticTest test = (AutomaticTest)getTest(family.getName(), testList.getName(), tsf.getTestName());
0752:                        	if (!campaign.containsTest(tsf.getTestName())) {
0753:                        		SalomeTMF.getCampaignDynamicTree().addObject(testListNode, test, false);
0754:                        	}
0755:                        	campaign.addTest(test);
0756:                        }*/
0757:
0758:                    }
0759:
0760:                    Vector dataSetVector = ConnectionData.getCampTestSelect()
0761:                            .getCampJeuxDonnees(campaign.getIdBdd());
0762:                    for (int h = 0; h < dataSetVector.size(); h++) {
0763:                        DataSet dataSet = new DataSet(
0764:                                (DataSetWrapper) dataSetVector.get(h));
0765:                        Vector paramNameOfDataSet = ConnectionData
0766:                                .getCampTestSelect().getJeuDonneesParamsName(
0767:                                        campaign.getName(), dataSet.getName());
0768:                        Vector paramValueOfDataSet = ConnectionData
0769:                                .getCampTestSelect().getJeuDonneesParamsValue(
0770:                                        campaign.getName(), dataSet.getName());
0771:                        for (int m = 0; m < paramNameOfDataSet.size(); m++) {
0772:                            Parameter param = currentProject
0773:                                    .getParameter((String) paramNameOfDataSet
0774:                                            .get(m));
0775:                            dataSet.addParameter(param.getName(),
0776:                                    (String) paramValueOfDataSet.get(m));
0777:
0778:                        }
0779:                        campaign.addDataSet(dataSet);
0780:                    }
0781:
0782:                    Vector execVector = ConnectionData.getCampTestSelect()
0783:                            .getCampaignExecutions(campaign.getIdBdd());
0784:                    for (int l = 0; l < execVector.size(); l++) {
0785:                        Execution exec = new Execution(
0786:                                (ExecutionWrapper) execVector.get(l));
0787:                        exec.setCampagne(campaign);
0788:                        String envName = ConnectionData.getCampTestSelect()
0789:                                .getExecutionEnv(campaign.getName(),
0790:                                        exec.getName());
0791:                        if (envName == null) {
0792:                            exec.setEnvironment(getEmptyEnvironment());
0793:                        } else {
0794:                            exec.setEnvironment(currentProject
0795:                                    .getEnvironment(envName));
0796:                        }
0797:                        String dataSetName = ConnectionData.getCampTestSelect()
0798:                                .getExecutionJeuDonnees(campaign.getName(),
0799:                                        exec.getName());
0800:                        if (dataSetName == null) {
0801:                            exec.setDataSet(getEmptyDataSet());
0802:                        } else {
0803:                            exec.setDataSet(campaign.getDataSet(dataSetName));
0804:                        }
0805:
0806:                        ScriptWrapper[] pScript = ConnectionData
0807:                                .getCampTestSelect().getExecutionScript(
0808:                                        exec.getIdBdd());
0809:                        if (pScript[0] != null) {
0810:                            if (pScript[0].getType().equals(PRE_SCRIPT))
0811:                                exec.setInitScript(new Script(pScript[0]));
0812:                            else
0813:                                exec.setPostScript(new Script(pScript[0]));
0814:
0815:                            if (pScript[1] != null) {
0816:                                if (pScript[1].getType().equals(PRE_SCRIPT))
0817:                                    exec.setInitScript(new Script(pScript[1]));
0818:                                else
0819:                                    exec.setPostScript(new Script(pScript[1]));
0820:                            }
0821:                        }
0822:
0823:                        campaign.addExecution(exec);
0824:
0825:                        Vector execResults = ConnectionData.getCampTestSelect()
0826:                                .getExecutionResults(exec.getIdBdd());
0827:
0828:                        for (int h = 0; h < execResults.size(); h++) {
0829:                            ExecutionResult execResult = new ExecutionResult(
0830:                                    (ExecutionResultWrapper) execResults.get(h));
0831:                            for (int m = 0; m < campaign.getTestList().size(); m++) {
0832:                                Test testOfCampaignForStatus = (Test) campaign
0833:                                        .getTestList().get(m);
0834:                                String testStatus = ConnectionData
0835:                                        .getCampTestSelect().getResExecTest(
0836:                                                testOfCampaignForStatus
0837:                                                        .getIdBDD(),
0838:                                                execResult.getIdBDD());
0839:                                execResult.initTestResultStatus(
0840:                                        testOfCampaignForStatus, testStatus, m,
0841:                                        null);
0842:                                if (testOfCampaignForStatus instanceof  ManualTest) {
0843:                                    for (int n = 0; n < ((ManualTest) testOfCampaignForStatus)
0844:                                            .getActionList().size(); n++) {
0845:                                        Action actionForStatus = (Action) ((ManualTest) testOfCampaignForStatus)
0846:                                                .getActionList().get(n);
0847:                                        String[] actionResultInfo = ConnectionData
0848:                                                .getCampTestSelect()
0849:                                                .getResExecActionResult(
0850:                                                        execResult.getIdBDD(),
0851:                                                        testOfCampaignForStatus
0852:                                                                .getIdBDD(),
0853:                                                        actionForStatus
0854:                                                                .getIdBdd());
0855:                                        if (actionResultInfo != null) {
0856:                                            execResult.addStatusForAction(
0857:                                                    actionForStatus,
0858:                                                    actionResultInfo[3]);
0859:                                            execResult.addEffectivResult(
0860:                                                    actionForStatus,
0861:                                                    actionResultInfo[2]);
0862:                                            execResult.addDescriptionResult(
0863:                                                    actionForStatus,
0864:                                                    actionResultInfo[0]);
0865:                                            execResult.addAwaitedResult(
0866:                                                    actionForStatus,
0867:                                                    actionResultInfo[1]);
0868:                                        }
0869:                                    }
0870:                                }
0871:                                Vector fileNameAttachTestResultVector = ConnectionData
0872:                                        .getCampTestSelect()
0873:                                        .getExecTestResultAttachFiles(
0874:                                                execResult.getIdBDD(),
0875:                                                testOfCampaignForStatus
0876:                                                        .getIdBDD());
0877:                                Vector urlAttachTestResultVector = ConnectionData
0878:                                        .getCampTestSelect()
0879:                                        .getExecTestResultAttachUrls(
0880:                                                execResult.getIdBDD(),
0881:                                                testOfCampaignForStatus
0882:                                                        .getIdBDD());
0883:                                loadAttachmentData(
0884:                                        execResult
0885:                                                .getExecutionTestResult(testOfCampaignForStatus),
0886:                                        fileNameAttachTestResultVector,
0887:                                        urlAttachTestResultVector);
0888:
0889:                            }
0890:
0891:                            Vector fileNameAttachVector = ConnectionData
0892:                                    .getCampTestSelect()
0893:                                    .getExecResultAttachFiles(
0894:                                            execResult.getIdBDD());
0895:                            Vector urlAttachvector = ConnectionData
0896:                                    .getCampTestSelect()
0897:                                    .getExecResultAttachUrls(
0898:                                            execResult.getIdBDD());
0899:                            loadAttachmentData(execResult,
0900:                                    fileNameAttachVector, urlAttachvector);
0901:
0902:                            exec.addExecutionResult(execResult);
0903:                        }
0904:
0905:                        Vector fileNameAtttachVector = ConnectionData
0906:                                .getCampTestSelect().getExecAttachFiles(
0907:                                        exec.getIdBdd());
0908:                        Vector urlAttachVector = ConnectionData
0909:                                .getCampTestSelect().getExecAttachUrls(
0910:                                        exec.getIdBdd());
0911:                        loadAttachmentData(exec, fileNameAtttachVector,
0912:                                urlAttachVector);
0913:                    }
0914:
0915:                    Vector fileNameAtttachVector = ConnectionData
0916:                            .getCampTestSelect().getCampaignAttachFiles(
0917:                                    campaign.getIdBdd());
0918:                    Vector urlAttachVector = ConnectionData.getCampTestSelect()
0919:                            .getCampaignAttachUrls(campaign.getIdBdd());
0920:                    loadAttachmentData(campaign, fileNameAtttachVector,
0921:                            urlAttachVector);
0922:
0923:                    CampaignData.addCampaignInModel(campaign);
0924:                    pDataModelWrapper.refreshCampaignToModel(campaign);
0925:                }
0926:
0927:            }
0928:
0929:            private static void loadAttachmentData(WithAttachment elem,
0930:                    Vector fileNameAttachVector, Vector urlAttachVector) {
0931:                for (int i = 0; i < fileNameAttachVector.size(); i++) {
0932:                    FileAttachment fileAttach = new FileAttachment(
0933:                            (FileAttachementWrapper) fileNameAttachVector
0934:                                    .get(i));
0935:                    elem.addAttachment(fileAttach);
0936:                }
0937:
0938:                for (int i = 0; i < urlAttachVector.size(); i++) {
0939:                    UrlAttachment urlAttach = new UrlAttachment(
0940:                            (UrlAttachementWrapper) urlAttachVector.get(i));
0941:                    elem.addAttachment(urlAttach);
0942:                }
0943:            }
0944:
0945:            /*
0946:            // Nettoyage du modèle de données
0947:            public static void clearTestData() {
0948:            	familyList.clear();
0949:            } // Fin de la méthode clear/0
0950:            
0951:             */
0952:
0953:            /********************************** Sélécteur *************************************************/
0954:
0955:            public static ArrayList getEnvironmentOfParameter(String paramName) {
0956:                ArrayList result = new ArrayList();
0957:                for (int i = 0; i < currentProject.getEnvironmentList().size(); i++) {
0958:                    if (((Environment) currentProject.getEnvironmentList().get(
0959:                            i)).containsParameter(paramName)) {
0960:                        result.add(currentProject.getEnvironmentList().get(i));
0961:                    }
0962:                }
0963:                return result;
0964:            }
0965:
0966:            /************************************ Suppréssion *****************************/
0967:
0968:            static void delParamInModel(Parameter pParam) {
0969:                ArrayList envOfParam = getEnvironmentOfParameter(pParam
0970:                        .getName());
0971:                ArrayList testsOfParam = TestPlanData.getTestOfParameter(pParam
0972:                        .getName());
0973:
0974:                // Suppression du paramétre des environnements
0975:                for (int i = 0; i < envOfParam.size(); i++) {
0976:                    ((Environment) envOfParam.get(i)).removeParameter(pParam
0977:                            .getName());
0978:                }
0979:                //Suppression du paramètre des tests (et actions) 
0980:                for (int j = 0; j < testsOfParam.size(); j++) {
0981:
0982:                    Test currentTest = (Test) testsOfParam.get(j);
0983:                    currentTest.deleteParameterInModel(pParam);
0984:
0985:                    // On purge les campagnes concernées des tests utilisant le paramètre
0986:                    ArrayList campaignOfTest = CampaignData
0987:                            .getCampaignOfTest(currentTest);
0988:                    for (int k = 0; k < campaignOfTest.size(); k++) {
0989:                        Campaign campaign = (Campaign) campaignOfTest.get(k);
0990:                        CampaignData.deleteTestFromCampaignInModel(
0991:                                (Test) testsOfParam.get(j), campaign);
0992:
0993:                        //Suppression du paramétre des jeux de données des campagnes concernées
0994:                        for (int l = 0; l < campaign.getDataSetList().size(); l++) {
0995:                            DataSet dataSet = (DataSet) campaign
0996:                                    .getDataSetList().get(l);
0997:                            dataSet.removeParameter(pParam.getName());
0998:                        }
0999:                    }
1000:
1001:                }
1002:                currentProject.removeParameter(pParam.getName());
1003:            }
1004:
1005:            public static void delParamInBddAndModel(Parameter pParam)
1006:                    throws Exception {
1007:                //BDD
1008:                pParam.deleteFromDB();
1009:
1010:                //DATA
1011:                delParamInModel(pParam);
1012:            }
1013:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.