001: /*
002: * SalomeTMF is a Test Management Framework
003: * Copyright (C) 2005 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * @author Marche Mikael
020: *
021: * Contact: mikael.marche@rd.francetelecom.com
022: */
023:
024: package salomeTMF_plug.requirements.data;
025:
026: import org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel;
027:
028: import salomeTMF_plug.requirements.ReqPlugin;
029: import salomeTMF_plug.requirements.sqlWrapper.ReqWrapper;
030:
031: public class ReqLeaf extends Requirement {
032:
033: //FROM 1.2
034: int priority = 100;
035: String version;
036:
037: //FROM 1.3
038: int cat;
039: int complexe;
040: String origine;
041: String reference;
042: int state;
043: String verif;
044:
045: public ReqLeaf(String name, String description, ReqFamily parent,
046: int p) {
047: super (name, description, parent);
048: //FROM 1.2
049: priority = p;
050: version = "1"; //Default
051: //FROM 1.3
052: cat = 0;
053: complexe = 100;
054: origine = "Marketing";
055: state = 0;
056: verif = "";
057: reference = "";
058: }
059:
060: public ReqLeaf(ReqWrapper pReqWrapper, ReqFamily parent) {
061: super (pReqWrapper.getName(), pReqWrapper.getDescription(),
062: parent);
063: idBdd = pReqWrapper.getIdBDD();
064: //FROM 1.2
065: priority = pReqWrapper.getPriority();
066: version = pReqWrapper.getVersion();
067: //FROM 1.3
068: cat = pReqWrapper.getCat();
069: complexe = pReqWrapper.getComplexe();
070: origine = pReqWrapper.getOrigine();
071: state = pReqWrapper.getState();
072: verif = pReqWrapper.getVerif();
073: reference = pReqWrapper.getReference();
074: //LoadAttachement
075: }
076:
077: public Requirement getCopie(ReqFamily pReqFamily) {
078: ReqLeaf pReq = new ReqLeaf(name, description, pReqFamily,
079: priority);
080: //FROM 1.2
081: if (version != null) {
082: pReq.version = version;
083: }
084: //FROM 1.3
085: pReq.cat = cat;
086: pReq.complexe = complexe;
087: if (origine != null) {
088: pReq.origine = origine;
089: }
090: pReq.state = state;
091: if (verif != null) {
092: pReq.verif = verif;
093: }
094: if (reference != null) {
095: pReq.reference = reference;
096: }
097: //LoadAttachement
098: return pReq;
099: }
100:
101: public boolean isFamilyReq() {
102: return false;
103: }
104:
105: public int getPriorityFromModel() {
106: return priority;
107: }
108:
109: public String getVersionFromModel() {
110: return version;
111: }
112:
113: public String getReferenceFromModel() {
114: return reference;
115: }
116:
117: public int getCatFromModel() {
118: return cat;
119: }
120:
121: public int getComplexeFromModel() {
122: return complexe;
123: }
124:
125: public String getOrigineFromModel() {
126: return origine;
127: }
128:
129: public int getStateFromModel() {
130: return state;
131: }
132:
133: public String getVerifFromModel() {
134: return verif;
135: }
136:
137: public String toString() {
138: return "Req : " + name;
139: }
140:
141: public String getLongName() {
142: if (m_parent != null) {
143: //return m_parent.getLongName() + "->" + name;
144: String parentName = m_parent.getLongName();
145: if (parentName != "") {
146: return parentName + "->" + name;
147: } else {
148: return name;
149: }
150: } else {
151: return name;
152: }
153: //return "Req : " + name;
154: }
155:
156: void deleteInModel() {
157: ((ReqFamily) m_parent).removeRequirment(this );
158: }
159:
160: public void addInDB() throws Exception {
161: if (isInBase()) {
162: throw new Exception(
163: "[ReqLeaf->addInDB] requirement already in base");
164: }
165: if (!(m_parent instanceof ReqFamily)) {
166: throw new Exception(
167: "[ReqLeaf->addInDB] requirement must have family in parent");
168: }
169: int idParent = m_parent.getIdBdd();
170: idBdd = pSQLRequirement.add(name, description, 1, idParent,
171: ReqPlugin.getProjectRef().getIdBdd(), priority);
172: coverChange = true;
173: }
174:
175: public void addTestCoverInDB(int idTest, boolean verifie)
176: throws Exception {
177: if (!isInBase()) {
178: throw new Exception(
179: "[ReqLeaf->addTestCover] requirment is not DB");
180: }
181: if (verifie) {
182: if (!pSQLRequirement.isReqReqCoveredByTest(idBdd, idTest)) {
183: pSQLRequirement.addReqConvert(idBdd, idTest);
184: }
185: } else {
186: pSQLRequirement.addReqConvert(idBdd, idTest);
187: }
188: coverChange = true;
189: }
190:
191: public void updateVersionInModel(String _version) {
192: version = _version;
193: }
194:
195: public void updateVersionInDB(String _version) throws Exception {
196: if (!isInBase()) {
197: throw new Exception(
198: "[Requirement->updateVersionInDB] requirement is not in DB");
199: }
200: pSQLRequirement.updateVersion(idBdd, _version);
201: }
202:
203: public void updateVersionInDBAndModel(String _version)
204: throws Exception {
205: if (_version.trim().equals(version.trim())) {
206: return;
207: }
208: updateVersionInDB(_version);
209: updateVersionInModel(_version);
210: }
211:
212: public void updateReferenceInModel(String _reference) {
213: reference = _reference;
214: }
215:
216: public void updateReferenceInDB(String _reference) throws Exception {
217: if (!isInBase()) {
218: throw new Exception(
219: "[Requirement->updateReferenceInDB] requirement is not in DB");
220: }
221: pSQLRequirement.updateReference(idBdd, _reference);
222: }
223:
224: public void updateReferenceInDBAndModel(String _reference)
225: throws Exception {
226: if (_reference.trim().equals(reference.trim())) {
227: return;
228: }
229: updateReferenceInDB(_reference);
230: updateReferenceInModel(_reference);
231: }
232:
233: public void updateInfoInDB(String _version, String _origine,
234: String _verif, String _reference) throws Exception {
235: if (!isInBase()) {
236: throw new Exception(
237: "[Requirement->updateVersionInDB] requirement is not in DB");
238: }
239: pSQLRequirement.updateInfo(idBdd, _version, _origine, _verif,
240: _reference);
241: }
242:
243: public void updateInfoInDBAndModel(String _version,
244: String _origine, String _verif, String _reference)
245: throws Exception {
246: updateInfoInDB(_version, _origine, _verif, _reference);
247: updateVersionInModel(_version);
248: updateOrigineInModel(_origine);
249: updateVerifInModel(_verif);
250: updateReferenceInModel(_reference);
251: }
252:
253: public void updatePriorityInModel(int _priority) {
254: priority = _priority;
255: }
256:
257: public void updatePriorityInDB(int _priority) throws Exception {
258: if (!isInBase()) {
259: throw new Exception(
260: "[Requirement->updatePriorityInDB] requirement is not in DB");
261: }
262: pSQLRequirement.updatePriority(idBdd, _priority);
263: }
264:
265: public void updatePriorityInDBAndModel(int _priority)
266: throws Exception {
267: if (_priority == priority) {
268: return;
269: }
270: updatePriorityInDB(_priority);
271: updatePriorityInModel(_priority);
272: }
273:
274: public void updateCatInModel(int _cat) {
275: this .cat = _cat;
276: }
277:
278: public void updateCatInDB(int _cat) throws Exception {
279: if (!isInBase()) {
280: throw new Exception(
281: "[Requirement->updateCatInDB] requirement is not in DB");
282: }
283: pSQLRequirement.updateCat(idBdd, _cat);
284: }
285:
286: public void updateCatInDBAndModel(int _cat) throws Exception {
287: if (_cat == cat) {
288: return;
289: }
290: updateCatInDB(_cat);
291: updateCatInModel(_cat);
292: }
293:
294: public void updateComplexeInModel(int _complexe) {
295: this .complexe = _complexe;
296: }
297:
298: public void updateComplexeInDB(int _complexe) throws Exception {
299: if (!isInBase()) {
300: throw new Exception(
301: "[Requirement->updateComplexeInDB] requirement is not in DB");
302: }
303: pSQLRequirement.updateComplexe(idBdd, _complexe);
304: }
305:
306: public void updateComplexeInDBAndModel(int _complexe)
307: throws Exception {
308: if (_complexe == complexe) {
309: return;
310: }
311: updateComplexeInDB(_complexe);
312: updateComplexeInModel(_complexe);
313: }
314:
315: public void updateOrigineInModel(String _origine) {
316: this .origine = _origine;
317: }
318:
319: public void updateOrigineInDB(String _origine) throws Exception {
320: if (!isInBase()) {
321: throw new Exception(
322: "[Requirement->updateOrigineInDB] requirement is not in DB");
323: }
324: pSQLRequirement.updateOrigine(idBdd, _origine);
325: }
326:
327: public void updateOrigineInDBAndModel(String _origine)
328: throws Exception {
329: if (_origine.trim().equals(origine.trim())) {
330: return;
331: }
332: updateOrigineInDB(_origine);
333: updateOrigineInModel(_origine);
334: }
335:
336: public void updateStateInModel(int _state) {
337: this .state = _state;
338: }
339:
340: public void updateStateInDB(int _state) throws Exception {
341: if (!isInBase()) {
342: throw new Exception(
343: "[Requirement->updateStateInDB] requirement is not in DB");
344: }
345: pSQLRequirement.updateState(idBdd, _state);
346: }
347:
348: public void updateStateInDBAndModel(int _state) throws Exception {
349: if (_state == state) {
350: return;
351: }
352: updateStateInDB(_state);
353: updateStateInModel(_state);
354: }
355:
356: public void updateVerifInModel(String _verif) {
357: this .verif = _verif;
358: }
359:
360: public void updateVerifInDB(String _verif) throws Exception {
361: if (!isInBase()) {
362: throw new Exception(
363: "[Requirement->updateVerifInDB] requirement is not in DB");
364: }
365: pSQLRequirement.updateVerif(idBdd, _verif);
366: }
367:
368: public void updateVerifInDBAndModel(String _verif) throws Exception {
369: if (_verif.trim().equals(verif.trim())) {
370: return;
371: }
372: updateVerifInDB(_verif);
373: updateVerifInModel(_verif);
374: }
375: }
|