0001: package salomeTMF_plug.requirements.data;
0002:
0003: import java.util.Hashtable;
0004: import java.util.StringTokenizer;
0005: import java.util.Vector;
0006:
0007: import javax.swing.tree.DefaultMutableTreeNode;
0008: import javax.swing.tree.DefaultTreeModel;
0009:
0010: import org.objectweb.salome_tmf.api.Util;
0011: import org.objectweb.salome_tmf.api.data.TestWrapper;
0012: import org.objectweb.salome_tmf.data.DataConstants;
0013: import org.objectweb.salome_tmf.data.Family;
0014: import org.objectweb.salome_tmf.data.ManualTest;
0015: import org.objectweb.salome_tmf.data.SimpleData;
0016: import org.objectweb.salome_tmf.data.Test;
0017: import org.objectweb.salome_tmf.data.TestList;
0018: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
0019: import org.objectweb.salome_tmf.ihm.models.DynamicTree;
0020:
0021: import salomeTMF_plug.requirements.ihm.RequirementTree;
0022: import salomeTMF_plug.requirements.ihm.SimpleDynamicTestTree;
0023:
0024: public class GenTestTools {
0025:
0026: /* simpleData prefix */
0027: static String PREFIX_FAMILLE = "RF_";
0028: static String PREFIX_SUITE = "RS_";
0029: static String PREFIX_TEST = "RT_";
0030: static String PREFIX = ".";
0031:
0032: /* Requirement type */
0033: static int REQ_FAMILY = 0;
0034: static int REQ_LEAF = 1;
0035:
0036: /* Cache used in order to avoid recomputing element */
0037: static Hashtable reqMapp = new Hashtable();
0038: static Hashtable simpeDataMapp = new Hashtable();
0039:
0040: /* Key : Requirement , Values : Vector of String representing testName */
0041: static Hashtable reqLink = new Hashtable();
0042:
0043: /* Key : Requirement , Values : Vector of String representing testName */
0044: static Hashtable defaultreqLink = new Hashtable();
0045: static Hashtable testLink = new Hashtable();
0046:
0047: static SimpleDynamicTestTree pCopyDynamicTestTree;
0048: static RequirementTree pOrgReqTree;
0049:
0050: //static DefaultMutableTreeNode rootReq;
0051:
0052: static public void initTools(RequirementTree _reqTree,
0053: DynamicTree _pDynamicTree) {
0054: reqMapp = new Hashtable();
0055: simpeDataMapp = new Hashtable();
0056: pCopyDynamicTestTree = createCopyOfTestTree(_pDynamicTree);
0057: reqLink = new Hashtable();
0058: defaultreqLink = new Hashtable();
0059: testLink = new Hashtable();
0060: pOrgReqTree = _reqTree;
0061: //rootReq = (DefaultMutableTreeNode)((JTree)_reqTree).getModel().getRoot();
0062: initReqLink();
0063: }
0064:
0065: /**************************** Bijection functions ****************************/
0066:
0067: /**
0068: *
0069: * @param pSimpleData (family,testList,test)
0070: * @return the associated requirement to the simpleData
0071: */
0072: static public Requirement getRequirement(SimpleData pSimpleData) {
0073: Util.log("[requirements] -> GenTestTools : getRequirment("
0074: + pSimpleData.getDescriptionFromModel() + ") start");
0075: Requirement pReqReturn = null;
0076:
0077: pReqReturn = (Requirement) simpeDataMapp.get(pSimpleData);
0078: if (pReqReturn != null) {
0079: return pReqReturn;
0080: }
0081: if (pSimpleData instanceof Family) {
0082: // look at the first child (only ReqFamily type)
0083: pReqReturn = findReqForFamily(pSimpleData);
0084:
0085: } else if (pSimpleData instanceof TestList) {
0086: // Look at the grandson (only ReqFamily type)
0087: pReqReturn = findReqForTestList(pSimpleData);
0088:
0089: } else if (pSimpleData instanceof Test) {
0090: // Look at the great-grandson (arriere petit fils)
0091: // if search failed
0092: // for each ReqFamily build prefix until reqLeaf and check
0093:
0094: TestList pTestList = ((Test) pSimpleData)
0095: .getTestListFromModel();
0096: Family pFamily = pTestList.getFamilyFromModel();
0097: if (pFamily.getNameFromModel().equals(
0098: DataModel.DEFAULT_FAMILY_NAME)) {
0099:
0100: if (pTestList.getNameFromModel().equals(
0101: DataModel.DEFAULT_TESTLIST_NAME)) {
0102: // requirement level is 1
0103:
0104: if (!(pSimpleData.getNameFromModel()
0105: .startsWith(PREFIX_TEST))) {
0106: return null;
0107: }
0108: String nameOfrequirement = pSimpleData
0109: .getNameFromModel().substring(
0110: PREFIX_TEST.length(),
0111: pSimpleData.getNameFromModel()
0112: .length()); //A VERIFIER
0113: DefaultMutableTreeNode reqNode = pOrgReqTree
0114: .findRequirementByNameFromParent(nameOfrequirement);
0115: //DefaultMutableTreeNode reqNode = searchString(rootReq, nameOfrequirement);
0116: if (reqNode == null) {
0117: return null;
0118: }
0119: Requirement pReq = (Requirement) reqNode
0120: .getUserObject();
0121: if (pReq.isFamilyReq() || reqNode.getLevel() > 1) {
0122: return null;
0123: }
0124: pReqReturn = pReq;
0125:
0126: } else {
0127: Requirement reqParent = findReqForTestList(pTestList);
0128: if (reqParent != null && reqParent.isFamilyReq()) {
0129: pReqReturn = findInLeaf(reqParent, pSimpleData,
0130: PREFIX_TEST, REQ_LEAF);
0131: }
0132:
0133: }
0134: } else {
0135: if (pTestList.getNameFromModel().equals(
0136: DataModel.DEFAULT_TESTLIST_NAME)) {
0137: if (!(pSimpleData.getNameFromModel()
0138: .startsWith(PREFIX_TEST))) {
0139: return null;
0140: }
0141: Requirement reqParent = findReqForFamily(pFamily);
0142: if (reqParent != null && reqParent.isFamilyReq()) {
0143: pReqReturn = findInLeaf(reqParent, pSimpleData,
0144: PREFIX_TEST, REQ_LEAF);
0145: }
0146: } else {
0147: //prefix or level 3
0148: Requirement reqParent = findReqForTestList(pTestList);
0149: if (reqParent != null && reqParent.isFamilyReq()) {
0150: Vector resultPrefix = getPrefixListForTest(
0151: pSimpleData, PREFIX_TEST);
0152:
0153: int size = resultPrefix.size();
0154: if (size == 0) {
0155: pReqReturn = findInLeaf(reqParent,
0156: pSimpleData, PREFIX_TEST, REQ_LEAF);
0157: } else {
0158: int i = 0;
0159: boolean trouve = false;
0160: String totalPrefix = "";
0161: while (!trouve && i < size) {
0162: totalPrefix += (String) resultPrefix
0163: .elementAt(i)
0164: + PREFIX; //A verifier
0165:
0166: reqParent = findInLeafFamilyByName(
0167: reqParent,
0168: (String) resultPrefix
0169: .elementAt(i), "");
0170: if (reqParent != null
0171: && reqParent.isFamilyReq()) {
0172: if (i + 1 == size) {
0173: trouve = true;
0174: } else {
0175: i++;
0176: }
0177: } else {
0178: i = size + 1;
0179: }
0180: }
0181: if (trouve == true) {
0182: pReqReturn = findInLeaf(reqParent,
0183: pSimpleData, totalPrefix
0184: + PREFIX_TEST, REQ_LEAF); //A verifier : totalPrefix + PREFIX_TEST
0185: }
0186: }
0187: }
0188: }
0189: }
0190: }
0191: if (pReqReturn != null) {
0192: //simpeDataMapp.put(pSimpleData, pReqReturn);
0193: }
0194: Util.log("[requirements] -> GenTestTools : getRequirment("
0195: + pSimpleData.getDescriptionFromModel() + ") end");
0196: return pReqReturn;
0197:
0198: }
0199:
0200: /**
0201: * Find a prefix List from the Test
0202: * @param pSimpleData (Test)
0203: * @param defaultPrefix default prefix used for the simpleData
0204: * @return the prefix List in a String Vector
0205: */
0206: static Vector getPrefixListForTest(SimpleData pSimpleData,
0207: String defaultPrefix) {
0208: Util
0209: .log("[requirements] -> GenTestTools : getPrefixListForTest("
0210: + pSimpleData.getDescriptionFromModel()
0211: + ", "
0212: + defaultPrefix + ") start");
0213: Vector result = new Vector();
0214: String dataName = pSimpleData.getNameFromModel();
0215: int beginIndex = dataName.indexOf(defaultPrefix);
0216: if (beginIndex != -1) {
0217: String pathPrefix = dataName.substring(0, beginIndex
0218: + defaultPrefix.length());
0219: StringTokenizer st = new StringTokenizer(pathPrefix, PREFIX);
0220: while (st.hasMoreTokens()) {
0221: result.add(st.nextToken());
0222: }
0223: }
0224: if (result.size() > 0) {
0225: result.remove(result.size() - 1);
0226: }
0227: Util
0228: .log("[requirements] -> GenTestTools : getPrefixListForTest("
0229: + pSimpleData.getDescriptionFromModel()
0230: + ", "
0231: + defaultPrefix + ") return =" + result);
0232: Util
0233: .log("[requirements] -> GenTestTools : getPrefixListForTest("
0234: + pSimpleData.getDescriptionFromModel()
0235: + ", "
0236: + defaultPrefix + ") end");
0237: return result;
0238: }
0239:
0240: /**
0241: * Find a requirement from the Family
0242: * @param pSimpleData (Family)
0243: * @return the requirement corresponding to the Family name
0244: */
0245: static Requirement findReqForFamily(SimpleData pSimpleData) {
0246: Util.log("[requirements] -> GenTestTools : findReqForFamily("
0247: + pSimpleData.getDescriptionFromModel() + ") start");
0248: // Look at the first child in the pRequirementTree (only ReqFamily type)
0249: Requirement pReqReturn = null;
0250:
0251: pReqReturn = (Requirement) simpeDataMapp.get(pSimpleData);
0252: if (pReqReturn != null) {
0253: return pReqReturn;
0254: }
0255: if (!pSimpleData.getNameFromModel().startsWith(PREFIX_FAMILLE)) {
0256: return null;
0257: }
0258:
0259: String nameOfrequirement = pSimpleData.getNameFromModel()
0260: .substring(PREFIX_FAMILLE.length(),
0261: pSimpleData.getNameFromModel().length());
0262: DefaultMutableTreeNode reqNode = pOrgReqTree
0263: .findRequirementByNameFromParent(nameOfrequirement);
0264: //DefaultMutableTreeNode reqNode = searchString(rootReq, nameOfrequirement);
0265: if (reqNode == null) {
0266: return null;
0267: }
0268:
0269: pReqReturn = (Requirement) reqNode.getUserObject();
0270: if (!pReqReturn.isFamilyReq() || reqNode.getLevel() > 1) {
0271: return null;
0272: }
0273: Util.log("[requirements] -> GenTestTools : findReqForFamily("
0274: + pSimpleData.getDescriptionFromModel() + ") end");
0275: return pReqReturn;
0276: }
0277:
0278: /**
0279: * Find a requirement from the TestList
0280: * @param pSimpleData (TestList)
0281: * @return the requirement corresponding to the TestList Name
0282: */
0283: static Requirement findReqForTestList(SimpleData pSimpleData) {
0284: Util.log("[requirements] -> GenTestTools : findReqForTestList("
0285: + pSimpleData.getDescriptionFromModel() + ") start");
0286: Requirement pReqReturn = null;
0287:
0288: pReqReturn = (Requirement) simpeDataMapp.get(pSimpleData);
0289: if (pReqReturn != null) {
0290: return pReqReturn;
0291: }
0292: // Look at the great-grandson (arriere petit fils)
0293: Requirement pRootReq = pOrgReqTree.getRootRequirement();
0294: //Requirement pRootReq = (Requirement) rootReq.getUserObject();
0295: if (pRootReq == null || !pRootReq.isFamilyReq()) {
0296: return null;
0297: }
0298: Vector listFirstLeaf = ((ReqFamily) pRootReq).getFirstFamily();
0299: int size = listFirstLeaf.size();
0300: int i = 0;
0301: boolean trouve = false;
0302: while (!trouve && i < size) {
0303: Requirement pTempReq = (Requirement) listFirstLeaf
0304: .elementAt(i);
0305: Requirement reqFind = findInLeaf(pTempReq, pSimpleData,
0306: PREFIX_SUITE, REQ_FAMILY);
0307: if (reqFind != null) {
0308: trouve = true;
0309: pReqReturn = reqFind;
0310: }
0311: i++;
0312: }
0313:
0314: Util.log("[requirements] -> GenTestTools : findReqForTestList("
0315: + pSimpleData.getDescriptionFromModel() + ") end");
0316: return pReqReturn;
0317: }
0318:
0319: /**
0320: * Find a requirement from a Family requirement
0321: * @param pReq the selected requirement
0322: * @param name of the requirement to find
0323: * @param prefix prefix corresponding to the test
0324: * @return the found requirement or null
0325: */
0326: static Requirement findInLeafFamilyByName(Requirement pReq,
0327: String name, String prefix) {
0328: Util
0329: .log("[requirements] -> GenTestTools : findInLeafFamilyByName("
0330: + pReq.getDescriptionFromModel()
0331: + ", "
0332: + name
0333: + ", " + prefix + ") start");
0334: Requirement pReqReturn = null;
0335: if (pReq.isFamilyReq()) {
0336: Vector listFirstLeaf = ((ReqFamily) pReq).getFirstFamily();
0337: int size = listFirstLeaf.size();
0338: int i = 0;
0339: boolean trouve = false;
0340: while (!trouve && i < size) {
0341: Requirement pTempReq = (Requirement) listFirstLeaf
0342: .elementAt(i);
0343: if (pTempReq.isFamilyReq()) {
0344: if (name.equals(prefix
0345: + pTempReq.getNameFromModel())) {
0346: pReqReturn = pTempReq;
0347: trouve = true;
0348: }
0349: }
0350: i++;
0351: }
0352: }
0353: Util
0354: .log("[requirements] -> GenTestTools : findInLeafFamilyByName("
0355: + pReq.getDescriptionFromModel()
0356: + ", "
0357: + name
0358: + ", " + prefix + ") end");
0359: return pReqReturn;
0360: }
0361:
0362: /**
0363: * Find a requirement from a test
0364: * @param pReq the requirement root to start the research
0365: * @param pSimpleData the test to find
0366: * @param prefix prefix corresponding to the test
0367: * @param type REQ_FAMILY=0 or REQ_LEAF = 1
0368: * @return the found requirement or null
0369: */
0370: static Requirement findInLeaf(Requirement pReq,
0371: SimpleData pSimpleData, String prefix, int type) {
0372: Util.log("[requirements] -> GenTestTools : findInLeaf("
0373: + pReq.getDescriptionFromModel() + ", "
0374: + pSimpleData.getDescriptionFromModel() + ", " + prefix
0375: + ", " + type + ") start");
0376: Requirement pReqReturn = null;
0377: if (pReq.isFamilyReq()) {
0378: Vector listFirstLeaf = new Vector();
0379: if (type == REQ_FAMILY) {
0380: listFirstLeaf = ((ReqFamily) pReq).getFirstFamily();
0381: } else {
0382: listFirstLeaf = ((ReqFamily) pReq).getFistLeaf();
0383: }
0384: int size = listFirstLeaf.size();
0385: int i = 0;
0386: boolean trouve = false;
0387: while (!trouve && i < size) {
0388: Requirement pTempReq = (Requirement) listFirstLeaf
0389: .elementAt(i);
0390: if (pSimpleData.getNameFromModel().equals(
0391: prefix + pTempReq.getNameFromModel())) {
0392: pReqReturn = pTempReq;
0393: trouve = true;
0394: }
0395: i++;
0396: }
0397: }
0398: Util.log("[requirements] -> GenTestTools : findInLeaf("
0399: + pReq.getDescriptionFromModel() + ", "
0400: + pSimpleData.getDescriptionFromModel() + ", " + prefix
0401: + ", " + type + ") end");
0402: return pReqReturn;
0403: }
0404:
0405: //static Vector getFistLeaf(Requirement pReq){
0406: //Vector listFirstLeaf = new Vector();
0407: //DefaultMutableTreeNode reqNode = pOrgReqTree.findRequirementFromParent(pReq);
0408: //}
0409: /**
0410: * get the simpledata corresponding to the requirement
0411: * @param pReq the selected requirement
0412: * @param path path from root to the simpleData
0413: * @param create force to create simpleData if not found
0414: * @return the simpledata found or if create true it returns a new simpledata corresponding to the requirement
0415: */
0416: static public SimpleData getSimpleData(Requirement pReq,
0417: Vector path, boolean create) {
0418: Util.log("[requirements] -> GenTestTools : getSimpleData("
0419: + pReq.getDescriptionFromModel() + ", " + path + ", "
0420: + create + ") start");
0421: SimpleData pSimpleData = null;
0422:
0423: // Does SimpleData exist ?
0424: pSimpleData = (SimpleData) reqMapp.get(pReq);
0425: if (pSimpleData != null) {
0426: // Already created
0427: return pSimpleData;
0428: }
0429:
0430: int level = getLevel(pReq);
0431: if (level == -1) {
0432: return null;
0433: }
0434:
0435: int type = -1;
0436: if (pReq.isFamilyReq()) {
0437: type = REQ_FAMILY;
0438: } else {
0439: type = REQ_LEAF;
0440: }
0441:
0442: if (type == REQ_FAMILY && level == 1) {
0443: // Se transforme en Famille
0444: pSimpleData = getOrCreateFamily(pReq, true, create);
0445: if (pSimpleData != null)
0446: path.add(pSimpleData);
0447:
0448: } else if (type == REQ_FAMILY && level == 2) {
0449: // Se transforme en Suite
0450: Family pFamily = (Family) getOrCreateFamily(pReq
0451: .getParent(), true, create);
0452: if (pFamily != null) {
0453: path.add(pFamily);
0454: pSimpleData = getOrCreateSuite(pReq, pFamily, true,
0455: create);
0456: if (pSimpleData != null)
0457: path.add(pSimpleData);
0458: }
0459: } else if (type == REQ_FAMILY && level > 2) {
0460: // Pas de transformation mais prefix
0461:
0462: } else if (type == REQ_LEAF && level == 1) {
0463: Family pFamily = getDefaultFamily();
0464: if (pFamily != null) {
0465: path.add(pFamily);
0466: TestList pTestList = getDefaultTestList(pFamily);
0467: if (pTestList != null)
0468: path.add(pTestList);
0469:
0470: // transformed in test (FamilY def, TestList def)
0471: pSimpleData = getOrCreateTest(pReq, pFamily, pTestList,
0472: true, "", create);
0473: if (pSimpleData != null)
0474: path.add(pSimpleData);
0475: }
0476: } else if (type == REQ_LEAF && level == 2) {
0477: Family pFamily = (Family) getOrCreateFamily(pReq
0478: .getParent(), true, create);
0479:
0480: if (pFamily != null) {
0481: path.add(pFamily);
0482: TestList pTestList = getDefaultTestList(pFamily);
0483: if (pTestList != null)
0484: path.add(pTestList);
0485:
0486: // Se transforme en test (Famille def, Suite nom du per)
0487: pSimpleData = getOrCreateTest(pReq, pFamily, pTestList,
0488: true, "", create);
0489: if (pSimpleData != null)
0490: path.add(pSimpleData);
0491: }
0492: } else if (type == REQ_LEAF && level == 3) {
0493: // Se transforme en test (Famille nom du grand pere , Suite nom du pere)
0494: Family pFamily = (Family) getOrCreateFamily(pReq
0495: .getParent().getParent(), true, create);
0496: if (pFamily != null) {
0497: path.add(pFamily);
0498:
0499: TestList pTestList = (TestList) getOrCreateSuite(pReq
0500: .getParent(), pFamily, true, create);
0501: if (pTestList != null) {
0502: path.add(pTestList);
0503: // Se transforme en test (Famille def, Suite nom du per)
0504: pSimpleData = getOrCreateTest(pReq, pFamily,
0505: pTestList, true, "", create);
0506: if (pSimpleData != null) {
0507: path.add(pSimpleData);
0508: }
0509: }
0510: }
0511:
0512: } else if (type == REQ_LEAF && level > 3) {
0513: Vector parent = new Vector();
0514: String prefix = getPrefix(pReq, level, parent);
0515:
0516: Requirement pReqSuite = (Requirement) parent.elementAt(0);
0517: Family pFamily = (Family) getOrCreateFamily(pReqSuite
0518: .getParent(), true, create);
0519: if (pFamily != null) {
0520: path.add(pFamily);
0521: TestList pTestList = (TestList) getOrCreateSuite(
0522: pReqSuite, pFamily, true, create);
0523: if (pTestList != null) {
0524: path.add(pTestList);
0525:
0526: pSimpleData = getOrCreateTest(pReq, pFamily,
0527: pTestList, true, prefix, create);
0528: if (pSimpleData != null) {
0529: path.add(pSimpleData);
0530: }
0531: }
0532: }
0533: }
0534: Util.log("[requirements] -> GenTestTools : getSimpleData("
0535: + pReq.getDescriptionFromModel() + ", " + path + ", "
0536: + create + ") end");
0537: return pSimpleData;
0538: }
0539:
0540: /**
0541: * Get prefix corresponding to the requirement
0542: * @param pReq the selected requirement
0543: * @param level the level
0544: * @param parent List of requirement parents
0545: * @return
0546: */
0547: static String getPrefix(Requirement pReq, int level, Vector parent) {
0548: Util.log("[requirements] -> GenTestTools : getPrefix("
0549: + pReq.getDescriptionFromModel() + ", " + level + ", "
0550: + parent + ") start");
0551: int remonte = level - 3;
0552: String prefix = "";
0553: Requirement pCurrentReq = pReq;
0554: for (int i = 0; i < remonte; i++) {
0555: Requirement pReqParent = pCurrentReq.getParent();
0556: if (prefix.equals("")) {
0557: prefix = pReqParent.getNameFromModel();
0558: } else {
0559: prefix = pReqParent.getNameFromModel() + PREFIX
0560: + prefix;
0561: }
0562: pCurrentReq = pReqParent;
0563: }
0564: prefix += ".";
0565: parent.add(pCurrentReq.getParent());
0566: Util.log("[requirements] -> GenTestTools : getPrefix("
0567: + pReq.getDescriptionFromModel() + ", " + level + ", "
0568: + parent + ") return =" + prefix);
0569: Util.log("[requirements] -> GenTestTools : getPrefix("
0570: + pReq.getDescriptionFromModel() + ", " + level + ", "
0571: + parent + ") end");
0572: return prefix;
0573: }
0574:
0575: /**
0576: * get Requirement level
0577: * @param pReq the Requirement selected
0578: * @param pRequirementTree the current Requiremenet tree
0579: * @return the Requirment level
0580: */
0581: static int getLevel(Requirement pReq) {
0582: Util.log("[requirements] -> GenTestTools : getLevel("
0583: + pReq.getDescriptionFromModel() + ") start");
0584: int level = -1;
0585: DefaultMutableTreeNode reqNode = pOrgReqTree
0586: .findRequirementFromParent(pReq);
0587: //DefaultMutableTreeNode reqNode = searchString(rootReq, pReq.getNameFromModel());
0588: if (reqNode != null) {
0589: level = reqNode.getLevel();
0590: }
0591: Util.log("[requirements] -> GenTestTools : getLevel("
0592: + pReq.getDescriptionFromModel() + ") return ="
0593: + level);
0594: Util.log("[requirements] -> GenTestTools : getLevel("
0595: + pReq.getDescriptionFromModel() + ") end");
0596: return level;
0597: }
0598:
0599: /**
0600: *
0601: * @return the default family
0602: */
0603: static Family getDefaultFamily() {
0604: Util
0605: .log("[requirements] -> GenTestTools : getDefaultFamily() start");
0606: Family pFamily = null;
0607: DefaultMutableTreeNode pSimpleDataNode = pCopyDynamicTestTree
0608: .findRemoveFamilyNode(DataModel.DEFAULT_FAMILY_NAME,
0609: false);
0610: if (pSimpleDataNode != null) {
0611: // Already created
0612: pFamily = (Family) pSimpleDataNode.getUserObject();
0613: } else {
0614: // Create one
0615: pFamily = new Family(DataModel.DEFAULT_FAMILY_NAME,
0616: DataModel.DEFAULT_FAMILY_DESC);
0617: }
0618: Util
0619: .log("[requirements] -> GenTestTools : getDefaultFamily() return ="
0620: + pFamily.getNameFromModel());
0621: Util
0622: .log("[requirements] -> GenTestTools : getDefaultFamily() end");
0623: return pFamily;
0624: }
0625:
0626: /**
0627: *
0628: * @param pFamily
0629: * @return the default TestList and add testList to the family
0630: */
0631: static TestList getDefaultTestList(Family pFamily) {
0632: Util
0633: .log("[requirements] -> GenTestTools : getDefaultTestList() start");
0634: TestList pTestList = null;
0635: DefaultMutableTreeNode pSimpleDataNode = pCopyDynamicTestTree
0636: .findRemoveTestListNode(
0637: DataModel.DEFAULT_TESTLIST_NAME, pFamily
0638: .getNameFromModel(), false);
0639: if (pSimpleDataNode != null) {
0640: // Already created
0641: pTestList = (TestList) pSimpleDataNode.getUserObject();
0642: } else {
0643: // Create one
0644: pTestList = new TestList(DataModel.DEFAULT_TESTLIST_NAME,
0645: DataModel.DEFAULT_TESTLIST_DESC);
0646: pFamily.addTestListInModel(pTestList);
0647: }
0648: Util
0649: .log("[requirements] -> GenTestTools : getDefaultTestList() return ="
0650: + pTestList.getNameFromModel());
0651: Util
0652: .log("[requirements] -> GenTestTools : getDefaultTestList() end");
0653: return pTestList;
0654: }
0655:
0656: /**
0657: * get the family of the corresponding selected requirement
0658: * @param pReq the selected requirement
0659: * @param insertInMap keep family
0660: * @param create force to create a new family
0661: * @return get the family if found or if create it returns a new family corresponding to the requirement
0662: */
0663: static SimpleData getOrCreateFamily(Requirement pReq,
0664: boolean insertInMap, boolean create) {
0665: Util.log("[requirements] -> GenTestTools : getOrCreateFamily("
0666: + pReq.getNameFromModel() + ", " + insertInMap + ","
0667: + create + ") start");
0668: SimpleData pSimpleData = null;
0669:
0670: pSimpleData = (SimpleData) reqMapp.get(pReq);
0671: if (pSimpleData != null) {
0672: return pSimpleData;
0673: }
0674:
0675: DefaultMutableTreeNode pSimpleDataNode = pCopyDynamicTestTree
0676: .findRemoveFamilyNode(PREFIX_FAMILLE
0677: + pReq.getNameFromModel(), false);
0678: if (pSimpleDataNode != null) {
0679: // Already created
0680: pSimpleData = (SimpleData) pSimpleDataNode.getUserObject();
0681: if (insertInMap) {
0682: }
0683: } else {
0684: // Create one
0685: if (create) {
0686: pSimpleData = new Family(PREFIX_FAMILLE
0687: + pReq.getNameFromModel(), pReq
0688: .getDescriptionFromModel());
0689: if (insertInMap) {
0690: }
0691: }
0692: }
0693: Util.log("[requirements] -> GenTestTools : getOrCreateFamily("
0694: + pReq.getNameFromModel() + ", " + insertInMap + ","
0695: + create + ") end");
0696: return pSimpleData;
0697: }
0698:
0699: /**
0700: * get the testList of the corresponding selected requirement
0701: * @param pReq the selected requirement
0702: * @param pFamily the family
0703: * @param insertInMap
0704: * @param create force to create a new testList
0705: * @return get the family if found or if create it returns a new family corresponding to the requirement
0706: */
0707: static SimpleData getOrCreateSuite(Requirement pReq,
0708: Family pFamily, boolean insertInMap, boolean create) {
0709: Util.log("[requirements] -> GenTestTools : getOrCreateSuite("
0710: + pReq.getNameFromModel() + ", "
0711: + pFamily.getNameFromModel() + ", " + insertInMap + ","
0712: + create + ") start");
0713: SimpleData pSimpleData = null;
0714:
0715: pSimpleData = (SimpleData) reqMapp.get(pReq);
0716: if (pSimpleData != null) {
0717: return pSimpleData;
0718: }
0719:
0720: DefaultMutableTreeNode pSimpleDataNode = pCopyDynamicTestTree
0721: .findRemoveTestListNode(PREFIX_SUITE
0722: + pReq.getNameFromModel(), pFamily
0723: .getNameFromModel(), false);
0724: if (pSimpleDataNode != null) {
0725: // Already created
0726: pSimpleData = (SimpleData) pSimpleDataNode.getUserObject();
0727: } else {
0728: // Create one
0729: if (create) {
0730: pSimpleData = new TestList(PREFIX_SUITE
0731: + pReq.getNameFromModel(), pReq
0732: .getDescriptionFromModel());
0733: pFamily.addTestListInModel((TestList) pSimpleData);
0734: }
0735: }
0736:
0737: Util.log("[requirements] -> GenTestTools : getOrCreateSuite("
0738: + pReq.getNameFromModel() + ", "
0739: + pFamily.getNameFromModel() + ", " + insertInMap + ","
0740: + create + ") end");
0741: return pSimpleData;
0742: }
0743:
0744: /**
0745: * Get the test if exists or creates it if not.
0746: * @param pReq the requirement corresponding to the test
0747: * @param pFamily the family
0748: * @param pTestList the testList
0749: * @param insertInMap using a cache or not
0750: * @param prefix prefix used
0751: * @param create force create if not exists
0752: * @return the corresponding test
0753: */
0754: static SimpleData getOrCreateTest(Requirement pReq, Family pFamily,
0755: TestList pTestList, boolean insertInMap, String prefix,
0756: boolean create) {
0757: Util.log("[requirements] -> GenTestTools : getOrCreateSuite("
0758: + pReq.getNameFromModel() + ", "
0759: + pFamily.getNameFromModel() + ", "
0760: + pTestList.getDescriptionFromModel() + ", "
0761: + insertInMap + "," + create + ") start");
0762: SimpleData pSimpleData = null;
0763:
0764: pSimpleData = (SimpleData) reqMapp.get(pReq);
0765: if (pSimpleData != null) {
0766: return pSimpleData;
0767: }
0768:
0769: DefaultMutableTreeNode pSimpleDataNode = pCopyDynamicTestTree
0770: .findRemoveTestNode(prefix + PREFIX_TEST
0771: + pReq.getNameFromModel(), pTestList
0772: .getNameFromModel(),
0773: pFamily.getNameFromModel(), false);
0774:
0775: //Add by MIK
0776: boolean exist_covered = false;
0777: if (pSimpleDataNode != null) {
0778: pSimpleData = (SimpleData) pSimpleDataNode.getUserObject();
0779: exist_covered = isReqBijectiveCovered(pReq, pSimpleData
0780: .getNameFromModel());
0781: }
0782:
0783: if (exist_covered) {
0784: if (insertInMap) {
0785: }
0786:
0787: } else {
0788: pSimpleData = null; //Added by MM
0789: // Create one
0790: if (create) {
0791: pSimpleData = new ManualTest(prefix + PREFIX_TEST
0792: + pReq.getNameFromModel(), pReq
0793: .getDescriptionFromModel());
0794: pTestList.addTestInModel((Test) pSimpleData);
0795: addReqBijectiveCovered(pReq, pSimpleData
0796: .getNameFromModel()); //Added by MM
0797: addSimleDataToDynamicTestTree(pSimpleData); //Added by MM
0798:
0799: }
0800: }
0801:
0802: Util.log("[requirements] -> GenTestTools : getOrCreateSuite("
0803: + pReq.getNameFromModel() + ", "
0804: + pFamily.getNameFromModel() + ", "
0805: + pTestList.getDescriptionFromModel() + ", "
0806: + insertInMap + ", " + create + ") end");
0807: return pSimpleData;
0808: }
0809:
0810: /**************************** TOOLS ***********************************/
0811:
0812: /**
0813: * Recursive procedure that builds the test tree by parsing the requirement tree
0814: * @param pTempNode the currentNode
0815: * @param pRequirementTree the requirement tree
0816: */
0817: public static void getBijectiveSimpleDataTree(
0818: DefaultMutableTreeNode pTempNode,
0819: SimpleDynamicTestTree dynTestTree) {
0820: Util
0821: .log("[requirements] -> GenTestTools : addSimpleDataTree : start ");
0822: Requirement pTempReq = (Requirement) pTempNode.getUserObject();
0823: SimpleData data = getSimpleData(pTempReq, new Vector(), false);
0824: Util
0825: .log("[requirements] -> GenTestTools : addSimpleDataTree : Data for "
0826: + pTempReq + ", is " + data);
0827:
0828: if (data != null) {
0829: /* if data element is a test */
0830: if (data instanceof Test) {
0831: if (data.getNameFromModel().length() < 255) {
0832: TestList testList = (TestList) ((Test) data)
0833: .getTestListFromModel();
0834: Family family = testList.getFamilyFromModel();
0835:
0836: String familyName = family.getNameFromModel();
0837: String testListName = testList.getNameFromModel();
0838: String testName = data.getNameFromModel();
0839:
0840: /* Add family if not in model*/
0841: DefaultMutableTreeNode familyNode = dynTestTree
0842: .findRemoveFamilyNode(familyName, false);
0843: if (familyNode == null) {
0844: familyNode = dynTestTree.addObject(dynTestTree
0845: .getRoot(), family);
0846: }
0847:
0848: /* Add testList if not in model */
0849: DefaultMutableTreeNode testListNode = dynTestTree
0850: .findRemoveTestListNode(testListName,
0851: familyName, false);
0852: if (testListNode == null) {
0853: testListNode = dynTestTree.addObject(
0854: familyNode, testList);
0855: }
0856:
0857: /* Add test in model */
0858: DefaultMutableTreeNode testNode = dynTestTree
0859: .findRemoveTestNode(testName, testListName,
0860: familyName, false);
0861: if (testNode == null) {
0862: dynTestTree.addObject(testListNode, data);
0863: }
0864: }
0865: }
0866:
0867: }
0868:
0869: if (pTempNode.getChildCount() == 0) {
0870: // On Stop
0871: return;
0872: } else {
0873: int nbChild = pTempNode.getChildCount();
0874: int i = 0;
0875: while (i < nbChild) {
0876: getBijectiveSimpleDataTree(
0877: (DefaultMutableTreeNode) pTempNode
0878: .getChildAt(i), dynTestTree);
0879: i++;
0880: }
0881: }
0882: Util
0883: .log("[requirements] -> GenTestTools : addSimpleDataTree : end ");
0884: }
0885:
0886: // ADD by MM
0887: /**
0888: * Add the simpleData to the pCopyDynamicTestTree
0889: * @param data simpleData to add
0890: */
0891: static void addSimleDataToDynamicTestTree(SimpleData data) {
0892: Util
0893: .log("[requirements] -> GenTestTools : addSimleDataToDynamicTestTree("
0894: + data.getDescriptionFromModel() + ") : start ");
0895: if (data != null && data instanceof Test) {
0896: TestList testList = (TestList) ((Test) data)
0897: .getTestListFromModel();
0898: Family family = testList.getFamilyFromModel();
0899:
0900: String familyName = family.getNameFromModel();
0901: String testListName = testList.getNameFromModel();
0902: String testName = data.getNameFromModel();
0903:
0904: /* Add family if not in model*/
0905: DefaultMutableTreeNode familyNode = pCopyDynamicTestTree
0906: .findRemoveFamilyNode(familyName, false);
0907: if (familyNode == null) {
0908: familyNode = pCopyDynamicTestTree.addObject(null,
0909: family, false);
0910: }
0911:
0912: /* Add testList if not in model */
0913: DefaultMutableTreeNode testListNode = pCopyDynamicTestTree
0914: .findRemoveTestListNode(testListName, familyName,
0915: false);
0916: if (testListNode == null) {
0917: testListNode = pCopyDynamicTestTree.addObject(
0918: familyNode, testList, false);
0919: }
0920:
0921: /* Add test in model */
0922: DefaultMutableTreeNode testNode = pCopyDynamicTestTree
0923: .findRemoveTestNode(testName, testListName,
0924: familyName, false);
0925: if (testNode == null) {
0926: pCopyDynamicTestTree.addObject(testListNode, data,
0927: false);
0928: }
0929: }
0930: Util
0931: .log("[requirements] -> GenTestTools : addSimleDataToDynamicTestTree("
0932: + data.getDescriptionFromModel() + ") : end ");
0933: }
0934:
0935: /**
0936: * Remove the simpleData to the pCopyDynamicTestTree
0937: * @param data simpleData to remove
0938: */
0939: public static void removeSimpleDataToDynamicTestTree(SimpleData data) {
0940: Util
0941: .log("[requirements] -> GenTestTools : removeSimpleDataToDynamicTestTree("
0942: + data.getDescriptionFromModel() + ") : start ");
0943: if (data == null) {
0944: return;
0945: } else if (data instanceof Test) {
0946: TestList testList = (TestList) ((Test) data)
0947: .getTestListFromModel();
0948: Family family = testList.getFamilyFromModel();
0949: String familyName = family.getNameFromModel();
0950: String testListName = testList.getNameFromModel();
0951: String testName = data.getNameFromModel();
0952:
0953: DefaultMutableTreeNode testNode = pCopyDynamicTestTree
0954: .findRemoveTestNode(testName, testListName,
0955: familyName, false);
0956: if (testNode != null) {
0957: DefaultMutableTreeNode suiteNode = (DefaultMutableTreeNode) testNode
0958: .getParent();
0959: suiteNode.remove(testNode);
0960: if (suiteNode.getChildCount() == 0) {
0961: removeSimpleDataToDynamicTestTree((SimpleData) suiteNode
0962: .getUserObject());
0963: }
0964: }
0965: //remove testLinkToReq if link not in BDD
0966: removeNotDefaultReqBijectiveCovered(data.getNameFromModel());
0967: } else if (data instanceof TestList) {
0968: TestList testList = (TestList) data;
0969: Family family = testList.getFamilyFromModel();
0970: String familyName = family.getNameFromModel();
0971: String testListName = testList.getNameFromModel();
0972: DefaultMutableTreeNode testListNode = pCopyDynamicTestTree
0973: .findRemoveTestListNode(testListName, familyName,
0974: false);
0975: if (testListNode != null) {
0976: DefaultMutableTreeNode familyNode = (DefaultMutableTreeNode) testListNode
0977: .getParent();
0978: familyNode.remove(testListNode);
0979: if (familyNode.getChildCount() == 0) {
0980: removeSimpleDataToDynamicTestTree((SimpleData) familyNode
0981: .getUserObject());
0982: }
0983: }
0984: } else if (data instanceof Family) {
0985: Family family = (Family) data;
0986: String familyName = family.getNameFromModel();
0987: DefaultMutableTreeNode familNode = pCopyDynamicTestTree
0988: .findRemoveFamilyNode(familyName, false);
0989: if (familNode != null) {
0990: DefaultMutableTreeNode rootNode = (DefaultMutableTreeNode) familNode
0991: .getParent();
0992: rootNode.remove(familNode);
0993: }
0994: }
0995: Util
0996: .log("[requirements] -> GenTestTools : removeSimpleDataToDynamicTestTree("
0997: + data.getDescriptionFromModel() + ") : start ");
0998: }
0999:
1000: // ADD by MM
1001: /**
1002: * create a copy of a DynamicTree
1003: * @param _pDynamicTree
1004: * @return the new test dynamic tree
1005: */
1006: static SimpleDynamicTestTree createCopyOfTestTree(
1007: DynamicTree _pDynamicTree) {
1008: DefaultMutableTreeNode node = (DefaultMutableTreeNode) ((DefaultTreeModel) _pDynamicTree
1009: .getModel()).getRoot();
1010: DefaultMutableTreeNode nodeCopy = getCopyNode(node);
1011: SimpleDynamicTestTree _pCopyDynamicTestTree = new SimpleDynamicTestTree(
1012: nodeCopy, DataConstants.FAMILY);
1013: _pCopyDynamicTestTree.getModel().setRoot(nodeCopy);
1014: return _pCopyDynamicTestTree;
1015: }
1016:
1017: /**
1018: * create a copy of a node
1019: * @param node
1020: * @return the new copied node
1021: */
1022: static DefaultMutableTreeNode getCopyNode(
1023: DefaultMutableTreeNode node) {
1024: DefaultMutableTreeNode copy_node = new DefaultMutableTreeNode(
1025: node.getUserObject());
1026: int nbChild = node.getChildCount();
1027: if (nbChild == 0) {
1028: return copy_node;
1029: } else {
1030: int i = 0;
1031: while (i < nbChild) {
1032: DefaultMutableTreeNode child_copy = getCopyNode((DefaultMutableTreeNode) node
1033: .getChildAt(i));
1034: copy_node.insert(child_copy, i);
1035: i++;
1036: }
1037: }
1038: return copy_node;
1039: }
1040:
1041: /**
1042: * remove link from requirement if at least one test linked to it contains the same name
1043: * of the requirement. It removes also requirement leaf from the available requirement tree.
1044: * @param treeModel requirement tree model
1045: * @param pTempNode requirement node to start recursive function
1046: * @return true if one test have the same
1047: */
1048: public static boolean removeReqBijectiveLinked(
1049: DefaultTreeModel treeModel, DefaultMutableTreeNode pTempNode) {
1050: Requirement pTempReq = (Requirement) pTempNode.getUserObject();
1051: if (pTempReq instanceof ReqLeaf) {
1052: SimpleData pTest = getSimpleData(pTempReq, new Vector(),
1053: false);
1054: boolean res = false;
1055: if (pTest instanceof Test) {
1056: res = isReqBijectiveCovered(pTempReq, pTest
1057: .getNameFromModel());
1058: if (res) {
1059: treeModel.removeNodeFromParent(pTempNode);
1060: }
1061: }
1062: return res;
1063: } else {
1064: int nbChild = pTempNode.getChildCount();
1065: for (int i = 0; i < nbChild; i++) {
1066: if (removeReqBijectiveLinked(treeModel,
1067: (DefaultMutableTreeNode) pTempNode
1068: .getChildAt(i))) {
1069: i--;
1070: nbChild--;
1071: }
1072: }
1073: if (pTempNode.getChildCount() == 0
1074: && !pTempNode.equals(treeModel.getRoot())) {
1075: treeModel.removeNodeFromParent(pTempNode);
1076: return true;
1077: }
1078: }
1079: return false;
1080: }
1081:
1082: /**
1083: * Build the requirement tree without requirements linked to test which checks the bijection
1084: *
1085: */
1086: static void initReqLink() {
1087: DefaultMutableTreeNode node = (DefaultMutableTreeNode) ((DefaultTreeModel) pOrgReqTree
1088: .getModel()).getRoot();
1089: initReqWithTestLink((DefaultTreeModel) pOrgReqTree.getModel(),
1090: node);
1091: }
1092:
1093: /**
1094: * Init requirements by adding those which are linked to test
1095: * @param treeModel the requirement tree model
1096: * @param pTempNode the root node
1097: */
1098: static void initReqWithTestLink(DefaultTreeModel treeModel,
1099: DefaultMutableTreeNode pTempNode) {
1100: Requirement pTempReq = (Requirement) pTempNode.getUserObject();
1101: if (pTempReq instanceof ReqLeaf) {
1102: try {
1103: Vector testLinked = pTempReq
1104: .getTestWrapperCoveredFromDB();
1105: int testLinkedSize = testLinked.size();
1106: Vector linkedTestName = new Vector();
1107: Vector linkedTestName2 = new Vector();
1108:
1109: for (int i = 0; i < testLinkedSize; i++) {
1110: TestWrapper testWrap = (TestWrapper) testLinked
1111: .elementAt(i);
1112: linkedTestName.add(testWrap.getName());
1113: linkedTestName2.add(testWrap.getName());
1114: }
1115:
1116: //reqLink.put(pTempReq, linkedTestName);
1117: //defaultreqLink.put(pTempReq, linkedTestName2);
1118: reqLink
1119: .put(pTempReq.getNameFromModel(),
1120: linkedTestName);
1121: defaultreqLink.put(pTempReq.getNameFromModel(),
1122: linkedTestName2);
1123: } catch (Exception e) {
1124:
1125: //reqLink.put(pTempReq, new Vector());
1126: //defaultreqLink.put(pTempReq, new Vector());
1127: reqLink.put(pTempReq.getNameFromModel(), new Vector());
1128: defaultreqLink.put(pTempReq.getNameFromModel(),
1129: new Vector());
1130: }
1131: } else {
1132: int nbChild = pTempNode.getChildCount();
1133: for (int i = 0; i < nbChild; i++) {
1134: initReqWithTestLink(treeModel,
1135: (DefaultMutableTreeNode) pTempNode
1136: .getChildAt(i));
1137: }
1138: }
1139: }
1140:
1141: /**
1142: * Remove test link to the requirement
1143: * @param testName name of the test to unlink
1144: */
1145: static void removeNotDefaultReqBijectiveCovered(String testName) {
1146: Vector linkedReq = (Vector) testLink.get(testName);
1147: if (linkedReq == null) {
1148: return;
1149: }
1150: for (int i = 0; i < linkedReq.size(); i++) {
1151: Requirement pTempReq = (Requirement) linkedReq.elementAt(i);
1152: removeReqBijectiveCovered(pTempReq, testName);
1153:
1154: }
1155: }
1156:
1157: /**
1158: * Add test link to the requirement
1159: * @param pTempReq a requirement leaf
1160: * @param testName name of the test to add
1161: */
1162: static void addTestBijectiveCovered(Requirement pTempReq,
1163: String testName) {
1164: Vector linkedReq = (Vector) testLink.get(testName);
1165: if (linkedReq == null) {
1166: linkedReq = new Vector();
1167: linkedReq.add(pTempReq);
1168: testLink.put(testName, linkedReq);
1169: return;
1170: }
1171: if (!linkedReq.contains(pTempReq)) {
1172: linkedReq.add(pTempReq);
1173: }
1174: }
1175:
1176: /**
1177: * Remove link from test
1178: * @param pTempReq a requirement leaf
1179: * @param testName name of the test to unlink
1180: */
1181: static void removeTestBijectiveCovered(Requirement pTempReq,
1182: String testName) {
1183: Vector linkedReq = (Vector) testLink.get(testName);
1184: if (linkedReq == null) {
1185: linkedReq = new Vector();
1186: testLink.put(testName, linkedReq);
1187: return;
1188: }
1189: if (linkedReq.contains(pTempReq)) {
1190: linkedReq.remove(pTempReq);
1191: }
1192: }
1193:
1194: /**
1195: *
1196: * @param pTempReq a requirement leaf
1197: * @param testName name of the test
1198: * @return true if Requirement pTempReq is linked in DB with testName
1199: */
1200: public static boolean isReqDefaultCovered(Requirement pTempReq,
1201: String testName) {
1202: boolean covered = false;
1203: if (pTempReq instanceof ReqLeaf) {
1204: // Vector linkedTestName = (Vector) defaultreqLink.get(pTempReq);
1205: Vector linkedTestName = (Vector) defaultreqLink
1206: .get(pTempReq.getNameFromModel());
1207: return linkedTestName.contains(testName);
1208: }
1209: return covered;
1210: }
1211:
1212: /**
1213: *
1214: * @param pTempReq a requirement leaf
1215: * @param testName name of the test
1216: * @return Return true if Requirement is linked in model with testName
1217: */
1218: public static boolean isReqBijectiveCovered(Requirement pTempReq,
1219: String testName) {
1220: boolean covered = false;
1221: if (pTempReq instanceof ReqLeaf) {
1222: //Vector linkedTestName = (Vector) reqLink.get(pTempReq);
1223: Vector linkedTestName = (Vector) reqLink.get(pTempReq
1224: .getNameFromModel());
1225: return linkedTestName.contains(testName);
1226: }
1227: return covered;
1228: }
1229:
1230: /**
1231: *
1232: * @param pTempReq a requirement leaf
1233: * @param testName name of the test to add
1234: */
1235: static void addReqBijectiveCovered(Requirement pTempReq,
1236: String testName) {
1237: if (pTempReq instanceof ReqLeaf) {
1238: //Vector linkedTestName = (Vector) reqLink.get(pTempReq);
1239: Vector linkedTestName = (Vector) reqLink.get(pTempReq
1240: .getNameFromModel());
1241: if (!linkedTestName.contains(testName)) {
1242: linkedTestName.add(testName);
1243: }
1244: addTestBijectiveCovered(pTempReq, testName);
1245: }
1246: }
1247:
1248: /**
1249: * Remove link from requirement
1250: * @param pTempReq the selected requirement
1251: * @param testName the name of the test
1252: */
1253: static void removeReqBijectiveCovered(Requirement pTempReq,
1254: String testName) {
1255: if (pTempReq instanceof ReqLeaf) {
1256: //Vector linkedTestName = (Vector) reqLink.get(pTempReq);
1257: Vector linkedTestName = (Vector) reqLink.get(pTempReq
1258: .getNameFromModel());
1259: if (linkedTestName.contains(testName)) {
1260: linkedTestName.remove(testName);
1261: }
1262: }
1263: }
1264:
1265: /**
1266: * print all requirements links
1267: *
1268: */
1269: /* static public void printData(){
1270: Enumeration reqEnum = defaultreqLink.keys();
1271: System.out.println("Database Req Cover");
1272: while (reqEnum.hasMoreElements()){
1273: Requirement pTempReq = (Requirement) reqEnum.nextElement();
1274:
1275: System.out.println("\tReq "+ pTempReq + " is cover by");
1276: Vector linkedTestName = (Vector) defaultreqLink.get(pTempReq);
1277: for (int i = 0; i < linkedTestName.size(); i++){
1278: System.out.println("\t\t test "+ linkedTestName.elementAt(i));
1279: }
1280: }
1281: System.out.println("");
1282:
1283: reqEnum = reqLink.keys();
1284: System.out.println("Model Req Cover");
1285: while (reqEnum.hasMoreElements()){
1286: Requirement pTempReq = (Requirement) reqEnum.nextElement();
1287: System.out.println("\tReq "+ pTempReq + "( "+ ((Object)pTempReq).hashCode() +") is cover by");
1288: Vector linkedTestName = (Vector) reqLink.get(pTempReq);
1289: for (int i = 0; i < linkedTestName.size(); i++){
1290: System.out.println("\t\t test "+ linkedTestName.elementAt(i));
1291: }
1292: }
1293: }*/
1294:
1295: /**
1296: * Find a node by name in tree
1297: * @param pTempNode
1298: * @param name
1299: * @return
1300: */
1301: /*static DefaultMutableTreeNode searchString(DefaultMutableTreeNode pTempNode, String name) {
1302: Requirement pTempReq = (Requirement)pTempNode.getUserObject();
1303: DefaultMutableTreeNode retNode = null;
1304: if (pTempReq.getNameFromModel().equals(name)) {
1305: return pTempNode;
1306: } else {
1307: int nbChild = pTempNode.getChildCount();
1308: boolean trouve = false;
1309: int i = 0;
1310: while (i< nbChild && !trouve){
1311: retNode = searchString((DefaultMutableTreeNode)pTempNode.getChildAt(i), name);
1312: if (retNode != null){
1313: trouve = true;
1314: }
1315: i++;
1316: }
1317: return retNode;
1318: }
1319: }*/
1320: }
|