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 org.objectweb.salome_tmf.data;
025:
026: import java.util.HashMap;
027:
028: import org.objectweb.salome_tmf.api.Api;
029: import org.objectweb.salome_tmf.api.sql.ISQLExecutionActionResult;
030:
031: public class ManualExecutionResult extends ExecutionTestResult {
032:
033: static ISQLExecutionActionResult pISQLExecutionActionResult = null;
034:
035: protected HashMap actionsMap;
036: protected HashMap effectivResultMap;
037: protected HashMap descriptionResultMap;
038: protected HashMap awaitedResultMap;
039:
040: public ManualExecutionResult(ManualTest pTest) {
041: super (pTest);
042: actionsMap = new HashMap();
043: effectivResultMap = new HashMap();
044: descriptionResultMap = new HashMap();
045: awaitedResultMap = new HashMap();
046: if (pISQLExecutionActionResult == null) {
047: pISQLExecutionActionResult = Api.getISQLObjectFactory()
048: .getISQLExecutionActionResult();
049: }
050: }
051:
052: public ManualExecutionResult(ManualTest pTest, String status) {
053: super (pTest, status);
054: actionsMap = new HashMap();
055: effectivResultMap = new HashMap();
056: descriptionResultMap = new HashMap();
057: awaitedResultMap = new HashMap();
058: if (pISQLExecutionActionResult == null) {
059: pISQLExecutionActionResult = Api.getISQLObjectFactory()
060: .getISQLExecutionActionResult();
061: }
062: }
063:
064: public void setActionsMapInModel(HashMap map) {
065: actionsMap = map;
066: }
067:
068: public void setEffectivResultMapInModel(HashMap map) {
069: effectivResultMap = map;
070: }
071:
072: public void setAwaitedResultMapInModel(HashMap map) {
073: awaitedResultMap = map;
074: }
075:
076: public void setDescriptionResultMapInModel(HashMap map) {
077: descriptionResultMap = map;
078: }
079:
080: public void addStatusForActionInModel(Action action, String status) {
081: actionsMap.put(action, status);
082: }
083:
084: public void addEffectivResultInModel(Action act, String result) {
085: effectivResultMap.put(act, result);
086: }
087:
088: public void addDescriptionResultInModel(Action act, String descr) {
089: descriptionResultMap.put(act, descr);
090: }
091:
092: public void addAwaitedResultInModel(Action act, String result) {
093: awaitedResultMap.put(act, result);
094: }
095:
096: public void removeActionStatusInModel(Action action) {
097: actionsMap.remove(action);
098: }
099:
100: public void removeEffectivResultInModel(Action act) {
101: effectivResultMap.remove(act);
102: }
103:
104: public void removeDescriptionResultInModel(Action act) {
105: descriptionResultMap.remove(act);
106: }
107:
108: public void removeAwaitedResultInModel(Action act) {
109: awaitedResultMap.remove(act);
110: }
111:
112: public HashMap getActionsMapInModel() {
113: return actionsMap;
114: }
115:
116: public HashMap getEffectivResultMapFromModel() {
117: return effectivResultMap;
118: }
119:
120: public HashMap getAwaitedResultMapFromModel() {
121: return awaitedResultMap;
122: }
123:
124: public HashMap getDescriptionResultMapFromModel() {
125: return descriptionResultMap;
126: }
127:
128: public String getEffectivResultFromModel(Action act) {
129: return (String) effectivResultMap.get(act);
130: }
131:
132: public String getDescriptionResultFromModel(Action act) {
133: return (String) descriptionResultMap.get(act);
134: }
135:
136: public String getAwaitedResultFromModel(Action act) {
137: return (String) awaitedResultMap.get(act);
138: }
139:
140: public String getActionStatusInModel(Action action) {
141: String result = (String) actionsMap.get(action);
142: if (result == null) {
143: return "";
144: }
145: return result;
146: }
147:
148: int addActionResultInDB(Action action) throws Exception {
149: if (!isInBase()) {
150: throw new Exception("ExecutionTestResult " + name
151: + " is not in BDD");
152: }
153: int id = pISQLExecutionActionResult.insert(idBdd, action
154: .getIdBdd(), getDescriptionResultFromModel(action),
155: getAwaitedResultFromModel(action),
156: getEffectivResultFromModel(action),
157: getActionStatusInModel(action));
158: return id;
159: }
160:
161: public void updateActionEffectiveResInDB(Action action)
162: throws Exception {
163: if (!isInBase()) {
164: throw new Exception("ExecutionTestResult " + name
165: + " is not in BDD");
166: }
167: pISQLExecutionActionResult.update(idBdd, action.getIdBdd(),
168: getEffectivResultFromModel(action),
169: getActionStatusInModel(action));
170: }
171:
172: public void updateActionResInDB(Action action) throws Exception {
173: if (!isInBase()) {
174: throw new Exception("ExecutionTestResult " + name
175: + " is not in BDD");
176: }
177: pISQLExecutionActionResult.update(idBdd, action.getIdBdd(),
178: getDescriptionResultFromModel(action),
179: getAwaitedResultFromModel(action),
180: getEffectivResultFromModel(action),
181: getActionStatusInModel(action));
182: }
183:
184: void deleteInModel() {
185: test = null;
186: actionsMap.clear();
187: effectivResultMap.clear();
188: descriptionResultMap.clear();
189: awaitedResultMap.clear();
190: clearAttachInModel();
191: }
192:
193: void deleteInDBAndModel() throws Exception {
194: deleteInDB();
195: deleteInModel();
196: }
197: }
|