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.databaseSQL;
025:
026: import org.objectweb.salome_tmf.api.IChangeDispatcher;
027: import org.objectweb.salome_tmf.api.ISafeThread;
028: import org.objectweb.salome_tmf.api.sql.IDataBase;
029: import org.objectweb.salome_tmf.api.sql.ISQLAction;
030: import org.objectweb.salome_tmf.api.sql.ISQLAttachment;
031: import org.objectweb.salome_tmf.api.sql.ISQLAutomaticTest;
032: import org.objectweb.salome_tmf.api.sql.ISQLCampaign;
033: import org.objectweb.salome_tmf.api.sql.ISQLConfig;
034: import org.objectweb.salome_tmf.api.sql.ISQLDataset;
035: import org.objectweb.salome_tmf.api.sql.ISQLEngine;
036: import org.objectweb.salome_tmf.api.sql.ISQLEnvironment;
037: import org.objectweb.salome_tmf.api.sql.ISQLExecution;
038: import org.objectweb.salome_tmf.api.sql.ISQLExecutionActionResult;
039: import org.objectweb.salome_tmf.api.sql.ISQLExecutionResult;
040: import org.objectweb.salome_tmf.api.sql.ISQLExecutionTestResult;
041: import org.objectweb.salome_tmf.api.sql.ISQLFamily;
042: import org.objectweb.salome_tmf.api.sql.ISQLFileAttachment;
043: import org.objectweb.salome_tmf.api.sql.ISQLGroup;
044: import org.objectweb.salome_tmf.api.sql.ISQLManualTest;
045: import org.objectweb.salome_tmf.api.sql.ISQLObjectFactory;
046: import org.objectweb.salome_tmf.api.sql.ISQLParameter;
047: import org.objectweb.salome_tmf.api.sql.ISQLPersonne;
048: import org.objectweb.salome_tmf.api.sql.ISQLProject;
049: import org.objectweb.salome_tmf.api.sql.ISQLSalomeLock;
050: import org.objectweb.salome_tmf.api.sql.ISQLScript;
051: import org.objectweb.salome_tmf.api.sql.ISQLSession;
052: import org.objectweb.salome_tmf.api.sql.ISQLTest;
053: import org.objectweb.salome_tmf.api.sql.ISQLTestList;
054: import org.objectweb.salome_tmf.api.sql.ISQLUrlAttachment;
055:
056: public class SQLObjectFactoryMSServer implements ISQLObjectFactory {
057:
058: static SQLManualTest pISQLManualTest = null;
059: static SQLAction pISQLAction = null;
060: static ISQLParameter pISQLParameter = null;
061: static ISQLAttachment pISQLAttachment = null;
062: static ISQLUrlAttachment pISQLUrlAttachment = null;
063: static ISQLFileAttachment pISQLFileAttachment = null;
064: static ISQLTestList pISQLTestList = null;
065: static ISQLAutomaticTest pISQLAutomaticTest = null;
066: static ISQLCampaign pISQLCampaign = null;
067: static ISQLScript pISQLScript = null;
068: static ISQLPersonne pISQLPersonne = null;
069: static ISQLFamily pISQLFamily = null;
070: static ISQLTest pISQLTest = null;
071: static ISQLProject pISQLProject = null;
072: static ISQLEnvironment pISQLEnvironment = null;
073: static ISQLExecution pISQLExecution = null;
074: static ISQLExecutionResult pISQLExecutionResult = null;
075: static ISQLExecutionTestResult pISQLExecutionTestResult = null;
076: static ISQLExecutionActionResult pISQLExecutionActionResult = null;
077: static ISQLDataset pISQLDataset = null;
078: static SQLEngine pSQLEngine = null;
079: static ChangeListener pChangeListener = null;
080: static ISQLSession pISQLSession = null;
081: static ISQLGroup pSQLGroup = null;
082: protected static ISQLConfig pSQLConfig = null;
083: static ISQLSalomeLock pSQLSalomeLock = null;
084:
085: static int projectID = 0;
086: static int personneID = 0;
087: DataBase pDB;
088:
089: public ISQLEngine getInstanceOfSQLEngine(String url,
090: String username, String password,
091: IChangeDispatcher pIChangeDispatcher, int pid,
092: String driverJDBC, int locktype) throws Exception {
093: if (pSQLEngine == null) {
094: pDB = new DataBase(driverJDBC);
095: pDB.open(url, username, password);
096: pSQLEngine = new SQLEngine();
097: SQLEngine.initSQLEngine(pDB, true,
098: "/org/objectweb/salome_tmf/databaseSQL/mssql/",
099: locktype);
100: pChangeListener = new ChangeListener(pid,
101: pIChangeDispatcher);
102: } else {
103: pDB = new DataBase(driverJDBC);
104: pDB.open(url, username, password);
105: pSQLEngine.initDB(pDB);
106: }
107: return pSQLEngine;
108: }
109:
110: public ISQLEngine getCurrentSQLEngine() {
111: return pSQLEngine;
112: }
113:
114: public String getSalomeVersion() {
115: return "INVALID";
116: }
117:
118: public IDataBase getInstanceOfDataBase(String driver)
119: throws Exception {
120: DataBase db = new DataBase(driver);
121: return (IDataBase) db;
122: }
123:
124: public IDataBase getInstanceOfSalomeDataBase() throws Exception {
125: return (IDataBase) pDB;
126: }
127:
128: public ISafeThread getChangeListener(String projet) {
129: pChangeListener.setProjet(projet);
130: return pChangeListener;
131: }
132:
133: public void changeListenerProject(String projet) {
134: pChangeListener.setProjet(projet);
135: }
136:
137: public ISQLSalomeLock getISQLSalomeLock() {
138: return getInstanceOfISQLSalomeLock();
139: }
140:
141: static ISQLSalomeLock getInstanceOfISQLSalomeLock() {
142: if (pSQLSalomeLock == null) {
143: pSQLSalomeLock = new SQLSalomeLock();
144: }
145: return pSQLSalomeLock;
146: }
147:
148: public ISQLConfig getISQLConfig() {
149: return getInstanceOfISQLConfig();
150: }
151:
152: static ISQLConfig getInstanceOfISQLConfig() {
153: if (pSQLConfig == null) {
154: pSQLConfig = new SQLConfig();
155: }
156: return pSQLConfig;
157: }
158:
159: public ISQLGroup getISQLGroup() {
160: return getInstanceOfISQLGroup();
161: }
162:
163: static ISQLGroup getInstanceOfISQLGroup() {
164: if (pSQLGroup == null) {
165: pSQLGroup = new SQLGroup();
166: }
167: return pSQLGroup;
168: }
169:
170: public ISQLSession getISQLSession() {
171: return getInstanceOfISQLSession();
172: }
173:
174: static ISQLSession getInstanceOfISQLSession() {
175: if (pISQLSession == null) {
176: pISQLSession = new SQLSession();
177: }
178: return pISQLSession;
179: }
180:
181: public ISQLDataset getISQLDataset() {
182: return getInstanceOfISQLDataset();
183: }
184:
185: static ISQLDataset getInstanceOfISQLDataset() {
186: if (pISQLDataset == null) {
187: pISQLDataset = new SQLDataset();
188: }
189: return pISQLDataset;
190: }
191:
192: public ISQLExecutionActionResult getISQLExecutionActionResult() {
193: return getInstanceOfISQLExecutionActionResult();
194: }
195:
196: static ISQLExecutionActionResult getInstanceOfISQLExecutionActionResult() {
197: if (pISQLExecutionActionResult == null) {
198: pISQLExecutionActionResult = new SQLExecutionActionResult();
199: }
200: return pISQLExecutionActionResult;
201: }
202:
203: public ISQLExecutionTestResult getISQLExecutionTestResult() {
204: return getInstanceOfISQLExecutionTestResult();
205: }
206:
207: static ISQLExecutionTestResult getInstanceOfISQLExecutionTestResult() {
208: if (pISQLExecutionTestResult == null) {
209: pISQLExecutionTestResult = new SQLExecutionTestResult();
210: }
211: return pISQLExecutionTestResult;
212: }
213:
214: public ISQLExecutionResult getISQLExecutionResult() {
215: return getInstanceOfISQLExecutionResult();
216: }
217:
218: static ISQLExecutionResult getInstanceOfISQLExecutionResult() {
219: if (pISQLExecutionResult == null) {
220: pISQLExecutionResult = new SQLExecutionResult();
221: }
222: return pISQLExecutionResult;
223: }
224:
225: public ISQLExecution getISQLExecution() {
226: return getInstanceOfISQLExecution();
227: }
228:
229: static ISQLExecution getInstanceOfISQLExecution() {
230: if (pISQLExecution == null) {
231: pISQLExecution = new SQLExecution();
232: }
233: return pISQLExecution;
234: }
235:
236: public ISQLEnvironment getISQLEnvironment() {
237: return getInstanceOfISQLEnvironment();
238: }
239:
240: static ISQLEnvironment getInstanceOfISQLEnvironment() {
241: if (pISQLEnvironment == null) {
242: pISQLEnvironment = new SQLEnvironment();
243: }
244: return pISQLEnvironment;
245: }
246:
247: public ISQLProject getISQLProject() {
248: return getInstanceOfISQLProject();
249: }
250:
251: static ISQLProject getInstanceOfISQLProject() {
252: if (pISQLProject == null) {
253: pISQLProject = new SQLProject();
254: }
255: return pISQLProject;
256: }
257:
258: public ISQLTest getISQLTest() {
259: return getInstanceOfISQLTest();
260: }
261:
262: static ISQLTest getInstanceOfISQLTest() {
263: if (pISQLTest == null) {
264: pISQLTest = new SQLTest();
265: }
266: return pISQLTest;
267: }
268:
269: public ISQLFamily getISQLFamily() {
270: return getInstanceOfISQLFamily();
271: }
272:
273: static ISQLFamily getInstanceOfISQLFamily() {
274: if (pISQLFamily == null) {
275: pISQLFamily = new SQLFamily();
276: }
277: return pISQLFamily;
278: }
279:
280: public ISQLPersonne getISQLPersonne() {
281: return getInstanceOfISQLPersonne();
282: }
283:
284: static ISQLPersonne getInstanceOfISQLPersonne() {
285: if (pISQLPersonne == null) {
286: pISQLPersonne = new SQLPersonne();
287: }
288: return pISQLPersonne;
289: }
290:
291: public ISQLScript getISQLScript() {
292: return getInstanceOfISQLScript();
293: }
294:
295: static ISQLScript getInstanceOfISQLScript() {
296: if (pISQLScript == null) {
297: pISQLScript = new SQLScript();
298: }
299: return pISQLScript;
300: }
301:
302: public ISQLCampaign getISQLCampaign() {
303: return getInstanceOfISQLCampaign();
304: }
305:
306: static ISQLCampaign getInstanceOfISQLCampaign() {
307: if (pISQLCampaign == null) {
308: pISQLCampaign = new SQLCampaign();
309: }
310: return pISQLCampaign;
311: }
312:
313: public ISQLAutomaticTest getISQLAutomaticTest() {
314: return getInstanceOfISQLAutomaticTest();
315: }
316:
317: static ISQLAutomaticTest getInstanceOfISQLAutomaticTest() {
318: if (pISQLAutomaticTest == null) {
319: pISQLAutomaticTest = new SQLAutomaticTest();
320: }
321: return pISQLAutomaticTest;
322: }
323:
324: public ISQLTestList getISQLTestList() {
325: return getInstanceOfISQLTestList();
326: }
327:
328: static ISQLTestList getInstanceOfISQLTestList() {
329: if (pISQLTestList == null) {
330: pISQLTestList = new SQLTestList();
331: }
332: return pISQLTestList;
333: }
334:
335: public ISQLFileAttachment getISQLFileAttachment() {
336: return getInstanceOfISQLFileAttachment();
337: }
338:
339: static ISQLFileAttachment getInstanceOfISQLFileAttachment() {
340: if (pISQLFileAttachment == null) {
341: pISQLFileAttachment = new SQLFileAttachment();
342: }
343: return pISQLFileAttachment;
344: }
345:
346: public ISQLUrlAttachment getISQLUrlAttachment() {
347: return getInstanceOfISQLUrlAttachment();
348: }
349:
350: static ISQLUrlAttachment getInstanceOfISQLUrlAttachment() {
351: if (pISQLUrlAttachment == null) {
352: pISQLUrlAttachment = new SQLUrlAttachment();
353: }
354: return pISQLUrlAttachment;
355: }
356:
357: public ISQLAttachment getISQLAttachment() {
358: return getInstanceOfISQLAttachment();
359: }
360:
361: static ISQLAttachment getInstanceOfISQLAttachment() {
362: if (pISQLAttachment == null) {
363: pISQLAttachment = new SQLAttachment();
364: }
365: return pISQLAttachment;
366: }
367:
368: public ISQLParameter getISQLParameter() {
369: return getInstanceOfISQLParameter();
370: }
371:
372: static ISQLParameter getInstanceOfISQLParameter() {
373: if (pISQLParameter == null) {
374: pISQLParameter = new SQLParameter();
375: }
376: return pISQLParameter;
377: }
378:
379: public ISQLAction getISQLAction() {
380: return getInstanceOfISQLAction();
381: }
382:
383: static public ISQLAction getInstanceOfISQLAction() {
384: if (pISQLAction == null) {
385: pISQLAction = new SQLAction();
386: }
387: return pISQLAction;
388: }
389:
390: public ISQLManualTest getISQLManualTest() {
391: return getInstanceOfISQLManualTest();
392: }
393:
394: static public ISQLManualTest getInstanceOfISQLManualTest() {
395: if (pISQLManualTest == null) {
396: pISQLManualTest = new SQLManualTest();
397: }
398: return pISQLManualTest;
399: }
400:
401: public void setConnexionInfo(int _projectID, int _personneID) {
402: projectID = _projectID;
403: personneID = _personneID;
404: }
405:
406: public int getProjectID() {
407: return projectID;
408: }
409:
410: public int getPersonneID() {
411: return personneID;
412: }
413: }
|