0001: /*
0002: * SalomeTMF is a Test Management Framework
0003: * Copyright (C) 2005 France Telecom R&D
0004: *
0005: * This library is free software; you can redistribute it and/or
0006: * modify it under the terms of the GNU Lesser General Public
0007: * License as published by the Free Software Foundation; either
0008: * version 2 of the License, or (at your option) any later version.
0009: *
0010: * This library is distributed in the hope that it will be useful,
0011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0013: * Lesser General Public License for more details.
0014: *
0015: * You should have received a copy of the GNU Lesser General Public
0016: * License along with this library; if not, write to the Free Software
0017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0018: *
0019: * @author Aurore PENAULT
0020: *
0021: * Contact: mikael.marche@rd.francetelecom.com
0022: */
0023:
0024: package salomeTMF_plug.gen_doc_xml;
0025:
0026: import java.io.BufferedReader;
0027: import java.io.BufferedWriter;
0028: import java.io.File;
0029: import java.io.FileInputStream;
0030: import java.io.FileOutputStream;
0031: import java.io.FileReader;
0032: import java.io.FileWriter;
0033: import java.io.OutputStream;
0034: import java.io.Writer;
0035: import java.net.URL;
0036: import java.text.DateFormat;
0037: import java.util.ArrayList;
0038: import java.util.Enumeration;
0039: import java.util.HashMap;
0040: import java.util.Hashtable;
0041: import java.util.Iterator;
0042: import java.util.Locale;
0043: import java.util.Properties;
0044: import java.util.Vector;
0045:
0046: import javax.swing.JTree;
0047: import javax.swing.tree.DefaultMutableTreeNode;
0048: import javax.swing.tree.DefaultTreeModel;
0049: import javax.xml.transform.OutputKeys;
0050: import javax.xml.transform.Result;
0051: import javax.xml.transform.Source;
0052: import javax.xml.transform.Transformer;
0053: import javax.xml.transform.TransformerFactory;
0054: import javax.xml.transform.dom.DOMResult;
0055: import javax.xml.transform.stream.StreamSource;
0056: import org.apache.batik.transcoder.TranscoderInput;
0057: import org.apache.batik.transcoder.TranscoderOutput;
0058: import org.apache.batik.transcoder.image.JPEGTranscoder;
0059: import org.dom4j.Attribute;
0060: import org.dom4j.Document;
0061: import org.dom4j.DocumentHelper;
0062: import org.dom4j.Element;
0063: import org.dom4j.io.DocumentResult;
0064: import org.dom4j.io.DocumentSource;
0065: import org.dom4j.io.OutputFormat;
0066: import org.dom4j.io.SAXReader;
0067: import org.dom4j.io.XMLWriter;
0068: import org.java.plugin.Extension;
0069: import org.objectweb.salome_tmf.api.Api;
0070: import org.objectweb.salome_tmf.api.Util;
0071: import org.objectweb.salome_tmf.api.data.GroupWrapper;
0072: import org.objectweb.salome_tmf.api.data.UserWrapper;
0073: import org.objectweb.salome_tmf.api.sql.ISQLGroup;
0074: import org.objectweb.salome_tmf.api.sql.ISQLProject;
0075: import org.objectweb.salome_tmf.data.Action;
0076: import org.objectweb.salome_tmf.data.Attachment;
0077: import org.objectweb.salome_tmf.data.AutomaticTest;
0078: import org.objectweb.salome_tmf.data.Campaign;
0079: import org.objectweb.salome_tmf.data.DataSet;
0080: import org.objectweb.salome_tmf.data.Environment;
0081: import org.objectweb.salome_tmf.data.Execution;
0082: import org.objectweb.salome_tmf.data.ExecutionResult;
0083: import org.objectweb.salome_tmf.data.ExecutionTestResult;
0084: import org.objectweb.salome_tmf.data.Family;
0085: import org.objectweb.salome_tmf.data.FileAttachment;
0086: import org.objectweb.salome_tmf.data.ManualExecutionResult;
0087: import org.objectweb.salome_tmf.data.ManualTest;
0088: import org.objectweb.salome_tmf.data.Parameter;
0089: import org.objectweb.salome_tmf.data.Project;
0090: import org.objectweb.salome_tmf.data.Script;
0091: import org.objectweb.salome_tmf.data.Test;
0092: import org.objectweb.salome_tmf.data.TestList;
0093: import org.objectweb.salome_tmf.data.UrlAttachment;
0094: import org.objectweb.salome_tmf.ihm.main.SalomeTMFPanels;
0095: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
0096: import org.objectweb.salome_tmf.ihm.tools.Tools;
0097: import org.objectweb.salome_tmf.plugins.IPlugObject;
0098:
0099: import salomeTMF_plug.requirements.ReqPlugin;
0100: import salomeTMF_plug.requirements.data.ReqLeaf;
0101: import salomeTMF_plug.requirements.data.Requirement;
0102: import salomeTMF_plug.requirements.sqlWrapper.ReqWrapper;
0103:
0104: /**
0105: * Classe qui permet la construction des documents xml,
0106: * leur transformation en Html et leur sauvegarde dans un fichier
0107: * @author vapu8214
0108: */
0109: public class XmlGenerator {
0110:
0111: private String fs = System.getProperties().getProperty(
0112: "file.separator");
0113:
0114: public boolean addDocType = true;
0115:
0116: private Properties statements;
0117: IPlugObject pIPlugObject;
0118:
0119: public static boolean hasCampRequirementsGraph = false;
0120: public static boolean hasResExecRequirementsGraph = false;
0121: public static boolean hasRequirementsGraph = false;
0122:
0123: public XmlGenerator(IPlugObject _pIPlugObject) {
0124: pIPlugObject = _pIPlugObject;
0125: URL sql_stmts_url = getClass()
0126: .getResource(
0127: "/salomeTMF_plug/gen_doc_xml/resources/sql/gendoc_Stmts.properties");
0128: try {
0129: statements = Util.getPropertiesFile(sql_stmts_url);
0130: } catch (Exception e) {
0131: e.printStackTrace();
0132: }
0133: }
0134:
0135: void writeRequirement(Element reqsElem,
0136: DefaultMutableTreeNode pTempNode, boolean first,
0137: String pathAttach, String[] ficType) {
0138: Requirement pTempReq = (Requirement) pTempNode.getUserObject();
0139: HashMap attachs = null;
0140: try {
0141: if (!first) {
0142: attachs = pTempReq.getAttachmentMapFromModel();
0143: }
0144: } catch (Exception e) {
0145:
0146: }
0147: if (pTempReq instanceof ReqLeaf) {
0148: //Write leaf
0149: Element reqLeafElem = reqsElem.addElement("Requirement");
0150: reqLeafElem.addElement("Nom").setText(
0151: pTempReq.getNameFromModel());
0152: reqLeafElem.addAttribute("priority", ""
0153: + ((ReqLeaf) pTempReq).getPriorityFromModel());
0154: reqLeafElem.addAttribute("version", ((ReqLeaf) pTempReq)
0155: .getVersionFromModel());
0156:
0157: reqLeafElem.addAttribute("id_req", "Req_"
0158: + new Integer(pTempReq.getIdBdd()).toString());
0159: reqLeafElem.addAttribute("id_req_parent", "Req_"
0160: + new Integer(pTempReq.getParent().getIdBdd())
0161: .toString());
0162: if (pTempReq.getDescriptionFromModel() != null
0163: && !pTempReq.getDescriptionFromModel().equals("")) {
0164: reqLeafElem.addElement("Description").setText(
0165: pTempReq.getDescriptionFromModel().replaceAll(
0166: "\n", "\\\\n"));
0167: }
0168: if (attachs != null) {
0169: addAttach(
0170: reqLeafElem,
0171: pathAttach + fs + "Attachements" + fs
0172: + "Requirements" + fs
0173: + formater(pTempReq.getNameFromModel()),
0174: attachs,
0175: "Attachements" + fs + "Requirements" + fs
0176: + formater(pTempReq.getNameFromModel()),
0177: ficType);
0178: }
0179: } else {
0180: //Write family
0181: Element reqFamilyElem = reqsElem;
0182: if (!first) {
0183: reqFamilyElem = reqsElem
0184: .addElement("RequirementFamily");
0185:
0186: reqFamilyElem.addElement("Nom").setText(
0187: pTempReq.getNameFromModel());
0188: reqFamilyElem.addAttribute("id_req", "Req_"
0189: + new Integer(pTempReq.getIdBdd()).toString());
0190: reqFamilyElem.addAttribute("id_req_parent", "Req_"
0191: + new Integer(pTempReq.getParent().getIdBdd())
0192: .toString());
0193: if (pTempReq.getDescriptionFromModel() != null
0194: && !pTempReq.getDescriptionFromModel().equals(
0195: "")) {
0196: reqFamilyElem.addElement("Description").setText(
0197: pTempReq.getDescriptionFromModel()
0198: .replaceAll("\n", "\\\\n"));
0199: }
0200: if (attachs != null) {
0201: addAttach(reqFamilyElem, pathAttach + fs
0202: + "Attachements" + fs + "Requirements" + fs
0203: + formater(pTempReq.getNameFromModel()),
0204: attachs, "Attachements"
0205: + fs
0206: + "Requirements"
0207: + fs
0208: + formater(pTempReq
0209: .getNameFromModel()),
0210: ficType);
0211: }
0212: } else {
0213: first = false;
0214: }
0215: int nbChild = pTempNode.getChildCount();
0216:
0217: for (int i = 0; i < nbChild; i++) {
0218: writeRequirement(reqFamilyElem,
0219: (DefaultMutableTreeNode) pTempNode
0220: .getChildAt(i), first, pathAttach,
0221: ficType);
0222: }
0223:
0224: }
0225: }
0226:
0227: /**
0228: * Méthode de création du document xml contenant la description
0229: * de la partie statique du projet Salomé courant
0230: * @param pathAttach répertoire pour la sauvegarde des attachements
0231: * @param selectFamilyList liste des familles de tests sélectionnées pour figurer dans le rapport
0232: * @param selectSuiteList liste des suites de tests sélectionnées pour figurer dans le rapport
0233: * @param selectTestList liste des tests sélectionnés pour figurer dans le rapport
0234: * @param ficType liste des types de fichier à insérer dans le document
0235: */
0236: public Document toDocument(String pathAttach,
0237: ArrayList selectFamilyList, ArrayList selectSuiteList,
0238: ArrayList selectTestList, String[] ficType) {
0239: boolean filtre = (selectFamilyList != null
0240: || selectSuiteList != null || selectTestList != null);
0241:
0242: if (!filtre) {
0243: selectFamilyList = new ArrayList();
0244: selectSuiteList = new ArrayList();
0245: selectTestList = new ArrayList();
0246: }
0247: Document document = DocumentHelper.createDocument();
0248: if (addDocType) {
0249: File fileSalomeStatique = new File(pathAttach + fs
0250: + "SalomeStatique.dtd");
0251: try {
0252: document.addDocType("SalomeStatique", null,
0253: fileSalomeStatique.toURL().toString());
0254: } catch (Exception e) {
0255: e.printStackTrace();
0256: document.addDocType("SalomeStatique", null, pathAttach
0257: + fs + "SalomeStatique.dtd");
0258: }
0259: }
0260: Element salomeStatique = document.addElement("SalomeStatique");
0261: Element projetVT = salomeStatique.addElement("ProjetVT");
0262: Project proj = DataModel.getCurrentProject();
0263: if (!proj.getNameFromModel().equals("")) {
0264: projetVT.addElement("Nom").setText(proj.getNameFromModel());
0265: }
0266: if (!proj.getDescriptionFromModel().equals("")) {
0267: projetVT.addElement("Description").setText(
0268: proj.getDescriptionFromModel().replaceAll("\n",
0269: "\\\\n"));
0270: }
0271: String date_proj = DateFormat.getDateInstance(
0272: DateFormat.MEDIUM, Locale.FRANCE).format(
0273: proj.getCreationDateFromModel());
0274: projetVT.addElement("Date_crea").setText(date_proj);
0275:
0276: if (!proj.getParameterSetFromModel().isEmpty()) {
0277: Element params = projetVT.addElement("Params");
0278: Enumeration it = proj.getParameterSetFromModel().elements();
0279: //iterator();
0280: while (it.hasMoreElements()) {
0281: Element param = params.addElement("Param");
0282: Parameter par = (Parameter) it.nextElement();
0283: param.addElement("Nom").setText(par.getNameFromModel());
0284: if (!par.getDescriptionFromModel().equals("")) {
0285: param.addElement("Description").setText(
0286: par.getDescriptionFromModel().replaceAll(
0287: "\n", "\\\\n"));
0288: }
0289: param.addAttribute("id_param", "Param_"
0290: + new Integer(par.getIdBdd()).toString());
0291: }
0292: }
0293:
0294: HashMap attachsProj = proj.getAttachmentMapFromModel();
0295: addAttach(projetVT, pathAttach + fs + "Attachements",
0296: attachsProj, "Attachements", ficType);
0297:
0298: try {
0299: ISQLProject pISQLProject = Api.getISQLObjectFactory()
0300: .getISQLProject();
0301: GroupWrapper[] tmpArray = pISQLProject
0302: .getProjectGroups(DataModel.getCurrentProject()
0303: .getIdBdd());
0304: Vector tmpVector = new Vector();
0305: for (int tmpI = 0; tmpI < tmpArray.length; tmpI++) {
0306: tmpVector.add(tmpArray[tmpI]);
0307: }
0308: Vector project_Group = tmpVector;
0309: //Vector group_desc = ConnectionData.getAdminProjectSelect().getAllProjectGroupsDesc();
0310: //Vector group_name = ConnectionData.getAdminProjectSelect().getAllProjectGroupsName();
0311:
0312: if (project_Group.size() != 0) {
0313: Element groups = projetVT
0314: .addElement("GroupesDePersonnes");
0315: for (int i = 0; i < project_Group.size(); i++) {
0316: GroupWrapper pGroupWrapper = (GroupWrapper) project_Group
0317: .get(i);
0318: Element grElem = groups
0319: .addElement("GroupeDePersonnes");
0320: grElem.addElement("Nom").setText(
0321: pGroupWrapper.getName());
0322: if (!pGroupWrapper.getDescription().equals("")) {
0323: grElem.addElement("Description").setText(
0324: pGroupWrapper.getDescription()
0325: .replaceAll("\n", "\\\\n"));
0326: }
0327: ISQLGroup pISQLGroup = Api.getISQLObjectFactory()
0328: .getISQLGroup();
0329: UserWrapper[] tmpUserArray = pISQLGroup
0330: .getUserWrappersInGroup(pGroupWrapper
0331: .getIdBDD());
0332: Vector tmpUserVector = new Vector();
0333: for (int tmpI = 0; tmpI < tmpUserArray.length; tmpI++) {
0334: tmpUserVector.add(tmpUserArray[tmpI]);
0335: }
0336: Vector group_users = tmpUserVector;
0337: /*
0338: Vector group_users = ConnectionData.getAdminProjectSelect().getGroupUsers((String)group_name.get(i));
0339: Vector group_users_name = ConnectionData.getAdminProjectSelect().getGroupLastNameUsers((String)group_name.get(i));
0340: Vector group_users_firstname = ConnectionData.getAdminProjectSelect().getGroupFirstNameUsers((String)group_name.get(i));
0341: Vector group_users_desc = ConnectionData.getAdminProjectSelect().getGroupDescUsers((String)group_name.geOt(i));
0342: Vector group_users_email = ConnectionData.getAdminProjectSelect().getGroupEmailUsers((String)group_name.get(i));
0343: Vector group_users_tel = ConnectionData.getAdminProjectSelect().getGroupTelUsers((String)group_name.get(i));
0344: Vector group_users_date = ConnectionData.getAdminProjectSelect().getGroupDateUsers((String)group_name.get(i));
0345: */
0346: if (group_users.size() != 0) {
0347: Element listPersElem = grElem
0348: .addElement("Personnes");
0349: for (int j = 0; j < group_users.size(); j++) {
0350: UserWrapper pUserWrapper = (UserWrapper) group_users
0351: .elementAt(j);
0352: Element persElem = listPersElem
0353: .addElement("Personne");
0354: if (!pUserWrapper.getLogin().equals("")) {
0355: persElem.addElement("Login").setText(
0356: pUserWrapper.getLogin());
0357: }
0358: if (pUserWrapper.getName() != null
0359: && !pUserWrapper.getName().equals(
0360: "")) {
0361: persElem.addElement("Nom").setText(
0362: pUserWrapper.getName());
0363: }
0364: if (pUserWrapper.getPrenom() != null
0365: && !pUserWrapper.getPrenom()
0366: .equals("")) {
0367: persElem.addElement("Prenom").setText(
0368: pUserWrapper.getPrenom());
0369: }
0370: if (pUserWrapper.getDescription() != null
0371: && !pUserWrapper.getDescription()
0372: .equals("")) {
0373: persElem
0374: .addElement("Description")
0375: .setText(
0376: pUserWrapper
0377: .getDescription()
0378: .replaceAll(
0379: "\n",
0380: "\\\\n"));
0381: }
0382: if (pUserWrapper.getEmail() != null
0383: && !pUserWrapper.getEmail().equals(
0384: "")) {
0385: persElem.addElement("Email").setText(
0386: pUserWrapper.getEmail());
0387: }
0388: if (pUserWrapper.getTel() != null
0389: && !pUserWrapper.getTel()
0390: .equals("")) {
0391: persElem.addElement("Tel").setText(
0392: pUserWrapper.getTel());
0393: }
0394: if (pUserWrapper.getCreateDate().toString() != null
0395: && !pUserWrapper.getCreateDate()
0396: .toString().equals("")) {
0397: persElem
0398: .addElement("Date_crea")
0399: .setText(
0400: pUserWrapper
0401: .getCreateDate()
0402: .toString());
0403: }
0404: }
0405: }
0406: }
0407: }
0408: } catch (Exception e) {
0409: Tools.ihmExceptionView(e);
0410: }
0411:
0412: // Requirments //
0413: ReqPlugin pReqPlugin = null;
0414:
0415: Extension ext = (Extension) pIPlugObject
0416: .getAssociatedExtension("requirements.Common");
0417: if (ext != null) {
0418: try {
0419: pReqPlugin = (ReqPlugin) pIPlugObject
0420: .getPluginManager().activateExtension(ext);
0421: JTree pTree = pReqPlugin.getTreeRequirement();
0422: DefaultMutableTreeNode node = (DefaultMutableTreeNode) ((DefaultTreeModel) pTree
0423: .getModel()).getRoot();
0424: if (node.getChildCount() > 0) {
0425: Element reqsElem = projetVT
0426: .addElement("Requirements");
0427: Requirement pTempReq = (Requirement) node
0428: .getUserObject();
0429: reqsElem.addAttribute("id_req", "Req_"
0430: + new Integer(pTempReq.getIdBdd())
0431: .toString());
0432: writeRequirement(reqsElem, node, true, pathAttach,
0433: ficType);
0434: }
0435: hasCampRequirementsGraph = true;
0436: hasResExecRequirementsGraph = true;
0437: hasRequirementsGraph = true;
0438: try {
0439: File dir = new File(pathAttach + fs
0440: + "Attachements" + fs + "Requirements");
0441: if (!dir.exists()) {
0442: dir.mkdirs();
0443: }
0444: Requirement.writeReqCoverChart(pathAttach + fs
0445: + "Attachements" + fs + "Requirements" + fs
0446: + "requirements.jpeg");
0447: } catch (Exception e) {
0448: hasRequirementsGraph = false;
0449: }
0450: } catch (Exception e) {
0451:
0452: }
0453: }
0454:
0455: ArrayList envirs = DataModel.getCurrentProject()
0456: .getEnvironmentListFromModel();
0457: if (!envirs.isEmpty()) {
0458: Element envsElem = projetVT.addElement("Environnements");
0459: Iterator it = envirs.iterator();
0460: while (it.hasNext()) {
0461: Environment env_courant = (Environment) it.next();
0462: Element envElem = envsElem.addElement("Environnement");
0463: envElem.addElement("Nom").setText(
0464: env_courant.getNameFromModel());
0465: envElem.addAttribute("idEnv", "Env_"
0466: + new Integer(env_courant.getIdBdd())
0467: .toString());
0468: if (env_courant.getDescriptionFromModel() != null
0469: && !env_courant.getDescriptionFromModel()
0470: .equals("")) {
0471: envElem.addElement("Description").setText(
0472: env_courant.getDescriptionFromModel()
0473: .replaceAll("\n", "\\\\n"));
0474: }
0475: Hashtable params = env_courant
0476: .getParametersHashTableFromModel();
0477: if (!params.isEmpty()) {
0478: Element elemValParams = envElem
0479: .addElement("ValeurParams");
0480: Enumeration e = params.keys();
0481: while (e.hasMoreElements()) {
0482: Element elemValParam = elemValParams
0483: .addElement("ValeurParam");
0484: Parameter p = (Parameter) e.nextElement();
0485: elemValParam.addAttribute("ref", "Param_"
0486: + new Integer(p.getIdBdd()).toString());
0487: elemValParam.addElement("Nom").setText(
0488: p.getNameFromModel());
0489: if (!((String) params.get(p)).equals("")) {
0490: elemValParam.addAttribute("valeur",
0491: (String) params.get(p));
0492: }
0493: }
0494: }
0495: Script scInit = env_courant.getInitScriptFromModel();
0496: if (scInit != null) {
0497: Element scriptElem = envElem.addElement("Script");
0498: if (scInit.getScriptExtensionFromModel() != null) {
0499: scriptElem.addElement("Classpath").setText(
0500: scInit.getScriptExtensionFromModel());
0501: }
0502: if (scInit.getPlugArgFromModel() != null
0503: && !scInit.getPlugArgFromModel().equals("")) {
0504: scriptElem.addElement("ArgScript").setText(
0505: scInit.getPlugArgFromModel());
0506: }
0507: if (!scInit.getTypeFromModel().equals("")) {
0508: scriptElem.addAttribute("type", scInit
0509: .getTypeFromModel());
0510: }
0511: scriptElem.addAttribute("nom", scInit
0512: .getNameFromModel());
0513:
0514: String dest = new String(pathAttach + fs
0515: + "Attachements" + fs + "Environnements"
0516: + fs
0517: + formater(env_courant.getNameFromModel())
0518: + fs + "Script");
0519: scriptElem.addAttribute("dir", "Attachements" + fs
0520: + "Environnements" + fs
0521: + formater(env_courant.getNameFromModel())
0522: + fs + "Script" + fs
0523: + formater(scInit.getNameFromModel()));
0524:
0525: //ConnectionData.getCampTestSelect().getScriptOfEnvironment(env_courant.getNameFromModel(), scInit.getNameFromModel(), dest);
0526: try {
0527: scInit.getFileFromDB(dest);
0528: String extension = scInit.getNameFromModel()
0529: .substring(
0530: scInit.getNameFromModel()
0531: .lastIndexOf("."));
0532: if (ficType != null) {
0533: for (int i = 0; i < ficType.length; i++) {
0534: if (ficType[i].indexOf(".") != -1
0535: && extension
0536: .equals(ficType[i]
0537: .substring(ficType[i]
0538: .lastIndexOf(".")))) {
0539: Element text = scriptElem
0540: .addElement("Text");
0541: ajouterTexte(
0542: text,
0543: pathAttach
0544: + fs
0545: + "Attachements"
0546: + fs
0547: + "Environnements"
0548: + fs
0549: + formater(env_courant
0550: .getNameFromModel())
0551: + fs
0552: + "Script"
0553: + fs
0554: + formater(scInit
0555: .getNameFromModel()));
0556: }
0557: }
0558: }
0559: } catch (Exception e) {
0560: Tools.ihmExceptionView(e);
0561: }
0562: }
0563: HashMap attachs = env_courant
0564: .getAttachmentMapFromModel();
0565: addAttach(envElem, pathAttach + fs + "Attachements"
0566: + fs + "Environnements" + fs
0567: + formater(env_courant.getNameFromModel()),
0568: attachs, "Attachements"
0569: + fs
0570: + "Environnements"
0571: + fs
0572: + formater(env_courant
0573: .getNameFromModel()), ficType);
0574: }
0575: }
0576: ArrayList familleList = DataModel.getCurrentProject()
0577: .getFamilyListFromModel();
0578: if ((familleList != null) && (!familleList.isEmpty())
0579: || (filtre && !selectFamilyList.isEmpty())) {
0580: Element famsElem = projetVT.addElement("Familles");
0581: Iterator it = familleList.iterator();
0582: while (it.hasNext()) {
0583: Family family = (Family) it.next();
0584: if (!filtre || selectFamilyList.contains(family)) {
0585: Element famElem = famsElem.addElement("Famille");
0586: famElem.addElement("Nom").setText(
0587: family.getNameFromModel());
0588: if (family.getDescriptionFromModel() != null
0589: && !family.getDescriptionFromModel()
0590: .equals("")) {
0591: famElem.addElement("Description").setText(
0592: family.getDescriptionFromModel()
0593: .replaceAll("\n", "\\\\n"));
0594: }
0595: famElem
0596: .addAttribute("id_famille", "Fam_"
0597: + new Integer(family.getIdBdd())
0598: .toString());
0599: HashMap attachsFam = family
0600: .getAttachmentMapFromModel();
0601: addAttach(famElem, pathAttach + fs + "Attachements"
0602: + fs + formater(family.getNameFromModel()),
0603: attachsFam, "Attachements"
0604: + fs
0605: + formater(family
0606: .getNameFromModel()),
0607: ficType);
0608: ArrayList suiteTestList = family
0609: .getSuiteListFromModel();
0610: if ((suiteTestList != null)
0611: && (!suiteTestList.isEmpty())
0612: || (filtre && !selectSuiteList.isEmpty())) {
0613: Element suitesElem = famElem
0614: .addElement("SuiteTests");
0615: Iterator iter = suiteTestList.iterator();
0616: while (iter.hasNext()) {
0617: TestList suiteTest = (TestList) iter.next();
0618: if (!filtre
0619: || selectSuiteList
0620: .contains(suiteTest)) {
0621: Element suiteElem = suitesElem
0622: .addElement("SuiteTest");
0623: suiteElem.addElement("Nom").setText(
0624: suiteTest.getNameFromModel());
0625: if (suiteTest.getDescriptionFromModel() != null
0626: && !suiteTest
0627: .getDescriptionFromModel()
0628: .equals("")) {
0629: suiteElem
0630: .addElement("Description")
0631: .setText(
0632: suiteTest
0633: .getDescriptionFromModel()
0634: .replaceAll(
0635: "\n",
0636: "\\\\n"));
0637: }
0638: suiteElem.addAttribute("id_suite",
0639: "SuiteTest_"
0640: + new Integer(suiteTest
0641: .getIdBdd())
0642: .toString());
0643: ArrayList testList = DataModel
0644: .getCurrentProject()
0645: .getAllTestFromModel(suiteTest);
0646: if ((testList != null)
0647: && (!testList.isEmpty())
0648: || (filtre && !selectTestList
0649: .isEmpty())) {
0650: Element testsElem = suiteElem
0651: .addElement("Tests");
0652: Iterator it2 = testList.iterator();
0653: while (it2.hasNext()) {
0654: Test test_cour = (Test) it2
0655: .next();
0656: if (!filtre
0657: || selectTestList
0658: .contains(test_cour)) {
0659: Element testElem = testsElem
0660: .addElement("Test");
0661: Element pers = testElem
0662: .addElement("Concepteur");
0663: if (test_cour
0664: .getConceptorFromModel() != null
0665: && !test_cour
0666: .getConceptorFromModel()
0667: .equals("")) {
0668: pers
0669: .addElement(
0670: "Nom")
0671: .setText(
0672: test_cour
0673: .getConceptorFromModel());
0674: }
0675: //String login = ConnectionData.getSuiteTestSelect().getTestDesignerLogin(test_cour.getNameFromModel(), suiteTest.getNameFromModel(), family.getNameFromModel());
0676: String login = test_cour
0677: .getConceptorLoginFromModel();
0678: if (login != null
0679: && !login
0680: .equals("")) {
0681: pers
0682: .addElement(
0683: "Login")
0684: .setText(login);
0685: }
0686: testElem
0687: .addElement("Nom")
0688: .setText(
0689: test_cour
0690: .getNameFromModel());
0691: String laDate = DateFormat
0692: .getDateInstance(
0693: DateFormat.MEDIUM,
0694: Locale.FRANCE)
0695: .format(
0696: test_cour
0697: .getCreationDateFromModel());
0698: testElem.addElement(
0699: "Date_crea")
0700: .setText(laDate);
0701: if (test_cour
0702: .getDescriptionFromModel() != null
0703: && !test_cour
0704: .getDescriptionFromModel()
0705: .equals("")) {
0706: testElem
0707: .addElement(
0708: "Description")
0709: .setText(
0710: test_cour
0711: .getDescriptionFromModel()
0712: .replaceAll(
0713: "\n",
0714: "\\\\n"));
0715: }
0716: testElem
0717: .addAttribute(
0718: "id_test",
0719: "Test_"
0720: + new Integer(
0721: test_cour
0722: .getIdBdd())
0723: .toString());
0724: String poids = getPoids(test_cour
0725: .getIdBdd());
0726: testElem.addAttribute(
0727: "poids", poids);
0728:
0729: ajouterInfoExecToTest(
0730: test_cour, testElem);
0731:
0732: ArrayList paramList = test_cour
0733: .getParameterListFromModel();
0734: if (!paramList.isEmpty()) {
0735: Element params = testElem
0736: .addElement("ParamsT");
0737: Iterator itp = paramList
0738: .iterator();
0739: while (itp.hasNext()) {
0740: Parameter param = (Parameter) itp
0741: .next();
0742: Element paramElem = params
0743: .addElement("ParamT");
0744: paramElem
0745: .addAttribute(
0746: "ref",
0747: "Param_"
0748: + new Integer(
0749: param
0750: .getIdBdd())
0751: .toString());
0752: paramElem
0753: .addElement(
0754: "Nom")
0755: .setText(
0756: param
0757: .getNameFromModel());
0758: }
0759: }
0760: if (pReqPlugin != null) {
0761: Vector reqCoveredWrapper;
0762: try {
0763: reqCoveredWrapper = Requirement
0764: .getReqWrapperCoveredByTest(test_cour
0765: .getIdBdd());
0766: int size = reqCoveredWrapper
0767: .size();
0768: if (size > 0) {
0769: Element reqLinkElem = testElem
0770: .addElement("LinkRequirement");
0771: for (int i = 0; i < size; i++) {
0772: ReqWrapper pReqWrapper = (ReqWrapper) reqCoveredWrapper
0773: .elementAt(i);
0774: Element reqRef = reqLinkElem
0775: .addElement("RequirementRef");
0776: reqRef
0777: .addAttribute(
0778: "ref",
0779: "Req_"
0780: + new Integer(
0781: pReqWrapper
0782: .getIdBDD())
0783: .toString());
0784: reqRef
0785: .addElement(
0786: "Nom")
0787: .setText(
0788: pReqWrapper
0789: .getName());
0790: String description = pReqWrapper
0791: .getDescription();
0792: if (description != null
0793: && !description
0794: .equals("")) {
0795: reqRef
0796: .addElement(
0797: "Description")
0798: .setText(
0799: pReqWrapper
0800: .getDescription());
0801: }
0802: }
0803: }
0804: } catch (Exception e) {
0805:
0806: }
0807: }
0808:
0809: HashMap attachs = test_cour
0810: .getAttachmentMapFromModel();
0811: addAttach(
0812: testElem,
0813: pathAttach
0814: + fs
0815: + "Attachements"
0816: + fs
0817: + formater(family
0818: .getNameFromModel())
0819: + fs
0820: + formater(suiteTest
0821: .getNameFromModel())
0822: + fs
0823: + formater(test_cour
0824: .getNameFromModel()),
0825: attachs,
0826: "Attachements"
0827: + fs
0828: + formater(family
0829: .getNameFromModel())
0830: + fs
0831: + formater(suiteTest
0832: .getNameFromModel())
0833: + fs
0834: + formater(test_cour
0835: .getNameFromModel()),
0836: ficType);
0837:
0838: if (test_cour instanceof ManualTest) {
0839: Element testManElem = testElem
0840: .addElement("TestManuel");
0841: ArrayList actionList = ((ManualTest) test_cour)
0842: .getActionListFromModel(false);
0843: Iterator it3 = actionList
0844: .iterator();
0845: while (it3.hasNext()) {
0846: Element actionElem = testManElem
0847: .addElement("ActionTest");
0848: Action ac = (Action) it3
0849: .next();
0850: actionElem
0851: .addElement(
0852: "Nom")
0853: .setText(
0854: ac
0855: .getNameFromModel());
0856: if (ac
0857: .getDescriptionFromModel() != null
0858: && !ac
0859: .getDescriptionFromModel()
0860: .equals(
0861: "")) {
0862: actionElem
0863: .addElement(
0864: "Description")
0865: .setText(
0866: ac
0867: .getDescriptionFromModel()
0868: .replaceAll(
0869: "\n",
0870: "\\\\n"));
0871: }
0872: if (ac
0873: .getAwaitedResultFromModel() != null
0874: && !ac
0875: .getAwaitedResultFromModel()
0876: .equals(
0877: "")) {
0878: actionElem
0879: .addElement(
0880: "ResultAttendu")
0881: .setText(
0882: ac
0883: .getAwaitedResultFromModel()
0884: .replaceAll(
0885: "\n",
0886: "\\\\n"));
0887: }
0888:
0889: actionElem
0890: .addAttribute(
0891: "id_action",
0892: "Action_"
0893: + new Integer(
0894: ac
0895: .getIdBdd())
0896: .toString());
0897: Hashtable paramEns = ac
0898: .getParameterHashSetFromModel();
0899: if (!paramEns
0900: .isEmpty()) {
0901: Element params = actionElem
0902: .addElement("ParamsT");
0903: Enumeration itp = paramEns
0904: .elements();
0905: while (itp
0906: .hasMoreElements()) {
0907: Parameter param = (Parameter) itp
0908: .nextElement();
0909: Element paramElem = params
0910: .addElement("ParamT");
0911: paramElem
0912: .addAttribute(
0913: "ref",
0914: "Param_"
0915: + new Integer(
0916: param
0917: .getIdBdd())
0918: .toString());
0919: paramElem
0920: .addElement(
0921: "Nom")
0922: .setText(
0923: param
0924: .getNameFromModel());
0925: }
0926: }
0927: attachs = ac
0928: .getAttachmentMapFromModel();
0929: addAttach(
0930: actionElem,
0931: pathAttach
0932: + fs
0933: + "Attachements"
0934: + fs
0935: + formater(family
0936: .getNameFromModel())
0937: + fs
0938: + formater(suiteTest
0939: .getNameFromModel())
0940: + fs
0941: + formater(test_cour
0942: .getNameFromModel())
0943: + fs
0944: + formater(ac
0945: .getNameFromModel()),
0946: attachs,
0947: "Attachements"
0948: + fs
0949: + formater(family
0950: .getNameFromModel())
0951: + fs
0952: + formater(suiteTest
0953: .getNameFromModel())
0954: + fs
0955: + formater(test_cour
0956: .getNameFromModel())
0957: + fs
0958: + formater(ac
0959: .getNameFromModel()),
0960: ficType);
0961: }
0962: } else {
0963: Element testAutoElem = testElem
0964: .addElement("TestAuto");
0965: testAutoElem
0966: .addAttribute(
0967: "plug_ext",
0968: ((AutomaticTest) test_cour)
0969: .getExtensionFromModel());
0970: Script sc = ((AutomaticTest) test_cour)
0971: .getScriptFromModel();
0972: if (sc != null) {
0973: Element scriptElem = testAutoElem
0974: .addElement("Script");
0975: if (sc
0976: .getScriptExtensionFromModel() != null
0977: && !sc
0978: .getScriptExtensionFromModel()
0979: .equals(
0980: "")) {
0981: scriptElem
0982: .addElement(
0983: "Classpath")
0984: .setText(
0985: sc
0986: .getScriptExtensionFromModel());
0987: }
0988: if (sc
0989: .getPlugArgFromModel() != null
0990: && !sc
0991: .getPlugArgFromModel()
0992: .equals(
0993: "")) {
0994: scriptElem
0995: .addElement(
0996: "ArgScript")
0997: .setText(
0998: sc
0999: .getPlugArgFromModel());
1000: }
1001: if (!sc
1002: .getTypeFromModel()
1003: .equals("")) {
1004: scriptElem
1005: .addAttribute(
1006: "type",
1007: sc
1008: .getTypeFromModel());
1009: }
1010: scriptElem
1011: .addAttribute(
1012: "nom",
1013: sc
1014: .getNameFromModel());
1015: String dest = new String(
1016: pathAttach
1017: + fs
1018: + "Attachements"
1019: + fs
1020: + formater(family
1021: .getNameFromModel())
1022: + fs
1023: + formater(suiteTest
1024: .getNameFromModel())
1025: + fs
1026: + formater(test_cour
1027: .getNameFromModel())
1028: + fs
1029: + "Script");
1030: scriptElem
1031: .addAttribute(
1032: "dir",
1033: "Attachements"
1034: + fs
1035: + formater(family
1036: .getNameFromModel())
1037: + fs
1038: + formater(suiteTest
1039: .getNameFromModel())
1040: + fs
1041: + formater(test_cour
1042: .getNameFromModel())
1043: + fs
1044: + "Script"
1045: + fs
1046: + formater(sc
1047: .getNameFromModel()));
1048: //ConnectionData.getSuiteTestSelect().getScriptOfTest(family.getNameFromModel(), suiteTest.getNameFromModel(), test_cour.getNameFromModel(), sc.getNameFromModel(), dest);
1049: try {
1050: sc
1051: .getFileFromDB(dest);
1052: String extension = sc
1053: .getNameFromModel()
1054: .substring(
1055: sc
1056: .getNameFromModel()
1057: .lastIndexOf(
1058: "."));
1059: if (ficType != null) {
1060: for (int i = 0; i < ficType.length; i++) {
1061: if (ficType[i]
1062: .indexOf(".") != -1
1063: && extension
1064: .equals(ficType[i]
1065: .substring(ficType[i]
1066: .lastIndexOf(".")))) {
1067: Element text = scriptElem
1068: .addElement("Text");
1069: ajouterTexte(
1070: text,
1071: pathAttach
1072: + fs
1073: + "Attachements"
1074: + fs
1075: + formater(family
1076: .getNameFromModel())
1077: + fs
1078: + formater(suiteTest
1079: .getNameFromModel())
1080: + fs
1081: + formater(test_cour
1082: .getNameFromModel())
1083: + fs
1084: + "Script"
1085: + fs
1086: + formater(sc
1087: .getNameFromModel()));
1088: }
1089: }
1090: }
1091: } catch (Exception e) {
1092: Tools
1093: .ihmExceptionView(e);
1094: }
1095: }
1096: }
1097: }
1098: }
1099: }
1100: HashMap attachs = suiteTest
1101: .getAttachmentMapFromModel();
1102: addAttach(
1103: suiteElem,
1104: pathAttach
1105: + fs
1106: + "Attachements"
1107: + fs
1108: + formater(family
1109: .getNameFromModel())
1110: + fs
1111: + formater(suiteTest
1112: .getNameFromModel()),
1113: attachs,
1114: "Attachements"
1115: + fs
1116: + formater(family
1117: .getNameFromModel())
1118: + fs
1119: + formater(suiteTest
1120: .getNameFromModel()),
1121: ficType);
1122: }
1123:
1124: }
1125: }
1126: }
1127: }
1128: }
1129: return document;
1130: }
1131:
1132: /**
1133: * Méthode qui ajoute dans le document résultant le texte contenu
1134: * dans le fichier dont le chemin est indiqué en paramètre
1135: * @param text élément auquel on rajoute lengthcontenu du fichier
1136: * @param path chemin du fichier dont le contenu doit être ajouté au document
1137: */
1138: public void ajouterTexte(Element text, String path) {
1139: File fichier = new File(path);
1140: FileReader fluxFichier = null;
1141: try {
1142: fluxFichier = new FileReader(fichier);
1143: BufferedReader tamponLecture = new BufferedReader(
1144: fluxFichier);
1145: String ligne;
1146: while ((ligne = tamponLecture.readLine()) != null) {
1147: text.addElement("ligne").setText(ligne);
1148: }
1149: tamponLecture.close();
1150: fluxFichier.close();
1151: } catch (Exception e) {
1152: Tools.ihmExceptionView(e);
1153: //Tools.ihmExceptionView(Language.getInstance().getText("Problème_lors_de_l'inclusion_des_attachements_dans_le_document_généré")+e.toString());
1154: }
1155: }
1156:
1157: void ajouterInfoExecToTest(Test pTest, Element testElem) {
1158: boolean executed = false;
1159: ArrayList campaignList = DataModel.getCurrentProject()
1160: .getCampaignOfTest(pTest);
1161: if (campaignList != null && campaignList.size() > 0) {
1162: int i = 0;
1163: int size = campaignList.size();
1164: SalomeTMFPanels.getAutomaticButtonCampaignDetails()
1165: .setEnabled(true);
1166: while (i < size && !executed) {
1167: Campaign pCampaign = (Campaign) campaignList.get(i);
1168: if (pCampaign.containsExecutionResultInModel()) {
1169: executed = true;
1170: }
1171: i++;
1172: }
1173: }
1174: testElem.addElement("Executed").setText("" + executed);
1175: }
1176:
1177: /**
1178: * Méthode de création du document xml contenant la description
1179: * de la partie dynamique du projet Salomé courant
1180: * @param pathAttach répertoire pour la sauvegarde des attachements
1181: * @param selectCampList liste des campagnes de tests sélectionnées pour figurer dans le rapport
1182: * @param selectExecList liste des exécutions sélectionnées pour figurer dans le rapport
1183: * @param ficType liste des types de fichier à insérer dans le document
1184: * @param tab tab[3] -> inclusion des exécutions ; tab[4] -> inclusion des résultats d'exécutions
1185: */
1186: public Document toDocumentDyna(String pathAttach,
1187: ArrayList selectCampList, ArrayList selectExecList,
1188: String[] ficType) {
1189: Document doc = toDocument(pathAttach, null, null, null, ficType);
1190: boolean filtre = (selectCampList != null || selectExecList != null);
1191: if (!filtre) {
1192: selectCampList = new ArrayList();
1193: selectExecList = new ArrayList();
1194: }
1195: int nbTest2 = 0;
1196: if (addDocType) {
1197: File fileSalomeStatique = new File(pathAttach + fs
1198: + "SalomeDynamique.dtd");
1199: try {
1200: doc.addDocType("SalomeStatique", null,
1201: fileSalomeStatique.toURL().toString());
1202: } catch (Exception e) {
1203: doc.addDocType("SalomeStatique", null, pathAttach + fs
1204: + "SalomeStatique.dtd");
1205: }
1206: //doc.addDocType("SalomeDynamique", null, pathAttach+ fs +"SalomeDynamique.dtd");
1207: }
1208: Element root = doc.getRootElement();
1209: root.setName("SalomeDynamique");
1210:
1211: ArrayList campList = DataModel.getCurrentProject()
1212: .getCampaignListFromModel();
1213: if (!campList.isEmpty()
1214: || (filtre && !selectCampList.isEmpty())) {
1215: Element nodeProj = (Element) doc
1216: .selectSingleNode("//ProjetVT");
1217:
1218: /* Requirments */
1219: ReqPlugin pReqPlugin = null;
1220: Extension ext = (Extension) pIPlugObject
1221: .getAssociatedExtension("requirements.Common");
1222: Util.log("[toDocumentDyna] Requirements extention is : "
1223: + ext);
1224: if (ext != null) {
1225: try {
1226: pReqPlugin = (ReqPlugin) pIPlugObject
1227: .getPluginManager().activateExtension(ext);
1228: /*JTree pTree = pReqPlugin.getTreeRequirement();
1229: DefaultMutableTreeNode node = (DefaultMutableTreeNode)((DefaultTreeModel)pTree.getModel()).getRoot();
1230: if (node.getChildCount() > 0 ){
1231: Element reqsElem = nodeProj.addElement("Requirements");
1232: Requirement pTempReq = (Requirement)node.getUserObject();
1233: reqsElem.addAttribute("id_req", "Req_"+new Integer(pTempReq.getIdBdd()).toString());
1234: writeRequirement(reqsElem , node , true, pathAttach , ficType);
1235: }*/
1236: } catch (Exception e) {
1237:
1238: }
1239: }
1240:
1241: Element campsElem = nodeProj.addElement("CampagneTests");
1242: Iterator it = campList.iterator();
1243: while (it.hasNext()) {
1244: nbTest2 = 0;
1245: Campaign camp = (Campaign) it.next();
1246: if (!filtre || selectCampList.contains(camp)) {
1247: ArrayList tList2 = camp.getTestListFromModel();
1248: if (!tList2.isEmpty()) {
1249: Iterator itList2 = tList2.iterator();
1250: while (itList2.hasNext()) {
1251: itList2.next();
1252: nbTest2 = nbTest2 + 1;
1253: }
1254: }
1255:
1256: Element campElem = campsElem
1257: .addElement("CampagneTest");
1258: campElem.addAttribute("id_camp", "Camp_"
1259: + new Integer(camp.getIdBdd()).toString());
1260: Element conceptor = campElem
1261: .addElement("Concepteur");
1262: if (camp.getConceptorFroModel() != null
1263: && !camp.getConceptorFroModel().equals("")) {
1264: conceptor.addElement("Nom").setText(
1265: camp.getConceptorFroModel());
1266: }
1267: campElem.addElement("Nom").setText(
1268: camp.getNameFromModel());
1269: String date_camp = DateFormat.getDateInstance(
1270: DateFormat.MEDIUM, Locale.FRANCE).format(
1271: camp.getDateFromModel());
1272: campElem.addElement("Date_crea").setText(date_camp);
1273: if (!camp.getDescriptionFromModel().equals("")) {
1274: campElem.addElement("Description").setText(
1275: camp.getDescriptionFromModel()
1276: .replaceAll("\n", "\\\\n"));
1277: }
1278: HashMap attachs = camp.getAttachmentMapFromModel();
1279: addAttach(
1280: campElem,
1281: pathAttach + fs + "Attachements" + fs
1282: + "Campagnes" + fs
1283: + formater(camp.getNameFromModel()),
1284: attachs,
1285: "Attachements" + fs + "Campagnes" + fs
1286: + formater(camp.getNameFromModel()),
1287: ficType);
1288:
1289: if (pReqPlugin != null) {
1290: Vector reqCoveredWrapper = new Vector();
1291: try {
1292: ArrayList pTestList = camp
1293: .getTestListFromModel();
1294: int nbTest = pTestList.size();
1295: for (int i = 0; i < nbTest; i++) {
1296: Test pTest = (Test) pTestList.get(i);
1297: Vector tempCoveredWrapper = Requirement
1298: .getReqWrapperCoveredByTest(pTest
1299: .getIdBdd());
1300: int size = tempCoveredWrapper.size();
1301: for (int j = 0; j < size; j++) {
1302: ReqWrapper pReqWrapper = (ReqWrapper) tempCoveredWrapper
1303: .elementAt(j);
1304: if (!reqCoveredWrapper
1305: .contains(pReqWrapper)) {
1306: reqCoveredWrapper
1307: .add(pReqWrapper);
1308: }
1309: }
1310: }
1311:
1312: try {
1313: File dir = new File(pathAttach
1314: + fs
1315: + "Attachements"
1316: + fs
1317: + "Campagnes"
1318: + fs
1319: + formater(camp
1320: .getNameFromModel()));
1321: if (!dir.exists()) {
1322: dir.mkdirs();
1323: }
1324: Requirement
1325: .writeCampaingChart(
1326: reqCoveredWrapper,
1327: pathAttach
1328: + fs
1329: + "Attachements"
1330: + fs
1331: + "Campagnes"
1332: + fs
1333: + formater(camp
1334: .getNameFromModel())
1335: + fs
1336: + "requirements.jpeg");
1337: } catch (Exception e) {
1338: hasCampRequirementsGraph = false;
1339: }
1340: int size = reqCoveredWrapper.size();
1341: if (size > 0) {
1342: Element reqLinkElem = campElem
1343: .addElement("LinkRequirement");
1344: for (int i = 0; i < size; i++) {
1345: ReqWrapper pReqWrapper = (ReqWrapper) reqCoveredWrapper
1346: .elementAt(i);
1347: Element reqRef = reqLinkElem
1348: .addElement("RequirementRef");
1349: reqRef.addAttribute("ref", "Req_"
1350: + new Integer(pReqWrapper
1351: .getIdBDD())
1352: .toString());
1353: reqRef.addElement("Nom").setText(
1354: pReqWrapper.getName());
1355: String description = pReqWrapper
1356: .getDescription();
1357: if (description != null
1358: && !description.equals("")) {
1359: reqRef
1360: .addElement(
1361: "Description")
1362: .setText(
1363: pReqWrapper
1364: .getDescription());
1365: }
1366: }
1367: }
1368: } catch (Exception e) {
1369:
1370: }
1371: }
1372:
1373: //jeu de donnees
1374: ArrayList datasetList = camp
1375: .getDataSetListFromModel();
1376: if (!datasetList.isEmpty()) {
1377: Element datasetsElem = campElem
1378: .addElement("JeuxDonnees");
1379: Iterator iter = datasetList.iterator();
1380: while (iter.hasNext()) {
1381: Element datasetElem = datasetsElem
1382: .addElement("JeuDonnees");
1383: DataSet dataset = (DataSet) iter.next();
1384: datasetElem.addElement("Nom").setText(
1385: dataset.getNameFromModel());
1386: if (dataset.getDescriptionFromModel() != null
1387: && !dataset
1388: .getDescriptionFromModel()
1389: .equals("")) {
1390: datasetElem
1391: .addElement("Description")
1392: .setText(
1393: dataset
1394: .getDescriptionFromModel()
1395: .replaceAll(
1396: "\n",
1397: "\\\\n"));
1398: }
1399: HashMap parameters = dataset
1400: .getParametersHashMapFromModel();//HashMap nomParam -> ValeurParam String -> String
1401: if (!parameters.isEmpty()) {
1402: Element elemValParams = datasetElem
1403: .addElement("ValeurParams");
1404: Iterator it2 = parameters.keySet()
1405: .iterator();
1406: while (it2.hasNext()) {
1407: Element elemValParam = elemValParams
1408: .addElement("ValeurParam");
1409: String par = (String) it2.next();
1410: Parameter p = DataModel
1411: .getCurrentProject()
1412: .getParameterFromModel(par);
1413: elemValParam
1414: .addAttribute(
1415: "ref",
1416: "Param_"
1417: + new Integer(
1418: p
1419: .getIdBdd())
1420: .toString());
1421: elemValParam
1422: .addElement("Nom")
1423: .setText(
1424: p
1425: .getNameFromModel());
1426: if (parameters.get(par) != null
1427: && !((String) parameters
1428: .get(par))
1429: .equals("")) {
1430: elemValParam.addAttribute(
1431: "valeur",
1432: (String) parameters
1433: .get(par));
1434: }
1435: }
1436: }
1437: datasetElem.addAttribute("id_jeu", "Jeu_"
1438: + new Integer(dataset.getIdBdd())
1439: .toString());
1440: }
1441: }
1442: ArrayList testOrdonne = new ArrayList();
1443: ArrayList familyList = camp
1444: .getFamilyListFromModel();
1445: if (!familyList.isEmpty()) {
1446: Element famsElem = campElem
1447: .addElement("FamillesCamp");
1448: Iterator iter = familyList.iterator();
1449: while (iter.hasNext()) {
1450: Family fam = (Family) iter.next();
1451: Element famElem = famsElem
1452: .addElement("FamilleRef");
1453: famElem.addAttribute("ref", "Fam_"
1454: + new Integer(fam.getIdBdd())
1455: .toString());
1456: famElem.addElement("Nom").setText(
1457: fam.getNameFromModel());
1458: ArrayList suiteTestList = fam
1459: .getSuiteListFromModel();
1460: if (!suiteTestList.isEmpty()) {
1461: Iterator iter2 = suiteTestList
1462: .iterator();
1463: Element suiteTestsElem = famElem
1464: .addElement("SuiteTestsCamp");
1465: while (iter2.hasNext()) {
1466: TestList suitetest = (TestList) iter2
1467: .next();
1468: if (camp
1469: .containsTestListInModel(suitetest)) {
1470: Element suiteTestElem = suiteTestsElem
1471: .addElement("SuiteTestRef");
1472: suiteTestElem
1473: .addAttribute(
1474: "ref",
1475: "SuiteTest_"
1476: + new Integer(
1477: suitetest
1478: .getIdBdd())
1479: .toString());
1480: suiteTestElem
1481: .addElement("Nom")
1482: .setText(
1483: suitetest
1484: .getNameFromModel());
1485: ArrayList testList = suitetest
1486: .getTestListFromModel();
1487: if (!testList.isEmpty()) {
1488: Element testsElem = suiteTestElem
1489: .addElement("TestsCamp");
1490: Iterator iter3 = testList
1491: .iterator();
1492: while (iter3.hasNext()) {
1493: Test test = (Test) iter3
1494: .next();
1495: if (camp
1496: .containsTestInModel(test)) {
1497: testOrdonne
1498: .add(test);
1499: Element testElem = testsElem
1500: .addElement("TestRef");
1501: testElem
1502: .addAttribute(
1503: "ref",
1504: "Test_"
1505: + new Integer(
1506: test
1507: .getIdBdd())
1508: .toString());
1509: testElem
1510: .addElement(
1511: "Nom")
1512: .setText(
1513: test
1514: .getNameFromModel());
1515: }
1516: }
1517: }
1518: }
1519: }
1520: }
1521: }
1522: }
1523: ArrayList execList = camp
1524: .getExecutionListFromModel();
1525: if (!execList.isEmpty()
1526: || (filtre && !selectExecList.isEmpty())) {
1527: Element execsElem = campElem
1528: .addElement("ExecCampTests");
1529: Iterator iter = execList.iterator();
1530: while (iter.hasNext()) {
1531: Execution exec = (Execution) iter.next();
1532: if (!filtre
1533: || selectExecList.contains(exec)) {
1534: Element execElem = execsElem
1535: .addElement("ExecCampTest");
1536: execElem.addElement("Nom").setText(
1537: exec.getNameFromModel());
1538: Element nbGraph = execElem
1539: .addElement("NbGraph");
1540: nbGraph.setText(new Integer(
1541: (nbTest2 - 1) / 13).toString());
1542: execElem.addAttribute("id_exec_camp",
1543: "ExecCamp_"
1544: + new Integer(exec
1545: .getIdBdd())
1546: .toString());
1547: if (exec.getDescriptionFromModel() != null
1548: && !exec
1549: .getDescriptionFromModel()
1550: .equals("")) {
1551: execElem
1552: .addElement("Description")
1553: .setText(
1554: exec
1555: .getDescriptionFromModel()
1556: .replaceAll(
1557: "\n",
1558: "\\\\n"));
1559: }
1560: Element envRefElem = execElem
1561: .addElement("EnvironnementEx");
1562: envRefElem
1563: .addAttribute(
1564: "ref",
1565: "Env_"
1566: + new Integer(
1567: exec
1568: .getEnvironmentFromModel()
1569: .getIdBdd())
1570: .toString());
1571: envRefElem.addElement("Nom").setText(
1572: exec.getEnvironmentFromModel()
1573: .getNameFromModel());
1574: if (exec.getDataSetFromModel() != null
1575: && (exec.getDataSetFromModel()
1576: .getIdBdd() != -1)) {
1577: Element refJeu = execElem
1578: .addElement("JeuDonneesEx");
1579: refJeu
1580: .addAttribute(
1581: "ref",
1582: "Jeu_"
1583: + new Integer(
1584: exec
1585: .getDataSetFromModel()
1586: .getIdBdd())
1587: .toString());
1588: refJeu
1589: .addElement("Nom")
1590: .setText(
1591: exec
1592: .getDataSetFromModel()
1593: .getNameFromModel());
1594: }
1595: if (exec.getPreScriptFromModel() != null) {
1596: Element scriptInitElem = execElem
1597: .addElement("Script");
1598: Script scriptInit = exec
1599: .getPreScriptFromModel();
1600: if (scriptInit
1601: .getScriptExtensionFromModel() != null) {
1602: scriptInitElem
1603: .addElement("Classpath")
1604: .setText(
1605: scriptInit
1606: .getScriptExtensionFromModel());
1607: }
1608: if (scriptInit
1609: .getPlugArgFromModel() != null
1610: && !scriptInit
1611: .getPlugArgFromModel()
1612: .equals("")) {
1613: scriptInitElem
1614: .addElement("ArgScript")
1615: .setText(
1616: scriptInit
1617: .getPlugArgFromModel());
1618: }
1619: if (!scriptInit.getTypeFromModel()
1620: .equals("")) {
1621: scriptInitElem
1622: .addAttribute(
1623: "type",
1624: scriptInit
1625: .getTypeFromModel());
1626: }
1627: scriptInitElem
1628: .addAttribute(
1629: "nom",
1630: scriptInit
1631: .getNameFromModel());
1632: String dest = new String(
1633: pathAttach
1634: + fs
1635: + "Attachements"
1636: + fs
1637: + "Campagnes"
1638: + fs
1639: + formater(camp
1640: .getNameFromModel())
1641: + fs
1642: + formater(exec
1643: .getNameFromModel())
1644: + fs
1645: + "ScriptInitialisation");
1646: scriptInitElem
1647: .addAttribute(
1648: "dir",
1649: "Attachements"
1650: + fs
1651: + "Campagnes"
1652: + fs
1653: + formater(camp
1654: .getNameFromModel())
1655: + fs
1656: + formater(exec
1657: .getNameFromModel())
1658: + fs
1659: + "ScriptInitialisation"
1660: + fs
1661: + formater(scriptInit
1662: .getNameFromModel()));
1663: //ConnectionData.getCampTestSelect().getScriptOfExecution(camp.getNameFromModel(), exec.getNameFromModel(), scriptInit.getNameFromModel(), "PRE_SCRIPT", dest);
1664: try {
1665: scriptInit.getFileFromDB(dest);
1666: String extension = scriptInit
1667: .getNameFromModel()
1668: .substring(
1669: scriptInit
1670: .getNameFromModel()
1671: .lastIndexOf(
1672: "."));
1673: if (ficType != null) {
1674: for (int i = 0; i < ficType.length; i++) {
1675: if (ficType[i]
1676: .indexOf(".") != -1
1677: && extension
1678: .equals(ficType[i]
1679: .substring(ficType[i]
1680: .lastIndexOf(".")))) {
1681: Element text = scriptInitElem
1682: .addElement("Text");
1683: ajouterTexte(
1684: text,
1685: pathAttach
1686: + fs
1687: + "Attachements"
1688: + fs
1689: + "Campagnes"
1690: + fs
1691: + formater(camp
1692: .getNameFromModel())
1693: + fs
1694: + formater(exec
1695: .getNameFromModel())
1696: + fs
1697: + "ScriptInitialisation"
1698: + fs
1699: + formater(scriptInit
1700: .getNameFromModel()));
1701: }
1702: }
1703: }
1704: } catch (Exception e) {
1705: Tools.ihmExceptionView(e);
1706: }
1707: }
1708: if (exec.getPostScriptFromModel() != null) {
1709: Element scriptPostElem = execElem
1710: .addElement("Script");
1711: Script scriptPost = exec
1712: .getPostScriptFromModel();
1713: if (scriptPost
1714: .getScriptExtensionFromModel() != null) {
1715: scriptPostElem
1716: .addElement("Classpath")
1717: .setText(
1718: scriptPost
1719: .getScriptExtensionFromModel());
1720: }
1721: if (scriptPost
1722: .getPlugArgFromModel() != null
1723: && !scriptPost
1724: .getPlugArgFromModel()
1725: .equals("")) {
1726: scriptPostElem
1727: .addElement("ArgScript")
1728: .setText(
1729: scriptPost
1730: .getPlugArgFromModel());
1731: }
1732: if (!scriptPost.getTypeFromModel()
1733: .equals("")) {
1734: scriptPostElem
1735: .addAttribute(
1736: "type",
1737: scriptPost
1738: .getTypeFromModel());
1739: }
1740: scriptPostElem
1741: .addAttribute(
1742: "nom",
1743: scriptPost
1744: .getNameFromModel());
1745: String dest = new String(
1746: pathAttach
1747: + fs
1748: + "Attachements"
1749: + fs
1750: + "Campagnes"
1751: + fs
1752: + formater(camp
1753: .getNameFromModel())
1754: + fs
1755: + formater(exec
1756: .getNameFromModel())
1757: + fs
1758: + "ScriptRestitution");
1759: scriptPostElem
1760: .addAttribute(
1761: "dir",
1762: "Attachements"
1763: + fs
1764: + "Campagnes"
1765: + fs
1766: + formater(camp
1767: .getNameFromModel())
1768: + fs
1769: + formater(exec
1770: .getNameFromModel())
1771: + fs
1772: + "ScriptRestitution"
1773: + fs
1774: + formater(scriptPost
1775: .getNameFromModel()));
1776: //ConnectionData.getCampTestSelect().getScriptOfExecution(camp.getNameFromModel(), exec.getNameFromModel(), scriptPost.getNameFromModel(), "POST_SCRIPT", dest);
1777: try {
1778: scriptPost.getFileFromDB(dest);
1779: String extension = scriptPost
1780: .getNameFromModel()
1781: .substring(
1782: scriptPost
1783: .getNameFromModel()
1784: .lastIndexOf(
1785: "."));
1786: if (ficType != null) {
1787: for (int i = 0; i < ficType.length; i++) {
1788: if (ficType[i]
1789: .indexOf(".") != -1
1790: && extension
1791: .equals(ficType[i]
1792: .substring(ficType[i]
1793: .lastIndexOf(".")))) {
1794: Element text = scriptPostElem
1795: .addElement("Text");
1796: ajouterTexte(
1797: text,
1798: pathAttach
1799: + fs
1800: + "Attachements"
1801: + fs
1802: + "Campagnes"
1803: + fs
1804: + formater(camp
1805: .getNameFromModel())
1806: + fs
1807: + formater(exec
1808: .getNameFromModel())
1809: + fs
1810: + "ScriptRestitution"
1811: + fs
1812: + formater(scriptPost
1813: .getNameFromModel()));
1814: }
1815: }
1816: }
1817: } catch (Exception e1) {
1818: Tools.ihmExceptionView(e1);
1819: }
1820: }
1821: HashMap attachExec = exec
1822: .getAttachmentMapFromModel();
1823: addAttach(
1824: execElem,
1825: pathAttach
1826: + fs
1827: + "Attachements"
1828: + fs
1829: + "Campagnes"
1830: + fs
1831: + formater(camp
1832: .getNameFromModel())
1833: + fs
1834: + formater(exec
1835: .getNameFromModel()),
1836: attachExec,
1837: "Attachements"
1838: + fs
1839: + "Campagnes"
1840: + fs
1841: + formater(camp
1842: .getNameFromModel())
1843: + fs
1844: + formater(exec
1845: .getNameFromModel()),
1846: ficType);
1847: ArrayList resulExecList = exec
1848: .getExecutionResultListFromModel();
1849: if (!resulExecList.isEmpty()) {
1850: Element resulExecsElem = execElem
1851: .addElement("ResulExecCampTests");
1852: Iterator it2 = resulExecList
1853: .iterator();
1854: while (it2.hasNext()) {
1855: ExecutionResult execRes = (ExecutionResult) it2
1856: .next();
1857: Element execResElem = resulExecsElem
1858: .addElement("ResulExecCampTest");
1859: execResElem
1860: .addAttribute(
1861: "id_exec_res",
1862: "ResExecCamp_"
1863: + new Integer(
1864: execRes
1865: .getIdBdd())
1866: .toString());
1867: if (execRes
1868: .getTesterFromModel() != null
1869: && !execRes
1870: .getTesterFromModel()
1871: .equals("")) {
1872: execResElem
1873: .addElement(
1874: "Testeur")
1875: .setText(
1876: execRes
1877: .getTesterFromModel());
1878: }
1879: if (!execRes.getNameFromModel()
1880: .equals("")) {
1881: execResElem
1882: .addElement("Nom")
1883: .setText(
1884: execRes
1885: .getNameFromModel());
1886: }
1887: if (execRes
1888: .getDescriptionFromModel() != null
1889: && !execRes
1890: .getDescriptionFromModel()
1891: .equals("")) {
1892: execResElem
1893: .addElement(
1894: "Description")
1895: .setText(
1896: execRes
1897: .getDescriptionFromModel()
1898: .replaceAll(
1899: "\n",
1900: "\\\\n"));
1901: }
1902: if (execRes
1903: .getExecutionDateFromModel() != null) {
1904: String date_exec = DateFormat
1905: .getDateInstance(
1906: DateFormat.MEDIUM,
1907: Locale.FRANCE)
1908: .format(
1909: execRes
1910: .getExecutionDateFromModel());
1911: execResElem.addElement(
1912: "Date_crea")
1913: .setText(date_exec);
1914: }
1915: if (execRes.getTimeFromModel() != null) {
1916: execResElem
1917: .addElement(
1918: "Heure_crea")
1919: .setText(
1920: execRes
1921: .getTimeFromModel()
1922: .toString());
1923: }
1924: HashMap attachRes = execRes
1925: .getAttachmentMapFromModel();
1926: addAttach(
1927: execResElem,
1928: pathAttach
1929: + fs
1930: + "Attachements"
1931: + fs
1932: + "Campagnes"
1933: + fs
1934: + formater(camp
1935: .getNameFromModel())
1936: + fs
1937: + formater(exec
1938: .getNameFromModel())
1939: + fs
1940: + formater(execRes
1941: .getNameFromModel()),
1942: attachRes,
1943: "Attachements"
1944: + fs
1945: + "Campagnes"
1946: + fs
1947: + formater(camp
1948: .getNameFromModel())
1949: + fs
1950: + formater(exec
1951: .getNameFromModel())
1952: + fs
1953: + formater(execRes
1954: .getNameFromModel()),
1955: ficType);
1956: execResElem
1957: .addAttribute(
1958: "statut",
1959: execRes
1960: .getExecutionStatusFromModel());
1961: HashMap resultTest = execRes
1962: .getTestsResultMapFromModel();
1963: if (!resultTest.isEmpty()) {
1964: Element resElems = execResElem
1965: .addElement("ResulExecs");
1966: if (!testOrdonne.isEmpty()) {
1967: Iterator it3 = testOrdonne
1968: .iterator();
1969: while (it3.hasNext()) {
1970: Test test = (Test) it3
1971: .next();
1972: if (resultTest
1973: .containsKey(test)) {
1974: ExecutionTestResult etr = (ExecutionTestResult) resultTest
1975: .get(test);
1976: Element resElem = resElems
1977: .addElement("ResulExec");
1978: resElem
1979: .addAttribute(
1980: "refTest",
1981: "Test_"
1982: + new Integer(
1983: etr
1984: .getTestFromModel()
1985: .getIdBdd())
1986: .toString());
1987: Element refTest = resElem
1988: .addElement("RefTest");
1989: refTest
1990: .addElement(
1991: "NomTest")
1992: .setText(
1993: test
1994: .getNameFromModel());
1995: refTest
1996: .addElement(
1997: "NomSuite")
1998: .setText(
1999: test
2000: .getTestListFromModel()
2001: .getNameFromModel());
2002: refTest
2003: .addElement(
2004: "NomFamille")
2005: .setText(
2006: test
2007: .getTestListFromModel()
2008: .getFamilyFromModel()
2009: .getNameFromModel());
2010: resElem
2011: .addAttribute(
2012: "res",
2013: etr
2014: .getStatusFromModel());
2015: HashMap attachsExecRes = etr
2016: .getAttachmentMapFromModel();
2017: addAttach(
2018: resElem,
2019: pathAttach
2020: + fs
2021: + "Attachements"
2022: + fs
2023: + "Campagnes"
2024: + fs
2025: + formater(camp
2026: .getNameFromModel())
2027: + fs
2028: + formater(exec
2029: .getNameFromModel())
2030: + fs
2031: + formater(execRes
2032: .getNameFromModel())
2033: + fs
2034: + formater(etr
2035: .getTestFromModel()
2036: .getNameFromModel()),
2037: attachsExecRes,
2038: "Attachements"
2039: + fs
2040: + "Campagnes"
2041: + fs
2042: + formater(camp
2043: .getNameFromModel())
2044: + fs
2045: + formater(exec
2046: .getNameFromModel())
2047: + fs
2048: + formater(execRes
2049: .getNameFromModel())
2050: + fs
2051: + formater(etr
2052: .getTestFromModel()
2053: .getNameFromModel()),
2054: ficType);
2055: }
2056: }
2057: }
2058: }
2059: if (pReqPlugin != null) {
2060: try {
2061: File dir = new File(
2062: pathAttach
2063: + fs
2064: + "Attachements"
2065: + fs
2066: + "Campagnes"
2067: + fs
2068: + formater(camp
2069: .getNameFromModel())
2070: + fs
2071: + formater(exec
2072: .getNameFromModel())
2073: + fs
2074: + formater(execRes
2075: .getNameFromModel()));
2076: if (!dir.exists()) {
2077: dir.mkdirs();
2078: }
2079: Requirement
2080: .writeResExecChart(
2081: execRes,
2082: pathAttach
2083: + fs
2084: + "Attachements"
2085: + fs
2086: + "Campagnes"
2087: + fs
2088: + formater(camp
2089: .getNameFromModel())
2090: + fs
2091: + formater(exec
2092: .getNameFromModel())
2093: + fs
2094: + formater(execRes
2095: .getNameFromModel())
2096: + fs
2097: + "requirements.jpeg");
2098: } catch (Exception e) {
2099: hasResExecRequirementsGraph = false;
2100: }
2101: }
2102: //HashMap actionMap = execRes.getActionsMap();
2103: //if (!actionMap.isEmpty()){
2104: // Element actionsElem = execResElem.addElement("ResulActionTests");
2105:
2106: Element actionsElem = null;
2107: boolean elementActionWrited = false;
2108: if (!testOrdonne.isEmpty()) {
2109: Iterator it3 = testOrdonne
2110: .iterator();
2111: while (it3.hasNext()) {
2112: Test test = (Test) it3
2113: .next();
2114: ExecutionTestResult pExecutionTestResult = execRes
2115: .getExecutionTestResultFromModel(test);
2116: if (test instanceof ManualTest) {
2117: if (!elementActionWrited) {
2118: actionsElem = execResElem
2119: .addElement("ResulActionTests");
2120: elementActionWrited = true;
2121: }
2122: ManualExecutionResult pManualExecutionResult = (ManualExecutionResult) pExecutionTestResult;
2123: HashMap actionMap = pManualExecutionResult
2124: .getActionsMapInModel();
2125: ArrayList actionList = ((ManualTest) test)
2126: .getActionListFromModel(false);
2127: if (!actionList
2128: .isEmpty()) {
2129: Iterator it4 = actionList
2130: .iterator();
2131: while (it4
2132: .hasNext()) {
2133: Action action = (Action) it4
2134: .next();
2135: if (actionMap
2136: .containsKey(action)) {
2137: Element actionElem = actionsElem
2138: .addElement("ResulActionTest");
2139: actionElem
2140: .addAttribute(
2141: "refAction",
2142: "Action_"
2143: + new Integer(
2144: action
2145: .getIdBdd())
2146: .toString());
2147: Element refAction = actionElem
2148: .addElement("RefAction");
2149: refAction
2150: .addElement(
2151: "NomAction")
2152: .setText(
2153: action
2154: .getNameFromModel());
2155: refAction
2156: .addElement(
2157: "NomTest")
2158: .setText(
2159: test
2160: .getNameFromModel());
2161: refAction
2162: .addElement(
2163: "NomSuite")
2164: .setText(
2165: test
2166: .getTestListFromModel()
2167: .getNameFromModel());
2168: refAction
2169: .addElement(
2170: "NomFamille")
2171: .setText(
2172: test
2173: .getTestListFromModel()
2174: .getFamilyFromModel()
2175: .getNameFromModel());
2176: String resultat = (String) actionMap
2177: .get(action);
2178: if (resultat == null
2179: || resultat
2180: .equals("")) {
2181: resultat = "NonRenseigne";
2182: }
2183: actionElem
2184: .addAttribute(
2185: "res",
2186: resultat);
2187: if (pManualExecutionResult
2188: .getDescriptionResultFromModel(action) != null) {
2189: Element test2 = actionElem
2190: .addElement("Description");
2191: test2
2192: .setText(pManualExecutionResult
2193: .getDescriptionResultFromModel(
2194: action)
2195: .replaceAll(
2196: "\n",
2197: "\\\\n"));
2198: }
2199: if (pManualExecutionResult
2200: .getAwaitedResultFromModel(action) != null) {
2201: actionElem
2202: .addElement(
2203: "ResultAttendu")
2204: .setText(
2205: pManualExecutionResult
2206: .getAwaitedResultFromModel(
2207: action)
2208: .replaceAll(
2209: "\n",
2210: "\\\\n"));
2211: }
2212: if (pManualExecutionResult
2213: .getEffectivResultFromModel(action) != null) {
2214: actionElem
2215: .addElement(
2216: "ResulEffectif")
2217: .setText(
2218: pManualExecutionResult
2219: .getEffectivResultFromModel(
2220: action)
2221: .replaceAll(
2222: "\n",
2223: "\\\\n"));
2224: }
2225: }
2226: }
2227: }
2228: }
2229: }
2230: }
2231: //}
2232: }
2233: }
2234: }
2235: }
2236: }
2237: }
2238: }
2239: }
2240: return doc;
2241: }
2242:
2243: /**
2244: * Méthode de création du document dom4j correspondant
2245: * aux graphiques svg à générer pour les tests
2246: * @param docList liste des documents dom4j générés
2247: * @param selectCampList liste des campagnes sélectionnées
2248: */
2249: public Document toTestSVG(ArrayList selectFamilyList,
2250: ArrayList selectSuiteList, ArrayList selectTestList) {
2251: ArrayList familyList = DataModel.getCurrentProject()
2252: .getFamilyListFromModel();
2253: boolean filtre = (selectFamilyList != null
2254: || selectSuiteList != null || selectTestList != null);
2255: if (!filtre) {
2256: selectFamilyList = new ArrayList();
2257: selectSuiteList = new ArrayList();
2258: selectTestList = new ArrayList();
2259: }
2260: Document document = DocumentHelper.createDocument();
2261: Element root = document.addElement("ForSVG");
2262: Element tests = root.addElement("Tests");
2263: Element maxElem = tests.addElement("MaxTest");
2264: int max = 0;
2265: if ((familyList != null) && (!familyList.isEmpty())
2266: || (filtre && !selectFamilyList.isEmpty())) {
2267: Iterator it = familyList.iterator();
2268: while (it.hasNext()) {
2269: Family family = (Family) it.next();
2270: if (!filtre || selectFamilyList.contains(family)) {
2271: Element famElem = tests.addElement("Famille");
2272: famElem
2273: .addAttribute("id_famille", "Fam_"
2274: + new Integer(family.getIdBdd())
2275: .toString());
2276: famElem.addElement("Nom").setText(
2277: family.getNameFromModel());
2278: Element manuelElem = famElem.addElement("Manuel");
2279: Element autoElem = famElem.addElement("Auto");
2280: int manuel = 0;
2281: int auto = 0;
2282: ArrayList suiteTestList = family
2283: .getSuiteListFromModel();
2284: if ((suiteTestList != null)
2285: && (!suiteTestList.isEmpty())
2286: || (filtre && !selectSuiteList.isEmpty())) {
2287: Iterator iter = suiteTestList.iterator();
2288: while (iter.hasNext()) {
2289: TestList suiteTest = (TestList) iter.next();
2290: if (!filtre
2291: || selectSuiteList
2292: .contains(suiteTest)) {
2293: ArrayList testList = DataModel
2294: .getCurrentProject()
2295: .getAllTestFromModel(suiteTest);
2296: if ((testList != null)
2297: && (!testList.isEmpty())
2298: || (filtre && !selectTestList
2299: .isEmpty())) {
2300: Iterator it2 = testList.iterator();
2301: while (it2.hasNext()) {
2302: Test test_cour = (Test) it2
2303: .next();
2304: if (!filtre
2305: || selectTestList
2306: .contains(test_cour)) {
2307: if (test_cour instanceof ManualTest) {
2308: manuel++;
2309: } else {
2310: auto++;
2311: }
2312: }
2313: }
2314: }
2315: }
2316: }
2317: }
2318: manuelElem.setText(new Integer(manuel).toString());
2319: autoElem.setText(new Integer(auto).toString());
2320: if (manuel + auto > max) {
2321: max = manuel + auto;
2322: }
2323: }
2324: }
2325: }
2326: maxElem.setText(new Integer(max).toString());
2327: return document;
2328: }
2329:
2330: /**
2331: * Méthode de création du document dom4j correspondant
2332: * aux graphiques svg à générer pour les campagnes
2333: * @param docList liste des documents dom4j générés
2334: * @param selectCampList liste des campagnes sélectionnées
2335: */
2336: public ArrayList toSVG(ArrayList docList, ArrayList selectCampList) {
2337: ArrayList campList = DataModel.getCurrentProject()
2338: .getCampaignListFromModel();
2339: boolean filtre = (selectCampList != null);
2340: if (!filtre) {
2341: selectCampList = new ArrayList();
2342: }
2343: if (!campList.isEmpty()
2344: || (filtre && !selectCampList.isEmpty())) {
2345: Iterator it = campList.iterator();
2346: while (it.hasNext()) {
2347: Document document = DocumentHelper.createDocument();
2348: Element root = document.addElement("ForSVG");
2349: Campaign camp = (Campaign) it.next();
2350: if (!filtre || selectCampList.contains(camp)) {
2351: Element campElem = root.addElement("Campagne");
2352: Element nbTest = campElem.addElement("NbTest");
2353: campElem.addAttribute("id_camp", "Camp_"
2354: + new Integer(camp.getIdBdd()).toString());
2355: campElem.addElement("Nom").setText(
2356: camp.getNameFromModel());
2357: Element passedElem = campElem.addElement("Passed");
2358: Element failedElem = campElem.addElement("Failed");
2359: Element inconclusifElem = campElem
2360: .addElement("Inconclusif");
2361: int nb = 0;
2362: int passed = 0;
2363: int failed = 0;
2364: int inconclusif = 0;
2365: int max1Passed = 0;
2366: int max2Passed = 0;
2367: int max3Passed = 0;
2368: int max1Inconclusif = 0;
2369: int max2Inconclusif = 0;
2370: int max3Inconclusif = 0;
2371: int max1Failed = 0;
2372: int max2Failed = 0;
2373: int max3Failed = 0;
2374: String max1PassedNom = "";
2375: String max2PassedNom = "";
2376: String max3PassedNom = "";
2377: String max1InconclusifNom = "";
2378: String max2InconclusifNom = "";
2379: String max3InconclusifNom = "";
2380: String max1FailedNom = "";
2381: String max2FailedNom = "";
2382: String max3FailedNom = "";
2383: ArrayList testList = camp.getTestListFromModel();
2384: if (!testList.isEmpty()) {
2385: Iterator iter = testList.iterator();
2386: while (iter.hasNext()) {
2387: int passedTest = 0;
2388: int inconclusifTest = 0;
2389: int failedTest = 0;
2390: Test test = (Test) iter.next();
2391: ArrayList executionList = camp
2392: .getExecutionListFromModel();
2393: if (!executionList.isEmpty()) {
2394: Iterator it2 = executionList.iterator();
2395: while (it2.hasNext()) {
2396: Execution execution = (Execution) it2
2397: .next();
2398: ArrayList executionResultList = execution
2399: .getExecutionResultListFromModel();
2400: if (!executionResultList.isEmpty()) {
2401: Iterator it3 = executionResultList
2402: .iterator();
2403: while (it3.hasNext()) {
2404: ExecutionResult executionResult = (ExecutionResult) it3
2405: .next();
2406: HashMap testsResultMap = executionResult
2407: .getTestsResultMapFromModel();
2408: ExecutionTestResult executionTestResult = (ExecutionTestResult) testsResultMap
2409: .get(test);
2410: if (executionTestResult
2411: .getStatusFromModel() != null) {
2412: if (executionTestResult
2413: .getStatusFromModel()
2414: .equals(
2415: "PASSED")) {
2416: passed += 1;
2417: passedTest++;
2418: nb++;
2419: } else if (executionTestResult
2420: .getStatusFromModel()
2421: .equals(
2422: "FAILED")) {
2423: failed += 1;
2424: failedTest++;
2425: nb++;
2426: } else if (executionTestResult
2427: .getStatusFromModel()
2428: .equals(
2429: "INCONCLUSIF")) {
2430: inconclusif += 1;
2431: inconclusifTest++;
2432: nb++;
2433: }
2434: }
2435: }
2436: }
2437: }
2438: }
2439: if (passedTest >= max1Passed) {
2440: max3Passed = max2Passed;
2441: max3PassedNom = new String(
2442: max2PassedNom);
2443: max2Passed = max1Passed;
2444: max2PassedNom = new String(
2445: max1PassedNom);
2446: max1Passed = passedTest;
2447: max1PassedNom = test.getNameFromModel();
2448: } else if (passedTest >= max2Passed) {
2449: max3Passed = max2Passed;
2450: max3PassedNom = new String(
2451: max2PassedNom);
2452: max2Passed = passedTest;
2453: max2PassedNom = test.getNameFromModel();
2454: } else if (passedTest >= max3Passed) {
2455: max3Passed = passedTest;
2456: max3PassedNom = test.getNameFromModel();
2457: }
2458: if (inconclusifTest >= max1Inconclusif) {
2459: max3Inconclusif = max2Inconclusif;
2460: max3InconclusifNom = new String(
2461: max2InconclusifNom);
2462: max2Inconclusif = max1Inconclusif;
2463: max2InconclusifNom = new String(
2464: max1InconclusifNom);
2465: max1Inconclusif = inconclusifTest;
2466: max1InconclusifNom = test
2467: .getNameFromModel();
2468: } else if (inconclusifTest >= max2Inconclusif) {
2469: max3Inconclusif = max2Inconclusif;
2470: max3InconclusifNom = new String(
2471: max2InconclusifNom);
2472: max2Inconclusif = inconclusifTest;
2473: max2InconclusifNom = test
2474: .getNameFromModel();
2475: } else if (inconclusifTest >= max3Inconclusif) {
2476: max3Inconclusif = inconclusifTest;
2477: max3InconclusifNom = test
2478: .getNameFromModel();
2479: }
2480: if (failedTest >= max1Failed) {
2481: max3Failed = max2Failed;
2482: max3FailedNom = new String(
2483: max2FailedNom);
2484: max2Failed = max1Failed;
2485: max2FailedNom = new String(
2486: max1FailedNom);
2487: max1Failed = failedTest;
2488: max1FailedNom = test.getNameFromModel();
2489: } else if (failedTest >= max2Failed) {
2490: max3Failed = max2Failed;
2491: max3FailedNom = new String(
2492: max2FailedNom);
2493: max2Failed = failedTest;
2494: max2FailedNom = test.getNameFromModel();
2495: } else if (failedTest >= max3Failed) {
2496: max3Failed = failedTest;
2497: max3FailedNom = test.getNameFromModel();
2498: }
2499: }
2500: }
2501: passedElem.addElement("Nb").setText(
2502: new Integer(passed).toString());
2503: failedElem.addElement("Nb").setText(
2504: new Integer(failed).toString());
2505: inconclusifElem.addElement("Nb").setText(
2506: new Integer(inconclusif).toString());
2507: nbTest.setText(new Integer(nb).toString());
2508: if (max1Passed != 0) {
2509: passedElem.addElement("Test1").setText(
2510: max1PassedNom);
2511: if (max2Passed != 0) {
2512: passedElem.addElement("Test2").setText(
2513: max2PassedNom);
2514: if (max3Passed != 0) {
2515: passedElem.addElement("Test3").setText(
2516: max3PassedNom);
2517: }
2518: }
2519: }
2520: if (max1Inconclusif != 0) {
2521: inconclusifElem.addElement("Test1").setText(
2522: max1InconclusifNom);
2523: if (max2Inconclusif != 0) {
2524: inconclusifElem.addElement("Test2")
2525: .setText(max2InconclusifNom);
2526: if (max3Inconclusif != 0) {
2527: inconclusifElem.addElement("Test3")
2528: .setText(max3InconclusifNom);
2529: }
2530: }
2531: }
2532: if (max1Failed != 0) {
2533: failedElem.addElement("Test1").setText(
2534: max1FailedNom);
2535: if (max2Failed != 0) {
2536: failedElem.addElement("Test2").setText(
2537: max2FailedNom);
2538: if (max3Failed != 0) {
2539: failedElem.addElement("Test3").setText(
2540: max3FailedNom);
2541: }
2542: }
2543: }
2544: if (nb != 0) {
2545: docList.add(document);
2546: }
2547: }
2548: }
2549: }
2550: return docList;
2551: }
2552:
2553: /**
2554: * Méthode de création du document dom4j correspondant
2555: * aux graphiques svg à générer pour les exécutions
2556: * @param docList liste des documents svg générés
2557: * @param selectCampList liste des campagnes sélectionnées
2558: * @param selectExecList liste des exécutions sélectionnées
2559: */
2560: public ArrayList toExecSVG(ArrayList docList,
2561: ArrayList selectCampList, ArrayList selectExecList) {
2562: ArrayList campList = DataModel.getCurrentProject()
2563: .getCampaignListFromModel();
2564: boolean filtre = (selectCampList != null || selectExecList != null);
2565: if (!filtre) {
2566: selectCampList = new ArrayList();
2567: selectExecList = new ArrayList();
2568: }
2569: if (!campList.isEmpty()
2570: || (filtre && !selectCampList.isEmpty())) {
2571: Iterator it = campList.iterator();
2572: while (it.hasNext()) {
2573: Campaign camp = (Campaign) it.next();
2574: if (!filtre || selectCampList.contains(camp)) {
2575: ArrayList executionList = camp
2576: .getExecutionListFromModel();
2577: if (!executionList.isEmpty()
2578: || (filtre && !selectExecList.isEmpty())) {
2579: Iterator it2 = executionList.iterator();
2580: while (it2.hasNext()) {
2581: Execution execution = (Execution) it2
2582: .next();
2583: if (!filtre
2584: || selectExecList
2585: .contains(execution)) {
2586: int max = 0;
2587: int nbTest = -1;
2588: Document document = DocumentHelper
2589: .createDocument();
2590: Element root = document
2591: .addElement("ForSVG");
2592: Element execElem = root
2593: .addElement("Execution");
2594: execElem.addAttribute("id_exec",
2595: "ExecCamp_"
2596: + new Integer(execution
2597: .getIdBdd())
2598: .toString());
2599: execElem.addElement("Nom").setText(
2600: execution.getNameFromModel());
2601: Element maxTest = execElem
2602: .addElement("MaxTest");
2603: ArrayList testList = camp
2604: .getTestListFromModel();
2605: if (!testList.isEmpty()) {
2606: Iterator iter = testList.iterator();
2607: Iterator iter_autre = testList
2608: .iterator();
2609: while (iter_autre.hasNext()) {
2610: Test test = (Test) iter_autre
2611: .next();
2612: int passed = 0;
2613: int failed = 0;
2614: int inconclusif = 0;
2615: ArrayList executionResultList = execution
2616: .getExecutionResultListFromModel();
2617: if (!executionResultList
2618: .isEmpty()) {
2619: Iterator it3 = executionResultList
2620: .iterator();
2621: while (it3.hasNext()) {
2622: ExecutionResult executionResult = (ExecutionResult) it3
2623: .next();
2624: HashMap testsResultMap = executionResult
2625: .getTestsResultMapFromModel();
2626: ExecutionTestResult executionTestResult = (ExecutionTestResult) testsResultMap
2627: .get(test);
2628: if (executionTestResult
2629: .getStatusFromModel() != null) {
2630: if (executionTestResult
2631: .getStatusFromModel()
2632: .equals(
2633: "PASSED")) {
2634: passed += 1;
2635: } else if (executionTestResult
2636: .getStatusFromModel()
2637: .equals(
2638: "FAILED")) {
2639: failed += 1;
2640: } else if (executionTestResult
2641: .getStatusFromModel()
2642: .equals(
2643: "INCONCLUSIF")) {
2644: inconclusif += 1;
2645: }
2646: }
2647: }
2648: if (passed + failed
2649: + inconclusif > max) {
2650: max = passed + failed
2651: + inconclusif;
2652: }
2653: }
2654: }
2655: while (iter.hasNext()) {
2656: nbTest++;
2657: maxTest
2658: .setText(new Integer(
2659: max).toString());
2660: if (nbTest >= 13) {
2661: nbTest = 0;
2662: if (max != 0) {
2663: docList.add(document);
2664: }
2665: document = DocumentHelper
2666: .createDocument();
2667: root = document
2668: .addElement("ForSVG");
2669: execElem = root
2670: .addElement("Execution");
2671: execElem
2672: .addAttribute(
2673: "id_exec",
2674: "ExecCamp_"
2675: + new Integer(
2676: execution
2677: .getIdBdd())
2678: .toString());
2679: execElem
2680: .addElement("Nom")
2681: .setText(
2682: execution
2683: .getNameFromModel());
2684: maxTest = execElem
2685: .addElement("MaxTest");
2686: maxTest
2687: .setText(new Integer(
2688: max)
2689: .toString());
2690: }
2691: Element testElem = execElem
2692: .addElement("Test");
2693: Test test = (Test) iter.next();
2694: testElem
2695: .addAttribute(
2696: "id_test",
2697: "Test_"
2698: + new Integer(
2699: test
2700: .getIdBdd())
2701: .toString());
2702: testElem
2703: .addElement("Nom")
2704: .setText(
2705: test
2706: .getNameFromModel());
2707: Element passedElem = testElem
2708: .addElement("Passed");
2709: Element failedElem = testElem
2710: .addElement("Failed");
2711: Element inconclusifElem = testElem
2712: .addElement("Inconclusif");
2713: int passed = 0;
2714: int failed = 0;
2715: int inconclusif = 0;
2716: ArrayList executionResultList = execution
2717: .getExecutionResultListFromModel();
2718: if (!executionResultList
2719: .isEmpty()) {
2720: Iterator it3 = executionResultList
2721: .iterator();
2722: while (it3.hasNext()) {
2723: ExecutionResult executionResult = (ExecutionResult) it3
2724: .next();
2725: HashMap testsResultMap = executionResult
2726: .getTestsResultMapFromModel();
2727: ExecutionTestResult executionTestResult = (ExecutionTestResult) testsResultMap
2728: .get(test);
2729: if (executionTestResult
2730: .getStatusFromModel() != null) {
2731: if (executionTestResult
2732: .getStatusFromModel()
2733: .equals(
2734: "PASSED")) {
2735: passed += 1;
2736: } else if (executionTestResult
2737: .getStatusFromModel()
2738: .equals(
2739: "FAILED")) {
2740: failed += 1;
2741: } else if (executionTestResult
2742: .getStatusFromModel()
2743: .equals(
2744: "INCONCLUSIF")) {
2745: inconclusif += 1;
2746: }
2747: }
2748: }
2749: passedElem
2750: .setText(new Integer(
2751: passed)
2752: .toString());
2753: failedElem
2754: .setText(new Integer(
2755: failed)
2756: .toString());
2757: inconclusifElem
2758: .setText(new Integer(
2759: inconclusif)
2760: .toString());
2761: }
2762: }
2763: }
2764: if (max != 0) {
2765: docList.add(document);
2766: }
2767: }
2768: }
2769: }
2770: }
2771: }
2772: }
2773: return docList;
2774: }
2775:
2776: /**
2777: * Méthode de création du document dom4j correspondant
2778: * aux graphiques svg à générer pour les résultats
2779: * @param docList liste des documents svg générés
2780: * @param selectCampList liste des campagnes sélectionnées
2781: * @param selectExecList liste des exécutions sélectionnées
2782: */
2783: public ArrayList toResExecSVG(ArrayList docList,
2784: ArrayList selectCampList, ArrayList selectExecList) {
2785: ArrayList campList = DataModel.getCurrentProject()
2786: .getCampaignListFromModel();
2787: boolean filtre = (selectCampList != null || selectExecList != null);
2788: if (!filtre) {
2789: selectCampList = new ArrayList();
2790: selectExecList = new ArrayList();
2791: }
2792: if (!campList.isEmpty()
2793: || (filtre && !selectCampList.isEmpty())) {
2794: Iterator it = campList.iterator();
2795: while (it.hasNext()) {
2796: Campaign camp = (Campaign) it.next();
2797: if (!filtre || selectCampList.contains(camp)) {
2798: ArrayList executionList = camp
2799: .getExecutionListFromModel();
2800: if (!executionList.isEmpty()
2801: || (filtre && !selectExecList.isEmpty())) {
2802: Iterator it2 = executionList.iterator();
2803: while (it2.hasNext()) {
2804: Execution execution = (Execution) it2
2805: .next();
2806: if (!filtre
2807: || selectExecList
2808: .contains(execution)) {
2809: ArrayList executionResultList = execution
2810: .getExecutionResultListFromModel();
2811: if (!executionResultList.isEmpty()) {
2812: Iterator it3 = executionResultList
2813: .iterator();
2814: while (it3.hasNext()) {
2815: ExecutionResult executionResult = (ExecutionResult) it3
2816: .next();
2817: int nb = 0;
2818: Document document = DocumentHelper
2819: .createDocument();
2820: Element root = document
2821: .addElement("ForSVG");
2822: Element resExecElem = root
2823: .addElement("ResExecution");
2824: resExecElem
2825: .addAttribute(
2826: "id_res_exec",
2827: "ResExecCamp_"
2828: + new Integer(
2829: executionResult
2830: .getIdBdd())
2831: .toString());
2832: resExecElem
2833: .addElement("Nom")
2834: .setText(
2835: executionResult
2836: .getNameFromModel());
2837: Element nbTest = resExecElem
2838: .addElement("NbTest");
2839: Element passedElem = resExecElem
2840: .addElement("Passed");
2841: Element failedElem = resExecElem
2842: .addElement("Failed");
2843: Element inconclusifElem = resExecElem
2844: .addElement("Inconclusif");
2845: int passed = 0;
2846: int failed = 0;
2847: int inconclusif = 0;
2848: int max1Passed = 0;
2849: int max2Passed = 0;
2850: int max3Passed = 0;
2851: int max1Inconclusif = 0;
2852: int max2Inconclusif = 0;
2853: int max3Inconclusif = 0;
2854: int max1Failed = 0;
2855: int max2Failed = 0;
2856: int max3Failed = 0;
2857: String max1PassedNom = "";
2858: String max2PassedNom = "";
2859: String max3PassedNom = "";
2860: String max1InconclusifNom = "";
2861: String max2InconclusifNom = "";
2862: String max3InconclusifNom = "";
2863: String max1FailedNom = "";
2864: String max2FailedNom = "";
2865: String max3FailedNom = "";
2866: ArrayList testList = camp
2867: .getTestListFromModel();
2868: if (!testList.isEmpty()) {
2869: Iterator iter = testList
2870: .iterator();
2871: while (iter.hasNext()) {
2872: int passedTest = 0;
2873: int inconclusifTest = 0;
2874: int failedTest = 0;
2875: Test test = (Test) iter
2876: .next();
2877: HashMap testsResultMap = executionResult
2878: .getTestsResultMapFromModel();
2879: ExecutionTestResult executionTestResult = (ExecutionTestResult) testsResultMap
2880: .get(test);
2881: if (executionTestResult
2882: .getStatusFromModel() != null) {
2883: if (executionTestResult
2884: .getStatusFromModel()
2885: .equals(
2886: "PASSED")) {
2887: passed += 1;
2888: passedTest++;
2889: nb++;
2890: } else if (executionTestResult
2891: .getStatusFromModel()
2892: .equals(
2893: "FAILED")) {
2894: failed += 1;
2895: failedTest++;
2896: nb++;
2897: } else if (executionTestResult
2898: .getStatusFromModel()
2899: .equals(
2900: "INCONCLUSIF")) {
2901: inconclusif += 1;
2902: inconclusifTest++;
2903: nb++;
2904: }
2905: }
2906: if (passedTest >= max1Passed) {
2907: max3Passed = max2Passed;
2908: max3PassedNom = new String(
2909: max2PassedNom);
2910: max2Passed = max1Passed;
2911: max2PassedNom = new String(
2912: max1PassedNom);
2913: max1Passed = passedTest;
2914: max1PassedNom = test
2915: .getNameFromModel();
2916: } else if (passedTest >= max2Passed) {
2917: max3Passed = max2Passed;
2918: max3PassedNom = new String(
2919: max2PassedNom);
2920: max2Passed = passedTest;
2921: max2PassedNom = test
2922: .getNameFromModel();
2923: } else if (passedTest >= max3Passed) {
2924: max3Passed = passedTest;
2925: max3PassedNom = test
2926: .getNameFromModel();
2927: }
2928: if (inconclusifTest >= max1Inconclusif) {
2929: max3Inconclusif = max2Inconclusif;
2930: max3InconclusifNom = new String(
2931: max2InconclusifNom);
2932: max2Inconclusif = max1Inconclusif;
2933: max2InconclusifNom = new String(
2934: max1InconclusifNom);
2935: max1Inconclusif = inconclusifTest;
2936: max1InconclusifNom = test
2937: .getNameFromModel();
2938: } else if (inconclusifTest >= max2Inconclusif) {
2939: max3Inconclusif = max2Inconclusif;
2940: max3InconclusifNom = new String(
2941: max2InconclusifNom);
2942: max2Inconclusif = inconclusifTest;
2943: max2InconclusifNom = test
2944: .getNameFromModel();
2945: } else if (inconclusifTest >= max3Inconclusif) {
2946: max3Inconclusif = inconclusifTest;
2947: max3InconclusifNom = test
2948: .getNameFromModel();
2949: }
2950: if (failedTest >= max1Failed) {
2951: max3Failed = max2Failed;
2952: max3FailedNom = new String(
2953: max2FailedNom);
2954: max2Failed = max1Failed;
2955: max2FailedNom = new String(
2956: max1FailedNom);
2957: max1Failed = failedTest;
2958: max1FailedNom = test
2959: .getNameFromModel();
2960: } else if (failedTest >= max2Failed) {
2961: max3Failed = max2Failed;
2962: max3FailedNom = new String(
2963: max2FailedNom);
2964: max2Failed = failedTest;
2965: max2FailedNom = test
2966: .getNameFromModel();
2967: } else if (failedTest >= max3Failed) {
2968: max3Failed = failedTest;
2969: max3FailedNom = test
2970: .getNameFromModel();
2971: }
2972: }
2973: }
2974: passedElem
2975: .addElement("Nb")
2976: .setText(
2977: new Integer(
2978: passed)
2979: .toString());
2980: failedElem
2981: .addElement("Nb")
2982: .setText(
2983: new Integer(
2984: failed)
2985: .toString());
2986: inconclusifElem
2987: .addElement("Nb")
2988: .setText(
2989: new Integer(
2990: inconclusif)
2991: .toString());
2992: nbTest.setText(new Integer(nb)
2993: .toString());
2994: if (max1Passed != 0) {
2995: passedElem.addElement(
2996: "Test1").setText(
2997: max1PassedNom);
2998: if (max2Passed != 0) {
2999: passedElem
3000: .addElement(
3001: "Test2")
3002: .setText(
3003: max2PassedNom);
3004: if (max3Passed != 0) {
3005: passedElem
3006: .addElement(
3007: "Test3")
3008: .setText(
3009: max3PassedNom);
3010: }
3011: }
3012: }
3013: if (max1Inconclusif != 0) {
3014: inconclusifElem.addElement(
3015: "Test1").setText(
3016: max1InconclusifNom);
3017: if (max2Inconclusif != 0) {
3018: inconclusifElem
3019: .addElement(
3020: "Test2")
3021: .setText(
3022: max2InconclusifNom);
3023: if (max3Inconclusif != 0) {
3024: inconclusifElem
3025: .addElement(
3026: "Test3")
3027: .setText(
3028: max3InconclusifNom);
3029: }
3030: }
3031: }
3032: if (max1Failed != 0) {
3033: failedElem.addElement(
3034: "Test1").setText(
3035: max1FailedNom);
3036: if (max2Failed != 0) {
3037: failedElem
3038: .addElement(
3039: "Test2")
3040: .setText(
3041: max2FailedNom);
3042: if (max3Failed != 0) {
3043: failedElem
3044: .addElement(
3045: "Test3")
3046: .setText(
3047: max3FailedNom);
3048: }
3049: }
3050: }
3051: if (nb != 0) {
3052: docList.add(document);
3053: }
3054: }
3055: }
3056: }
3057: }
3058: }
3059: }
3060: }
3061: }
3062: return docList;
3063: }
3064:
3065: /**
3066: * Méthode pour la création du graphique du plan de test
3067: * @param tab tableaude booléens indiquant quels sont les graphiques qui sont requis
3068: * @param dirJpeg répertoire où doivent être sauvegardés les graphiques
3069: * @param pathXslt feuille de style xslt pour la création des graphiques en svg
3070: * @param selectFamilyList liste des familles sélectionnées
3071: * @param selectSuiteList liste des suites de test sélectionnées
3072: * @param selectTestList liste des tests sélectionnées
3073: * @param noirEtBlanc sélection du mode d'impression
3074: */
3075: public void createJpegFile(String dirJpeg, String url_txt,
3076: String pathXslt, ArrayList selectFamilyList,
3077: ArrayList selectSuiteList, ArrayList selectTestList,
3078: boolean noirEtBlanc) {
3079: Document doc = toTestSVG(selectFamilyList, selectSuiteList,
3080: selectTestList);
3081: /*try{
3082: documentToXML(doc, "/users/vapu8214/Projet/test/test/testGraphique.xml");
3083: }catch (Exception e){
3084: e.printStackTrace();
3085: }*/
3086: //Transformation Xslt
3087: TransformerFactory factory = TransformerFactory.newInstance();
3088: Transformer transformer = null;
3089: StreamSource streamSource = null;
3090: try {
3091: streamSource = new StreamSource(new URL(url_txt + pathXslt)
3092: .openStream());
3093: } catch (Exception e) {
3094: streamSource = new StreamSource(XmlGenerator.class
3095: .getResourceAsStream("/salome" + pathXslt));
3096: }
3097: try {
3098: transformer = factory.newTransformer(streamSource);
3099: if (noirEtBlanc) {
3100: transformer.setParameter("noirEtBlanc", "1");
3101: }
3102: //Transformation du document
3103: DocumentSource source = new DocumentSource(doc);
3104: DocumentResult result = new DocumentResult();
3105: transformer.transform(source, result);
3106: //on retourne le document dom4j transformé
3107: doc = result.getDocument();
3108: doc.addDocType("svg", "-//W3C//DTD SVG 1.0//EN",
3109: "http://www.w3.org/TR/SVG/DTD/svg10.dtd");
3110: //documentToXML(doc, "/users/vapu8214/Projet/test/test/testGraphique.svg");
3111:
3112: //Transformation JPEG
3113: JPEGTranscoder transcod = new JPEGTranscoder();
3114:
3115: //transformer le document dom4j en org.w3c.dom.Document
3116: //pour pouvoir être utiliser par la librairie Batik
3117: factory = TransformerFactory.newInstance();
3118: transformer = null;
3119: transformer = factory.newTransformer();
3120: source = new DocumentSource(doc);
3121: DOMResult resultDom = new DOMResult();
3122: transformer.transform(source, resultDom);
3123: org.w3c.dom.Document resultat = (org.w3c.dom.Document) resultDom
3124: .getNode();
3125:
3126: //créer le transcodeur input
3127: TranscoderInput trans_input = new TranscoderInput(resultat);
3128: //paramètres du transcodeur jpeg
3129: transcod.addTranscodingHint(JPEGTranscoder.KEY_QUALITY,
3130: new Float(.8));
3131: OutputStream ostream = new FileOutputStream(dirJpeg + fs
3132: + "testGraphique.jpeg");
3133: TranscoderOutput output = new TranscoderOutput(ostream);
3134: transcod.transcode(trans_input, output);
3135: ostream.flush();
3136: ostream.close();
3137: } catch (Exception e) {
3138: //e.printStackTrace();
3139: Tools.ihmExceptionView(e);
3140: //Tools.ihmExceptionView(Language.getInstance().getText("Problème_lors_de_la_création_des_graphiques")+e.toString());
3141: }
3142: ;
3143: }
3144:
3145: /**
3146: * Méthode pour la création des graphiques
3147: * @param tab tableaude booléens indiquant quels sont les graphiques qui sont requis
3148: * @param dirJpeg répertoire où doivent être sauvegardés les graphiques
3149: * @param pathXslt feuille de style xslt pour la création des graphiques en svg
3150: * @param selectCampList liste des campagnes sélectionnées
3151: * @param selectExecList liste des exécutions sélectionnées
3152: * @param noirEtBlanc sélection du mode d'impression
3153: */
3154: public void createJpegFile(boolean[] tab, String dirJpeg,
3155: String url_txt, String pathXslt, ArrayList selectCampList,
3156: ArrayList selectExecList, boolean noirEtBlanc) {
3157: ArrayList docList = new ArrayList();
3158: if (tab[0]) {
3159: docList = toSVG(docList, selectCampList);
3160: }
3161: if (tab[1] && tab[4]) {
3162: docList = toExecSVG(docList, selectCampList, selectExecList);
3163: }
3164: if (tab[2] && tab[5]) {
3165: docList = toResExecSVG(docList, selectCampList,
3166: selectExecList);
3167: }
3168: String nomExec = "";
3169: int noExec = 0;
3170: if (!docList.isEmpty()) {
3171: Iterator it = docList.iterator();
3172: while (it.hasNext()) {
3173: Document doc = (Document) it.next();
3174: //Récupération de l'id
3175: //pour le nom du fichier Jpeg
3176: Attribute idCampagne = (Attribute) doc
3177: .selectSingleNode("//Campagne/@id_camp");
3178: Attribute idExec = (Attribute) doc
3179: .selectSingleNode("//Execution/@id_exec");
3180: Attribute idResExec = (Attribute) doc
3181: .selectSingleNode("//ResExecution/@id_res_exec");
3182: String fileName = "";
3183: if (idCampagne != null) {
3184: fileName = idCampagne.getValue() + ".jpeg";
3185: } else if (idExec != null) {
3186: if (nomExec.equals(idExec.getValue())) {
3187: noExec++;
3188: } else {
3189: noExec = 0;
3190: nomExec = idExec.getValue();
3191: }
3192: fileName = idExec.getValue() + "_" + noExec
3193: + ".jpeg";
3194: } else if (idResExec != null) {
3195: fileName = idResExec.getValue() + ".jpeg";
3196: }
3197: /*try{
3198: documentToXML(doc, "/users/vapu8214/Projet/test/test/"+fileNameWithoutExtension+".xml");
3199: }catch (Exception e){
3200: e.printStackTrace();
3201: }*/
3202: //Transformation Xslt
3203: TransformerFactory factory = TransformerFactory
3204: .newInstance();
3205: Transformer transformer = null;
3206: StreamSource streamSource = null;
3207: try {
3208: streamSource = new StreamSource(new URL(url_txt
3209: + pathXslt).openStream());
3210: } catch (Exception e) {
3211: streamSource = new StreamSource(XmlGenerator.class
3212: .getResourceAsStream("/salome" + pathXslt));
3213: }
3214: try {
3215: transformer = factory.newTransformer(streamSource);
3216: if (noirEtBlanc) {
3217: transformer.setParameter("noirEtBlanc", "1");
3218: }
3219: //Transformation du document
3220: DocumentSource source = new DocumentSource(doc);
3221: DocumentResult result = new DocumentResult();
3222: transformer.transform(source, result);
3223: //on retourne le document dom4j transformé
3224: doc = result.getDocument();
3225: doc.addDocType("svg", "-//W3C//DTD SVG 1.0//EN",
3226: "http://www.w3.org/TR/SVG/DTD/svg10.dtd");
3227: //documentToXML(doc, "/users/vapu8214/Projet/test/test/"+fileNameWithoutExtension+".svg");
3228:
3229: //Transformation JPEG
3230: JPEGTranscoder transcod = new JPEGTranscoder();
3231:
3232: //transformer le document dom4j en org.w3c.dom.Document
3233: //pour pouvoir être utiliser par la librairie Batik
3234: factory = TransformerFactory.newInstance();
3235: transformer = null;
3236: transformer = factory.newTransformer();
3237: source = new DocumentSource(doc);
3238: DOMResult resultDom = new DOMResult();
3239: transformer.transform(source, resultDom);
3240: org.w3c.dom.Document resultat = (org.w3c.dom.Document) resultDom
3241: .getNode();
3242:
3243: //créer le transcodeur input
3244: TranscoderInput trans_input = new TranscoderInput(
3245: resultat);
3246: //paramètres du transcodeur jpeg
3247: transcod.addTranscodingHint(
3248: JPEGTranscoder.KEY_QUALITY, new Float(.8));
3249: OutputStream ostream = new FileOutputStream(dirJpeg
3250: + fs + fileName);
3251: TranscoderOutput output = new TranscoderOutput(
3252: ostream);
3253: transcod.transcode(trans_input, output);
3254: ostream.flush();
3255: ostream.close();
3256: } catch (Exception e) {
3257: Tools.ihmExceptionView(e);
3258: //Tools.ihmExceptionView(Language.getInstance().getText("Problème_lors_de_la_création_des_graphiques")+e.toString());
3259: }
3260: ;
3261: }
3262: }
3263: }
3264:
3265: /**
3266: * Méthode qui ajoute les attachements à l'élément elem passé en paramètre,
3267: * copie le fichier d'attachement à l'emplacement spécifié par le paramètre path
3268: * et suivant le tableau ficType inclut le contenu des fichiers dans le document xml
3269: * @param elem élément auquel sont ajoutés les attachements
3270: * @param path chemin où sont sauvegardé les attachements
3271: * @param attachs HashMap qui contient les attachements
3272: * @param relativePath chemin relatif
3273: * @param ficType indiquant les extensions des fichiers à inclure dans le document
3274: */
3275: public void addAttach(Element elem, String path, HashMap attachs,
3276: String relativePath, String[] ficType) {
3277:
3278: if (!attachs.isEmpty()) {
3279: File dir = new File(path);
3280: if (!dir.exists()) {
3281: dir.mkdirs();
3282: }
3283: Element attachsElem = elem.addElement("Attachements");
3284: Iterator ita = attachs.values().iterator();
3285: while (ita.hasNext()) {
3286: Attachment at = (Attachment) ita.next();
3287: if (at instanceof UrlAttachment) {
3288: Element urlElem = attachsElem
3289: .addElement("UrlAttachement");
3290: if (at.getDescriptionFromModel() != null
3291: && !at.getDescriptionFromModel().equals("")) {
3292: urlElem.addElement("Description").setText(
3293: at.getDescriptionFromModel()
3294: .replaceAll("\n", "\\\\n"));
3295: }
3296: urlElem.addAttribute("url", at.getNameFromModel());
3297: } else {
3298: FileAttachment fa = (FileAttachment) at;
3299: Element fileElem = attachsElem
3300: .addElement("FileAttachement");
3301: if (fa.getDate() != null) {
3302: //à modifier pour formater la date
3303: fileElem.addElement("Date").setText(
3304: fa.getDate().toString());
3305: }
3306: if (fa.getDescriptionFromModel() != null
3307: && !fa.getDescriptionFromModel().equals("")) {
3308: fileElem.addElement("Description").setText(
3309: fa.getDescriptionFromModel()
3310: .replaceAll("\n", "\\\\n"));
3311: }
3312: fileElem.addAttribute("nom", at.getNameFromModel());
3313: String destElem = new String(relativePath + fs
3314: + formater(at.getNameFromModel()));
3315: fileElem.addAttribute("dir", destElem);
3316: String dest = new String(path + fs
3317: + formater(at.getNameFromModel()));
3318: dest = dest.substring(0, dest.lastIndexOf(fs));
3319: //ConnectionData.getSuiteTestSelect().getAttachFile(at.getIdBdd(), dest);
3320: try {
3321: ((FileAttachment) at).getFileFromDB(dest);
3322:
3323: String extension = at.getNameFromModel()
3324: .substring(
3325: at.getNameFromModel()
3326: .lastIndexOf("."));
3327: if (ficType != null) {
3328: for (int i = 0; i < ficType.length; i++) {
3329: if (ficType[i].indexOf(".") != -1
3330: && extension
3331: .equals(ficType[i]
3332: .substring(ficType[i]
3333: .lastIndexOf(".")))) {
3334: Element text = fileElem
3335: .addElement("Text");
3336: ajouterTexte(
3337: text,
3338: path
3339: + fs
3340: + formater(at
3341: .getNameFromModel()));
3342: }
3343: }
3344: }
3345: } catch (Exception e) {
3346: Tools.ihmExceptionView(e);
3347: }
3348: }
3349: }
3350: }
3351: }
3352:
3353: /**
3354: * Méthode pour écrire le document dom4j dans un fichier
3355: * @param doc le document dom4j
3356: * @param path chemin et nom du fichier à créer
3357: */
3358: public void documentToXML(Document doc, String path)
3359: throws Exception {
3360: FileWriter file = new FileWriter(new File(path));
3361: OutputFormat format = OutputFormat.createPrettyPrint();
3362: //si en anglais US-ASCII
3363: format.setEncoding("ISO-8859-1");
3364: XMLWriter writer = new XMLWriter(file, format);
3365: writer.write(doc);
3366: writer.close();
3367: }
3368:
3369: /**
3370: * Méthode pour le formatage des noms de fichiers
3371: *
3372: */
3373: public String formater(String s) {
3374: s = s.replace('/', '_');
3375: s = s.replace('\\', '_');
3376: s = s.replace(':', '_');
3377: s = s.replace('*', '_');
3378: s = s.replace('?', '_');
3379: s = s.replace('\"', '_');
3380: s = s.replace('<', '_');
3381: s = s.replace('>', '_');
3382: s = s.replace('|', '_');
3383: return s;
3384: }
3385:
3386: /**
3387: * Méthode pour effectuer une transformation xslt
3388: * @param tab tab[0]->insertion graphiques des campagnes, tab[1]->insertion graphiques des exécutions, tab[2]->insertion graphiques des résultats d'exécution, tab[3]->mode multi-frames
3389: * @param staticHtml si document des campagnes -> nom du fichier contenant lengthdocument des tests
3390: * @param srcXml document xml source pour la transformation
3391: * @param srcXslt document xslt pour la transformation
3392: * @param outHtml fichier dans lequel doit être mis lengthrésultat de la transformation
3393: * @param jpegImg si true, insertion des fichiers jpeg dans le document html
3394: * @param gifImg si true, insertion des fichiers gif dans le document html
3395: * @param pngImg si true, insertion des fichiers png dans le document html
3396: * @param testGraph insertion du graphique récapitulatif du plan de tests
3397: */
3398: public void transform(boolean[] tab, String staticHtml,
3399: String srcXml, String url_txt, String srcXslt,
3400: String outHtml, boolean jpegImg, boolean gifImg,
3401: boolean pngImg, boolean testGraph, String destDir)
3402: throws Exception {
3403: StreamSource styleSource = null;
3404: try {
3405: styleSource = new StreamSource(new URL(url_txt + srcXslt)
3406: .openStream());
3407: } catch (Exception e) {
3408: styleSource = new StreamSource(XmlGenerator.class
3409: .getResourceAsStream("/salome" + srcXslt));
3410: }
3411: TransformerFactory factory = TransformerFactory.newInstance();
3412: Transformer x = null;
3413: Util.log("[XmlGenerator:transform] create TransformerFactory");
3414: x = factory.newTransformer(styleSource);
3415:
3416: Util.log("[XmlGenerator:transform] set parameter");
3417:
3418: if (jpegImg) {
3419: Util.log("\t jpeg = true");
3420: x.setParameter("jpeg", "1");
3421: }
3422: if (gifImg) {
3423: Util.log("\t gif = true");
3424: x.setParameter("gif", "1");
3425: }
3426: if (pngImg) {
3427: Util.log("\t png = true");
3428: x.setParameter("png", "1");
3429: }
3430: Util.log("\t local = " + Api.getUsedLocale());
3431: x.setParameter("local", Api.getUsedLocale());
3432:
3433: /* Utilise pour que les xsl trouve translate.xml */
3434: //System.setProperty("user.dir", "file:///"+destDir);
3435: System.setProperty("user.dir", System.getProperties()
3436: .getProperty("java.io.tmpdir"));
3437:
3438: if (testGraph) {
3439: Util.log("\t testGraph = true");
3440: x.setParameter("testGraph", "1");
3441: }
3442: if (hasCampRequirementsGraph) {
3443: Util.log("\t graphCampRequirements = true");
3444: x.setParameter("graphCampRequirements", "1");
3445: }
3446: if (hasResExecRequirementsGraph) {
3447: Util.log("\t graphResExecRequirements = true");
3448: x.setParameter("graphResExecRequirements", "1");
3449: }
3450: if (hasRequirementsGraph) {
3451: Util.log("\t graphRequirements = true");
3452: x.setParameter("graphRequirements", "1");
3453: }
3454: if (!staticHtml.equals("")) {
3455: Util.log("\t staticName = " + staticHtml);
3456: x.setParameter("staticName", staticHtml);
3457: if (tab[4]) {
3458: Util.log("\t exec = true");
3459: x.setParameter("exec", "1");
3460: }
3461: if (tab[5]) {
3462: Util.log("\t resExec = true");
3463: x.setParameter("resExec", "1");
3464: }
3465: }
3466: if (tab != null) {
3467: if (tab[3]) {
3468: if (outHtml.lastIndexOf("_") < outHtml.lastIndexOf(fs)) {
3469: String frame1Param = outHtml.substring(outHtml
3470: .lastIndexOf(fs) + 1, outHtml
3471: .lastIndexOf("."))
3472: + "_sommaire.html";
3473: String frame2Param = outHtml.substring(outHtml
3474: .lastIndexOf(fs) + 1, outHtml
3475: .lastIndexOf("."))
3476: + "_princ.html";
3477: Util.log("\t frame1 = " + frame1Param);
3478: Util.log("\t frame2 = " + frame2Param);
3479: x.setParameter("frame1", frame1Param);
3480: x.setParameter("frame2", frame2Param);
3481: } else if (outHtml.substring(outHtml.lastIndexOf("_"))
3482: .equals("_sommaire.html")) {
3483: String frame2Param = outHtml.substring(outHtml
3484: .lastIndexOf(fs) + 1, outHtml
3485: .lastIndexOf("_"))
3486: + "_princ.html";
3487: Util.log("\t frame2 = " + frame2Param);
3488: x.setParameter("frame2", frame2Param);
3489: }
3490: }
3491: if (tab[0]) {
3492: Util.log("\t campGraph = true");
3493: x.setParameter("campGraph", "1");
3494: }
3495: if (tab[1]) {
3496: Util.log("\t execGraph = true");
3497: x.setParameter("execGraph", "1");
3498: }
3499: if (tab[2]) {
3500: Util.log("\t resGraph = true");
3501: x.setParameter("resGraph", "1");
3502: }
3503: }
3504: x.setOutputProperty(OutputKeys.INDENT, "yes");
3505: Util
3506: .log("[XmlGenerator:transform] get source file : "
3507: + srcXml);
3508: Source source = new StreamSource(new File(srcXml));
3509: Result target = null;
3510: Util.log("[XmlGenerator:transform] set target : " + outHtml);
3511: FileOutputStream fileOut = new FileOutputStream(outHtml);
3512:
3513: target = new javax.xml.transform.stream.StreamResult(fileOut);
3514: Util.log("[XmlGenerator:transform] do transformation ");
3515: x.transform(source, target);
3516: fileOut.close();
3517: }
3518:
3519: void createLangFile() {
3520:
3521: }
3522:
3523: /**
3524: * Méthode qui permet d'ajouter soit une page de garde soit une en-tête soit un pied de page
3525: * @param pathHtml document Html auquel il faut ajouter la mise en page
3526: * @param pathAdd document Html contenant la mise en page
3527: * @param tete true->en-tête ou page de garde, false->pied de page
3528: */
3529: public void addTitlePage(String pathHtml, String pathAdd,
3530: boolean tete) throws Exception {
3531: SAXReader reader = new SAXReader(false);
3532: reader.setIncludeExternalDTDDeclarations(false);
3533: reader.setIncludeInternalDTDDeclarations(false);
3534: Document doc = reader.read(new FileInputStream(new File(
3535: pathHtml)));
3536: SAXReader reader2 = new SAXReader(false);
3537: reader.setIncludeExternalDTDDeclarations(false);
3538: reader.setIncludeInternalDTDDeclarations(false);
3539: Document add = reader2.read(new FileInputStream(new File(
3540: pathAdd)));
3541:
3542: Document document = DocumentHelper.createDocument();
3543: Element root = document.addElement("html");
3544: Element head = ((Element) doc.selectSingleNode("//head"))
3545: .createCopy();
3546: root.add(head);
3547: Element body = root.addElement("body");
3548: if (tete) {
3549: ArrayList listElement = (ArrayList) add
3550: .selectNodes("//body/child::*");
3551: if (!listElement.isEmpty()) {
3552: Iterator it = listElement.iterator();
3553: while (it.hasNext()) {
3554: Element elem = ((Element) it.next()).createCopy();
3555: body.add(elem);
3556: }
3557: }
3558: ArrayList bodyElems = (ArrayList) doc
3559: .selectNodes("//body/child::*");
3560: if (!bodyElems.isEmpty()) {
3561: Iterator it = bodyElems.iterator();
3562: while (it.hasNext()) {
3563: Element elem = ((Element) it.next()).createCopy();
3564: body.add(elem);
3565: }
3566: }
3567: } else {
3568: ArrayList bodyElems = (ArrayList) doc
3569: .selectNodes("//body/child::*");
3570: if (!bodyElems.isEmpty()) {
3571: Iterator it = bodyElems.iterator();
3572: while (it.hasNext()) {
3573: Element elem = ((Element) it.next()).createCopy();
3574: body.add(elem);
3575: }
3576: }
3577: body.addElement("hr");
3578: ArrayList listElement = (ArrayList) add
3579: .selectNodes("//body/child::*");
3580: if (!listElement.isEmpty()) {
3581: Iterator it = listElement.iterator();
3582: while (it.hasNext()) {
3583: Element elem = ((Element) it.next()).createCopy();
3584: body.add(elem);
3585: }
3586: }
3587: }
3588: OutputFormat format = OutputFormat.createPrettyPrint();
3589: format.setEncoding("iso-8859-1");
3590: XMLWriter writer;
3591: Writer outputWriter = new BufferedWriter(new FileWriter(
3592: new File(pathHtml)));
3593: writer = new XMLWriter(outputWriter, format);
3594: writer.write(document);
3595: writer.close();
3596: }
3597:
3598: /**
3599: * Méthode qui récupère le poids associé à un test dans la BD
3600: * @param id_test identifiant du test
3601: * @return le poids du test
3602: */
3603: public String getPoids(int id_test) {
3604: String poids = "medium";
3605: /*try {
3606: // On execute la requete
3607: PreparedStatement prep = Api.DB.prepareStatement(statements.getProperty("SelectTestWeight"));
3608: prep.setInt(1,id_test);
3609: org.objectweb.salome_tmf.api.api2db.DataSet stmtRes = new org.objectweb.salome_tmf.api.api2db.DataSet(prep.executeQuery());
3610: // Ajoute les element un par un au resultat
3611: if (stmtRes.hasMoreElements()) {
3612: poids=stmtRes.getResults().getString("champs1");
3613: if (poids.equals("faible")){
3614: poids="low";
3615: }else if (poids.equals("moyen")){
3616: poids="medium";
3617: }else{
3618: poids="high";
3619: }
3620: }
3621: }
3622: catch (SQLException e) {
3623: e.printStackTrace();
3624: org.objectweb.salome_tmf.api.Api.addException("SelectTestWeight", null, e);
3625: }catch (Exception ex) {
3626: ex.printStackTrace();
3627: org.objectweb.salome_tmf.api.Api.addException( null, null, ex);
3628: }*/
3629: return poids;
3630: }
3631:
3632: /**
3633: * Méthode qui ajoute la mise en forme
3634: * si boolean tete = true : ajoute un en-tête
3635: * sinon ajoute un pied de page
3636: * @param pathHtml page html auquel on ajoute une mise en page
3637: * @param addElement élément à ajouter
3638: * @param tete détermine en-tête ou pied de page
3639: */
3640: public void addTitlePage(String pathHtml, Element addElement,
3641: boolean tete) throws Exception {
3642: SAXReader reader = new SAXReader(false);
3643: reader.setIncludeExternalDTDDeclarations(false);
3644: reader.setIncludeInternalDTDDeclarations(false);
3645: Document doc = reader.read(new FileInputStream(new File(
3646: pathHtml)));
3647:
3648: Document document = DocumentHelper.createDocument();
3649: Element elemCopy = addElement.createCopy();
3650: Element root = document.addElement("html");
3651: Element head = ((Element) doc.selectSingleNode("//head"))
3652: .createCopy();
3653: root.add(head);
3654: Element body = root.addElement("body");
3655: if (tete) {
3656: body.add(elemCopy);
3657: ArrayList bodyElems = (ArrayList) doc
3658: .selectNodes("//body/child::*");
3659: if (!bodyElems.isEmpty()) {
3660: Iterator it = bodyElems.iterator();
3661: while (it.hasNext()) {
3662: Element elem = ((Element) it.next()).createCopy();
3663: body.add(elem);
3664: }
3665: }
3666: } else {
3667: ArrayList bodyElems = (ArrayList) doc
3668: .selectNodes("//body/child::*");
3669: if (!bodyElems.isEmpty()) {
3670: Iterator it = bodyElems.iterator();
3671: while (it.hasNext()) {
3672: Element elem = ((Element) it.next()).createCopy();
3673: body.add(elem);
3674: }
3675: }
3676: body.addElement("hr");
3677: body.add(elemCopy);
3678: }
3679: OutputFormat format = OutputFormat.createPrettyPrint();
3680: format.setEncoding("iso-8859-1");
3681: XMLWriter writer;
3682: Writer outputWriter = new BufferedWriter(new FileWriter(
3683: new File(pathHtml)));
3684: writer = new XMLWriter(outputWriter, format);
3685: writer.write(document);
3686: writer.close();
3687: }
3688: }
|