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 Fayçal SOUGRATI, Vincent Pautret, Marche Mikael
0020: *
0021: * Contact: mikael.marche@rd.francetelecom.com
0022: * faycal.sougrati@francetelecom.com
0023: */
0024:
0025: package salomeTMF_plug.mantis;
0026:
0027: import java.awt.Color;
0028: import java.awt.FlowLayout;
0029: import java.awt.GridLayout;
0030: import java.io.File;
0031: import java.net.URL;
0032: import java.net.URLEncoder;
0033: import java.util.ArrayList;
0034: import java.util.Enumeration;
0035: import java.util.HashMap;
0036: import java.util.Hashtable;
0037: import java.util.Iterator;
0038: import java.util.Observable;
0039: import java.util.Observer;
0040: import java.util.Properties;
0041: import java.util.Set;
0042: import java.util.Vector;
0043:
0044: import javax.swing.BorderFactory;
0045: import javax.swing.JCheckBox;
0046: import javax.swing.JLabel;
0047: import javax.swing.JMenu;
0048: import javax.swing.JOptionPane;
0049: import javax.swing.JPanel;
0050: import javax.swing.JTabbedPane;
0051: import javax.swing.JTree;
0052: import javax.swing.event.ChangeEvent;
0053: import javax.swing.event.ChangeListener;
0054: import javax.swing.event.TreeSelectionEvent;
0055: import javax.swing.event.TreeSelectionListener;
0056: import javax.swing.tree.DefaultMutableTreeNode;
0057:
0058: import org.dom4j.Document;
0059: import org.dom4j.Element;
0060: import org.java.plugin.ExtensionPoint;
0061: import org.java.plugin.Plugin;
0062: import org.java.plugin.PluginDescriptor;
0063: import org.java.plugin.PluginManager;
0064: import org.objectweb.salome_tmf.api.Api;
0065: import org.objectweb.salome_tmf.api.ApiConstants;
0066: import org.objectweb.salome_tmf.api.Mail;
0067: import org.objectweb.salome_tmf.api.Util;
0068: import org.objectweb.salome_tmf.api.data.UserWrapper;
0069: import org.objectweb.salome_tmf.data.Action;
0070: import org.objectweb.salome_tmf.data.Attachment;
0071: import org.objectweb.salome_tmf.data.AutomaticTest;
0072: import org.objectweb.salome_tmf.data.Campaign;
0073: import org.objectweb.salome_tmf.data.DataSet;
0074: import org.objectweb.salome_tmf.data.Environment;
0075: import org.objectweb.salome_tmf.data.Execution;
0076: import org.objectweb.salome_tmf.data.ExecutionResult;
0077: import org.objectweb.salome_tmf.data.ExecutionTestResult;
0078: import org.objectweb.salome_tmf.data.Family;
0079: import org.objectweb.salome_tmf.data.ManualTest;
0080: import org.objectweb.salome_tmf.data.Parameter;
0081: import org.objectweb.salome_tmf.data.Project;
0082: import org.objectweb.salome_tmf.data.SalomeEvent;
0083: import org.objectweb.salome_tmf.data.Test;
0084: import org.objectweb.salome_tmf.data.TestList;
0085: import org.objectweb.salome_tmf.data.UrlAttachment;
0086: import org.objectweb.salome_tmf.data.User;
0087: import org.objectweb.salome_tmf.ihm.main.IBugJDialog;
0088: import org.objectweb.salome_tmf.ihm.main.SalomeTMFContext;
0089: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
0090: import org.objectweb.salome_tmf.ihm.main.plugins.PluginsTools;
0091: import org.objectweb.salome_tmf.ihm.models.DynamicTree;
0092: import org.objectweb.salome_tmf.ihm.tools.Tools;
0093: import org.objectweb.salome_tmf.plugins.UICompCst;
0094: import org.objectweb.salome_tmf.plugins.core.BugTracker;
0095: import org.objectweb.salome_tmf.plugins.core.Common;
0096: import org.objectweb.salome_tmf.plugins.core.XMLLoaderPlugin;
0097: import org.objectweb.salome_tmf.plugins.core.XMLPrinterPlugin;
0098: import org.objectweb.salome_tmf.plugins.core.XMLWriterPlugin;
0099:
0100: import salomeTMF_plug.mantis.languages.Language;
0101: import salomeTMF_plug.mantis.sqlWrapper.DefectWrapper;
0102: import salomeTMF_plug.mantis.sqlWrapper.MantisConnector;
0103: import salomeTMF_plug.mantis.sqlWrapper.SQLMantis;
0104: import salomeTMF_plug.requirements.ReqPlugin;
0105:
0106: public class MantisPlugin extends Plugin implements BugTracker,
0107: Observer, XMLPrinterPlugin, Common {
0108:
0109: //JApplet applet = null;
0110: User currentUser = null;
0111: Project currentProject = null;
0112: Properties cfg_prop = null;
0113: static String mantis_host = "";
0114: //...IDataBase iDB = null;
0115: //...Properties sql_prop = null;
0116: boolean isCurrentUserExistsInProject = false;
0117: int bugUsrID = -1;
0118: int bugProjectID = -1;
0119:
0120: final String MANTIS_CFG_FILE = "/plugins/mantis/cfg/CfgMantis.properties";
0121: //...final String MANTIS_STMT_FILE ="/salomeTMF_plug/mantis/resources/sql/Mantis_Stmts.properties";
0122: final String MANTIS_SUB_MENU = "Mantis";
0123: final static String ATTACH_DESC = "[MANTIS_ATTACH]";
0124: final static boolean AUTOADD = true;
0125:
0126: /*
0127: final String BLOCKER_STR = "block";
0128: final String MAJOR_STR = "major";
0129: final String CRITICAL_STR = "crash";
0130: */
0131: final int DEFAULT_CORRECTED_VALUE = 90;
0132:
0133: Hashtable priorityByValues;
0134: public Hashtable priorityByID;
0135: Vector priority_values;
0136:
0137: Hashtable severityByValues;
0138: public Hashtable severityByID;
0139: Vector severity_values;
0140:
0141: Hashtable statusByValues;
0142: public Hashtable statusByID;
0143: Vector status_values;
0144:
0145: Hashtable reproductibilityByValues;
0146: public Hashtable reproductibilityByID;
0147: Vector reproductibility_values;
0148:
0149: Hashtable resolutionByValues;
0150: public Hashtable resolutionByID;
0151: Vector resolution_values;
0152:
0153: int access_level = 0;
0154: /*
0155: * 0 = VIEWER
0156: *
0157: * 70 = MANAGER
0158: * 90 = ADMIN of MANTIS
0159: */
0160:
0161: static boolean suspended = false;
0162:
0163: /****** MantisConnector *****/
0164: MantisConnector pMantisConnector;
0165: DefectPanel pDefectPanel1;
0166: DefectPanel pDefectPanel2;
0167: DefectPanel pDefectPanel3;
0168:
0169: DefectPanel pMTestDefectPanel;
0170: DefectPanel pATestDefectPanel;
0171: JTabbedPane pMTestJTabbedPane;
0172: JTabbedPane pATestJTabbedPane;
0173: JTree salomeDynamicTree;
0174:
0175: static JTabbedPane salomeMainTabs;
0176: JTabbedPane pJTabbedPane2;
0177: JTabbedPane pJTabbedPane3;
0178: Hashtable defectsCache;
0179:
0180: private boolean mandatoryImport = false;
0181: private boolean mandatoryExport = false;
0182:
0183: public MantisPlugin(PluginManager arg0, PluginDescriptor arg1) {
0184: super (arg0, arg1);
0185: }
0186:
0187: protected void doStart() throws Exception {
0188: // TODO Auto-generated method stub
0189:
0190: }
0191:
0192: protected void doStop() throws Exception {
0193: // TODO Auto-generated method stub
0194:
0195: }
0196:
0197: /**
0198: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0199: */
0200: public void initBugTracker(Object iPlugObject) throws Exception {
0201:
0202: //applet = (JApplet)iPlugObject;
0203: currentUser = PluginsTools.getCurrentUser();
0204: currentProject = PluginsTools.getCurrentProject();
0205:
0206: currentProject.registerObserver(this );
0207:
0208: // Opens mantis connexion
0209: try {
0210: URL _urlBase = SalomeTMFContext.getInstance().getUrlBase();
0211: String url_txt = _urlBase.toString();
0212: url_txt = url_txt.substring(0, url_txt.lastIndexOf("/"));
0213: URL urlBase = new URL(url_txt);
0214:
0215: // Mantis configuration file for DB connexion
0216: java.net.URL url_cfg = new java.net.URL(urlBase
0217: + MANTIS_CFG_FILE);
0218: try {
0219: cfg_prop = Util.getPropertiesFile(url_cfg);
0220: } catch (Exception e) {
0221: cfg_prop = Util.getPropertiesFile(MANTIS_CFG_FILE);
0222: }
0223:
0224: String driver = cfg_prop.getProperty("JDBC_DRIVER");
0225: String url_db = cfg_prop.getProperty("MANTIS_URL_DB");
0226: String user = cfg_prop.getProperty("MANTIS_USER_LOGIN");
0227: String pwd = cfg_prop.getProperty("MANTIS_USER_PWD");
0228:
0229: if (!Api.isIDE_DEV()) {
0230: try {
0231: pwd = org.objectweb.salome_tmf.api.MD5paswd
0232: .decryptString(pwd);
0233: } catch (Exception e) {
0234: Util
0235: .log("[MantisPlugin] Clear pwd used for Mantis");
0236: }
0237: }
0238:
0239: mantis_host = cfg_prop.getProperty("MANTIS_URL_HTTP");
0240: Util
0241: .log("[MantisPlugin] MANTIS open database : "
0242: + ", " + driver + ", " + url_db + ", "
0243: + user + ", " + pwd);
0244: if (!mantis_host.endsWith("/"))
0245: mantis_host = mantis_host + "/";
0246:
0247: /*** Create an Instance of Mantis Connector **/
0248: /** To be changed with classname getInstance readed from properties**/
0249: pMantisConnector = (MantisConnector) new SQLMantis();
0250:
0251: pMantisConnector.initConnector(driver, url_db, user, pwd);
0252: /*ISQLObjectFactory iSQL_OF = Api.getISQLObjectFactory();
0253: if (iDB == null){
0254: iDB = iSQL_OF.getInstanceOfDataBase(driver);
0255: iDB.open(url_db,user,pwd);
0256: SQLUtils.initSQLUtils(iDB);
0257: }
0258: // Mantis properties file for SQL statements
0259: sql_prop = Util.getPropertiesFile(getClass().getResource(MANTIS_STMT_FILE));
0260: */
0261:
0262: // Set bug Project
0263: bugProjectID = pMantisConnector.getProjectID(currentProject
0264: .getNameFromModel());
0265: if (bugProjectID < 1 && AUTOADD) {
0266: /* Add current project in Mantis */
0267: addProject_impl(currentProject);
0268: }
0269:
0270: // Set bug user
0271: String user_login = currentUser.getLoginFromModel();
0272: bugUsrID = pMantisConnector.getUserID(user_login);
0273: if (bugUsrID < 1 && AUTOADD) {
0274: /* Add current user in Mantis */
0275: addUser_impl(currentUser);
0276: }
0277:
0278: access_level = pMantisConnector.getUserAccesLevel(bugUsrID,
0279: bugProjectID);
0280: if (access_level != -1) {
0281: isCurrentUserExistsInProject = true;
0282: } else {
0283: if (AUTOADD) {
0284: addUserInProject_impl();
0285: } else {
0286: access_level = 0;
0287: }
0288: }
0289:
0290: // Init Mantis Fields
0291: initMantisFields();
0292: pDefectPanel1 = new DefectPanel(false, this , null, null);
0293: salomeMainTabs.addTab("Plug-in Mantis", pDefectPanel1);
0294: suspended = false;
0295: salomeMainTabs.addChangeListener(new ChangeListener() {
0296: public void stateChanged(ChangeEvent e) {
0297: if (salomeMainTabs.getSelectedComponent().equals(
0298: pDefectPanel1)) {
0299: if (bugProjectID > 0) {
0300: try {
0301: pDefectPanel1
0302: .loadData(pMantisConnector
0303: .getProjectDefects(bugProjectID));
0304: } catch (Exception ex) {
0305: ex.printStackTrace();
0306: }
0307: }
0308: System.out.println("MANTIS");
0309: }
0310: }
0311: });
0312:
0313: TestDefectActionPanel pATestDefectActionPanel = new TestDefectActionPanel(
0314: this );
0315: pATestDefectPanel = new DefectPanel(true, this ,
0316: pATestDefectActionPanel, null);
0317: pATestDefectActionPanel.setDefectPanel(pATestDefectPanel);
0318: pATestJTabbedPane.addTab("Plug-in Mantis",
0319: pATestDefectPanel);
0320: pATestJTabbedPane.addChangeListener(new ChangeListener() {
0321: public void stateChanged(ChangeEvent e) {
0322: if (pATestJTabbedPane.getSelectedComponent()
0323: .equals(pATestDefectPanel)) {
0324: if (bugProjectID > 0) {
0325: try {
0326: loadDefectTest(DataModel
0327: .getCurrentTest(),
0328: pATestDefectPanel);
0329: } catch (Exception ex) {
0330: ex.printStackTrace();
0331: }
0332: }
0333: System.out.println("MANTISA");
0334: }
0335: }
0336: });
0337:
0338: TestDefectActionPanel pMTestDefectActionPanel = new TestDefectActionPanel(
0339: this );
0340: pMTestDefectPanel = new DefectPanel(true, this ,
0341: pMTestDefectActionPanel, null);
0342: pMTestDefectActionPanel.setDefectPanel(pMTestDefectPanel);
0343: pMTestJTabbedPane.addTab("Plug-in Mantis",
0344: pMTestDefectPanel);
0345: pMTestJTabbedPane.addChangeListener(new ChangeListener() {
0346: public void stateChanged(ChangeEvent e) {
0347: if (pMTestJTabbedPane.getSelectedComponent()
0348: .equals(pMTestDefectPanel)) {
0349: if (bugProjectID > 0) {
0350: try {
0351: loadDefectTest(DataModel
0352: .getCurrentTest(),
0353: pMTestDefectPanel);
0354: } catch (Exception ex) {
0355: ex.printStackTrace();
0356: }
0357: }
0358: System.out.println("MANTISM");
0359: }
0360: }
0361: });
0362:
0363: } catch (Exception E) {
0364: E.printStackTrace();
0365: SalomeTMFContext.getInstance()
0366: .showMessage(
0367: Language.getInstance().getText(
0368: "Probleme_config"),
0369: Language.getInstance().getText(
0370: "Plugin_non_charge"),
0371: JOptionPane.WARNING_MESSAGE);
0372: throw E;
0373: }
0374:
0375: }
0376:
0377: /**
0378: * @return true if projet, and user are stored in other DB (not in salome DB)
0379: */
0380: public boolean isIndependantTracker() {
0381: return true;
0382: }
0383:
0384: /**
0385: * @return true if the tracker support ICAL/QSCORE
0386: */
0387: public boolean isSuportIndicators() {
0388: return true;
0389: }
0390:
0391: /**
0392: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0393: */
0394: public boolean isUserExistsInBugDB() {
0395: return isCurrentUserExistsInProject;
0396: }
0397:
0398: public void addUser(User user) throws Exception {
0399: if (bugProjectID < 1) {
0400: JOptionPane
0401: .showMessageDialog(
0402: SalomeTMFContext.getInstance()
0403: .getSalomeFrame(),
0404: Language
0405: .getInstance()
0406: .getText(
0407: "creation_projet_avant_creation_utilisateur"),
0408: Language.getInstance().getText(
0409: "Information..."),
0410: JOptionPane.INFORMATION_MESSAGE);
0411: return;
0412: }
0413:
0414: if (isCurrentUserExistsInProject) {
0415: JOptionPane.showMessageDialog(SalomeTMFContext
0416: .getInstance().getSalomeFrame(), Language
0417: .getInstance().getText("L'utilisateur_\"")
0418: + currentUser.getLoginFromModel()
0419: + Language.getInstance().getText(
0420: "\"_existe_déjà _dans_Mantis"), Language
0421: .getInstance().getText("Information..."),
0422: JOptionPane.INFORMATION_MESSAGE);
0423: } else {
0424:
0425: // Adding the user to Mantis
0426: /*
0427: int bugUsrID = pMantisConnector.getUserID(user.getLoginFromModel());
0428: if (bugUsrID == -1){
0429: bugUsrID = pMantisConnector.addUser(user);
0430: }
0431: // Add user to mantis project
0432: int access_l = 70; // manager
0433: if (currentProject.getAdministratorWrapperFromDB().getLogin().equals(currentUser.getLoginFromModel())) {
0434: access_l = 90; // admin
0435: }
0436:
0437: pMantisConnector.addUserInProject(bugUsrID, bugProjectID, access_l);
0438:
0439:
0440: isCurrentUserExistsInProject = true;
0441: access_level = access_l;
0442: */
0443:
0444: addUser_impl(user);
0445: access_level = addUserInProject_impl();
0446:
0447: JOptionPane
0448: .showMessageDialog(
0449: SalomeTMFContext.getInstance()
0450: .getSalomeFrame(),
0451: Language.getInstance().getText(
0452: "L'utilisateur_\"")
0453: + currentUser.getLoginFromModel()
0454: + Language
0455: .getInstance()
0456: .getText(
0457: "\"_a_été_créé_dans_Mantis_avec_succès\n")
0458: + Language
0459: .getInstance()
0460: .getText(
0461: "vous_devez_quitter_Salomé_et_vous_reconnecter_pour\n")
0462: + Language
0463: .getInstance()
0464: .getText(
0465: "accéder_aux_fonctionnalités_concernées"),
0466: Language.getInstance().getText(
0467: "Information..."),
0468: JOptionPane.INFORMATION_MESSAGE);
0469: }
0470: }
0471:
0472: private void addUser_impl(User user) throws Exception {
0473: bugUsrID = pMantisConnector.getUserID(user.getLoginFromModel());
0474: if (bugUsrID == -1) {
0475: bugUsrID = pMantisConnector.addUser(user);
0476: }
0477: }
0478:
0479: private int addUserInProject_impl() throws Exception {
0480: int access_l = 70; // manager
0481: if (currentProject.getAdministratorWrapperFromDB().getLogin()
0482: .equals(currentUser.getLoginFromModel())) {
0483: access_l = 90; // admin
0484: }
0485:
0486: pMantisConnector.addUserInProject(bugUsrID, bugProjectID,
0487: access_l);
0488: isCurrentUserExistsInProject = true;
0489: return access_l;
0490: }
0491:
0492: /**
0493: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0494: */
0495: public void addProject(Project project) throws Exception {
0496: if (bugProjectID > 0) {
0497: JOptionPane.showMessageDialog(SalomeTMFContext
0498: .getInstance().getSalomeFrame(), Language
0499: .getInstance().getText("Le_projet_\"")
0500: + currentProject.getNameFromModel()
0501: + Language.getInstance().getText(
0502: "\"_existe_déjà _dans_Mantis"), Language
0503: .getInstance().getText("Information..."),
0504: JOptionPane.INFORMATION_MESSAGE);
0505: } else {
0506: // Adding Salomé TMF project to Mantis DB
0507: /*bugProjectID = pMantisConnector.addProject(currentProject) ;
0508: if (bugProjectID != -1){
0509: pMantisConnector.addDefaultEnvToProject(bugProjectID);
0510: }*/
0511: addProject_impl(currentProject);
0512: JOptionPane.showMessageDialog(SalomeTMFContext
0513: .getInstance().getSalomeFrame(), Language
0514: .getInstance().getText("Le_projet_\"")
0515: + currentProject.getNameFromModel()
0516: + Language.getInstance().getText(
0517: "\"_a_été_créé_dans_Mantis_avec_succès\n"),
0518: Language.getInstance().getText("Information..."),
0519: JOptionPane.INFORMATION_MESSAGE);
0520: }
0521: }
0522:
0523: private void addProject_impl(Project project) throws Exception {
0524: bugProjectID = pMantisConnector.addProject(project);
0525: if (bugProjectID != -1) {
0526: pMantisConnector.addDefaultEnvToProject(bugProjectID);
0527: }
0528: }
0529:
0530: /**
0531: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0532: */
0533: public void addEnvironment(Environment environment)
0534: throws Exception {
0535: if (!(bugProjectID > 0)) {
0536: return;
0537: }
0538: pMantisConnector.addEnvironment(environment, bugProjectID);
0539: }
0540:
0541: void addEnvironment(String envName) throws Exception {
0542: if (!(bugProjectID > 0)) {
0543: return;
0544: }
0545: Environment environment = DataModel.getCurrentProject()
0546: .getEnvironmentFromModel(envName);
0547: if (environment == null) {
0548: pMantisConnector.addEnvironment(envName, "", bugProjectID);
0549: } else {
0550: addEnvironment(environment);
0551: }
0552: }
0553:
0554: /**
0555: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0556: */
0557: public void updateEnvironment(String old_component,
0558: String new_component, String description) throws Exception {
0559: if (!(bugProjectID > 0)) {
0560: return;
0561: }
0562: pMantisConnector.updateEnvironment(old_component,
0563: new_component, description, bugProjectID);
0564: }
0565:
0566: /**
0567: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0568: */
0569: public void deleteEnvironment(String environment) throws Exception {
0570: if (!(bugProjectID > 0)) {
0571: return;
0572: }
0573: pMantisConnector.deleteEnvironment(environment, bugProjectID);
0574: }
0575:
0576: public JPanel getBugViewPanel(IBugJDialog pIBugJDialog,
0577: String actionName, String actionDesc,
0578: String actionAwatedRes, String actionEffectiveRes) {
0579: ExecutionResult execResult = DataModel
0580: .getObservedExecutionResult();
0581: ExecutionTestResult executionTestResult = DataModel
0582: .getCurrentExecutionTestResult();
0583: return new DefectViewPanel(pIBugJDialog, execResult,
0584: executionTestResult, actionName, actionDesc,
0585: actionAwatedRes, actionEffectiveRes, this );
0586: }
0587:
0588: /**
0589: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0590: */
0591: public Attachment addBug(String long_desc, String assigned_to,
0592: String url_attach, String bug_severity, String short_desc,
0593: String bug_OS, String bug_priority, String bug_platform,
0594: String bug_reproductibility, Execution pExec,
0595: ExecutionResult pExecRes, Test ptest) throws Exception {
0596:
0597: if (access_level <= 10) {
0598: JOptionPane.showMessageDialog(SalomeTMFContext
0599: .getInstance().getSalomeFrame(), Language
0600: .getInstance().getText("Access_level_insuffisant"),
0601: "Error!", JOptionPane.ERROR_MESSAGE);
0602: throw new Exception("[Mantis] Project not found");
0603: }
0604: if (!(bugProjectID > 0)) {
0605: JOptionPane.showMessageDialog(SalomeTMFContext
0606: .getInstance().getSalomeFrame(), Language
0607: .getInstance().getText("Must_create_project"),
0608: "Error!", JOptionPane.ERROR_MESSAGE);
0609: throw new Exception("[Mantis] Project not found");
0610: }
0611:
0612: UrlAttachment bugURL = null;
0613:
0614: // If bug environment doesn't exist, we create it!
0615: Environment env = pExec.getEnvironmentFromModel();
0616: if (!pMantisConnector.isExistEnv(bugProjectID, env
0617: .getNameFromModel())) {
0618: addEnvironment(env);
0619: }
0620:
0621: // Assigned to ID init
0622: int assigned_to_ID = -1;
0623: try {
0624: assigned_to_ID = pMantisConnector.getUserIDInProject(
0625: assigned_to, bugProjectID);
0626: } catch (Exception e) {
0627: e.printStackTrace();
0628: }
0629: if (assigned_to_ID == -1) {
0630: assigned_to_ID = bugUsrID;
0631: assigned_to = currentUser.getLoginFromModel();
0632: }
0633: if ((url_attach != null) && (!url_attach.equals(""))) {
0634: short_desc += " (URL = " + url_attach + ")";
0635: }
0636: if ((bug_OS == null) || (bug_OS.equals(""))) {
0637: bug_OS = " ";
0638: }
0639: if ((short_desc == null) || (short_desc.equals(""))) {
0640: short_desc = " ";
0641: }
0642: int int_bug_priority;
0643: int int_bug_severity;
0644: int int_bug_reproductibility;
0645:
0646: if ((bug_priority == null) || (bug_priority == "")) {
0647: int_bug_priority = 10;
0648: } else {
0649: int_bug_priority = ((Integer) priorityByValues
0650: .get(bug_priority)).intValue();
0651: }
0652: if ((bug_severity == null) || (bug_severity == "")) {
0653: int_bug_severity = 10;
0654: } else {
0655: int_bug_severity = ((Integer) severityByValues
0656: .get(bug_severity)).intValue();
0657: }
0658: if ((bug_reproductibility == null)
0659: || (bug_reproductibility == "")) {
0660: int_bug_reproductibility = 10;
0661: } else {
0662: int_bug_reproductibility = ((Integer) reproductibilityByValues
0663: .get(bug_reproductibility)).intValue();
0664: }
0665:
0666: int bug_id = pMantisConnector.addDefect(bugUsrID, bugProjectID,
0667: assigned_to_ID, long_desc, url_attach, short_desc,
0668: bug_OS, int_bug_priority, bug_platform,
0669: int_bug_reproductibility, int_bug_severity, env
0670: .getNameFromModel());
0671:
0672: String url_res = mantis_host
0673: + "view_salome_bug_page.php?project_id="
0674: + URLEncoder.encode("" + bugProjectID) + "&bug_id="
0675: + URLEncoder.encode("" + bug_id) + "&user_id="
0676: + URLEncoder.encode("" + bugUsrID);
0677: bugURL = new UrlAttachment(url_res, MantisPlugin.ATTACH_DESC);
0678:
0679: return bugURL;
0680:
0681: }
0682:
0683: /**
0684: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0685: */
0686: int addBug(DefectWrapper pDefectWrapper) throws Exception {
0687:
0688: if (access_level <= 10) {
0689: JOptionPane.showMessageDialog(SalomeTMFContext
0690: .getInstance().getSalomeFrame(), Language
0691: .getInstance().getText("Access_level_insuffisant"),
0692: "Error!", JOptionPane.ERROR_MESSAGE);
0693: throw new Exception("[Mantis] Project not found");
0694: }
0695: if (!(bugProjectID > 0)) {
0696: JOptionPane.showMessageDialog(SalomeTMFContext
0697: .getInstance().getSalomeFrame(), Language
0698: .getInstance().getText("Must_create_project"),
0699: "Error!", JOptionPane.ERROR_MESSAGE);
0700: throw new Exception("[Mantis] Project not found");
0701: }
0702:
0703: UrlAttachment bugURL = null;
0704:
0705: // If bug environment doesn't exist, we create it!
0706: String env = pDefectWrapper.getEnvironement();
0707: if (env == null || env.equals("")) {
0708: env = "___NO_ENV___";
0709: }
0710: if (!pMantisConnector.isExistEnv(bugProjectID, env)) {
0711: addEnvironment(env);
0712: }
0713:
0714: // Assigned to ID init
0715: int assigned_to_ID = -1;
0716: try {
0717: assigned_to_ID = pMantisConnector.getUserIDInProject(
0718: pDefectWrapper.getRecipient(), bugProjectID);
0719: } catch (Exception e) {
0720: e.printStackTrace();
0721: }
0722: if (assigned_to_ID == -1) {
0723: assigned_to_ID = bugUsrID;
0724: }
0725:
0726: int int_bug_priority = pDefectWrapper.getPriority();
0727: int int_bug_severity = pDefectWrapper.getSeverity();
0728: int int_bug_reproductibility = pDefectWrapper
0729: .getReproducibility();
0730: String long_desc = pDefectWrapper.getDescription();
0731: String short_desc = pDefectWrapper.getResume();
0732: String bug_OS = pDefectWrapper.getOs();
0733: String bug_platform = pDefectWrapper.getPlateforme();
0734:
0735: int bug_id = pMantisConnector.addDefect(bugUsrID, bugProjectID,
0736: assigned_to_ID, long_desc, null, short_desc, bug_OS,
0737: int_bug_priority, bug_platform,
0738: int_bug_reproductibility, int_bug_severity, env);
0739:
0740: /*String url_res = mantis_host + "view_salome_bug_page.php?project_id=" + URLEncoder.encode (""+bugProjectID) + "&bug_id=" +
0741: URLEncoder.encode(""+bug_id) + "&user_id=" + URLEncoder.encode (""+bugUsrID);
0742: bugURL = new UrlAttachment(url_res,MantisPlugin.ATTACH_DESC);
0743: */
0744: pDefectWrapper.setId(bug_id);
0745: sendMail(pDefectWrapper, "added", false);
0746: return bug_id;
0747:
0748: }
0749:
0750: void modifyBug(DefectWrapper pDefectWrapper) throws Exception {
0751:
0752: if (access_level <= 10) {
0753: JOptionPane.showMessageDialog(SalomeTMFContext
0754: .getInstance().getSalomeFrame(), Language
0755: .getInstance().getText("Access_level_insuffisant"),
0756: "Error!", JOptionPane.ERROR_MESSAGE);
0757: throw new Exception("[Mantis] Project not found");
0758: }
0759: int id = pDefectWrapper.getId();
0760: if (!(bugProjectID > 0) || id < 1) {
0761: JOptionPane.showMessageDialog(SalomeTMFContext
0762: .getInstance().getSalomeFrame(), Language
0763: .getInstance().getText("Must_create_project"),
0764: "Error!", JOptionPane.ERROR_MESSAGE);
0765: throw new Exception("[Mantis] Project not found");
0766: }
0767:
0768: int id_assigned_to = -1;
0769: try {
0770: id_assigned_to = pMantisConnector.getUserIDInProject(
0771: pDefectWrapper.getRecipient(), bugProjectID);
0772: } catch (Exception e) {
0773: e.printStackTrace();
0774: }
0775: if (id_assigned_to == -1) {
0776: id_assigned_to = bugUsrID;
0777: }
0778:
0779: int id_bug_severity = pDefectWrapper.getSeverity();
0780: int id_bug_satus = pDefectWrapper.getStatus();
0781: int id_bug_priority = pDefectWrapper.getPriority();
0782: int id_bug_reproducibility = pDefectWrapper
0783: .getReproducibility();
0784: int id_bug_resolution = pDefectWrapper.getResolution();
0785: String short_desc = pDefectWrapper.getResume();
0786: String long_desc = pDefectWrapper.getDescription();
0787: String bug_OS = pDefectWrapper.getOs();
0788: String bug_platform = pDefectWrapper.getPlateforme();
0789: String env = pDefectWrapper.getEnvironement();
0790: if (env == null || env.equals("")) {
0791: env = "___NO_ENV___";
0792: }
0793: if (!pMantisConnector.isExistEnv(bugProjectID, env)) {
0794: addEnvironment(env);
0795: }
0796:
0797: pMantisConnector.updateDefect(bugUsrID, bugProjectID, id,
0798: id_assigned_to, long_desc, id_bug_severity,
0799: id_bug_satus, short_desc, bug_OS, id_bug_priority,
0800: bug_platform, env, id_bug_reproducibility,
0801: id_bug_resolution);
0802:
0803: sendMail(pDefectWrapper, "updated", true);
0804: }
0805:
0806: private void sendMail(DefectWrapper pDefectWrapper, String action,
0807: boolean isUpdate) {
0808: try {
0809: String to[] = new String[1];
0810: String userFrom = "";
0811: if (isUpdate) {
0812: userFrom = pDefectWrapper.getUser();
0813: } else {
0814: userFrom = pDefectWrapper.getRecipient();
0815: }
0816: Vector<UserWrapper> listOfUser = currentProject
0817: .getAllUsersWrapper();
0818: boolean trouve = false;
0819: int index = 0;
0820: int taille = listOfUser.size();
0821: while (!trouve && index < taille) {
0822: UserWrapper pUserWrapper = listOfUser.elementAt(index);
0823: if (pUserWrapper.getLogin().equals(userFrom)) {
0824: to[0] = pUserWrapper.getEmail();
0825: trouve = true;
0826: }
0827: index++;
0828: }
0829: if (trouve == true && !to[0].equals("")) {
0830: //String recipients[ ], String subject, String message , String from
0831: Mail.postMail(to, "["
0832: + currentProject.getNameFromModel()
0833: + "] Mantis defect " + pDefectWrapper.getId()
0834: + " is " + action, pDefectWrapper.getResume()
0835: + "\n" + pDefectWrapper.getDescription(),
0836: currentUser.getEmailFromModel());
0837: }
0838: } catch (Exception e) {
0839:
0840: }
0841: }
0842:
0843: /**
0844: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0845: */
0846: public void modifyBug(Attachment pAttach, String long_desc,
0847: String assigned_to, String url_attach, String bug_severity,
0848: String bug_satus, String short_desc, String bug_OS,
0849: String bug_priority, String bug_platform, String bug_env,
0850: String bug_reproducibility, String bug_resolution)
0851: throws Exception {
0852:
0853: if (access_level <= 10) {
0854: JOptionPane.showMessageDialog(SalomeTMFContext
0855: .getInstance().getSalomeFrame(), Language
0856: .getInstance().getText("Access_level_insuffisant"),
0857: "Error!", JOptionPane.ERROR_MESSAGE);
0858: throw new Exception("[Mantis] Project not found");
0859: }
0860: int id = getIDofBug(pAttach);
0861: if (!(bugProjectID > 0) || id < 1) {
0862: JOptionPane.showMessageDialog(SalomeTMFContext
0863: .getInstance().getSalomeFrame(), Language
0864: .getInstance().getText("Must_create_project"),
0865: "Error!", JOptionPane.ERROR_MESSAGE);
0866: throw new Exception("[Mantis] Project not found");
0867: }
0868:
0869: int id_assigned_to = -1;
0870: try {
0871: id_assigned_to = pMantisConnector.getUserIDInProject(
0872: assigned_to, bugProjectID);
0873: } catch (Exception e) {
0874: e.printStackTrace();
0875: }
0876: if (id_assigned_to == -1) {
0877: id_assigned_to = bugUsrID;
0878: assigned_to = currentUser.getLoginFromModel();
0879: }
0880:
0881: //int id_assigned_to = bugUsrID;
0882:
0883: int id_bug_severity = ((Integer) severityByValues
0884: .get(bug_severity)).intValue();
0885: int id_bug_satus = ((Integer) statusByValues.get(bug_satus))
0886: .intValue();
0887: int id_bug_priority = ((Integer) priorityByValues
0888: .get(bug_priority)).intValue();
0889: int id_bug_reproducibility = ((Integer) reproductibilityByValues
0890: .get(bug_reproducibility)).intValue();
0891: int id_bug_resolution = ((Integer) resolutionByValues
0892: .get(bug_resolution)).intValue();
0893:
0894: pMantisConnector.updateDefect(bugUsrID, bugProjectID, id,
0895: id_assigned_to, long_desc, id_bug_severity,
0896: id_bug_satus, short_desc, bug_OS, id_bug_priority,
0897: bug_platform, bug_env, id_bug_reproducibility,
0898: id_bug_resolution);
0899: }
0900:
0901: /**
0902: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
0903: */
0904: public void showBug(Attachment attach) {
0905: int bug_id = getIDofBug(attach);
0906: if (bug_id < 1) {
0907: showBugInBugTracker(attach);
0908: }
0909: /*
0910: String environement; //OK
0911: String user; //OK
0912: String plateforme; //OK
0913: String os; //OK
0914: String priority; //OK
0915: String severity; //OK
0916: String status; //OK
0917: String reproducibility;
0918: String resolution;
0919: String recipient;
0920: String url =""; //NONE
0921: String resume; //OK
0922: String description; //OK
0923: */
0924: try {
0925: Integer id = new Integer(bug_id);
0926: DefectWrapper pDefectWrapper = null;
0927: if (defectsCache != null) {
0928: pDefectWrapper = (DefectWrapper) defectsCache.get(id);
0929: }
0930: if (pDefectWrapper == null) {
0931: defectsCache = pMantisConnector
0932: .getProjectDefects(bugProjectID);
0933: pDefectWrapper = (DefectWrapper) defectsCache.get(id);
0934: }
0935: new DefectView(SalomeTMFContext.getInstance()
0936: .getSalomeFrame(), pDefectWrapper, this , true);
0937: /*
0938: DefectWrapper pDefectWrapper= pMantisConnector.getDefectInfo(bug_id);
0939: environement = pDefectWrapper.getEnvironement();
0940: user = pDefectWrapper.getUser();
0941: plateforme = pDefectWrapper.getPlateforme();
0942: os = pDefectWrapper.getOs();
0943: priority = getBugPriority(new Integer(pDefectWrapper.getPriority()));
0944: severity = getBugSeverity(new Integer(pDefectWrapper.getSeverity()));
0945: status = getBugStatus(new Integer(pDefectWrapper.getStatus()));
0946: reproducibility = getBugReproducibility(new Integer(pDefectWrapper.getReproducibility()));
0947: resolution = getBugResolution(new Integer(pDefectWrapper.getResolution()));
0948: resume = pDefectWrapper.getResume();
0949: description = pDefectWrapper.getDescription();
0950: recipient = pDefectWrapper.getRecipient();
0951: //new AskNewBug(this, true, attach, environement, user, plateforme, os, priority, severity, status,reproducibility,resolution, recipient, url, resume, description);
0952: */
0953: } catch (Exception e) {
0954: e.printStackTrace();
0955: showBugInBugTracker(attach);
0956: }
0957: }
0958:
0959: /**
0960: * Return the bug ID of the defect représenting by pAttachment
0961: * @param pAttachment
0962: * @return
0963: */
0964: public String getBugID(Attachment pAttachment) {
0965: String res = pAttachment.getNameFromModel();
0966: int debut = res.lastIndexOf("bug_id=");
0967: if (debut > 0) {
0968: int fin = res.indexOf("&", debut);
0969: if (fin > 0) {
0970: try {
0971: res = res.substring(debut + 7, fin);
0972: int bugID = Integer.parseInt(res);
0973: DefectWrapper pDefectWrapper = getDefectInfo(bugID,
0974: false);
0975: if (pDefectWrapper == null) {
0976: res = null;
0977: }
0978: } catch (Exception e) {
0979:
0980: }
0981: }
0982: }
0983:
0984: return res;
0985: }
0986:
0987: int getIDofBug(Attachment pAttachment) {
0988: int id = -1;
0989:
0990: String res = pAttachment.getNameFromModel();
0991: String desc = pAttachment.getDescriptionFromModel();
0992: if (!desc.equals(ATTACH_DESC)) {
0993: return id;
0994: }
0995: int debut = res.lastIndexOf("bug_id=");
0996: if (debut > 0) {
0997: int fin = res.indexOf("&", debut);
0998: if (fin > 0) {
0999: try {
1000: res = res.substring(debut + 7, fin).trim();
1001: id = Integer.parseInt(res);
1002: } catch (Exception e) {
1003: }
1004: }
1005: }
1006:
1007: return id;
1008: }
1009:
1010: UrlAttachment makeAttachement(int bug_id) {
1011: String url_res = mantis_host
1012: + "view_salome_bug_page.php?project_id="
1013: + URLEncoder.encode("" + bugProjectID) + "&bug_id="
1014: + URLEncoder.encode("" + bug_id) + "&user_id="
1015: + URLEncoder.encode("" + bugUsrID);
1016: return new UrlAttachment(url_res, MantisPlugin.ATTACH_DESC);
1017: }
1018:
1019: public void showBugInBugTracker(Attachment attach) {
1020: if (attach == null || !(attach instanceof UrlAttachment))
1021: return;
1022: try {
1023: URL newUrl = new URL(attach.getNameFromModel());
1024: SalomeTMFContext.getBaseIHM().showDocument(newUrl,
1025: getBugTrackerName());
1026: } catch (Exception e) {
1027: e.printStackTrace();
1028: }
1029: }
1030:
1031: /**
1032: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
1033: */
1034: public void showEnvironmentBugs(Environment env) {
1035: if (!(bugProjectID > 0)) {
1036: return;
1037: }
1038: String url_res = mantis_host
1039: + "view_salome_bug_page.php?project_id="
1040: + URLEncoder.encode("" + bugProjectID)
1041: + "&version_name="
1042: + URLEncoder.encode(env.getNameFromModel())
1043: + "&user_id=" + URLEncoder.encode("" + bugUsrID);
1044: try {
1045: //applet.getAppletContext().showDocument(new URL(url_res), getBugTrackerName());
1046: SalomeTMFContext.getBaseIHM().showDocument(
1047: new URL(url_res), getBugTrackerName());
1048: } catch (Exception e) {
1049: e.printStackTrace();
1050: }
1051: }
1052:
1053: Vector getBugHistory(DefectWrapper pDefectWrapper) throws Exception {
1054: Vector bugHistories = pMantisConnector.getBugHistory(
1055: bugProjectID, pDefectWrapper.getId());
1056: return bugHistories;
1057: }
1058:
1059: Hashtable getDefectLink(DefectWrapper pDefectWrapper)
1060: throws Exception {
1061: Hashtable defectsLinked;
1062: defectsLinked = pMantisConnector.getDefectLink(bugProjectID,
1063: pDefectWrapper.getId());
1064: if (defectsLinked == null) {
1065: return new Hashtable();
1066: }
1067: return defectsLinked;
1068: }
1069:
1070: void addDefectLink(DefectWrapper pDefectSource,
1071: DefectWrapper pDefectDestination) throws Exception {
1072: pMantisConnector.addDefectLink(bugUsrID, pDefectSource.getId(),
1073: pDefectDestination.getId());
1074: }
1075:
1076: void deleteDefectLink(DefectWrapper pDefectSource,
1077: DefectWrapper pDefectDestination) throws Exception {
1078: pMantisConnector.deleteDefectLink(bugUsrID, pDefectSource
1079: .getId(), pDefectDestination.getId());
1080: }
1081:
1082: void deleteDefect(DefectWrapper pDefectSource) throws Exception {
1083: pMantisConnector.deleteDefect(bugProjectID, pDefectSource
1084: .getId());
1085:
1086: Project pProject = DataModel.getCurrentProject();
1087: ArrayList listOfCampaign = pProject.getCampaignListFromModel();
1088: for (int i = 0; i < listOfCampaign.size(); i++) {
1089: Campaign pCamp = (Campaign) listOfCampaign.get(i);
1090: ArrayList listOfExecution = pCamp
1091: .getExecutionListFromModel();
1092: for (int j = 0; j < listOfExecution.size(); j++) {
1093: Execution pExec = (Execution) listOfExecution.get(j);
1094: ArrayList listOfExecutionRes = pExec
1095: .getExecutionResultListFromModel();
1096: for (int k = 0; k < listOfExecutionRes.size(); k++) {
1097: ExecutionResult pExecutionResult = (ExecutionResult) listOfExecutionRes
1098: .get(k);
1099: Test[] tests = pExecutionResult
1100: .getTestOrderedFromModel();
1101: for (int l = 0; l < tests.length; l++) {
1102: ExecutionTestResult pExecutionTestResult = pExecutionResult
1103: .getExecutionTestResultFromModel(tests[l]);
1104: deleteTestLinkDefect(pExecutionTestResult,
1105: pDefectSource);
1106: }
1107: }
1108: }
1109: }
1110: sendMail(pDefectSource, "deleted", true);
1111: }
1112:
1113: Hashtable getDefectsOfProject(boolean forceReload) throws Exception {
1114: if (forceReload == false && defectsCache != null) {
1115: return defectsCache;
1116: }
1117: defectsCache = pMantisConnector.getProjectDefects(bugProjectID);
1118: return defectsCache;
1119: }
1120:
1121: DefectWrapper getDefectInfo(int id_bug, boolean forceReload)
1122: throws Exception {
1123: DefectWrapper pDefectWrapper = null;
1124: if (id_bug < 0) {
1125: return pDefectWrapper;
1126: }
1127: Integer id = new Integer(id_bug);
1128: if (forceReload == false && defectsCache != null) {
1129: pDefectWrapper = (DefectWrapper) defectsCache.get(id);
1130:
1131: }
1132: if (pDefectWrapper == null) {
1133: getDefectsOfProject(true);
1134: pDefectWrapper = (DefectWrapper) defectsCache.get(id);
1135: }
1136: return pDefectWrapper;
1137: }
1138:
1139: /**
1140: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
1141: */
1142: public int getEnvNbBugs(Environment env, boolean onlyCorretedBugs) {
1143: int res = 0;
1144: if ((!cfg_prop.containsKey("MAJOR_BUG_LIST"))
1145: || ((!cfg_prop.containsKey("CLOSED_BUG_LIST")))) {
1146: res = getEnvironmentNbBugs(env, CRITICAL, onlyCorretedBugs)
1147: + getEnvironmentNbBugs(env, MAJOR, onlyCorretedBugs);
1148: } else {
1149: try {
1150: Hashtable allDefectsByID = pMantisConnector
1151: .getProjectDefects(bugProjectID);
1152: Enumeration allDefects = allDefectsByID.elements();
1153: String matchEnvName = env.getNameFromModel().trim();
1154: String major_list = cfg_prop
1155: .getProperty("MAJOR_BUG_LIST");
1156: String[] major_members = major_list.split("[,]");
1157: String closed_list = cfg_prop
1158: .getProperty("CLOSED_BUG_LIST");
1159: String[] closed_members = closed_list.split("[,]");
1160: while (allDefects.hasMoreElements()) {
1161: DefectWrapper pDefectWrapper = (DefectWrapper) allDefects
1162: .nextElement();
1163: String envName = pDefectWrapper.getEnvironement()
1164: .trim();
1165: if (envName.equals(matchEnvName)) {
1166: int severity = pDefectWrapper.getSeverity();
1167: boolean matchSeverity = false;
1168: int i = 0;
1169: while (!matchSeverity
1170: && i < major_members.length) {
1171: int major_int = Integer
1172: .parseInt(major_members[i].trim());
1173: if (severity == major_int) {
1174: matchSeverity = true;
1175: }
1176: i++;
1177: }
1178: if (matchSeverity) {
1179: if (!onlyCorretedBugs) {
1180: res++;
1181: } else {
1182: boolean isCorected = false;
1183: int correction = pDefectWrapper
1184: .getStatus();
1185: int j = 0;
1186: while (!isCorected
1187: && i < closed_members.length) {
1188: int close_int = Integer
1189: .parseInt(closed_members[j]
1190: .trim());
1191: if (correction == close_int) {
1192: isCorected = true;
1193: res++;
1194: }
1195: j++;
1196: }
1197: }
1198: }
1199: }
1200: }
1201: } catch (Exception e) {
1202: e.printStackTrace();
1203: }
1204:
1205: }
1206: /*try {
1207: String major_list = cfg_prop.getProperty("MAJOR_BUG_LIST");
1208: String[] major_members = major_list.split("[,]");
1209: for (int i=0 ; i<major_members.length ; i++) {
1210: int major_int = Integer.parseInt(major_members[i].trim());
1211: ResultSet stmtRes;
1212: PreparedStatement prep;
1213: if (!onlyCorretedBugs) {
1214: prep = iDB.prepareStatement(sql_prop.getProperty("SelectBugsBySeverity"));
1215: prep.setInt(1,major_int);
1216: prep.setString(2,env.getNameFromModel());
1217: prep.setInt(3,bugProjectID);
1218: stmtRes = prep.executeQuery();
1219: while(stmtRes.next()) {
1220: res++;
1221: }
1222: } else {
1223: String closed_list = cfg_prop.getProperty("CLOSED_BUG_LIST");
1224: String[] closed_members = closed_list.split("[,]");
1225: for (int j=0 ; j<closed_members.length ; j++) {
1226: int closed_int = Integer.parseInt(closed_members[j].trim());
1227: prep = iDB.prepareStatement(sql_prop.getProperty("SelectCorretedBugsBySeverity"));
1228: prep.setInt(1,closed_int);
1229: prep.setInt(2,major_int);
1230: prep.setString(3,env.getNameFromModel());
1231: prep.setInt(4,bugProjectID);
1232: stmtRes = prep.executeQuery();
1233: while(stmtRes.next()) {
1234: res++;
1235: }
1236: }
1237: }
1238:
1239: }
1240: } catch (Exception e) {
1241: e.printStackTrace();
1242: }
1243: }*/
1244: return res;
1245: }
1246:
1247: /**
1248: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
1249: */
1250: public int getEnvironmentNbBugs(Environment env, int severity,
1251: boolean onlyCorretedBugs) {
1252: int res = 0;
1253: int severity_value = 0;
1254:
1255: Vector severities_int = new Vector(severityByValues.values());
1256: int critical = 80;
1257: int major = 70;
1258: int major_tmp = 70;
1259: int closed = DEFAULT_CORRECTED_VALUE;
1260:
1261: if (cfg_prop.containsKey("BUG_CRITICAL_INT")) {
1262: critical = Integer.parseInt(cfg_prop
1263: .getProperty("BUG_CRITICAL_INT"));
1264: } else {
1265: critical = ((Integer) severities_int.elementAt(0))
1266: .intValue();
1267: major_tmp = ((Integer) severities_int.elementAt(0))
1268: .intValue();
1269: for (int i = 1; i < severities_int.size(); i++) {
1270: int tmp = ((Integer) severities_int.elementAt(i))
1271: .intValue();
1272: if (critical < tmp) {
1273: major_tmp = critical;
1274: critical = tmp;
1275: }
1276: }
1277: }
1278:
1279: if (cfg_prop.containsKey("BUG_MAJOR_INT")) {
1280: major = Integer.parseInt(cfg_prop
1281: .getProperty("BUG_MAJOR_INT"));
1282: } else {
1283: major = major_tmp;
1284: }
1285:
1286: Util.log("[MantisPlugin]getEnvironmentNbBugs() critical = "
1287: + critical + " and major = " + major);
1288:
1289: if (severity == CRITICAL) {
1290: severity_value = critical;
1291: } else if (severity == MAJOR) {
1292: severity_value = major;
1293: }
1294:
1295: if (cfg_prop.containsKey("BUG_CLOSED_INT")) {
1296: closed = Integer.parseInt(cfg_prop
1297: .getProperty("BUG_CLOSED_INT"));
1298: }
1299:
1300: try {
1301: Hashtable allDefectsByID = pMantisConnector
1302: .getProjectDefects(bugProjectID);
1303: Enumeration allDefects = allDefectsByID.elements();
1304: String matchEnvName = env.getNameFromModel().trim();
1305: while (allDefects.hasMoreElements()) {
1306: DefectWrapper pDefectWrapper = (DefectWrapper) allDefects
1307: .nextElement();
1308: String envName = pDefectWrapper.getEnvironement()
1309: .trim();
1310: if (envName.equals(matchEnvName)) {
1311: int severity_v = pDefectWrapper.getSeverity();
1312: //boolean matchSeverity = false;
1313: //int i = 0;
1314: if (severity_v == severity_value) {
1315: if (!onlyCorretedBugs) {
1316: res++;
1317: } else {
1318: //boolean isCorected = false;
1319: int correction = pDefectWrapper.getStatus();
1320: if (closed == correction) {
1321: res++;
1322: }
1323: }
1324: }
1325: }
1326: }
1327: } catch (Exception e) {
1328: e.printStackTrace();
1329: }
1330:
1331: /*try{
1332: ResultSet stmtRes;
1333: PreparedStatement prep;
1334: if (onlyCorretedBugs) {
1335: prep = iDB.prepareStatement(sql_prop.getProperty("SelectCorretedBugsBySeverity"));
1336: prep.setInt(1,closed);
1337: prep.setInt(2,severity_value);
1338: prep.setString(3,env.getNameFromModel());
1339: prep.setInt(4,bugProjectID);
1340: stmtRes = prep.executeQuery();
1341: while(stmtRes.next()) {
1342: res++;
1343: }
1344: } else {
1345: prep = iDB.prepareStatement(sql_prop.getProperty("SelectBugsBySeverity"));
1346: prep.setInt(1,severity_value);
1347: prep.setString(2,env.getNameFromModel());
1348: prep.setInt(3,bugProjectID);
1349: stmtRes = prep.executeQuery();
1350: while(stmtRes.next()) {
1351: res++;
1352: }
1353: }
1354: }catch(Exception E){
1355: E.printStackTrace();
1356: }*/
1357:
1358: return res;
1359: }
1360:
1361: public Vector getBugTrackerAllUsers() {
1362: return pMantisConnector.getBugTrackerAllUsers(bugProjectID);
1363: }
1364:
1365: /**
1366: * @see org.objectweb.salome_tmf.plugins.core.BugTracker
1367: */
1368: public String getBugTrackerName() {
1369: return MANTIS_SUB_MENU;
1370: }
1371:
1372: /**
1373: * Get bug tracker attachment description
1374: * @return bug tracker name
1375: */
1376: public String getBugTrackerAttachDesc() {
1377: return ATTACH_DESC;
1378: }
1379:
1380: public void update(Observable o, Object arg) {
1381: try {
1382: if (arg instanceof SalomeEvent) {
1383: SalomeEvent pSalomeEvent = (SalomeEvent) arg;
1384: int code = pSalomeEvent.getCode();
1385: if (code == ApiConstants.INSERT_ENVIRONMENT) {
1386: Environment env = (Environment) pSalomeEvent
1387: .getArg();
1388: Util
1389: .log("[MantisPlugin]dispach event INSERT_ENVIRONMENT env = "
1390: + env.getNameFromModel());
1391: if (!pMantisConnector.isExistEnv(bugProjectID, env
1392: .getNameFromModel())) {
1393: addEnvironment(env);
1394: }
1395: } else if (code == ApiConstants.UPDATE_ENVIRONMENT) {
1396: String oldName = (String) pSalomeEvent
1397: .getOldValue();
1398: String newName = (String) pSalomeEvent
1399: .getNewValue();
1400: Util
1401: .log("[MantisPlugin]dispach event UPDATE_ENVIRONMENT old env = "
1402: + oldName
1403: + " - new env = "
1404: + newName);
1405: if (pMantisConnector.isExistEnv(bugProjectID,
1406: oldName))
1407: updateEnvironment(oldName, newName,
1408: "[SALOME_ENV]");
1409: } else if (code == ApiConstants.DELETE_ENVIRONMENT) {
1410: Environment env = (Environment) pSalomeEvent
1411: .getArg();
1412: Util
1413: .log("[MantisPlugin]dispach event DELETE_ENVIRONMENT env = "
1414: + env.getNameFromModel());
1415: if (pMantisConnector.isExistEnv(bugProjectID, env
1416: .getNameFromModel()))
1417: deleteEnvironment(env.getNameFromModel());
1418: }
1419: }
1420:
1421: } catch (Exception e) {
1422: e.printStackTrace();
1423: }
1424:
1425: }
1426:
1427: public Vector getBugOSList() {
1428: return null;
1429: }
1430:
1431: public Vector getBugPriorityList() {
1432: Vector list = new Vector();
1433:
1434: for (Enumeration e = priorityByValues.keys(); e
1435: .hasMoreElements();) {
1436: list.add((String) e.nextElement());
1437: }
1438:
1439: return list;
1440: }
1441:
1442: String getBugPriority(Integer i) {
1443: String res = null;
1444:
1445: for (Enumeration e = priorityByValues.keys(); e
1446: .hasMoreElements();) {
1447: String key = (String) e.nextElement();
1448: Integer value = (Integer) priorityByValues.get(key);
1449: if (value.equals(i)) {
1450: return key;
1451: }
1452: }
1453: return res;
1454: }
1455:
1456: public Vector getBugPlateformList() {
1457: return null;
1458: }
1459:
1460: public Vector getBugSeverityList() {
1461: Vector list = new Vector();
1462:
1463: for (Enumeration e = severityByValues.keys(); e
1464: .hasMoreElements();) {
1465: list.add((String) e.nextElement());
1466: }
1467:
1468: return list;
1469: }
1470:
1471: String getBugSeverity(Integer i) {
1472: String res = null;
1473:
1474: for (Enumeration e = severityByValues.keys(); e
1475: .hasMoreElements();) {
1476: String key = (String) e.nextElement();
1477: Integer value = (Integer) severityByValues.get(key);
1478: if (value.equals(i)) {
1479: return key;
1480: }
1481: }
1482: return res;
1483: }
1484:
1485: public Vector getBugTrackerStatusList() {
1486: Vector list = new Vector();
1487:
1488: for (Enumeration e = statusByValues.keys(); e.hasMoreElements();) {
1489: list.add((String) e.nextElement());
1490: }
1491:
1492: return list;
1493: }
1494:
1495: String getBugStatus(Integer i) {
1496: String res = null;
1497:
1498: for (Enumeration e = statusByValues.keys(); e.hasMoreElements();) {
1499: String key = (String) e.nextElement();
1500: Integer value = (Integer) statusByValues.get(key);
1501: if (value.equals(i)) {
1502: return key;
1503: }
1504: }
1505: return res;
1506: }
1507:
1508: String getBugReproducibility(Integer i) {
1509: String res = null;
1510:
1511: for (Enumeration e = reproductibilityByValues.keys(); e
1512: .hasMoreElements();) {
1513: String key = (String) e.nextElement();
1514: Integer value = (Integer) reproductibilityByValues.get(key);
1515: if (value.equals(i)) {
1516: return key;
1517: }
1518: }
1519: return res;
1520: }
1521:
1522: String getBugResolution(Integer i) {
1523: String res = null;
1524:
1525: for (Enumeration e = resolutionByValues.keys(); e
1526: .hasMoreElements();) {
1527: String key = (String) e.nextElement();
1528: Integer value = (Integer) resolutionByValues.get(key);
1529: if (value.equals(i)) {
1530: return key;
1531: }
1532: }
1533: return res;
1534: }
1535:
1536: public boolean isEditableOS() {
1537: // TODO Auto-generated method stub
1538: return true;
1539: }
1540:
1541: public boolean isEditablePlateForme() {
1542: // TODO Auto-generated method stub
1543: return true;
1544: }
1545:
1546: private void initMantisFields() {
1547: // init priority list
1548: priorityByValues = new Hashtable();
1549: priorityByID = new Hashtable();
1550: priority_values = new Vector();
1551: initMantisPriorities();
1552:
1553: // init severity list
1554: severityByValues = new Hashtable();
1555: severityByID = new Hashtable();
1556: severity_values = new Vector();
1557: initMantisSeverities();
1558:
1559: // init status list
1560: statusByValues = new Hashtable();
1561: statusByID = new Hashtable();
1562: status_values = new Vector();
1563: initMantisStatus();
1564:
1565: // init reproductibility list
1566: reproductibilityByValues = new Hashtable();
1567: reproductibilityByID = new Hashtable();
1568: reproductibility_values = new Vector();
1569: initMantisReproductibilities();
1570:
1571: // init resolution list
1572: resolutionByValues = new Hashtable();
1573: resolutionByID = new Hashtable();
1574: resolution_values = new Vector();
1575: initMantisResolutions();
1576:
1577: }
1578:
1579: private void initMantisPriorities() {
1580: if (priorityByValues == null) {
1581: priorityByValues = new Hashtable();
1582: priorityByID = new Hashtable();
1583: priority_values = new Vector();
1584: } else {
1585: priorityByValues.clear();
1586: priorityByID.clear();
1587: priority_values.clear();
1588: }
1589: if (cfg_prop.containsKey("MANTIS_PRIORITIES_LIST")) {
1590: try {
1591: String list = cfg_prop
1592: .getProperty("MANTIS_PRIORITIES_LIST");
1593: String[] members = list.split("[,]");
1594: for (int i = 0; i < members.length; i++) {
1595: String member = members[i];
1596: String[] parts = member.split("[:]");
1597: if (parts.length == 2) {
1598: priorityByValues.put(parts[1], Integer
1599: .valueOf(parts[0]));
1600: priorityByID.put(Integer.valueOf(parts[0]),
1601: parts[1]);
1602: priority_values.add(parts[1]);
1603: } else {
1604: initDefaultPriorities();
1605: }
1606: }
1607: } catch (Exception e) {
1608: e.printStackTrace();
1609: }
1610: } else {
1611: initDefaultPriorities();
1612: }
1613: }
1614:
1615: private void initDefaultPriorities() {
1616: if (priorityByValues == null) {
1617: priorityByValues = new Hashtable();
1618: priorityByID = new Hashtable();
1619: priority_values = new Vector();
1620: } else {
1621: priorityByValues = new Hashtable();
1622: priorityByID = new Hashtable();
1623: priority_values = new Vector();
1624: }
1625: priorityByValues.put("none", new Integer(10));
1626: priorityByValues.put("low", new Integer(20));
1627: priorityByValues.put("normal", new Integer(30));
1628: priorityByValues.put("high", new Integer(40));
1629: priorityByValues.put("urgent", new Integer(50));
1630: priorityByValues.put("immediate", new Integer(60));
1631:
1632: priorityByID.put(new Integer(10), "none");
1633: priorityByID.put(new Integer(20), "low");
1634: priorityByID.put(new Integer(30), "normal");
1635: priorityByID.put(new Integer(40), "high");
1636: priorityByID.put(new Integer(50), "urgent");
1637: priorityByID.put(new Integer(60), "immediate");
1638:
1639: priority_values.add("none");
1640: priority_values.add("low");
1641: priority_values.add("normal");
1642: priority_values.add("high");
1643: priority_values.add("urgent");
1644: priority_values.add("immediate");
1645: }
1646:
1647: private void initMantisSeverities() {
1648: if (severityByValues == null) {
1649: severityByValues = new Hashtable();
1650: severityByID = new Hashtable();
1651: severity_values = new Vector();
1652: }
1653: severityByValues.clear();
1654: severityByID.clear();
1655: severity_values.clear();
1656: if (cfg_prop.containsKey("MANTIS_SEVERITIES_LIST")) {
1657: try {
1658: String list = cfg_prop
1659: .getProperty("MANTIS_SEVERITIES_LIST");
1660: String[] members = list.split("[,]");
1661: for (int i = 0; i < members.length; i++) {
1662: String member = members[i];
1663: String[] parts = member.split("[:]");
1664: if (parts.length == 2) {
1665: severityByValues.put(parts[1], Integer
1666: .valueOf(parts[0]));
1667: severityByID.put(Integer.valueOf(parts[0]),
1668: parts[1]);
1669: severity_values.add(parts[1]);
1670: } else {
1671: initDefaultSeverities();
1672: }
1673: }
1674: } catch (Exception e) {
1675: e.printStackTrace();
1676: }
1677: } else {
1678: initDefaultSeverities();
1679: }
1680: }
1681:
1682: private void initDefaultSeverities() {
1683: if (severityByValues == null) {
1684: severityByValues = new Hashtable();
1685: severityByID = new Hashtable();
1686: severity_values = new Vector();
1687: } else {
1688: severityByValues.clear();
1689: severityByID.clear();
1690: severity_values.clear();
1691: }
1692: severityByValues.put("feature", new Integer(10));
1693: severityByValues.put("trivial", new Integer(20));
1694: severityByValues.put("text", new Integer(30));
1695: severityByValues.put("tweak", new Integer(40));
1696: severityByValues.put("minor", new Integer(50));
1697: severityByValues.put("major", new Integer(60));
1698: severityByValues.put("crash", new Integer(70));
1699: severityByValues.put("block", new Integer(80));
1700:
1701: severityByID.put(new Integer(10), "feature");
1702: severityByID.put(new Integer(20), "trivial");
1703: severityByID.put(new Integer(30), "text");
1704: severityByID.put(new Integer(40), "tweak");
1705: severityByID.put(new Integer(50), "minor");
1706: severityByID.put(new Integer(60), "major");
1707: severityByID.put(new Integer(70), "crash");
1708: severityByID.put(new Integer(80), "block");
1709:
1710: severity_values.add("feature");
1711: severity_values.add("trivial");
1712: severity_values.add("text");
1713: severity_values.add("tweak");
1714: severity_values.add("minor");
1715: severity_values.add("major");
1716: severity_values.add("crash");
1717: severity_values.add("block");
1718: }
1719:
1720: private void initMantisStatus() {
1721: if (statusByValues == null) {
1722: statusByValues = new Hashtable();
1723: statusByID = new Hashtable();
1724: status_values = new Vector();
1725: } else {
1726: statusByValues.clear();
1727: statusByID.clear();
1728: status_values.clear();
1729: }
1730: if (cfg_prop.containsKey("MANTIS_STATUS_LIST")) {
1731: try {
1732: String list = cfg_prop
1733: .getProperty("MANTIS_STATUS_LIST");
1734: String[] members = list.split("[,]");
1735: for (int i = 0; i < members.length; i++) {
1736: String member = members[i];
1737: String[] parts = member.split("[:]");
1738: if (parts.length == 2) {
1739: statusByValues.put(parts[1], Integer
1740: .valueOf(parts[0]));
1741: statusByID.put(Integer.valueOf(parts[0]),
1742: parts[1]);
1743: status_values.add(parts[1]);
1744: } else {
1745: initDefaultStatus();
1746: }
1747: }
1748: } catch (Exception e) {
1749: e.printStackTrace();
1750: }
1751: } else {
1752: initDefaultStatus();
1753: }
1754: }
1755:
1756: private void initDefaultStatus() {
1757: if (statusByValues == null) {
1758: statusByValues = new Hashtable();
1759: statusByID = new Hashtable();
1760: status_values = new Vector();
1761: } else {
1762: statusByValues.clear();
1763: statusByID.clear();
1764: status_values.clear();
1765: }
1766: statusByValues.put("new", new Integer(10));
1767: statusByValues.put("feedback", new Integer(20));
1768: statusByValues.put("acknowledged", new Integer(30));
1769: statusByValues.put("confirmed", new Integer(40));
1770: statusByValues.put("assigned", new Integer(50));
1771: statusByValues.put("resolved", new Integer(60));
1772: statusByValues.put("closed", new Integer(70));
1773:
1774: statusByID.put(new Integer(10), "new");
1775: statusByID.put(new Integer(20), "feedback");
1776: statusByID.put(new Integer(30), "acknowledged");
1777: statusByID.put(new Integer(40), "confirmed");
1778: statusByID.put(new Integer(50), "assigned");
1779: statusByID.put(new Integer(60), "resolved");
1780: statusByID.put(new Integer(70), "closed");
1781:
1782: status_values.add("new");
1783: status_values.add("feedback");
1784: status_values.add("acknowledged");
1785: status_values.add("confirmed");
1786: status_values.add("assigned");
1787: status_values.add("resolved");
1788: status_values.add("closed");
1789: }
1790:
1791: private void initMantisReproductibilities() {
1792: if (reproductibilityByValues == null) {
1793: reproductibilityByValues = new Hashtable();
1794: reproductibilityByID = new Hashtable();
1795: reproductibility_values = new Vector();
1796: } else {
1797: reproductibilityByValues.clear();
1798: reproductibilityByID.clear();
1799: reproductibility_values.clear();
1800: }
1801:
1802: reproductibilityByValues = new Hashtable();
1803: if (cfg_prop.containsKey("MANTIS_REPRODUCTIBILITIES_LIST")) {
1804: try {
1805: String list = cfg_prop
1806: .getProperty("MANTIS_REPRODUCTIBILITIES_LIST");
1807: String[] members = list.split("[,]");
1808: for (int i = 0; i < members.length; i++) {
1809: String member = members[i];
1810: String[] parts = member.split("[:]");
1811: if (parts.length == 2) {
1812: reproductibilityByValues.put(parts[1], Integer
1813: .valueOf(parts[0]));
1814: reproductibilityByID.put(Integer
1815: .valueOf(parts[0]), parts[1]);
1816: reproductibility_values.add(parts[1]);
1817: } else {
1818: initDefaultReproductibilities();
1819: }
1820: }
1821: } catch (Exception e) {
1822: e.printStackTrace();
1823: }
1824: } else {
1825: initDefaultReproductibilities();
1826: }
1827: }
1828:
1829: private void initDefaultReproductibilities() {
1830: if (reproductibilityByValues == null) {
1831: reproductibilityByValues = new Hashtable();
1832: reproductibilityByID = new Hashtable();
1833: reproductibility_values = new Vector();
1834: } else {
1835: reproductibilityByValues.clear();
1836: reproductibilityByID.clear();
1837: reproductibility_values.clear();
1838: }
1839: reproductibilityByValues.put("always", new Integer(10));
1840: reproductibilityByValues.put("sometimes", new Integer(30));
1841: reproductibilityByValues.put("random", new Integer(50));
1842: reproductibilityByValues.put("have not tried", new Integer(70));
1843: reproductibilityByValues.put("unable to duplicate",
1844: new Integer(90));
1845: reproductibilityByValues.put("N/A", new Integer(100));
1846:
1847: reproductibilityByID.put(new Integer(10), "always");
1848: reproductibilityByID.put(new Integer(30), "sometimes");
1849: reproductibilityByID.put(new Integer(50), "random");
1850: reproductibilityByID.put(new Integer(70), "have not tried");
1851: reproductibilityByID
1852: .put(new Integer(90), "unable to duplicate");
1853: reproductibilityByID.put(new Integer(100), "N/A");
1854:
1855: reproductibility_values.add("always");
1856: reproductibility_values.add("sometimes");
1857: reproductibility_values.add("random");
1858: reproductibility_values.add("have not tried");
1859: reproductibility_values.add("unable to duplicate");
1860: reproductibility_values.add("N/A");
1861: }
1862:
1863: private void initMantisResolutions() {
1864: if (resolutionByValues == null) {
1865: resolutionByValues = new Hashtable();
1866: resolutionByID = new Hashtable();
1867: resolution_values = new Vector();
1868: } else {
1869: resolutionByValues.clear();
1870: resolutionByID.clear();
1871: resolution_values.clear();
1872: }
1873: if (cfg_prop.containsKey("MANTIS_RESOLUTIONS_LIST")) {
1874: try {
1875: String list = cfg_prop
1876: .getProperty("MANTIS_RESOLUTIONS_LIST");
1877: String[] members = list.split("[,]");
1878: for (int i = 0; i < members.length; i++) {
1879: String member = members[i];
1880: String[] parts = member.split("[:]");
1881: if (parts.length == 2) {
1882: resolutionByValues.put(parts[1], Integer
1883: .valueOf(parts[0]));
1884: resolutionByID.put(Integer.valueOf(parts[0]),
1885: parts[1]);
1886: resolution_values.add(parts[1]);
1887: } else {
1888: initDefaultResolutions();
1889: }
1890: }
1891: } catch (Exception e) {
1892: e.printStackTrace();
1893: }
1894: } else {
1895: initDefaultResolutions();
1896: }
1897: }
1898:
1899: private void initDefaultResolutions() {
1900: if (resolutionByValues == null) {
1901: resolutionByValues = new Hashtable();
1902: resolutionByID = new Hashtable();
1903: resolution_values = new Vector();
1904: } else {
1905: resolutionByValues.clear();
1906: resolutionByID.clear();
1907: resolution_values.clear();
1908: }
1909: resolutionByValues.put("open", new Integer(10));
1910: resolutionByValues.put("fixed", new Integer(20));
1911: resolutionByValues.put("reopened", new Integer(30));
1912: resolutionByValues.put("unable to duplicate", new Integer(40));
1913: resolutionByValues.put("not fixable", new Integer(50));
1914: resolutionByValues.put("duplicate", new Integer(60));
1915: resolutionByValues.put("not a bug", new Integer(70));
1916: resolutionByValues.put("suspended", new Integer(80));
1917: resolutionByValues.put("wont fix", new Integer(90));
1918:
1919: resolutionByID.put(new Integer(10), "open");
1920: resolutionByID.put(new Integer(20), "fixed");
1921: resolutionByID.put(new Integer(30), "reopened");
1922: resolutionByID.put(new Integer(40), "unable to duplicate");
1923: resolutionByID.put(new Integer(50), "not fixable");
1924: resolutionByID.put(new Integer(60), "duplicate");
1925: resolutionByID.put(new Integer(70), "not a bug");
1926: resolutionByID.put(new Integer(80), "suspended");
1927: resolutionByID.put(new Integer(90), "wont fix");
1928:
1929: resolution_values.add("open");
1930: resolution_values.add("fixed");
1931: resolution_values.add("reopened");
1932: resolution_values.add("unable to duplicate");
1933: resolution_values.add("not fixable");
1934: resolution_values.add("duplicate");
1935: resolution_values.add("not a bug");
1936: resolution_values.add("suspended");
1937: resolution_values.add("wont fix");
1938: }
1939:
1940: public Vector getBugTrackerReproductibilityList() {
1941: Vector list = new Vector();
1942:
1943: for (Enumeration e = reproductibilityByValues.keys(); e
1944: .hasMoreElements();) {
1945: list.add((String) e.nextElement());
1946: }
1947:
1948: return list;
1949: }
1950:
1951: public Vector getBugTrackerResolutionList() {
1952: Vector list = new Vector();
1953:
1954: for (Enumeration e = resolutionByValues.keys(); e
1955: .hasMoreElements();) {
1956: list.add((String) e.nextElement());
1957: }
1958:
1959: return list;
1960: }
1961:
1962: public boolean isUsesBugReproducibily() {
1963: return true;
1964: }
1965:
1966: public boolean isUsesBugResolution() {
1967: // TODO Auto-generated method stub
1968: return true;
1969: }
1970:
1971: public String getAdditionalBugDesc() {
1972: String res = "";
1973: if (cfg_prop.containsKey("BUG_DESC_ADD_FIELDS")) {
1974: String fieldsList = cfg_prop
1975: .getProperty("BUG_DESC_ADD_FIELDS");
1976: String[] fields = fieldsList.split("[,]");
1977: for (int i = 0; i < fields.length; i++) {
1978: String field = fields[i].trim();
1979: if (cfg_prop.containsKey(field)) {
1980: res += "\n- " + cfg_prop.getProperty(field) + " : ";
1981: }
1982: }
1983: }
1984: return res;
1985: }
1986:
1987: /// LIVE ////
1988:
1989: public void suspend() {
1990: try {
1991: pMantisConnector.suspend();
1992: //iDB.close();
1993: //iDB = null;
1994: suspended = true;
1995: } catch (Exception e) {
1996:
1997: }
1998: }
1999:
2000: /*public void resume() {
2001: ISQLObjectFactory iSQL_OF = Api.getISQLObjectFactory();
2002: iDB = iSQL_OF.getInstanceOfDataBase(driver);
2003: iDB.open(url_db,user,pwd);
2004: SQLUtils.initSQLUtils(iDB);
2005: }*/
2006:
2007: public JPanel getStateColorPanel() {
2008: int size = pDefectPanel1.choiceState.size();
2009: JPanel statePanel = new JPanel();
2010: statePanel.setLayout(new GridLayout(1, size - 1));
2011: for (int i = 1; i < size; i++) {
2012: String state = (String) pDefectPanel1.choiceState
2013: .elementAt(i);
2014: JLabel pLabel = new JLabel(state);
2015: Integer id = (Integer) statusByValues.get(state);
2016: Color pColor = (Color) pDefectPanel1.colorState.get(id);
2017:
2018: pLabel.setBorder(BorderFactory
2019: .createLineBorder(Color.BLACK));
2020: pLabel.setBackground(pColor);
2021: //pLabel.setForeground(pColor);
2022: pLabel.setOpaque(true);
2023: statePanel.add(pLabel);
2024: }
2025: return statePanel;
2026: }
2027:
2028: public Color getStateDefect(Attachment pAttachment) {
2029: Color pColor = null;
2030: int id = getIDofBug(pAttachment);
2031: if (id >= 0) {
2032: try {
2033: DefectWrapper pDefectWrapper = getDefectInfo(id, false);
2034: if (pDefectWrapper != null) {
2035: int state = pDefectWrapper.getStatus();
2036: pColor = (Color) pDefectPanel1.colorState
2037: .get(new Integer(state));
2038: }
2039: } catch (Exception e) {
2040: e.printStackTrace();
2041: }
2042: }
2043: return pColor;
2044: }
2045:
2046: public JPanel getDefectPanelForTests(Vector testSelected) {
2047: TestDefectActionPanel pTestDefectActionPanel = new TestDefectActionPanel(
2048: this );
2049: DefectPanel pTestDefectPanel = new DefectPanel(true, this ,
2050: pTestDefectActionPanel, null);
2051: pTestDefectActionPanel.setDefectPanel(pTestDefectPanel);
2052: loadDefectTest(testSelected, pTestDefectPanel);
2053: return pTestDefectPanel;
2054: }
2055:
2056: /********************************* Common ********************************************/
2057: public void init(Object ihm) {
2058:
2059: }
2060:
2061: public boolean isActivableInTestToolsMenu() {
2062: return false;
2063: }
2064:
2065: public boolean isActivableInCampToolsMenu() {
2066: return false;
2067: }
2068:
2069: public boolean isActivableInDataToolsMenu() {
2070: return false;
2071: }
2072:
2073: public boolean usesOtherUIComponents() {
2074: return true;
2075: }
2076:
2077: public void activatePluginInTestToolsMenu(JMenu testToolsMenu) {
2078: }
2079:
2080: public void activatePluginInCampToolsMenu(JMenu campToolsMenu) {
2081: }
2082:
2083: public void activatePluginInDataToolsMenu(JMenu dataToolsMenu) {
2084: }
2085:
2086: public Vector getUsedUIComponents() {
2087: Vector uiComponentsUsed = new Vector();
2088: uiComponentsUsed.add(UICompCst.MAIN_TABBED_PANE);
2089: uiComponentsUsed
2090: .add(UICompCst.AUTOMATED_TEST_WORKSPACE_PANEL_FOR_TABS);
2091: uiComponentsUsed
2092: .add(UICompCst.MANUAL_TEST_WORKSPACE_PANEL_FOR_TABS);
2093: uiComponentsUsed
2094: .add(UICompCst.CAMPAIGN_WORKSPACE_PANEL_FOR_TABS);
2095: uiComponentsUsed
2096: .add(UICompCst.CAMP_EXECUTION_RESULTS_BUTTONS_PANEL);
2097: uiComponentsUsed
2098: .add(UICompCst.MANUAL_TEST_EXECUTION_RESULT_DETAILS_TAB);
2099: uiComponentsUsed.add(UICompCst.MANUAL_EXECUTION_TAB);
2100: uiComponentsUsed.add(UICompCst.TEST_DYNAMIC_TREE);
2101: return uiComponentsUsed;
2102: }
2103:
2104: public void activatePluginInStaticComponent(Integer uiCompCst) {
2105: if (uiCompCst.equals(UICompCst.MAIN_TABBED_PANE)) {
2106: salomeMainTabs = (JTabbedPane) SalomeTMFContext
2107: .getInstance().getUIComponent(uiCompCst);
2108: } else if (uiCompCst
2109: .equals(UICompCst.MANUAL_TEST_WORKSPACE_PANEL_FOR_TABS)) {
2110: pMTestJTabbedPane = (JTabbedPane) SalomeTMFContext
2111: .getInstance().getUIComponent(uiCompCst);
2112: } else if (uiCompCst
2113: .equals(UICompCst.AUTOMATED_TEST_WORKSPACE_PANEL_FOR_TABS)) {
2114: pATestJTabbedPane = (JTabbedPane) SalomeTMFContext
2115: .getInstance().getUIComponent(uiCompCst);
2116: } else if (uiCompCst.equals(UICompCst.TEST_DYNAMIC_TREE)) {
2117: DynamicTree pDynamicTree = (DynamicTree) SalomeTMFContext
2118: .getInstance().getUIComponent(uiCompCst);
2119: setTestTree(pDynamicTree);
2120: }
2121: }
2122:
2123: public void activatePluginInDynamicComponent(Integer uiCompCst) {
2124: if (uiCompCst
2125: .equals(UICompCst.MANUAL_TEST_EXECUTION_RESULT_DETAILS_TAB)) {
2126: pJTabbedPane2 = (JTabbedPane) SalomeTMFContext
2127: .getInstance().getUIComponent(uiCompCst);
2128:
2129: ExecResDefectActionPanel pExecResDefectActionPanel = new ExecResDefectActionPanel(
2130: this , true);
2131: pDefectPanel2 = new DefectPanel(true, this ,
2132: pExecResDefectActionPanel, null);
2133: pExecResDefectActionPanel.setDefectPanel(pDefectPanel2);
2134:
2135: pJTabbedPane2.addTab("Plug-in Mantis", pDefectPanel2);
2136: pJTabbedPane2.addChangeListener(new ChangeListener() {
2137: public void stateChanged(ChangeEvent e) {
2138: if (pJTabbedPane2.getSelectedComponent().equals(
2139: pDefectPanel2)) {
2140: if (bugProjectID > 0) {
2141:
2142: /* make hashofdefect */
2143: ExecutionTestResult pExecutionTestResult = DataModel
2144: .getCurrentExecutionTestResult();
2145: //pExecResDefectActionPanel.setExecutionResult(pExecutionTestResult);
2146:
2147: Hashtable defectsWrapper = new Hashtable();
2148: if (pExecutionTestResult != null) {
2149: HashMap attacMap = pExecutionTestResult
2150: .getAttachmentMapFromModel();
2151: Set keysSet = attacMap.keySet();
2152: for (Iterator iter = keysSet.iterator(); iter
2153: .hasNext();) {
2154: try {
2155: Object attachName = iter.next();
2156: Attachment pAttach = (Attachment) attacMap
2157: .get(attachName);
2158: int bugid = getIDofBug(pAttach);
2159: DefectWrapper pDefectWrapper = null;
2160:
2161: if (bugid != -1) {
2162: //pDefectWrapper = pMantisConnector.getDefectInfo(bugid);
2163: pDefectWrapper = getDefectInfo(
2164: bugid, false);
2165: }
2166: if (pDefectWrapper != null) {
2167: defectsWrapper.put(
2168: new Integer(bugid),
2169: pDefectWrapper);
2170: }
2171: } catch (Exception ex) {
2172: ex.printStackTrace();
2173: }
2174: }
2175: }
2176: pDefectPanel2.loadData(defectsWrapper);
2177: }
2178: System.out.println("MANTIS");
2179: }
2180: }
2181: });
2182: } else if (uiCompCst.equals(UICompCst.MANUAL_EXECUTION_TAB)) {
2183: pJTabbedPane3 = (JTabbedPane) SalomeTMFContext
2184: .getInstance().getUIComponent(uiCompCst);
2185:
2186: ExecResDefectActionPanel pExecResDefectActionPanel = new ExecResDefectActionPanel(
2187: this , true);
2188: pDefectPanel3 = new DefectPanel(true, this ,
2189: pExecResDefectActionPanel, null);
2190: pExecResDefectActionPanel.setDefectPanel(pDefectPanel3);
2191:
2192: pJTabbedPane3.addTab("Plug-in Mantis", pDefectPanel3);
2193: pJTabbedPane3.addChangeListener(new ChangeListener() {
2194: public void stateChanged(ChangeEvent e) {
2195: if (pJTabbedPane3.getSelectedComponent().equals(
2196: pDefectPanel3)) {
2197: if (bugProjectID > 0) {
2198:
2199: /* make hashofdefect */
2200: ExecutionTestResult pExecutionTestResult = DataModel
2201: .getCurrentExecutionTestResult();
2202: //pExecResDefectActionPanel.setExecutionResult(pExecutionTestResult);
2203:
2204: Hashtable defectsWrapper = new Hashtable();
2205: if (pExecutionTestResult != null) {
2206: HashMap attacMap = pExecutionTestResult
2207: .getAttachmentMapFromModel();
2208: Set keysSet = attacMap.keySet();
2209: for (Iterator iter = keysSet.iterator(); iter
2210: .hasNext();) {
2211: try {
2212: Object attachName = iter.next();
2213: Attachment pAttach = (Attachment) attacMap
2214: .get(attachName);
2215: int bugid = getIDofBug(pAttach);
2216: DefectWrapper pDefectWrapper = null;
2217: if (bugid != -1) {
2218: //pDefectWrapper = pMantisConnector.getDefectInfo(bugid);
2219: pDefectWrapper = getDefectInfo(
2220: bugid, false);
2221: }
2222: if (pDefectWrapper != null) {
2223: defectsWrapper.put(
2224: new Integer(bugid),
2225: pDefectWrapper);
2226: }
2227: } catch (Exception ex) {
2228: ex.printStackTrace();
2229: }
2230: }
2231: }
2232: pDefectPanel3.loadData(defectsWrapper);
2233: }
2234: //System.out.println("MANTIS");
2235: }
2236: }
2237: });
2238: }
2239:
2240: }
2241:
2242: public boolean isFreezable() {
2243: return false;
2244: }
2245:
2246: public void freeze() {
2247: }
2248:
2249: public void unFreeze() {
2250: }
2251:
2252: public boolean isFreezed() {
2253: return false;
2254: }
2255:
2256: /**
2257: * Called by Salome when all plugin are initialized and when Salome-tmf started
2258: * @param commonExtensions a ExtensionPoint of all plugin available of type common
2259: * @param testDriverExtensions a ExtensionPoint of all plugin available of type testDriver
2260: * @param scriptEngineExtensions a ExtensionPoint of all plugin available of type scriptEngine
2261: * @param bugTrackerExtensions a ExtensionPoint of all plugin available of type bugTrackerEngine
2262: */
2263: public void allPluginActived(ExtensionPoint commonExtensions,
2264: ExtensionPoint testDriverExtensions,
2265: ExtensionPoint scriptEngineExtensions,
2266: ExtensionPoint bugTrackerExtensions) {
2267:
2268: }
2269:
2270: public void setTestTree(DynamicTree pDynamicTree) {
2271: salomeDynamicTree = pDynamicTree.getTree();
2272: salomeDynamicTree
2273: .addTreeSelectionListener(new TreeSelectionListener() {
2274: public void valueChanged(TreeSelectionEvent e) {
2275: DefaultMutableTreeNode node = (DefaultMutableTreeNode) salomeDynamicTree
2276: .getLastSelectedPathComponent();
2277: if (node == null)
2278: return;
2279: Object nodeInfo = node.getUserObject();
2280: /* React to the node selection. */
2281: if ((nodeInfo instanceof ManualTest)) {
2282: if (pMTestJTabbedPane != null) {
2283: if (pMTestJTabbedPane
2284: .getSelectedComponent().equals(
2285: pMTestDefectPanel)) {
2286: System.out
2287: .println("pMTestDefectPanel");
2288: loadDefectTest((Test) nodeInfo,
2289: pMTestDefectPanel);
2290: }
2291: }
2292: } else if ((nodeInfo instanceof AutomaticTest)) {
2293: if (pATestJTabbedPane != null) {
2294: if (pATestJTabbedPane
2295: .getSelectedComponent().equals(
2296: pATestDefectPanel)) {
2297: System.out
2298: .println("pATestDefectPanel");
2299: loadDefectTest((Test) nodeInfo,
2300: pATestDefectPanel);
2301: }
2302: }
2303: }
2304: }
2305: });
2306: }
2307:
2308: void loadDefectTest(Test pTest, DefectPanel pDefectPanel) {
2309: Hashtable pDefectWrappers = new Hashtable();
2310: Project pProject = DataModel.getCurrentProject();
2311: ArrayList listOfCampaign = pProject.getCampaignListFromModel();
2312: for (int i = 0; i < listOfCampaign.size(); i++) {
2313: Campaign pCamp = (Campaign) listOfCampaign.get(i);
2314: ArrayList listOfExecution = pCamp
2315: .getExecutionListFromModel();
2316: for (int j = 0; j < listOfExecution.size(); j++) {
2317: Execution pExec = (Execution) listOfExecution.get(j);
2318: ArrayList listOfExecutionRes = pExec
2319: .getExecutionResultListFromModel();
2320: for (int k = 0; k < listOfExecutionRes.size(); k++) {
2321: ExecutionResult pExecutionResult = (ExecutionResult) listOfExecutionRes
2322: .get(k);
2323: Test[] tests = pExecutionResult
2324: .getTestOrderedFromModel();
2325: for (int l = 0; l < tests.length; l++) {
2326: if (pTest.getIdBdd() == tests[l].getIdBdd()) {
2327: ExecutionTestResult pExecutionTestResult = pExecutionResult
2328: .getExecutionTestResultFromModel(tests[l]);
2329: addTestLinkDefect(pExecutionTestResult,
2330: pDefectWrappers);
2331: }
2332: }
2333: }
2334: }
2335: }
2336: pDefectPanel.loadData(pDefectWrappers);
2337: }
2338:
2339: void loadDefectTest(Vector pTests, DefectPanel pDefectPanel) {
2340: Hashtable pDefectWrappers = new Hashtable();
2341: Project pProject = DataModel.getCurrentProject();
2342: ArrayList listOfCampaign = pProject.getCampaignListFromModel();
2343: for (int i = 0; i < listOfCampaign.size(); i++) {
2344: Campaign pCamp = (Campaign) listOfCampaign.get(i);
2345: ArrayList listOfExecution = pCamp
2346: .getExecutionListFromModel();
2347: for (int j = 0; j < listOfExecution.size(); j++) {
2348: Execution pExec = (Execution) listOfExecution.get(j);
2349: ArrayList listOfExecutionRes = pExec
2350: .getExecutionResultListFromModel();
2351: for (int k = 0; k < listOfExecutionRes.size(); k++) {
2352: ExecutionResult pExecutionResult = (ExecutionResult) listOfExecutionRes
2353: .get(k);
2354: Test[] tests = pExecutionResult
2355: .getTestOrderedFromModel();
2356: for (int l = 0; l < tests.length; l++) {
2357: if (isFiltred(pTests, tests[l])) {
2358: ExecutionTestResult pExecutionTestResult = pExecutionResult
2359: .getExecutionTestResultFromModel(tests[l]);
2360: addTestLinkDefect(pExecutionTestResult,
2361: pDefectWrappers);
2362: }
2363: }
2364: }
2365: }
2366: }
2367: pDefectPanel.loadData(pDefectWrappers);
2368: }
2369:
2370: boolean isFiltred(Vector testsList, Test pTest) {
2371: int size = testsList.size();
2372: int i = 0;
2373: boolean filtred = false;
2374: while (!filtred && i < size) {
2375: Test ptempTest = (Test) testsList.elementAt(i);
2376: if (ptempTest.getIdBdd() == pTest.getIdBdd()) {
2377: filtred = true;
2378: }
2379: i++;
2380: }
2381: return filtred;
2382: }
2383:
2384: void addTestLinkDefect(ExecutionTestResult pExecutionTestResult,
2385: Hashtable pDefectWrappers) {
2386: //Hashtable defectsWrapper = new Hashtable();
2387: if (pExecutionTestResult != null) {
2388: HashMap attacMap = pExecutionTestResult
2389: .getAttachmentMapFromModel();
2390: Set keysSet = attacMap.keySet();
2391: for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
2392: try {
2393: Object attachName = iter.next();
2394: Attachment pAttach = (Attachment) attacMap
2395: .get(attachName);
2396: int bugid = getIDofBug(pAttach);
2397: DefectWrapper pDefectWrapper = getDefectInfo(bugid,
2398: false);
2399: if (pDefectWrapper != null) {
2400: pDefectWrappers.put(new Integer(bugid),
2401: pDefectWrapper);
2402: }
2403: } catch (Exception ex) {
2404: ex.printStackTrace();
2405: }
2406: }
2407: }
2408: }
2409:
2410: void deleteTestLinkDefect(ExecutionTestResult pExecutionTestResult,
2411: DefectWrapper pDefectSource) {
2412:
2413: if (pExecutionTestResult != null) {
2414: HashMap attacMap = pExecutionTestResult
2415: .getCopyOfAttachmentMapFromModel();
2416: Set keysSet = attacMap.keySet();
2417: for (Iterator iter = keysSet.iterator(); iter.hasNext();) {
2418: try {
2419: Object attachName = iter.next();
2420: Attachment pAttach = (Attachment) attacMap
2421: .get(attachName);
2422: int bugid = getIDofBug(pAttach);
2423: DefectWrapper pDefectWrapper = getDefectInfo(bugid,
2424: false);
2425: if (pDefectWrapper != null
2426: && pDefectSource != null
2427: && pDefectSource.getId() == pDefectWrapper
2428: .getId()) {
2429: pExecutionTestResult
2430: .deleteAttachementInDBAndModel(pAttach);
2431: }
2432: } catch (Exception ex) {
2433: ex.printStackTrace();
2434: }
2435: }
2436: }
2437: }
2438:
2439: /************************ Confirmation ***************************/
2440:
2441: boolean deleteConfirme(String quoi) {
2442: Object[] options = {
2443: org.objectweb.salome_tmf.ihm.languages.Language
2444: .getInstance().getText("Oui"),
2445: org.objectweb.salome_tmf.ihm.languages.Language
2446: .getInstance().getText("Non") };
2447: int choice = -1;
2448:
2449: choice = SalomeTMFContext.getInstance().askQuestion(
2450: org.objectweb.salome_tmf.ihm.languages.Language
2451: .getInstance().getText(
2452: "confimation_suppression2")
2453: + " " + quoi + " ?",
2454: org.objectweb.salome_tmf.ihm.languages.Language
2455: .getInstance().getText("Attention_!"),
2456: JOptionPane.WARNING_MESSAGE, options);
2457:
2458: if (choice == JOptionPane.YES_OPTION) {
2459: return true;
2460: } else {
2461: return false;
2462: }
2463: }
2464:
2465: /********************** XML ******************************/
2466: /************** Option Panel *************/
2467: JCheckBox exportDefectBox;
2468: JPanel exportDefectPanel;
2469:
2470: public JPanel getExportOptionPanel() {
2471: exportDefectBox = new JCheckBox(Language.getInstance().getText(
2472: "Exporter_les_bugs"));
2473: exportDefectBox.setSelected(true);
2474: exportDefectPanel = new JPanel();
2475: exportDefectPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
2476: exportDefectPanel.add(exportDefectBox);
2477: exportDefectPanel.setName("Mantis");
2478: return exportDefectPanel;
2479: }
2480:
2481: public JPanel getImportOptionPanel() {
2482: return null;
2483: }
2484:
2485: boolean doExport() {
2486: if (mandatoryExport)
2487: return true;
2488: if (exportDefectBox == null || !exportDefectBox.isSelected()) {
2489: return false;
2490: }
2491: return true;
2492: }
2493:
2494: /************** EXPORT *****************/
2495:
2496: void writeXMLDefect(Element defectsElem,
2497: DefectWrapper pDefectWrapper, XMLWriterPlugin pXMLWriter) {
2498: if (pDefectWrapper == null) {
2499: return;
2500: }
2501: Element defectElem = defectsElem.addElement("Defect");
2502: int bugID = pDefectWrapper.getId();
2503: defectElem.addAttribute("id", "Bug_" + bugID);
2504: defectElem.addAttribute("summary", ""
2505: + pDefectWrapper.getResume().replaceAll("\n", "\\\\n"));
2506: defectElem.addAttribute("reporter", pDefectWrapper.getUser());
2507: defectElem.addAttribute("handler", pDefectWrapper
2508: .getRecipient());
2509:
2510: Element priorityElem = defectElem.addElement("Priority");
2511: priorityElem.addAttribute("id", ""
2512: + pDefectWrapper.getPriority());
2513: priorityElem.addAttribute("value", (String) priorityByID
2514: .get(new Integer(pDefectWrapper.getPriority())));
2515:
2516: Element severityElem = defectElem.addElement("Severity");
2517: severityElem.addAttribute("id", ""
2518: + pDefectWrapper.getSeverity());
2519: severityElem.addAttribute("value", (String) severityByID
2520: .get(new Integer(pDefectWrapper.getSeverity())));
2521:
2522: Element statusElem = defectElem.addElement("Status");
2523: statusElem.addAttribute("id", "" + pDefectWrapper.getStatus());
2524: statusElem.addAttribute("value", (String) statusByID
2525: .get(new Integer(pDefectWrapper.getStatus())));
2526:
2527: Element reproducibilityElem = defectElem
2528: .addElement("Reproducibility");
2529: reproducibilityElem.addAttribute("id", ""
2530: + pDefectWrapper.getReproducibility());
2531: reproducibilityElem.addAttribute("value",
2532: (String) reproductibilityByID.get(new Integer(
2533: pDefectWrapper.getReproducibility())));
2534:
2535: Element resolutionElem = defectElem.addElement("Resolution");
2536: resolutionElem.addAttribute("id", ""
2537: + pDefectWrapper.getResolution());
2538: resolutionElem.addAttribute("value", (String) resolutionByID
2539: .get(new Integer(pDefectWrapper.getResolution())));
2540:
2541: Element infoElem = defectElem.addElement("Info");
2542: infoElem.addAttribute("environment", pDefectWrapper
2543: .getEnvironement());
2544: infoElem.addAttribute("platform", pDefectWrapper
2545: .getPlateforme());
2546: infoElem.addAttribute("os", pDefectWrapper.getOs());
2547:
2548: defectElem.addElement("Description").setText(
2549: pDefectWrapper.getDescription().replaceAll("\n",
2550: "\\\\n"));
2551: Element attachsElem = defectElem.addElement("MantisURL");
2552: String url_res = mantis_host
2553: + "view_salome_bug_page.php?project_id="
2554: + URLEncoder.encode("" + bugProjectID) + "&bug_id="
2555: + URLEncoder.encode("" + bugID) + "&user_id="
2556: + URLEncoder.encode("" + bugUsrID);
2557: attachsElem.addAttribute("url", url_res);
2558:
2559: Element defectsRelations = defectElem
2560: .addElement("DefectRelations");
2561: try {
2562: Hashtable defectRelation = pMantisConnector.getDefectLink(
2563: bugProjectID, pDefectWrapper.getId());
2564: Enumeration defectRelationEnum = defectRelation.elements();
2565: while (defectRelationEnum.hasMoreElements()) {
2566: DefectWrapper pDefect = (DefectWrapper) defectRelationEnum
2567: .nextElement();
2568: Element defectsRelation = defectsRelations
2569: .addElement("DefectRelation");
2570: defectsRelation.addAttribute("ref", "Bug_"
2571: + pDefect.getId());
2572: }
2573: } catch (Exception e) {
2574:
2575: }
2576: }
2577:
2578: void writeXMLDefectLink(Element pElem,
2579: ExecutionResult pExecutionResult,
2580: ExecutionTestResult pExecTestRes,
2581: XMLWriterPlugin pXMLWriter, Vector addedBugs) {
2582: HashMap attachs = pExecTestRes.getAttachmentMapFromModel();
2583: Iterator ita = attachs.values().iterator();
2584: Element defectsElem = null;
2585: while (ita != null && ita.hasNext()) {
2586: Attachment at = (Attachment) ita.next();
2587: if (at instanceof UrlAttachment) {
2588: UrlAttachment uat = (UrlAttachment) at;
2589: if (uat.getDescriptionFromModel().equals(ATTACH_DESC)) {
2590: int bugID = getIDofBug(at);
2591: if (defectsCache != null) {
2592: DefectWrapper pDefectWrapper = (DefectWrapper) defectsCache
2593: .get(new Integer(bugID));
2594: if (pDefectWrapper != null) {
2595: String id_bug = "Bug_"
2596: + pDefectWrapper.getId();
2597: if (!addedBugs.contains(id_bug)) {
2598: defectsElem = pElem
2599: .addElement("DefectsLink");
2600: defectsElem.addAttribute(
2601: "defect_manager", "Mantis");
2602: defectsElem.addAttribute("host",
2603: mantis_host);
2604: defectsElem.addAttribute("ref", id_bug);
2605: addedBugs.add(id_bug);
2606: Element tempElem;
2607: if (pExecutionResult != null) {
2608: Execution pExec = pExecutionResult
2609: .getExecution();
2610: Environment pEnv = pExec
2611: .getEnvironmentFromModel();
2612: Campaign pCamp = pExec
2613: .getCampagneFromModel();
2614:
2615: tempElem = defectsElem
2616: .addElement("CampaignRef");
2617: tempElem.addAttribute("id", "Camp_"
2618: + pCamp.getIdBdd());
2619: tempElem.addAttribute("name", pCamp
2620: .getNameFromModel());
2621:
2622: tempElem = defectsElem
2623: .addElement("EnvironmentRef");
2624: tempElem.addAttribute("id", "Env_"
2625: + pEnv.getIdBdd());
2626: tempElem.addAttribute("name", pEnv
2627: .getNameFromModel());
2628:
2629: tempElem = defectsElem
2630: .addElement("ExecutionRef");
2631: tempElem.addAttribute("id",
2632: "ExecCamp_"
2633: + pExec.getIdBdd());
2634: tempElem.addAttribute("name", pExec
2635: .getNameFromModel());
2636:
2637: tempElem = defectsElem
2638: .addElement("ExecutionResultRef");
2639: tempElem
2640: .addAttribute(
2641: "id",
2642: "ResExecCamp_"
2643: + pExecutionResult
2644: .getIdBdd());
2645: tempElem
2646: .addAttribute(
2647: "name",
2648: pExecutionResult
2649: .getNameFromModel());
2650:
2651: /*tempElem = defectsElem.addElement("ExecutionTestResult");
2652: tempElem.addAttribute("id", ""+pExecTestRes.getIdBdd() );
2653: tempElem.addAttribute("name", pExecTestRes.getNameFromModel());
2654:
2655: tempElem = defectsElem.addElement("Test");
2656: tempElem.addAttribute("id", ""+pExecTestRes.getTestFromModel().getIdBdd() );
2657: tempElem.addAttribute("name", pExecTestRes.getTestFromModel().getNameFromModel());
2658: tempElem.addAttribute("execution_test_id", ""+pExecTestRes.getIdBdd());*/
2659: }
2660: tempElem = defectsElem
2661: .addElement("TestRef");
2662: tempElem.addAttribute("ref", "Test_"
2663: + pExecTestRes
2664: .getTestFromModel()
2665: .getIdBdd());
2666: tempElem.addElement("Nom").setText(
2667: pExecTestRes.getTestFromModel()
2668: .getNameFromModel());
2669: tempElem.addAttribute(
2670: "execution_test_id", "TestRes_"
2671: + pExecTestRes
2672: .getIdBdd());
2673: writeXMLDefect(defectsElem,
2674: pDefectWrapper, pXMLWriter);
2675: }
2676: }
2677: }
2678: }
2679: }
2680: }
2681: }
2682:
2683: //Hashtable alldefect ;
2684: public void addXMLElement2Root(Element rootElement,
2685: XMLWriterPlugin pXMLWriter, String pathAttach) {
2686: /* Reload defect cache */
2687: try {
2688: getDefectsOfProject(true);
2689: } catch (Exception e) {
2690: e.printStackTrace();
2691: }
2692: }
2693:
2694: /* Test Plan */
2695: public void addXMLElement2Project(Element projectElement,
2696: Project pProject, XMLWriterPlugin pXMLWriter,
2697: String pathAttach) {
2698: if (!doExport()) {
2699: return;
2700: }
2701: if (pMantisConnector != null && bugProjectID > 0) {
2702: try {
2703: Element defectsElem = projectElement
2704: .addElement("Defects");
2705: defectsElem.addAttribute("defect_manager", "Mantis");
2706: defectsElem.addAttribute("host", mantis_host);
2707: getDefectsOfProject(true);
2708: //alldefect = pMantisConnector.getProjectDefects(bugProjectID);
2709: Enumeration enumDefect = defectsCache.elements();
2710: while (enumDefect.hasMoreElements()) {
2711: DefectWrapper pDefectWrapper = (DefectWrapper) enumDefect
2712: .nextElement();
2713: writeXMLDefect(defectsElem, pDefectWrapper,
2714: pXMLWriter);
2715: }
2716: } catch (Exception e) {
2717: e.printStackTrace();
2718: }
2719: }
2720: }
2721:
2722: public void addXMLElement2Family(Element familyElement,
2723: Family pFamily, XMLWriterPlugin pXMLWriter,
2724: String pathAttach) {
2725: /*if (alldefect == null)
2726: return;
2727: HashMap attachs = pFamily.getAttachmentMapFromModel();
2728: Iterator ita = attachs.values().iterator();
2729: Element defectsElem = null;
2730: while (ita.hasNext()){
2731: Attachment at = (Attachment)ita.next();
2732: if (at instanceof UrlAttachment){
2733: UrlAttachment uat = (UrlAttachment)at;
2734: if (uat.getDescriptionFromModel().equals(ATTACH_DESC)){
2735: int bugID = getIDofBug(at);
2736: DefectWrapper pDefectWrapper = (DefectWrapper)alldefect.get(new Integer(bugID));
2737: if (defectsElem == null){
2738: defectsElem = familyElement.addElement("DefectsLink");
2739: defectsElem.addAttribute("defect_manager", "Mantis");
2740: defectsElem.addAttribute("host", mantis_host);
2741: }
2742: writeXMLDefect(defectsElem, pDefectWrapper, pXMLWriter);
2743: }
2744: }
2745: }*/
2746: }
2747:
2748: public void addXMLElement2Suite(Element suiteElement,
2749: TestList ptestList, XMLWriterPlugin pXMLWriter,
2750: String pathAttach) {
2751: /*if (alldefect == null)
2752: return;
2753: HashMap attachs = ptestList.getAttachmentMapFromModel();
2754: Iterator ita = attachs.values().iterator();
2755: Element defectsElem = null;
2756: while (ita.hasNext()){
2757: Attachment at = (Attachment)ita.next();
2758: if (at instanceof UrlAttachment){
2759: UrlAttachment uat = (UrlAttachment)at;
2760: if (uat.getDescriptionFromModel().equals(ATTACH_DESC)){
2761: int bugID = getIDofBug(at);
2762: DefectWrapper pDefectWrapper = (DefectWrapper)alldefect.get(new Integer(bugID));
2763: if (defectsElem == null){
2764: defectsElem = suiteElement.addElement("DefectsLink");
2765: defectsElem.addAttribute("defect_manager", "Mantis");
2766: defectsElem.addAttribute("host", mantis_host);
2767: }
2768: writeXMLDefect(defectsElem, pDefectWrapper, pXMLWriter);
2769: }
2770: }
2771: }*/
2772: }
2773:
2774: public void addXMLElement2Test(Element testElement, Test pTest,
2775: XMLWriterPlugin pXMLWriter, String pathAttach) {
2776: if (!doExport()) {
2777: return;
2778: }
2779: //Hashtable pDefectWrappers = new Hashtable();
2780: Project pProject = DataModel.getCurrentProject();
2781: ArrayList listOfCampaign = pProject.getCampaignListFromModel();
2782: Vector addedBugs = new Vector();
2783: Element defectsElem = testElement.addElement("DefectsLinks");
2784: for (int i = 0; i < listOfCampaign.size(); i++) {
2785: Campaign pCamp = (Campaign) listOfCampaign.get(i);
2786: ArrayList listOfExecution = pCamp
2787: .getExecutionListFromModel();
2788: for (int j = 0; j < listOfExecution.size(); j++) {
2789: Execution pExec = (Execution) listOfExecution.get(j);
2790: ArrayList listOfExecutionRes = pExec
2791: .getExecutionResultListFromModel();
2792: for (int k = 0; k < listOfExecutionRes.size(); k++) {
2793: ExecutionResult pExecutionResult = (ExecutionResult) listOfExecutionRes
2794: .get(k);
2795: Test[] tests = pExecutionResult
2796: .getTestOrderedFromModel();
2797: for (int l = 0; l < tests.length; l++) {
2798: if (pTest.getIdBdd() == tests[l].getIdBdd()) {
2799: ExecutionTestResult pExecutionTestResult = pExecutionResult
2800: .getExecutionTestResultFromModel(tests[l]);
2801: writeXMLDefectLink(defectsElem,
2802: pExecutionResult,
2803: pExecutionTestResult, pXMLWriter,
2804: addedBugs);
2805: //return; /*TO DO : remplace with while */
2806: }
2807: }
2808: }
2809: }
2810: }
2811:
2812: }
2813:
2814: //void addXMLElement2ValuedParameter(Element paramElement, Test pTest, Parameter pParam);
2815: public void addXMLElement2Action(Element testElement,
2816: Action pAction, XMLWriterPlugin pXMLWriter,
2817: String pathAttach) {
2818: /* NOT YET IMPLEMENTED */
2819: }
2820:
2821: /* Campaing plan */
2822: public void addXMLElement2Campaign(Element campaignElement,
2823: Campaign pcampaign, XMLWriterPlugin pXMLWriter,
2824: String pathAttach) {
2825: /*if (defectsCache == null)
2826: return;
2827: HashMap attachs = pcampaign.getAttachmentMapFromModel();
2828: Iterator ita = attachs.values().iterator();
2829: Element defectsElem = null;
2830: while (ita.hasNext()){
2831: Attachment at = (Attachment)ita.next();
2832: if (at instanceof UrlAttachment){
2833: UrlAttachment uat = (UrlAttachment)at;
2834: if (uat.getDescriptionFromModel().equals(ATTACH_DESC)){
2835: int bugID = getIDofBug(at);
2836: DefectWrapper pDefectWrapper = (DefectWrapper)defectsCache.get(new Integer(bugID));
2837: if (defectsElem == null){
2838: defectsElem = campaignElement.addElement("DefectsLink");
2839: defectsElem.addAttribute("defect_manager", "Mantis");
2840: defectsElem.addAttribute("host", mantis_host);
2841: }
2842: writeXMLDefect(defectsElem, pDefectWrapper, pXMLWriter);
2843: }
2844: }
2845: }*/
2846: }
2847:
2848: public void addXMLElement2Execution(Element execElement,
2849: Execution pExecution, XMLWriterPlugin pXMLWriter,
2850: String pathAttach) {
2851: if (!doExport()) {
2852: return;
2853: }
2854:
2855: //Hashtable pDefectWrappers = new Hashtable();
2856: Project pProject = DataModel.getCurrentProject();
2857: Vector addedBugs = new Vector();
2858: ArrayList listOfCampaign = pProject.getCampaignListFromModel();
2859: for (int i = 0; i < listOfCampaign.size(); i++) {
2860: Campaign pCamp = (Campaign) listOfCampaign.get(i);
2861: ArrayList listOfExecution = pCamp
2862: .getExecutionListFromModel();
2863: for (int j = 0; j < listOfExecution.size(); j++) {
2864: Execution pExec = (Execution) listOfExecution.get(j);
2865: //defectsElem = pElem.addElement("DefectsLink");
2866: if (pExec.getIdBdd() == pExecution.getIdBdd()) {
2867: Element defectsElem = execElement
2868: .addElement("DefectsLinks");
2869: ArrayList listOfExecutionRes = pExec
2870: .getExecutionResultListFromModel();
2871: for (int k = 0; k < listOfExecutionRes.size(); k++) {
2872: ExecutionResult pExecutionResult = (ExecutionResult) listOfExecutionRes
2873: .get(k);
2874: Test[] tests = pExecutionResult
2875: .getTestOrderedFromModel();
2876: for (int l = 0; l < tests.length; l++) {
2877: ExecutionTestResult pExecutionTestResult = pExecutionResult
2878: .getExecutionTestResultFromModel(tests[l]);
2879: writeXMLDefectLink(defectsElem,
2880: pExecutionResult,
2881: pExecutionTestResult, pXMLWriter,
2882: addedBugs);
2883: }
2884: }
2885: return; /*TO DO : remplace with while */
2886: }
2887:
2888: }
2889: }
2890: }
2891:
2892: public void addXMLElement2ResExecution(Element resExecElement,
2893: ExecutionResult pExecRes, XMLWriterPlugin pXMLWriter,
2894: String pathAttach) {
2895: if (!doExport()) {
2896: return;
2897: }
2898: Project pProject = DataModel.getCurrentProject();
2899: Vector addedBugs = new Vector();
2900: ArrayList listOfCampaign = pProject.getCampaignListFromModel();
2901: for (int i = 0; i < listOfCampaign.size(); i++) {
2902: Campaign pCamp = (Campaign) listOfCampaign.get(i);
2903: ArrayList listOfExecution = pCamp
2904: .getExecutionListFromModel();
2905: for (int j = 0; j < listOfExecution.size(); j++) {
2906: Execution pExec = (Execution) listOfExecution.get(j);
2907: ArrayList listOfExecutionRes = pExec
2908: .getExecutionResultListFromModel();
2909: for (int k = 0; k < listOfExecutionRes.size(); k++) {
2910: ExecutionResult pExecutionResult = (ExecutionResult) listOfExecutionRes
2911: .get(k);
2912: if (pExecutionResult.getIdBdd() == pExecRes
2913: .getIdBdd()) {
2914: Element defectsElem = resExecElement
2915: .addElement("DefectsLinks");
2916: Test[] tests = pExecutionResult
2917: .getTestOrderedFromModel();
2918: for (int l = 0; l < tests.length; l++) {
2919: ExecutionTestResult pExecutionTestResult = pExecutionResult
2920: .getExecutionTestResultFromModel(tests[l]);
2921: writeXMLDefectLink(defectsElem,
2922: pExecutionResult,
2923: pExecutionTestResult, pXMLWriter,
2924: addedBugs);
2925: }
2926: return; /*TO DO : remplace with while */
2927: }
2928: }
2929: }
2930: }
2931: }
2932:
2933: public void addXMLElement2ResTestExecution(Element resTestElem,
2934: ExecutionTestResult pExecTestRes, Test pTest,
2935: XMLWriterPlugin pXMLWriter, String pathAttach) {
2936: if (!doExport()) {
2937: return;
2938: }
2939:
2940: Element defectsElem = resTestElem.addElement("DefectsLinks");
2941: writeXMLDefectLink(defectsElem, null, pExecTestRes, pXMLWriter,
2942: new Vector());
2943:
2944: }
2945:
2946: public void addXMLElement2DataSet(Element dataSetElement,
2947: DataSet pDataSet, XMLWriterPlugin pXMLWriter,
2948: String pathAttach) {
2949: /* NOT YET IMPLEMENTED */
2950: }
2951:
2952: /* Data */
2953: public void addXMLElement2Parameter(Element paramElement,
2954: Parameter pParam, XMLWriterPlugin pXMLWriter,
2955: String pathAttach) {
2956: /* NOT YET IMPLEMENTED */
2957: }
2958:
2959: public void addXMLElement2Environment(Element envElement,
2960: Environment pEnv, XMLWriterPlugin pXMLWriter,
2961: String pathAttach) {
2962: if (!doExport()) {
2963: return;
2964: }
2965: Project pProject = DataModel.getCurrentProject();
2966: ArrayList listOfCampaign = pProject.getCampaignListFromModel();
2967: Element defectsElem = envElement.addElement("DefectsLinks");
2968: Vector addedBugs = new Vector();
2969: for (int i = 0; i < listOfCampaign.size(); i++) {
2970: Campaign pCamp = (Campaign) listOfCampaign.get(i);
2971: ArrayList listOfExecution = pCamp
2972: .getExecutionListFromModel();
2973: for (int j = 0; j < listOfExecution.size(); j++) {
2974: Execution pExec = (Execution) listOfExecution.get(j);
2975: if (pExec.getEnvironmentFromModel().getIdBdd() == pEnv
2976: .getIdBdd()) {
2977: ArrayList listOfExecutionRes = pExec
2978: .getExecutionResultListFromModel();
2979: for (int k = 0; k < listOfExecutionRes.size(); k++) {
2980: ExecutionResult pExecutionResult = (ExecutionResult) listOfExecutionRes
2981: .get(k);
2982: Test[] tests = pExecutionResult
2983: .getTestOrderedFromModel();
2984: for (int l = 0; l < tests.length; l++) {
2985: ExecutionTestResult pExecutionTestResult = pExecutionResult
2986: .getExecutionTestResultFromModel(tests[l]);
2987: writeXMLDefectLink(defectsElem,
2988: pExecutionResult,
2989: pExecutionTestResult, pXMLWriter,
2990: addedBugs);
2991: }
2992:
2993: }
2994: }
2995: }
2996: }
2997:
2998: /*if (defectsCache == null)
2999: return;
3000: Enumeration enumDefect = defectsCache.elements();
3001: Element defectsElem = null;
3002: while (enumDefect.hasMoreElements()){
3003: DefectWrapper pDefectWrapper = (DefectWrapper)enumDefect.nextElement();
3004: if (pDefectWrapper.getEnvironement().equals(pEnv.getNameFromModel())){
3005: if (defectsElem == null){
3006: defectsElem = envElement.addElement("DefectsLink");
3007: defectsElem.addAttribute("defect_manager", "Mantis");
3008: defectsElem.addAttribute("host", mantis_host);
3009: }
3010: writeXMLDefect(defectsElem, pDefectWrapper, pXMLWriter);
3011: }
3012: }*/
3013: }
3014:
3015: /**************** IMPORT *****************/
3016: /**
3017: * Called first before updateMethode if isSupOption = true
3018: */
3019: public void manageDelete(Document doc, XMLLoaderPlugin pXMLLoader)
3020: throws Exception {
3021: /* DO NOTHINK*/
3022: }
3023:
3024: /* Test Plan */
3025: public void updateProjectFromXML(Document doc, boolean isSupOption,
3026: Project project, XMLLoaderPlugin pXMLLoader)
3027: throws Exception {
3028: /* DO NOTHINK*/
3029: }
3030:
3031: public void updateFamilyFromXML(Element familyElement,
3032: Family pFamily, boolean isSupOption,
3033: XMLLoaderPlugin pXMLLoader) throws Exception {
3034: /* DO NOTHINK*/
3035: }
3036:
3037: public void updateSuiteFromXML(Element suiteElement,
3038: TestList pSuite, boolean isSupOption,
3039: XMLLoaderPlugin pXMLLoader) throws Exception {
3040: /* DO NOTHINK*/
3041: }
3042:
3043: public void updateTestFromXML(Element testElement, Test pTest,
3044: boolean isSupOption, XMLLoaderPlugin pXMLLoader)
3045: throws Exception {
3046: /* DO NOTHINK*/
3047: }
3048:
3049: public void updateActionFromXML(Element actionElement,
3050: Action pAction, boolean isSupOption,
3051: XMLLoaderPlugin pXMLLoader) throws Exception {
3052: /* DO NOTHINK*/
3053: }
3054:
3055: /* Campaing plan */
3056: public void updateCampaignFromXML(Element campaignElement,
3057: Campaign pcampaign, boolean isSupOption,
3058: XMLLoaderPlugin pXMLLoader) throws Exception {
3059: /* DO NOTHINK*/
3060: }
3061:
3062: public void updateExecutionFromXML(Element execElement,
3063: Execution pExecution, boolean isSupOption,
3064: XMLLoaderPlugin pXMLLoader) throws Exception {
3065: /* DO NOTHINK*/
3066: }
3067:
3068: public void updateResExecutionFromXML(Element resExecElement,
3069: ExecutionResult pExecRes, boolean isSupOption,
3070: XMLLoaderPlugin pXMLLoader) throws Exception {
3071: /* DO NOTHINK*/
3072: }
3073:
3074: public void updateDataSetFromXML(Element dataSetElement,
3075: DataSet pDataSet, boolean isSupOption,
3076: XMLLoaderPlugin pXMLLoader) throws Exception {
3077: /* DO NOTHINK*/
3078: }
3079:
3080: /* Data */
3081: public void updateParameterFromXML(Element paramElement,
3082: Parameter pParam, boolean isSupOption,
3083: XMLLoaderPlugin pXMLLoader) throws Exception {
3084: /* DO NOTHINK*/
3085: }
3086:
3087: public void updateEnvironmentFromXML(Element envElement,
3088: Environment pEnv, boolean isSupOption,
3089: XMLLoaderPlugin pXMLLoader) throws Exception {
3090: /* DO NOTHINK*/
3091: }
3092:
3093: /**
3094: *
3095: * Called last after import
3096: */
3097: public void refreshNewData() {
3098: /* DO NOTHINK*/
3099: }
3100:
3101: /**************** XSLT ******************
3102: * @param dynamicMode true if generated HTML report is the results' report, false otherwise
3103: * @param multiFrame true if the generated HTML report is in multi-frame mode, false otherwise
3104: */
3105: public File getXSLToImport(boolean dynamicMode, boolean multiFrame,
3106: boolean htmlFormat) {
3107: String _urlBase = SalomeTMFContext.getInstance().getUrlBase()
3108: .toString();
3109: String url_txt = _urlBase.substring(0, _urlBase
3110: .lastIndexOf("/"));
3111: String xsl = "";
3112: if (dynamicMode) {
3113: if (htmlFormat) {
3114: if (multiFrame) {
3115: xsl = "/plugins/mantis/xsl/frameDynaDefects.xsl";
3116: } else {
3117: xsl = "/plugins/mantis/xsl/dynaDefects.xsl";
3118: }
3119: } else
3120: xsl = "/plugins/mantis/xsl/dynaDefectsDocBook.xsl";
3121: } else {//staticMode
3122: if (htmlFormat) {
3123: if (multiFrame) {
3124: xsl = "/plugins/mantis/xsl/frameDefects.xsl";
3125: } else {
3126: xsl = "/plugins/mantis/xsl/defects.xsl";
3127: }
3128: } else
3129: xsl = "/plugins/mantis/xsl/defectsDocBook.xsl";
3130: }
3131: String temporaryFilePath = System.getProperties().getProperty(
3132: "java.io.tmpdir")
3133: + File.separator + "defectsXSLT.xsl";
3134: try {
3135: URL xsltURL = new URL(url_txt + xsl);
3136: Tools.writeFile(xsltURL.openStream(), temporaryFilePath);
3137: } catch (Exception e) {
3138: Tools.writeFile(ReqPlugin.class
3139: .getResourceAsStream("/salome/" + xsl),
3140: temporaryFilePath);
3141: }
3142: File xsltFile = new File(temporaryFilePath);
3143: return xsltFile;
3144: }
3145:
3146: /**
3147: * Get the translation file for the XSLT transformation
3148: * @return the XML file for translation
3149: */
3150: public File getTranslationFile() {
3151: String _urlBase = SalomeTMFContext.getInstance().getUrlBase()
3152: .toString();
3153: String url_txt = _urlBase.substring(0, _urlBase
3154: .lastIndexOf("/"));
3155: String translate = "/plugins/mantis/xsl/translate.xml";
3156: String temporaryFilePath = System.getProperties().getProperty(
3157: "java.io.tmpdir")
3158: + File.separator + "requirementsTranslate.xml";
3159: try {
3160: URL translateURL = new URL(url_txt + translate);
3161: Tools.writeFile(translateURL.openStream(),
3162: temporaryFilePath);
3163: } catch (Exception e) {
3164: Tools.writeFile(ReqPlugin.class
3165: .getResourceAsStream("/salome/" + translate),
3166: temporaryFilePath);
3167: }
3168: File translateFile = new File(temporaryFilePath);
3169: return translateFile;
3170: }
3171:
3172: public int getQsScoreDefectForTest(Test test, Environment env) {
3173: int res = 3;
3174:
3175: Vector defects = getOpenDefectWrappersListForTestAndEnv(test,
3176: env);
3177: if ((defects != null) && (defects.size() != 0)) {
3178: int i = 0;
3179: while ((i < defects.size()) && (res > 0)) {
3180: DefectWrapper defect = (DefectWrapper) defects
3181: .elementAt(i);
3182: int pri = defect.getPriority();
3183: int sev = defect.getSeverity();
3184: int qs_tmp = 3;
3185: if (pri >= 40) {
3186: qs_tmp = 0;
3187: } else if (pri == 30) {
3188: if (sev >= 30) {
3189: qs_tmp = 0;
3190: } else {
3191: qs_tmp = 1;
3192: }
3193: } else if (pri == 20) {
3194: if (sev >= 40) {
3195: qs_tmp = 1;
3196: } else {
3197: qs_tmp = 2;
3198: }
3199: }
3200: if (qs_tmp < res) {
3201: res = qs_tmp;
3202: }
3203: i++;
3204: }
3205: }
3206:
3207: return res;
3208: }
3209:
3210: Vector getOpenDefectWrappersListForTestAndEnv(Test test,
3211: Environment env) {
3212:
3213: Vector pDefectWrappers = new Vector();
3214: Project pProject = DataModel.getCurrentProject();
3215: ArrayList listOfCampaign = pProject.getCampaignListFromModel();
3216: for (int i = 0; i < listOfCampaign.size(); i++) {
3217: Campaign pCamp = (Campaign) listOfCampaign.get(i);
3218: ArrayList listOfExecution = pCamp
3219: .getExecutionListFromModel();
3220: for (int j = 0; j < listOfExecution.size(); j++) {
3221: Execution pExec = (Execution) listOfExecution.get(j);
3222: if (pExec.getEnvironmentFromModel().equals(env)) {
3223: ArrayList listOfExecutionRes = pExec
3224: .getExecutionResultListFromModel();
3225: for (int k = 0; k < listOfExecutionRes.size(); k++) {
3226: ExecutionResult pExecutionResult = (ExecutionResult) listOfExecutionRes
3227: .get(k);
3228: Test[] tests = pExecutionResult
3229: .getTestOrderedFromModel();
3230: for (int l = 0; l < tests.length; l++) {
3231: if (test.getIdBdd() == tests[l].getIdBdd()) {
3232: ExecutionTestResult pExecutionTestResult = pExecutionResult
3233: .getExecutionTestResultFromModel(tests[l]);
3234: if (pExecutionTestResult != null) {
3235: HashMap attacMap = pExecutionTestResult
3236: .getAttachmentMapFromModel();
3237: Set keysSet = attacMap.keySet();
3238: for (Iterator iter = keysSet
3239: .iterator(); iter.hasNext();) {
3240: try {
3241: Object attachName = iter
3242: .next();
3243: Attachment pAttach = (Attachment) attacMap
3244: .get(attachName);
3245: int bugid = getIDofBug(pAttach);
3246: DefectWrapper pDefectWrapper = getDefectInfo(
3247: bugid, false);
3248: if ((pDefectWrapper != null)
3249: && (pDefectWrapper
3250: .getStatus() != 90)) {
3251: pDefectWrappers
3252: .add(pDefectWrapper);
3253: }
3254: } catch (Exception ex) {
3255: ex.printStackTrace();
3256: }
3257: }
3258: }
3259: }
3260: }
3261: }
3262: }
3263: }
3264: }
3265: return pDefectWrappers;
3266: }
3267:
3268: public void setExport(boolean b) {
3269: mandatoryExport = b;
3270: }
3271:
3272: public void setImport(boolean b) {
3273: mandatoryImport = b;
3274: }
3275:
3276: public String getChapterTitleInReport() {
3277: if (doExport()) {
3278: return Language.getInstance().getText("Anomalies");
3279: } else {
3280: return null;
3281: }
3282: }
3283:
3284: public String getParameterName(String chapterName) {
3285: if (chapterName.equals(Language.getInstance().getText(
3286: "Anomalies"))) {
3287: return "anomalies";
3288: }
3289: return null;
3290: }
3291: }
|