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


001:        package salomeTMF_plug.gen_doc_xml;
002:
003:        import java.util.Enumeration;
004:        import java.util.Hashtable;
005:        import java.util.Iterator;
006:        import java.util.Vector;
007:
008:        import javax.swing.JTree;
009:        import javax.swing.tree.DefaultMutableTreeNode;
010:        import javax.swing.tree.DefaultTreeModel;
011:
012:        import org.dom4j.Document;
013:        import org.dom4j.Element;
014:        import org.java.plugin.Extension;
015:        import org.objectweb.salome_tmf.data.Test;
016:        import org.objectweb.salome_tmf.ihm.tools.Tools;
017:        import org.objectweb.salome_tmf.plugins.IPlugObject;
018:
019:        public class ImportReq {
020:
021:            //	ReqPlugin pReqPlugin = null;
022:            Object pReqPlugin = null;
023:            Hashtable projectReqByName;
024:            Hashtable projectReqById;
025:            //ReqFamily reqRoot;
026:            Object reqRoot;
027:            boolean reqAreUpdated;
028:            //boolean importReq;
029:            Import pImport;
030:
031:            ImportReq(IPlugObject pIPlugObject, Import _pImport)
032:                    throws Exception {
033:                //		Requirments //
034:                pReqPlugin = null;
035:                //importReq = _importReq;
036:                pImport = _pImport;
037:                projectReqByName = new Hashtable();
038:                projectReqById = new Hashtable();
039:                Extension ext = (Extension) pIPlugObject
040:                        .getAssociatedExtension("requirements.Common");
041:                if (ext != null) {
042:
043:                    pReqPlugin = (salomeTMF_plug.requirements.ReqPlugin) pIPlugObject
044:                            .getPluginManager().activateExtension(ext);
045:                    JTree pTree = ((salomeTMF_plug.requirements.ReqPlugin) pReqPlugin)
046:                            .getTreeRequirement();
047:                    DefaultMutableTreeNode node = (DefaultMutableTreeNode) ((DefaultTreeModel) pTree
048:                            .getModel()).getRoot();
049:                    salomeTMF_plug.requirements.data.Requirement pTempReq = (salomeTMF_plug.requirements.data.Requirement) node
050:                            .getUserObject();
051:                    projectReqByName.put(pTempReq.getNameFromModel(), pTempReq);
052:                    projectReqById.put(new Integer(0), pTempReq);
053:                    reqRoot = (salomeTMF_plug.requirements.data.ReqFamily) pTempReq;
054:                    if (node.getChildCount() > 0) {
055:                        loadRequirementModel(node, true, projectReqByName,
056:                                projectReqById);
057:                        reqAreUpdated = false;
058:                    }
059:                } else {
060:                    throw new Exception("No requirements plugins");
061:                }
062:            }
063:
064:            void loadRequirementModel(DefaultMutableTreeNode pTempNode,
065:                    boolean first, Hashtable projectReqByName,
066:                    Hashtable projectReqById) {
067:                salomeTMF_plug.requirements.data.Requirement pTempReq = (salomeTMF_plug.requirements.data.Requirement) pTempNode
068:                        .getUserObject();
069:                if (!first) {
070:                    projectReqByName.put(pTempReq.getNameFromModel(), pTempReq);
071:                    projectReqById.put(new Integer(0), pTempReq);
072:
073:                } else {
074:                    first = false;
075:                }
076:
077:                if (pTempReq instanceof  salomeTMF_plug.requirements.data.ReqLeaf) {
078:                    return;
079:                } else {
080:                    int nbChild = pTempNode.getChildCount();
081:
082:                    for (int i = 0; i < nbChild; i++) {
083:                        loadRequirementModel((DefaultMutableTreeNode) pTempNode
084:                                .getChildAt(i), first, projectReqByName,
085:                                projectReqById);
086:                    }
087:
088:                }
089:            }
090:
091:            void removeReqLink(Element testElem, Test test) {
092:                try {
093:                    Vector listReqWrapper = salomeTMF_plug.requirements.data.Requirement
094:                            .getReqWrapperCoveredByTest(test.getIdBdd());
095:                    int size = listReqWrapper.size();
096:
097:                    for (int i = 0; i < size; i++) {
098:                        salomeTMF_plug.requirements.sqlWrapper.ReqWrapper pReqWrapper = (salomeTMF_plug.requirements.sqlWrapper.ReqWrapper) listReqWrapper
099:                                .elementAt(i);
100:                        salomeTMF_plug.requirements.data.Requirement pReq = (salomeTMF_plug.requirements.data.Requirement) projectReqByName
101:                                .get(pReqWrapper.getName());
102:                        Iterator itReqLinkXML = testElem.selectNodes(
103:                                "LinkRequirement/RequirementRef").iterator();
104:                        boolean appartient = false;
105:                        while (itReqLinkXML.hasNext() && !appartient) {
106:                            Element linkElem = (Element) itReqLinkXML.next();
107:                            String nomReq = linkElem.elementText("Nom");
108:                            if (pReqWrapper.getName().equals(nomReq)) {
109:                                appartient = true;
110:                            }
111:                        }
112:                        if (!appartient) {
113:                            if (pReq != null) {
114:                                try {
115:
116:                                    pReq.deleteCoverForTest(test.getIdBdd());
117:                                } catch (Exception e1) {
118:                                    Tools.ihmExceptionView(e1);
119:                                }
120:                            }
121:                        }
122:                    }
123:                } catch (Exception e) {
124:                    Tools.ihmExceptionView(e);
125:                }
126:            }
127:
128:            public void gestionDesSuppressionsRequirements(Document doc)
129:                    throws Exception {
130:                //Suppression des requirements du projet
131:                reqAreUpdated = true;
132:                Enumeration itReqProjet = projectReqByName.elements();
133:
134:                while (itReqProjet.hasMoreElements()) {
135:                    salomeTMF_plug.requirements.data.Requirement pReq = (salomeTMF_plug.requirements.data.Requirement) itReqProjet
136:                            .nextElement();
137:                    if (pReq instanceof  salomeTMF_plug.requirements.data.ReqLeaf) {
138:
139:                        Iterator itReqLeqfXML = doc
140:                                .selectNodes("//Requirement").iterator();
141:                        boolean appartient = false;
142:                        Element reqElem = null;
143:                        String desc = null;
144:                        while (itReqLeqfXML.hasNext() && !appartient) {
145:                            reqElem = (Element) itReqLeqfXML.next();
146:                            if (reqElem.elementText("Nom").equals(
147:                                    pReq.getNameFromModel())) {
148:                                desc = (reqElem.elementText("Description") == null) ? ""
149:                                        : reqElem.elementText("Description");
150:                                desc = desc.replaceAll("\\\\n", "\n");
151:                                appartient = true;
152:                            }
153:                        }
154:                        if (!appartient) {
155:                            try {
156:                                pReq.deleteInDBAndModel();
157:                                projectReqByName
158:                                        .remove(pReq.getNameFromModel());
159:                                projectReqById.remove(new Integer(pReq
160:                                        .getIdBdd()));
161:                            } catch (Exception e) {
162:                                Tools.ihmExceptionView(e);
163:                            }
164:                        } else {
165:                            // Update
166:                            if (reqElem != null) {
167:                                pImport.updateElementAttachement(reqElem, pReq,
168:                                        false);
169:                                if (desc != null) {
170:                                    pReq.updateDescriptionInDBAndModel(desc);
171:                                }
172:                            }
173:                        }
174:                    }
175:                }
176:                itReqProjet = projectReqByName.elements();
177:                while (itReqProjet.hasMoreElements()) {
178:                    salomeTMF_plug.requirements.data.Requirement pReq = (salomeTMF_plug.requirements.data.Requirement) itReqProjet
179:                            .nextElement();
180:                    if (pReq instanceof  salomeTMF_plug.requirements.data.ReqFamily
181:                            && pReq.getIdBdd() > 0) {
182:
183:                        Iterator itReqFamXML = doc.selectNodes(
184:                                "//RequirementFamily").iterator();
185:                        boolean appartient = false;
186:                        Element reqElem = null;
187:                        String desc = null;
188:                        while (itReqFamXML.hasNext() && !appartient) {
189:                            reqElem = (Element) itReqFamXML.next();
190:                            if (reqElem.elementText("Nom").equals(
191:                                    pReq.getNameFromModel())) {
192:                                desc = (reqElem.elementText("Description") == null) ? ""
193:                                        : reqElem.elementText("Description");
194:                                desc = desc.replaceAll("\\\\n", "\n");
195:                                appartient = true;
196:                            }
197:                        }
198:                        if (!appartient) {
199:                            try {
200:                                Vector reqLeafs = ((salomeTMF_plug.requirements.data.ReqFamily) pReq)
201:                                        .getFistLeaf();
202:                                if (reqLeafs.size() == 0) {
203:                                    pReq.deleteInDBAndModel();
204:                                    projectReqByName.remove(pReq
205:                                            .getNameFromModel());
206:                                    projectReqById.remove(new Integer(pReq
207:                                            .getIdBdd()));
208:                                } else {
209:                                    for (int i = 0; i < reqLeafs.size(); i++) {
210:                                        salomeTMF_plug.requirements.data.Requirement pTmpReq = (salomeTMF_plug.requirements.data.Requirement) reqLeafs
211:                                                .elementAt(i);
212:                                        pTmpReq
213:                                                .updateParentInDBAndModel((salomeTMF_plug.requirements.data.ReqFamily) reqRoot);
214:                                    }
215:                                }
216:                            } catch (Exception e) {
217:                                Tools.ihmExceptionView(e);
218:                            }
219:                        } else {// Update
220:                            if (reqElem != null) {
221:                                pImport.updateElementAttachement(reqElem, pReq,
222:                                        false);
223:                                if (desc != null) {
224:                                    pReq.updateDescriptionInDBAndModel(desc);
225:                                }
226:                            }
227:                        }
228:                    }
229:                }
230:
231:            }
232:
233:            void updateReqLink(Element testElem, Test test, boolean supprElement) {
234:                Iterator itReqLinkXML = testElem.selectNodes(
235:                        "LinkRequirement/RequirementRef").iterator();
236:                try {
237:                    Vector listReqWrapper = salomeTMF_plug.requirements.data.Requirement
238:                            .getReqWrapperCoveredByTest(test.getIdBdd());
239:                    int size = listReqWrapper.size();
240:                    while (itReqLinkXML.hasNext()) {
241:                        Element linkElem = (Element) itReqLinkXML.next();
242:                        String nomReq = linkElem.elementText("Nom");
243:                        salomeTMF_plug.requirements.data.Requirement pReq = (salomeTMF_plug.requirements.data.Requirement) projectReqByName
244:                                .get(nomReq);
245:                        if (pReq == null) {
246:                            Tools.ihmExceptionView(new Exception(
247:                                    "[updateReqLink] Requirment " + nomReq
248:                                            + " not found"));
249:                        }
250:                        if (pReq instanceof  salomeTMF_plug.requirements.data.ReqFamily) {
251:                            Tools
252:                                    .ihmExceptionView(new Exception(
253:                                            "[updateReqLink] Requirment "
254:                                                    + nomReq
255:                                                    + " is a family and can't be linked to the test "
256:                                                    + test.getNameFromModel()));
257:                        }
258:                        boolean appartient = false;
259:                        int i = 0;
260:                        while (i < size && !appartient) {
261:                            salomeTMF_plug.requirements.sqlWrapper.ReqWrapper pReqWrapper = (salomeTMF_plug.requirements.sqlWrapper.ReqWrapper) listReqWrapper
262:                                    .elementAt(i);
263:                            if (pReqWrapper.getName().equals(nomReq)) {
264:                                appartient = true;
265:                            }
266:                            i++;
267:                        }
268:                        if (!appartient) {
269:                            try {
270:                                pReq.addTestCoverInDB(test.getIdBdd(), true);
271:                            } catch (Exception e1) {
272:                                Tools.ihmExceptionView(e1);
273:                            }
274:                        }
275:                    }
276:                    if (supprElement) {
277:                        removeReqLink(testElem, test);
278:                    }
279:                } catch (Exception e) {
280:                    Tools.ihmExceptionView(e);
281:                }
282:            }
283:
284:            void ajoutRequirement(Element reqElem, Hashtable docReqById) {
285:                String nomReq = reqElem.elementText("Nom");
286:
287:                int priority = (new Integer(reqElem.attributeValue("priority")))
288:                        .intValue();
289:                String version = reqElem.attributeValue("version");
290:
291:                String desc = (reqElem.elementText("Description") == null) ? ""
292:                        : reqElem.elementText("Description");
293:                desc = desc.replaceAll("\\\\n", "\n");
294:                String strId_reqParent = reqElem
295:                        .attributeValue("id_req_parent");
296:                strId_reqParent = strId_reqParent.substring(4, strId_reqParent
297:                        .length()); //remove Req_
298:                Integer id_reqParent = new Integer(strId_reqParent);
299:
300:                Element reqParentElement = (Element) docReqById
301:                        .get(id_reqParent);
302:                salomeTMF_plug.requirements.data.ReqFamily pReqParent;
303:                if (id_reqParent.equals(new Integer(0))) {
304:                    pReqParent = (salomeTMF_plug.requirements.data.ReqFamily) reqRoot;
305:                } else {
306:                    String nomParentReq = reqParentElement.elementText("Nom");
307:                    salomeTMF_plug.requirements.data.Requirement pTempReq = (salomeTMF_plug.requirements.data.Requirement) projectReqByName
308:                            .get(nomParentReq);
309:
310:                    if (pTempReq != null
311:                            && pTempReq instanceof  salomeTMF_plug.requirements.data.ReqFamily) {
312:                        pReqParent = (salomeTMF_plug.requirements.data.ReqFamily) pTempReq;
313:                    } else {
314:                        pReqParent = (salomeTMF_plug.requirements.data.ReqFamily) reqRoot;
315:                    }
316:                }
317:                salomeTMF_plug.requirements.data.ReqLeaf pNewReq = new salomeTMF_plug.requirements.data.ReqLeaf(
318:                        nomReq, desc, pReqParent, priority);
319:                pNewReq.updateVersionInModel(version);
320:                try {
321:                    pNewReq.addInDB();
322:                    pReqParent.addRequirement(pNewReq);
323:                    projectReqByName.put(pNewReq.getNameFromModel(), pNewReq);
324:                    projectReqById
325:                            .put(new Integer(pNewReq.getIdBdd()), pNewReq);
326:                    pImport.updateElementAttachement(reqElem, pNewReq, true);
327:                } catch (Exception e) {
328:                    Tools.ihmExceptionView(e);
329:                }
330:            }
331:
332:            salomeTMF_plug.requirements.data.ReqFamily ajoutReqFamily(
333:                    Element reqElem, Hashtable docReqByName,
334:                    Hashtable docReqById) {
335:                if (reqElem == null) {
336:                    return (salomeTMF_plug.requirements.data.ReqFamily) reqRoot;
337:                }
338:                String nomReq = reqElem.elementText("Nom");
339:                salomeTMF_plug.requirements.data.Requirement pTempReq = (salomeTMF_plug.requirements.data.Requirement) projectReqByName
340:                        .get(nomReq);
341:                if (pTempReq != null
342:                        && pTempReq instanceof  salomeTMF_plug.requirements.data.ReqFamily) {
343:                    return (salomeTMF_plug.requirements.data.ReqFamily) pTempReq;
344:                }
345:
346:                String strId_reqParent = reqElem
347:                        .attributeValue("id_req_parent");
348:                strId_reqParent = strId_reqParent.substring(4, strId_reqParent
349:                        .length()); //remove Req_
350:                Integer id_reqParent = new Integer(strId_reqParent);
351:
352:                Element reqParentElement = (Element) docReqById
353:                        .get(id_reqParent);
354:                salomeTMF_plug.requirements.data.ReqFamily pParent = ajoutReqFamily(
355:                        reqParentElement, docReqByName, docReqById);
356:                String desc = (reqElem.elementText("Description") == null) ? ""
357:                        : reqElem.elementText("Description");
358:                desc = desc.replaceAll("\\\\n", "\n");
359:                salomeTMF_plug.requirements.data.ReqFamily pNewReqFamily = new salomeTMF_plug.requirements.data.ReqFamily(
360:                        nomReq, desc, pParent);
361:
362:                try {
363:                    pNewReqFamily.addInDB();
364:                    pParent.addRequirement(pNewReqFamily);
365:                    projectReqByName.put(pNewReqFamily.getNameFromModel(),
366:                            pNewReqFamily);
367:                    projectReqById.put(new Integer(pNewReqFamily.getIdBdd()),
368:                            pNewReqFamily);
369:                    pImport.updateElementAttachement(reqElem, pNewReqFamily,
370:                            true);
371:                } catch (Exception e) {
372:                    Tools.ihmExceptionView(e);
373:                }
374:                return pNewReqFamily;
375:            }
376:
377:            void updateProjectRequirement(Document doc) throws Exception {
378:                //Mise a jour des Requirements existants et ajout des nouveaux
379:
380:                Hashtable docReqByName = new Hashtable();
381:                Hashtable docReqById = new Hashtable();
382:                Vector reqElementToAdd = new Vector();
383:                Vector reqFamilyToAdd = new Vector();
384:
385:                Iterator itReqLeqfXML = doc.selectNodes("//Requirement")
386:                        .iterator();
387:                while (itReqLeqfXML.hasNext()) {
388:                    Element reqElem = (Element) itReqLeqfXML.next();
389:                    String nomReq = reqElem.elementText("Nom");
390:                    String desc = (reqElem.elementText("Description") == null) ? ""
391:                            : reqElem.elementText("Description");
392:                    desc = desc.replaceAll("\\\\n", "\n");
393:                    String id_reqDoc = reqElem.attributeValue("id_req");
394:                    id_reqDoc = id_reqDoc.substring(4, id_reqDoc.length()); //remove Req_
395:                    salomeTMF_plug.requirements.data.Requirement pReq = (salomeTMF_plug.requirements.data.Requirement) projectReqByName
396:                            .get(nomReq);
397:                    docReqByName.put(nomReq, reqElem);
398:                    docReqById.put(new Integer(id_reqDoc), reqElem);
399:
400:                    if (pReq != null) {
401:                        //Existe --> Update
402:                        if (reqElem != null && !reqAreUpdated) {
403:                            pImport.updateElementAttachement(reqElem, pReq,
404:                                    false);
405:                            if (desc != null) {
406:                                pReq.updateDescriptionInDBAndModel(desc);
407:                            }
408:                        }
409:                    } else {
410:                        //Not Existe --> Ajout
411:                        reqElementToAdd.add(reqElem);
412:
413:                    }
414:                }
415:
416:                Iterator itReqFamilyfXML = doc.selectNodes(
417:                        "//RequirementFamily").iterator();
418:                while (itReqFamilyfXML.hasNext()) {
419:                    Element reqElem = (Element) itReqFamilyfXML.next();
420:                    String nomReq = reqElem.elementText("Nom");
421:                    String desc = (reqElem.elementText("Description") == null) ? ""
422:                            : reqElem.elementText("Description");
423:                    desc = desc.replaceAll("\\\\n", "\n");
424:                    String id_reqDoc = reqElem.attributeValue("id_req");
425:                    id_reqDoc = id_reqDoc.substring(4, id_reqDoc.length()); //remove Req_
426:                    salomeTMF_plug.requirements.data.Requirement pReq = (salomeTMF_plug.requirements.data.Requirement) projectReqByName
427:                            .get(nomReq);
428:                    docReqByName.put(nomReq, reqElem);
429:                    docReqById.put(new Integer(id_reqDoc), reqElem);
430:                    if (pReq != null) {
431:                        //Existe --> Update
432:                        if (reqElem != null && !reqAreUpdated) {
433:                            pImport.updateElementAttachement(reqElem, pReq,
434:                                    false);
435:                            if (desc != null) {
436:                                pReq.updateDescriptionInDBAndModel(desc);
437:                            }
438:                        }
439:                    } else {
440:                        //Not Existe --> Ajout
441:                        reqFamilyToAdd.add(reqElem);
442:                        //updateElementAttachement(reqElem, pReq, true);
443:                    }
444:                }
445:                // Ajput des nouveau requirements
446:                for (int i = 0; i < reqFamilyToAdd.size(); i++) {
447:                    Element reqElem = (Element) reqFamilyToAdd.elementAt(i);
448:                    ajoutReqFamily(reqElem, docReqByName, docReqById);
449:                }
450:                for (int i = 0; i < reqElementToAdd.size(); i++) {
451:                    Element reqElem = (Element) reqElementToAdd.elementAt(i);
452:                    ajoutRequirement(reqElem, docReqById);
453:                }
454:
455:            }
456:
457:            void reloadReq() {
458:                if (pReqPlugin != null) {
459:                    try {
460:                        ((salomeTMF_plug.requirements.ReqPlugin) pReqPlugin)
461:                                .reloadReq();
462:                    } catch (Exception e) {
463:                    }
464:                }
465:            }
466:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.