KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > appmappersistence > DODSApplicationMappingMgr


1
2 package org.enhydra.shark.appmappersistence;
3
4 import java.math.BigDecimal JavaDoc;
5 import java.util.ArrayList JavaDoc;
6 import java.util.List JavaDoc;
7
8 import org.enhydra.dods.DODS;
9 import org.enhydra.shark.api.ApplicationMappingTransaction;
10 import org.enhydra.shark.api.RootException;
11 import org.enhydra.shark.api.TransactionException;
12 import org.enhydra.shark.api.internal.appmappersistence.ApplicationMap;
13 import org.enhydra.shark.api.internal.appmappersistence.ApplicationMappingManager;
14 import org.enhydra.shark.api.internal.working.CallbackUtilities;
15 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppDO;
16 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppQuery;
17 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppTAAppDetailDO;
18 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppTAAppDetailQuery;
19 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppTAAppDetailUsrDO;
20 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppTAAppDetailUsrQuery;
21 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppTAAppUserDO;
22 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppTAAppUserQuery;
23 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppToolAgentAppDO;
24 import org.enhydra.shark.appmappersistence.data.PackLevelXPDLAppToolAgentAppQuery;
25 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppDO;
26 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppQuery;
27 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppTAAppDetailDO;
28 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppTAAppDetailQuery;
29 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppTAAppDetailUsrDO;
30 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppTAAppDetailUsrQuery;
31 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppTAAppUserDO;
32 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppTAAppUserQuery;
33 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppToolAgentAppDO;
34 import org.enhydra.shark.appmappersistence.data.ProcLevelXPDLAppToolAgentAppQuery;
35 import org.enhydra.shark.appmappersistence.data.ToolAgentAppDO;
36 import org.enhydra.shark.appmappersistence.data.ToolAgentAppDetailDO;
37 import org.enhydra.shark.appmappersistence.data.ToolAgentAppDetailQuery;
38 import org.enhydra.shark.appmappersistence.data.ToolAgentAppDetailUserDO;
39 import org.enhydra.shark.appmappersistence.data.ToolAgentAppDetailUserQuery;
40 import org.enhydra.shark.appmappersistence.data.ToolAgentAppQuery;
41 import org.enhydra.shark.appmappersistence.data.ToolAgentAppUserDO;
42 import org.enhydra.shark.appmappersistence.data.ToolAgentAppUserQuery;
43 import org.enhydra.shark.appmappersistence.data.ToolAgentUserDO;
44 import org.enhydra.shark.appmappersistence.data.ToolAgentUserQuery;
45 import org.enhydra.shark.appmappersistence.data.XPDLApplicationPackageDO;
46 import org.enhydra.shark.appmappersistence.data.XPDLApplicationPackageQuery;
47 import org.enhydra.shark.appmappersistence.data.XPDLApplicationProcessDO;
48 import org.enhydra.shark.appmappersistence.data.XPDLApplicationProcessQuery;
49
50 import com.lutris.appserver.server.sql.DBTransaction;
51
52
53 /**
54  * Implementation of ApplicationMappingsManager interface
55  *
56  * @author Zoran Milakovic
57  * @author Tanja Jovanovic
58  */

59 public class DODSApplicationMappingMgr implements ApplicationMappingManager
60 {
61    private final String JavaDoc COUNTER_NAME = "APPLICATIONMAPPINGS";
62
63    public static boolean _debug_ = false;
64
65    private static final String JavaDoc DBG_PARAM_NAME = "DODSApplicationMappingMgr.debug";
66
67    public void configure (CallbackUtilities cus) throws RootException {
68       if (null == cus)
69              throw new RootException("Cannot configure without call back impl.");
70            _debug_ = Boolean
71              .valueOf(cus.getProperty(DBG_PARAM_NAME, "false"))
72              .booleanValue();
73    }
74
75    /**
76     * Method saveApplicationMapping save new application mapping in database.
77     *
78     * @param trans a MappingTransaction
79     * @param am an ApplicationMap
80     * @return a boolean
81     * @exception RootException
82     *
83     */

84    public boolean saveApplicationMapping( ApplicationMappingTransaction trans, ApplicationMap am ) throws RootException {
85       boolean retVal = true;
86       if (!checkValidity(am)) {
87          throw new RootException("Application mapping is not valid");
88       }
89       try {
90          DBTransaction dbTrans = this.getDBTransaction(trans);
91          if (am.getProcessDefinitionId() != null){
92             if (am.getApplicationMode() != null){
93                if(am.getUsername() != null) {
94                   ProcLevelXPDLAppDO procLevelXPDLAppDO =
95                     this.checkProcLevelXPDLApp(trans, am);
96                   ToolAgentAppDetailUserDO toolAgentAppDetailUserDO =
97                     this.checkToolAgentAppDetailUser(trans, am);
98                   ProcLevelXPDLAppTAAppDetailUsrDO saveDO =
99                   ProcLevelXPDLAppTAAppDetailUsrDO.createVirgin(dbTrans);
100                   saveDO.setXPDL_APPOID(procLevelXPDLAppDO);
101                   saveDO.setTOOLAGENTOID(toolAgentAppDetailUserDO);
102                   saveDO.save();
103                }
104                else { // if(am.getUsername() != null)
105
ProcLevelXPDLAppDO procLevelXPDLAppDO =
106                     this.checkProcLevelXPDLApp(trans, am);
107                   ToolAgentAppDetailDO toolAgentAppDetailDO =
108                     this.checkToolAgentAppDetail(trans, am);
109                   ProcLevelXPDLAppTAAppDetailDO saveDO =
110                   ProcLevelXPDLAppTAAppDetailDO.createVirgin(dbTrans);
111                   saveDO.setXPDL_APPOID(procLevelXPDLAppDO);
112                   saveDO.setTOOLAGENTOID(toolAgentAppDetailDO);
113                   saveDO.save();
114                }
115             }
116             else { // if (am.getApplicationMode() != null)
117
if(am.getUsername() != null) {
118                   ProcLevelXPDLAppDO procLevelXPDLAppDO =
119                     this.checkProcLevelXPDLApp(trans, am);
120                   ToolAgentAppUserDO toolAgentAppUserDO =
121                     this.checkToolAgentAppUser(trans, am);
122                   ProcLevelXPDLAppTAAppUserDO saveDO =
123                   ProcLevelXPDLAppTAAppUserDO.createVirgin(dbTrans);
124                   saveDO.setXPDL_APPOID(procLevelXPDLAppDO);
125                   saveDO.setTOOLAGENTOID(toolAgentAppUserDO);
126                   saveDO.save();
127                }
128                else { // if(am.getUsername() != null)
129
ProcLevelXPDLAppDO procLevelXPDLAppDO =
130                     this.checkProcLevelXPDLApp(trans, am);
131                   ToolAgentAppDO toolAgentAppDO =
132                     this.checkToolAgentApp(trans, am);
133                   ProcLevelXPDLAppToolAgentAppDO saveDO =
134                   ProcLevelXPDLAppToolAgentAppDO.createVirgin(dbTrans);
135                   saveDO.setXPDL_APPOID(procLevelXPDLAppDO);
136                   saveDO.setTOOLAGENTOID(toolAgentAppDO);
137                   saveDO.save();
138                }
139             }
140
141           }
142           else { // if (am.getProcessDefinitionId())
143
if (am.getApplicationMode() != null){
144                if(am.getUsername() != null) {
145                   PackLevelXPDLAppDO packLevelXPDLAppDO =
146                     this.checkPackLevelXPDLApp(trans, am);
147                   ToolAgentAppDetailUserDO toolAgentAppDetailUserDO =
148                     this.checkToolAgentAppDetailUser(trans, am);
149                   PackLevelXPDLAppTAAppDetailUsrDO saveDO =
150                   PackLevelXPDLAppTAAppDetailUsrDO.createVirgin(dbTrans);
151                   saveDO.setXPDL_APPOID(packLevelXPDLAppDO);
152                   saveDO.setTOOLAGENTOID(toolAgentAppDetailUserDO);
153                   saveDO.save();
154                }
155                else { // if(am.getUsername() != null)
156
PackLevelXPDLAppDO packLevelXPDLAppDO =
157                     this.checkPackLevelXPDLApp(trans, am);
158                   ToolAgentAppDetailDO toolAgentAppDetailDO =
159                     this.checkToolAgentAppDetail(trans, am);
160                   PackLevelXPDLAppTAAppDetailDO saveDO =
161                   PackLevelXPDLAppTAAppDetailDO.createVirgin(dbTrans);
162                   saveDO.setXPDL_APPOID(packLevelXPDLAppDO);
163                   saveDO.setTOOLAGENTOID(toolAgentAppDetailDO);
164                   saveDO.save();
165                }
166             }
167             else { // if (am.getApplicationMode() != null)
168
if(am.getUsername() != null) {
169                   PackLevelXPDLAppDO packLevelXPDLAppDO =
170                     this.checkPackLevelXPDLApp(trans, am);
171                   ToolAgentAppUserDO toolAgentAppUserDO =
172                     this.checkToolAgentAppUser(trans, am);
173                   PackLevelXPDLAppTAAppUserDO saveDO =
174                   PackLevelXPDLAppTAAppUserDO.createVirgin(dbTrans);
175                   saveDO.setXPDL_APPOID(packLevelXPDLAppDO);
176                   saveDO.setTOOLAGENTOID(toolAgentAppUserDO);
177                   saveDO.save();
178                }
179                else { // if(am.getUsername() != null)
180
PackLevelXPDLAppDO packLevelXPDLAppDO =
181                     this.checkPackLevelXPDLApp(trans, am);
182                   ToolAgentAppDO toolAgentAppDO =
183                     this.checkToolAgentApp(trans, am);
184                   PackLevelXPDLAppToolAgentAppDO saveDO =
185                   PackLevelXPDLAppToolAgentAppDO.createVirgin(dbTrans);
186                   saveDO.setXPDL_APPOID(packLevelXPDLAppDO);
187                   saveDO.setTOOLAGENTOID(toolAgentAppDO);
188                   saveDO.save();
189                }
190             }
191           }
192
193       }catch(Exception JavaDoc e) {
194          throw new RootException(e);
195       }
196       return retVal;
197    }
198
199    /**
200     * Method deleteApplicationMapping delete specified application mapping
201     * from database.
202     *
203     * @param trans a MappingTransaction
204     * @param am an ApplicationMap
205     * @return a boolean
206     * @exception RootException
207     *
208     */

209    public boolean deleteApplicationMapping( ApplicationMappingTransaction trans, ApplicationMap am ) throws RootException {
210       boolean retVal = true;
211       try {
212          DBTransaction dbTrans = this.getDBTransaction(trans);
213
214          String JavaDoc processId = am.getProcessDefinitionId();
215          Integer JavaDoc appModeInt = am.getApplicationMode();
216          String JavaDoc username = am.getUsername();
217
218          if (processId != null){
219             if (appModeInt != null){
220                if(username != null) {
221                   this.deleteProcLevelXPDLAppToolAgentAppDetailUser(am, dbTrans);
222                }
223                else { // if(username != null)
224
this.deleteProcLevelXPDLAppToolAgentAppDetail(am, dbTrans);
225                }
226             }
227             else { // if appModeInt != nul)
228
if(username != null) {
229                   this.deleteProcLevelXPDLAppToolAgentAppUser(am, dbTrans);
230                }
231                else { // if(username != null)
232
this.deleteProcLevelXPDLAppToolAgentApp(am, dbTrans);
233                }
234             }
235           }
236           else { // if (processId != null)
237
if (appModeInt != null){
238                  if (username != null){
239                   this.deletePackLevelXPDLAppToolAgentAppDetailUser(am, dbTrans);
240                  }
241                  else { // if(username() != null)
242
this.deletePackLevelXPDLAppToolAgentAppDetail(am, dbTrans);
243                 }
244             }
245             else { // if (appModeInt != null)
246
if (username != null){
247                this.deletePackLevelXPDLAppToolAgentAppUser(am, dbTrans);
248                }
249                else { // if(username() != null)
250
this.deletePackLevelXPDLAppToolAgentApp(am, dbTrans);
251                }
252             }
253          }
254       }
255       catch(Exception JavaDoc e) {
256          throw new RootException(e);
257       }
258     return retVal;
259    }
260
261    public List JavaDoc getAllApplicationMappings( ApplicationMappingTransaction trans ) throws RootException {
262       List JavaDoc list = new ArrayList JavaDoc();
263       try {
264          DBTransaction dbTrans = this.getDBTransaction(trans);
265
266          //package level, mode, username and password not defined
267
PackLevelXPDLAppToolAgentAppQuery packLevelXPDLAppToolAgentAppQuery =
268             new PackLevelXPDLAppToolAgentAppQuery(dbTrans);
269          PackLevelXPDLAppToolAgentAppDO[] packLevelXPDLAppToolAgentAppDOArray =
270             packLevelXPDLAppToolAgentAppQuery.getDOArray();
271          for (int i = 0; i < packLevelXPDLAppToolAgentAppDOArray.length; i++) {
272             ApplicationMap am = this.createApplicationMap();
273             am.setApplicationDefinitionId(packLevelXPDLAppToolAgentAppDOArray[i].
274                getXPDL_APPOID().getAPPLICATION_ID());
275             am.setPackageId(packLevelXPDLAppToolAgentAppDOArray[i].
276                getXPDL_APPOID().getPACKAGEOID().getPACKAGE_ID());
277             am.setProcessDefinitionId(null);
278             am.setToolAgentClassName(packLevelXPDLAppToolAgentAppDOArray[i].getTOOLAGENTOID().getTOOL_AGENT_NAME());
279             am.setApplicationName(packLevelXPDLAppToolAgentAppDOArray[i].getTOOLAGENTOID().getAPP_NAME());
280             am.setApplicationMode(null);
281             am.setUsername(null);
282             am.setPassword(null);
283             list.add(am);
284          }
285
286          //package level, mode defined, username and password not defined
287
PackLevelXPDLAppTAAppDetailQuery packLevelXPDLAppToolAgentAppDetailQuery =
288             new PackLevelXPDLAppTAAppDetailQuery(dbTrans);
289          PackLevelXPDLAppTAAppDetailDO[] packLevelXPDLAppToolAgentAppDetailDOArray =
290             packLevelXPDLAppToolAgentAppDetailQuery.getDOArray();
291          for (int i = 0; i < packLevelXPDLAppToolAgentAppDetailDOArray.length; i++) {
292             ApplicationMap am = this.createApplicationMap();
293             am.setApplicationDefinitionId(packLevelXPDLAppToolAgentAppDetailDOArray[i].
294                getXPDL_APPOID().getAPPLICATION_ID());
295             am.setPackageId(packLevelXPDLAppToolAgentAppDetailDOArray[i].
296                getXPDL_APPOID().getPACKAGEOID().getPACKAGE_ID());
297             am.setProcessDefinitionId(null);
298             am.setToolAgentClassName(packLevelXPDLAppToolAgentAppDetailDOArray[i].
299                getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
300             am.setApplicationName(packLevelXPDLAppToolAgentAppDetailDOArray[i].
301                getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_NAME());
302             am.setApplicationMode(new Integer JavaDoc(packLevelXPDLAppToolAgentAppDetailDOArray[i].
303                getTOOLAGENTOID().getAPP_MODE().intValue()));
304             am.setUsername(null);
305             am.setPassword(null);
306             list.add(am);
307          }
308
309          //package level, mode not defined, username and password defined
310
PackLevelXPDLAppTAAppUserQuery packLevelXPDLAppToolAgentAppUserQuery =
311             new PackLevelXPDLAppTAAppUserQuery(dbTrans);
312          PackLevelXPDLAppTAAppUserDO[] packLevelXPDLAppToolAgentAppUserDOArray =
313             packLevelXPDLAppToolAgentAppUserQuery.getDOArray();
314          for (int i = 0; i < packLevelXPDLAppToolAgentAppUserDOArray.length; i++) {
315             ApplicationMap am = this.createApplicationMap();
316             am.setApplicationDefinitionId(packLevelXPDLAppToolAgentAppUserDOArray[i].
317                getXPDL_APPOID().getAPPLICATION_ID());
318             am.setPackageId(packLevelXPDLAppToolAgentAppUserDOArray[i].
319                getXPDL_APPOID().getPACKAGEOID().getPACKAGE_ID());
320             am.setProcessDefinitionId(null);
321             am.setToolAgentClassName(packLevelXPDLAppToolAgentAppUserDOArray[i].
322                getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
323             am.setApplicationName(packLevelXPDLAppToolAgentAppUserDOArray[i].
324                getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_NAME());
325             am.setApplicationMode(null);
326             am.setUsername(packLevelXPDLAppToolAgentAppUserDOArray[i].
327                getTOOLAGENTOID().getUSEROID().getUSERNAME());
328             am.setPassword(packLevelXPDLAppToolAgentAppUserDOArray[i].
329                getTOOLAGENTOID().getUSEROID().getPWD());
330             list.add(am);
331          }
332
333          //package level, mode, username and password defined
334
PackLevelXPDLAppTAAppDetailUsrQuery packLevelXPDLAppToolAgentAppDetailUserQuery =
335             new PackLevelXPDLAppTAAppDetailUsrQuery(dbTrans);
336          PackLevelXPDLAppTAAppDetailUsrDO[] packLevelXPDLAppToolAgentAppDetailUserDOArray =
337             packLevelXPDLAppToolAgentAppDetailUserQuery.getDOArray();
338          for (int i = 0; i < packLevelXPDLAppToolAgentAppDetailUserDOArray.length; i++) {
339             ApplicationMap am = this.createApplicationMap();
340             am.setApplicationDefinitionId(packLevelXPDLAppToolAgentAppDetailUserDOArray[i].
341                getXPDL_APPOID().getAPPLICATION_ID());
342             am.setPackageId(packLevelXPDLAppToolAgentAppDetailUserDOArray[i].
343                getXPDL_APPOID().getPACKAGEOID().getPACKAGE_ID());
344             am.setProcessDefinitionId(null);
345             am.setToolAgentClassName(packLevelXPDLAppToolAgentAppDetailUserDOArray[i].
346                getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
347             am.setApplicationName(packLevelXPDLAppToolAgentAppDetailUserDOArray[i].
348                getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getAPP_NAME());
349             am.setApplicationMode(new Integer JavaDoc(packLevelXPDLAppToolAgentAppDetailUserDOArray[i].
350                getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_MODE().intValue()));
351             am.setUsername(packLevelXPDLAppToolAgentAppDetailUserDOArray[i].
352                getTOOLAGENTOID().getUSEROID().getUSERNAME());
353             am.setPassword(packLevelXPDLAppToolAgentAppDetailUserDOArray[i].
354                getTOOLAGENTOID().getUSEROID().getPWD());
355             list.add(am);
356          }
357
358          //process level, mode, username and password not defined
359
ProcLevelXPDLAppToolAgentAppQuery procLevelXPDLAppToolAgentAppQuery =
360             new ProcLevelXPDLAppToolAgentAppQuery(dbTrans);
361          ProcLevelXPDLAppToolAgentAppDO[] procLevelXPDLAppToolAgentAppDOArray =
362             procLevelXPDLAppToolAgentAppQuery.getDOArray();
363          for (int i = 0; i < procLevelXPDLAppToolAgentAppDOArray.length; i++) {
364             ApplicationMap am = this.createApplicationMap();
365             am.setApplicationDefinitionId(procLevelXPDLAppToolAgentAppDOArray[i].
366                getXPDL_APPOID().getAPPLICATION_ID());
367             am.setPackageId(procLevelXPDLAppToolAgentAppDOArray[i].
368                getXPDL_APPOID().getPROCESSOID().getPACKAGEOID().getPACKAGE_ID());
369             am.setProcessDefinitionId(procLevelXPDLAppToolAgentAppDOArray[i].
370                getXPDL_APPOID().getPROCESSOID().getPROCESS_ID());
371             am.setToolAgentClassName(procLevelXPDLAppToolAgentAppDOArray[i].
372                getTOOLAGENTOID().getTOOL_AGENT_NAME());
373             am.setApplicationName(procLevelXPDLAppToolAgentAppDOArray[i].
374                getTOOLAGENTOID().getAPP_NAME());
375             am.setApplicationMode(null);
376             am.setUsername(null);
377             am.setPassword(null);
378             list.add(am);
379          }
380
381          //process level, mode defined, username and password not defined
382
ProcLevelXPDLAppTAAppDetailQuery procLevelXPDLAppToolAgentAppDetailQuery =
383             new ProcLevelXPDLAppTAAppDetailQuery(dbTrans);
384          ProcLevelXPDLAppTAAppDetailDO[] procLevelXPDLAppToolAgentAppDetailDOArray =
385             procLevelXPDLAppToolAgentAppDetailQuery.getDOArray();
386          for (int i = 0; i < procLevelXPDLAppToolAgentAppDetailDOArray.length; i++) {
387             ApplicationMap am = this.createApplicationMap();
388             am.setApplicationDefinitionId(procLevelXPDLAppToolAgentAppDetailDOArray[i].
389                getXPDL_APPOID().getAPPLICATION_ID());
390             am.setPackageId(procLevelXPDLAppToolAgentAppDetailDOArray[i].
391                getXPDL_APPOID().getPROCESSOID().getPACKAGEOID().getPACKAGE_ID());
392             am.setProcessDefinitionId(procLevelXPDLAppToolAgentAppDetailDOArray[i].
393                getXPDL_APPOID().getPROCESSOID().getPROCESS_ID());
394             am.setToolAgentClassName(procLevelXPDLAppToolAgentAppDetailDOArray[i].
395                getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
396             am.setApplicationName(procLevelXPDLAppToolAgentAppDetailDOArray[i].
397                getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_NAME());
398             am.setApplicationMode(new Integer JavaDoc(procLevelXPDLAppToolAgentAppDetailDOArray[i].
399                getTOOLAGENTOID().getAPP_MODE().intValue()));
400             am.setUsername(null);
401             am.setPassword(null);
402             list.add(am);
403          }
404
405          //process level, mode not defined, username and password defined
406
ProcLevelXPDLAppTAAppUserQuery procLevelXPDLAppToolAgentAppUserQuery =
407             new ProcLevelXPDLAppTAAppUserQuery(dbTrans);
408          ProcLevelXPDLAppTAAppUserDO[] procLevelXPDLAppToolAgentAppUserDOArray =
409             procLevelXPDLAppToolAgentAppUserQuery.getDOArray();
410          for (int i = 0; i < procLevelXPDLAppToolAgentAppUserDOArray.length; i++) {
411             ApplicationMap am = this.createApplicationMap();
412             am.setApplicationDefinitionId(procLevelXPDLAppToolAgentAppUserDOArray[i].
413                getXPDL_APPOID().getAPPLICATION_ID());
414             am.setPackageId(procLevelXPDLAppToolAgentAppUserDOArray[i].
415                getXPDL_APPOID().getPROCESSOID().getPACKAGEOID().getPACKAGE_ID());
416             am.setProcessDefinitionId(procLevelXPDLAppToolAgentAppUserDOArray[i].
417                getXPDL_APPOID().getPROCESSOID().getPROCESS_ID());
418             am.setToolAgentClassName(procLevelXPDLAppToolAgentAppUserDOArray[i].
419                getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
420             am.setApplicationName(procLevelXPDLAppToolAgentAppUserDOArray[i].
421                getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_NAME());
422             am.setApplicationMode(null);
423             am.setUsername(procLevelXPDLAppToolAgentAppUserDOArray[i].
424                getTOOLAGENTOID().getUSEROID().getUSERNAME());
425             am.setPassword(procLevelXPDLAppToolAgentAppUserDOArray[i].
426                getTOOLAGENTOID().getUSEROID().getPWD());
427             list.add(am);
428          }
429
430          //process level, mode, username and password defined
431
ProcLevelXPDLAppTAAppDetailUsrQuery procLevelXPDLAppToolAgentAppDetailUserQuery =
432             new ProcLevelXPDLAppTAAppDetailUsrQuery(dbTrans);
433          ProcLevelXPDLAppTAAppDetailUsrDO[] procLevelXPDLAppToolAgentAppDetailUserDOArray =
434             procLevelXPDLAppToolAgentAppDetailUserQuery.getDOArray();
435          for (int i = 0; i < procLevelXPDLAppToolAgentAppDetailUserDOArray.length; i++) {
436             ApplicationMap am = this.createApplicationMap();
437             am.setApplicationDefinitionId(procLevelXPDLAppToolAgentAppDetailUserDOArray[i].
438                getXPDL_APPOID().getAPPLICATION_ID());
439             am.setPackageId(procLevelXPDLAppToolAgentAppDetailUserDOArray[i].
440                getXPDL_APPOID().getPROCESSOID().getPACKAGEOID().getPACKAGE_ID());
441             am.setProcessDefinitionId(procLevelXPDLAppToolAgentAppDetailUserDOArray[i].
442                getXPDL_APPOID().getPROCESSOID().getPROCESS_ID());
443             am.setToolAgentClassName(procLevelXPDLAppToolAgentAppDetailUserDOArray[i].
444                getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
445             am.setApplicationName(procLevelXPDLAppToolAgentAppDetailUserDOArray[i].
446                getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getAPP_NAME());
447             am.setApplicationMode(new Integer JavaDoc(procLevelXPDLAppToolAgentAppDetailUserDOArray[i].
448                getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_MODE().intValue()));
449             am.setUsername(procLevelXPDLAppToolAgentAppDetailUserDOArray[i].
450                getTOOLAGENTOID().getUSEROID().getUSERNAME());
451             am.setPassword(procLevelXPDLAppToolAgentAppDetailUserDOArray[i].
452                getTOOLAGENTOID().getUSEROID().getPWD());
453             list.add(am);
454          }
455
456          //return list with all application mappings
457
return list;
458       }catch(Exception JavaDoc e) {
459          throw new RootException(e);
460       }
461    }
462
463    public ApplicationMap createApplicationMap () {
464       return new DODSApplicationMap();
465    }
466
467    public boolean deleteApplicationMapping (
468       ApplicationMappingTransaction trans,
469       String JavaDoc packageId,
470       String JavaDoc processDefinitionId,
471       String JavaDoc applicationId ) throws RootException {
472
473       boolean retVal = true;
474       try {
475          //empty string is same as null
476
if( processDefinitionId != null && processDefinitionId.trim().equals("") )
477           processDefinitionId = null;
478          ApplicationMap am = this.createApplicationMap();
479          DBTransaction dbTrans = this.getDBTransaction(trans);
480          am.setPackageId(packageId);
481          am.setProcessDefinitionId(processDefinitionId);
482          am.setApplicationDefinitionId(applicationId);
483
484          // appMode, username and password not defined
485
ToolAgentAppQuery toolAgentAppQuery = new ToolAgentAppQuery(dbTrans);
486          ToolAgentAppDO[] toolAgentAppDOArr = toolAgentAppQuery.getDOArray();
487          for (int i = 0; i < toolAgentAppDOArr.length; i++) {
488             am.setToolAgentClassName(toolAgentAppDOArr[i].getTOOL_AGENT_NAME());
489             am.setApplicationName(toolAgentAppDOArr[i].getAPP_NAME());
490             am.setApplicationMode(null);
491             am.setUsername(null);
492             am.setPassword(null);
493             if (processDefinitionId != null) {
494                this.deleteProcLevelXPDLAppToolAgentApp(am, dbTrans);
495             } else {
496                this.deletePackLevelXPDLAppToolAgentApp(am, dbTrans);
497             }
498          }
499
500          // appMode defined, username and password not defined
501
ToolAgentAppDetailQuery toolAgentAppDetailQuery = new ToolAgentAppDetailQuery(dbTrans);
502          ToolAgentAppDetailDO[] toolAgentAppDetailDOArr = toolAgentAppDetailQuery.getDOArray();
503          for (int i = 0; i < toolAgentAppDetailDOArr.length; i++) {
504             am.setApplicationMode(new Integer JavaDoc(toolAgentAppDetailDOArr[i].getAPP_MODE().intValue()));
505             am.setToolAgentClassName(toolAgentAppDetailDOArr[i].getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
506             am.setApplicationName(toolAgentAppDetailDOArr[i].getTOOLAGENT_APPOID().getAPP_NAME());
507             am.setUsername(null);
508             am.setPassword(null);
509             if (processDefinitionId != null) {
510                this.deleteProcLevelXPDLAppToolAgentAppDetail(am, dbTrans);
511             } else {
512                this.deletePackLevelXPDLAppToolAgentAppDetail(am, dbTrans);
513             }
514          }
515
516          // appMode not defined, username and password defined
517
ToolAgentAppUserQuery toolAgentAppUserQuery = new ToolAgentAppUserQuery(dbTrans);
518          ToolAgentAppUserDO[] toolAgentAppUserDOArr = toolAgentAppUserQuery.getDOArray();
519          for (int i = 0; i < toolAgentAppUserDOArr.length; i++) {
520             am.setUsername(toolAgentAppUserDOArr[i].getUSEROID().getUSERNAME());
521             am.setPassword(toolAgentAppUserDOArr[i].getUSEROID().getPWD());
522             am.setToolAgentClassName(toolAgentAppUserDOArr[i].getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
523             am.setApplicationName(toolAgentAppUserDOArr[i].getTOOLAGENT_APPOID().getAPP_NAME());
524             am.setApplicationMode(null);
525             if (processDefinitionId != null) {
526                this.deleteProcLevelXPDLAppToolAgentAppUser(am, dbTrans);
527             } else {
528                this.deletePackLevelXPDLAppToolAgentAppUser(am, dbTrans);
529             }
530          }
531
532          // appMode, username and password defined
533
ToolAgentAppDetailUserQuery toolAgentAppDetailUserQuery = new ToolAgentAppDetailUserQuery(dbTrans);
534          ToolAgentAppDetailUserDO[] toolAgentAppDetailUserDOArr = toolAgentAppDetailUserQuery.getDOArray();
535          for (int i = 0; i < toolAgentAppDetailUserDOArr.length; i++) {
536             am.setApplicationMode(new Integer JavaDoc (toolAgentAppDetailUserDOArr[i].getTOOLAGENT_APPOID().getAPP_MODE().intValue()));
537             am.setUsername(toolAgentAppDetailUserDOArr[i].getUSEROID().getUSERNAME());
538             am.setPassword(toolAgentAppDetailUserDOArr[i].getUSEROID().getPWD());
539             am.setToolAgentClassName(toolAgentAppDetailUserDOArr[i].getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
540             am.setApplicationName(toolAgentAppDetailUserDOArr[i].getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getAPP_NAME());
541             if (processDefinitionId != null) {
542                this.deleteProcLevelXPDLAppToolAgentAppDetailUser(am, dbTrans);
543             } else {
544                this.deletePackLevelXPDLAppToolAgentAppDetailUser(am, dbTrans);
545             }
546          }
547
548          dbTrans.write();
549       } catch (Exception JavaDoc e) {
550          throw new RootException(e);
551       }
552       return retVal;
553 /*
554       ApplicationMap am = this.createApplicationMap();
555       am.setPackageId(packageId);
556       am.setProcessDefinitionId(processDefinitionId);
557       am.setApplicationDefinitionId(applicationId);
558
559       return this.deleteApplicationMapping(trans, am);
560 */

561    }
562
563    /**
564     * Method getApplicationMap finds application map in database.
565     *
566     * @param trans a MappingTransaction
567     * @param packageId an Integer
568     * @param processDefinitionId an Integer
569     * @param applicationDefinitionId an Integer
570     * @return an ApplicationMap, or null if map do not exist for specified params
571     * @exception RootException
572     *
573     */

574    public ApplicationMap getApplicationMap (
575    ApplicationMappingTransaction trans,
576       String JavaDoc packageId,
577       String JavaDoc processDefinitionId,
578       String JavaDoc applicationDefinitionId) throws RootException {
579       ApplicationMap am = null;
580        try {
581          // empty string is same as null
582
if( processDefinitionId != null && processDefinitionId.trim().equals("") )
583             processDefinitionId = null;
584          DBTransaction dbTrans = this.getDBTransaction(trans);
585          if (processDefinitionId == null) {
586
587             XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
588             packageQuery.setQueryPACKAGE_ID(packageId);
589             packageQuery.requireUniqueInstance();
590             XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
591
592             PackLevelXPDLAppQuery packLevelXPDLAppQuery =
593                new PackLevelXPDLAppQuery(dbTrans);
594             packLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationDefinitionId);
595             packLevelXPDLAppQuery.setQueryPACKAGEOID(packageDO);
596             packLevelXPDLAppQuery.requireUniqueInstance();
597             PackLevelXPDLAppDO packLevelXPDLAppDO = packLevelXPDLAppQuery.getNextDO();
598
599             //package level, mode, username and password not defined
600
PackLevelXPDLAppToolAgentAppQuery packLevelXPDLAppToolAgentAppQuery =
601                new PackLevelXPDLAppToolAgentAppQuery(dbTrans);
602             packLevelXPDLAppToolAgentAppQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
603             packLevelXPDLAppToolAgentAppQuery.requireUniqueInstance();
604             PackLevelXPDLAppToolAgentAppDO packLevelXPDLAppToolAgentAppDO =
605                packLevelXPDLAppToolAgentAppQuery.getNextDO();
606
607             if (packLevelXPDLAppToolAgentAppDO != null) {
608                am = this.createApplicationMap();
609                am.setApplicationDefinitionId(packLevelXPDLAppToolAgentAppDO
610                   .getXPDL_APPOID().getAPPLICATION_ID());
611                am.setPackageId(packLevelXPDLAppToolAgentAppDO
612                    .getXPDL_APPOID().getPACKAGEOID().getPACKAGE_ID());
613                am.setProcessDefinitionId(null);
614                am.setToolAgentClassName(packLevelXPDLAppToolAgentAppDO
615                   .getTOOLAGENTOID().getTOOL_AGENT_NAME());
616                am.setApplicationName(packLevelXPDLAppToolAgentAppDO
617                   .getTOOLAGENTOID().getAPP_NAME());
618                am.setApplicationMode(null);
619                am.setUsername(null);
620                am.setPassword(null);
621                return am;
622             }
623
624             //package level, mode defined, username and password not defined
625
PackLevelXPDLAppTAAppDetailQuery packLevelXPDLAppToolAgentAppDetailQuery =
626                new PackLevelXPDLAppTAAppDetailQuery(dbTrans);
627             packLevelXPDLAppToolAgentAppDetailQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
628             packLevelXPDLAppToolAgentAppDetailQuery.requireUniqueInstance();
629             PackLevelXPDLAppTAAppDetailDO packLevelXPDLAppToolAgentAppDetailDO =
630                packLevelXPDLAppToolAgentAppDetailQuery.getNextDO();
631
632             if (packLevelXPDLAppToolAgentAppDetailDO != null){
633                am = this.createApplicationMap();
634                am.setApplicationDefinitionId(packLevelXPDLAppToolAgentAppDetailDO
635                   .getXPDL_APPOID().getAPPLICATION_ID());
636                am.setPackageId(packLevelXPDLAppToolAgentAppDetailDO
637                    .getXPDL_APPOID().getPACKAGEOID().getPACKAGE_ID());
638                am.setProcessDefinitionId(null);
639                am.setToolAgentClassName(packLevelXPDLAppToolAgentAppDetailDO
640                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
641                am.setApplicationName(packLevelXPDLAppToolAgentAppDetailDO
642                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_NAME());
643                am.setApplicationMode(new Integer JavaDoc(packLevelXPDLAppToolAgentAppDetailDO
644                   .getTOOLAGENTOID().getAPP_MODE().intValue()));
645                am.setUsername(null);
646                am.setPassword(null);
647                return am;
648             }
649
650             //package level, mode not defined, username and password defined
651

652             PackLevelXPDLAppTAAppUserQuery packLevelXPDLAppToolAgentAppUserQuery =
653                new PackLevelXPDLAppTAAppUserQuery(dbTrans);
654             packLevelXPDLAppToolAgentAppUserQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
655             packLevelXPDLAppToolAgentAppUserQuery.requireUniqueInstance();
656             PackLevelXPDLAppTAAppUserDO packLevelXPDLAppToolAgentAppUserDO =
657                packLevelXPDLAppToolAgentAppUserQuery.getNextDO();
658
659             if (packLevelXPDLAppToolAgentAppUserDO != null) {
660                am = this.createApplicationMap();
661                am.setApplicationDefinitionId(packLevelXPDLAppToolAgentAppUserDO
662                   .getXPDL_APPOID().getAPPLICATION_ID());
663                am.setPackageId(packLevelXPDLAppToolAgentAppUserDO
664                    .getXPDL_APPOID().getPACKAGEOID().getPACKAGE_ID());
665                am.setProcessDefinitionId(null);
666                am.setToolAgentClassName(packLevelXPDLAppToolAgentAppUserDO
667                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
668                am.setApplicationName(packLevelXPDLAppToolAgentAppUserDO
669                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_NAME());
670                am.setApplicationMode(null);
671                am.setUsername(packLevelXPDLAppToolAgentAppUserDO
672                   .getTOOLAGENTOID().getUSEROID().getUSERNAME());
673                am.setPassword(packLevelXPDLAppToolAgentAppUserDO
674                   .getTOOLAGENTOID().getUSEROID().getPWD());
675                return am;
676             }
677
678             //package level, mode, username and password defined
679
PackLevelXPDLAppTAAppDetailUsrQuery packLevelXPDLAppToolAgentAppDetailUserQuery =
680                new PackLevelXPDLAppTAAppDetailUsrQuery(dbTrans);
681             packLevelXPDLAppToolAgentAppDetailUserQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
682             packLevelXPDLAppToolAgentAppDetailUserQuery.requireUniqueInstance();
683             PackLevelXPDLAppTAAppDetailUsrDO packLevelXPDLAppToolAgentAppDetailUserDO =
684                packLevelXPDLAppToolAgentAppDetailUserQuery.getNextDO();
685
686             if (packLevelXPDLAppToolAgentAppDetailUserDO != null){
687                am = this.createApplicationMap();
688                am.setApplicationDefinitionId(packLevelXPDLAppToolAgentAppDetailUserDO
689                   .getXPDL_APPOID().getAPPLICATION_ID());
690                am.setPackageId(packLevelXPDLAppToolAgentAppDetailUserDO
691                    .getXPDL_APPOID().getPACKAGEOID().getPACKAGE_ID());
692                am.setProcessDefinitionId(null);
693                am.setToolAgentClassName(packLevelXPDLAppToolAgentAppDetailUserDO
694                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
695                am.setApplicationName(packLevelXPDLAppToolAgentAppDetailUserDO
696                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getAPP_NAME());
697                am.setApplicationMode(new Integer JavaDoc(packLevelXPDLAppToolAgentAppDetailUserDO
698                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_MODE().intValue()));
699                am.setUsername(packLevelXPDLAppToolAgentAppDetailUserDO
700                   .getTOOLAGENTOID().getUSEROID().getUSERNAME());
701                am.setPassword(packLevelXPDLAppToolAgentAppDetailUserDO
702                   .getTOOLAGENTOID().getUSEROID().getPWD());
703                return am;
704             }
705
706          } else {
707
708             XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
709             packageQuery.setQueryPACKAGE_ID(packageId);
710             packageQuery.requireUniqueInstance();
711             XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
712
713             XPDLApplicationProcessQuery processQuery = new XPDLApplicationProcessQuery(dbTrans);
714             processQuery.setQueryPROCESS_ID(processDefinitionId);
715             processQuery.setQueryPACKAGEOID(packageDO);
716             processQuery.requireUniqueInstance();
717             XPDLApplicationProcessDO processDO = processQuery.getNextDO();
718
719             ProcLevelXPDLAppQuery procLevelXPDLAppQuery =
720                new ProcLevelXPDLAppQuery(dbTrans);
721             procLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationDefinitionId);
722             procLevelXPDLAppQuery.setQueryPROCESSOID(processDO);
723             procLevelXPDLAppQuery.requireUniqueInstance();
724             ProcLevelXPDLAppDO procLevelXPDLAppDO = procLevelXPDLAppQuery.getNextDO();
725
726             //process level, mode, username and password not defined
727
ProcLevelXPDLAppToolAgentAppQuery procLevelXPDLAppToolAgentAppQuery =
728                new ProcLevelXPDLAppToolAgentAppQuery(dbTrans);
729             procLevelXPDLAppToolAgentAppQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
730             procLevelXPDLAppToolAgentAppQuery.requireUniqueInstance();
731             ProcLevelXPDLAppToolAgentAppDO procLevelXPDLAppToolAgentAppDO =
732                procLevelXPDLAppToolAgentAppQuery.getNextDO();
733
734             if (procLevelXPDLAppToolAgentAppDO != null){
735                am = this.createApplicationMap();
736                am.setApplicationDefinitionId(procLevelXPDLAppToolAgentAppDO
737                   .getXPDL_APPOID().getAPPLICATION_ID());
738                am.setPackageId(procLevelXPDLAppToolAgentAppDO
739                    .getXPDL_APPOID().getPROCESSOID().getPACKAGEOID().getPACKAGE_ID());
740                am.setProcessDefinitionId(procLevelXPDLAppToolAgentAppDO
741                    .getXPDL_APPOID().getPROCESSOID().getPROCESS_ID());
742                am.setToolAgentClassName(procLevelXPDLAppToolAgentAppDO
743                   .getTOOLAGENTOID().getTOOL_AGENT_NAME());
744                am.setApplicationName(procLevelXPDLAppToolAgentAppDO
745                   .getTOOLAGENTOID().getAPP_NAME());
746                am.setApplicationMode(null);
747                am.setUsername(null);
748                am.setPassword(null);
749                return am;
750             }
751
752             //process level, mode defined, username and password not defined
753
ProcLevelXPDLAppTAAppDetailQuery procLevelXPDLAppToolAgentAppDetailQuery =
754                new ProcLevelXPDLAppTAAppDetailQuery(dbTrans);
755             procLevelXPDLAppToolAgentAppDetailQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
756             procLevelXPDLAppToolAgentAppDetailQuery.requireUniqueInstance();
757             ProcLevelXPDLAppTAAppDetailDO procLevelXPDLAppToolAgentAppDetailDO =
758                procLevelXPDLAppToolAgentAppDetailQuery.getNextDO();
759
760             if (procLevelXPDLAppToolAgentAppDetailDO != null){
761                am = this.createApplicationMap();
762                am.setApplicationDefinitionId(procLevelXPDLAppToolAgentAppDetailDO
763                   .getXPDL_APPOID().getAPPLICATION_ID());
764                am.setPackageId(procLevelXPDLAppToolAgentAppDetailDO
765                    .getXPDL_APPOID().getPROCESSOID().getPACKAGEOID().getPACKAGE_ID());
766                am.setProcessDefinitionId(procLevelXPDLAppToolAgentAppDetailDO
767                    .getXPDL_APPOID().getPROCESSOID().getPROCESS_ID());
768                am.setToolAgentClassName(procLevelXPDLAppToolAgentAppDetailDO
769                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
770                am.setApplicationName(procLevelXPDLAppToolAgentAppDetailDO
771                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_NAME());
772                am.setApplicationMode(new Integer JavaDoc(procLevelXPDLAppToolAgentAppDetailDO
773                   .getTOOLAGENTOID().getAPP_MODE().intValue()));
774                am.setUsername(null);
775                am.setPassword(null);
776                return am;
777             }
778
779            //process level, mode not defined, username and password defined
780
ProcLevelXPDLAppTAAppUserQuery procLevelXPDLAppToolAgentAppUserQuery =
781                new ProcLevelXPDLAppTAAppUserQuery(dbTrans);
782             procLevelXPDLAppToolAgentAppUserQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
783             procLevelXPDLAppToolAgentAppUserQuery.requireUniqueInstance();
784             ProcLevelXPDLAppTAAppUserDO procLevelXPDLAppToolAgentAppUserDO =
785                procLevelXPDLAppToolAgentAppUserQuery.getNextDO();
786
787             if (procLevelXPDLAppToolAgentAppUserDO != null){
788                am = this.createApplicationMap();
789                am.setApplicationDefinitionId(procLevelXPDLAppToolAgentAppUserDO
790                   .getXPDL_APPOID().getAPPLICATION_ID());
791                am.setPackageId(procLevelXPDLAppToolAgentAppUserDO
792                    .getXPDL_APPOID().getPROCESSOID().getPACKAGEOID().getPACKAGE_ID());
793                am.setProcessDefinitionId(procLevelXPDLAppToolAgentAppUserDO
794                    .getXPDL_APPOID().getPROCESSOID().getPROCESS_ID());
795                am.setToolAgentClassName(procLevelXPDLAppToolAgentAppUserDO
796                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
797                am.setApplicationName(procLevelXPDLAppToolAgentAppUserDO
798                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_NAME());
799                am.setApplicationMode(null);
800                am.setUsername(procLevelXPDLAppToolAgentAppUserDO
801                   .getTOOLAGENTOID().getUSEROID().getUSERNAME());
802                am.setPassword(procLevelXPDLAppToolAgentAppUserDO
803                   .getTOOLAGENTOID().getUSEROID().getPWD());
804                return am;
805             }
806
807             //process level, mode, username and password defined
808
ProcLevelXPDLAppTAAppDetailUsrQuery procLevelXPDLAppToolAgentAppDetailUserQuery =
809                new ProcLevelXPDLAppTAAppDetailUsrQuery(dbTrans);
810             procLevelXPDLAppToolAgentAppDetailUserQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
811             procLevelXPDLAppToolAgentAppDetailUserQuery.requireUniqueInstance();
812             ProcLevelXPDLAppTAAppDetailUsrDO procLevelXPDLAppToolAgentAppDetailUserDO =
813                procLevelXPDLAppToolAgentAppDetailUserQuery.getNextDO();
814
815             if (procLevelXPDLAppToolAgentAppDetailUserDO != null){
816                am = this.createApplicationMap();
817                am.setApplicationDefinitionId(procLevelXPDLAppToolAgentAppDetailUserDO
818                   .getXPDL_APPOID().getAPPLICATION_ID());
819                am.setPackageId(procLevelXPDLAppToolAgentAppDetailUserDO
820                    .getXPDL_APPOID().getPROCESSOID().getPACKAGEOID().getPACKAGE_ID());
821                am.setProcessDefinitionId(procLevelXPDLAppToolAgentAppDetailUserDO
822                    .getXPDL_APPOID().getPROCESSOID().getPROCESS_ID());
823                am.setToolAgentClassName(procLevelXPDLAppToolAgentAppDetailUserDO
824                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getTOOL_AGENT_NAME());
825                am.setApplicationName(procLevelXPDLAppToolAgentAppDetailUserDO
826                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getTOOLAGENT_APPOID().getAPP_NAME());
827                am.setApplicationMode(new Integer JavaDoc(procLevelXPDLAppToolAgentAppDetailUserDO
828                   .getTOOLAGENTOID().getTOOLAGENT_APPOID().getAPP_MODE().intValue()));
829                am.setUsername(procLevelXPDLAppToolAgentAppDetailUserDO
830                   .getTOOLAGENTOID().getUSEROID().getUSERNAME());
831                am.setPassword(procLevelXPDLAppToolAgentAppDetailUserDO
832                   .getTOOLAGENTOID().getUSEROID().getPWD());
833                return am;
834             }
835
836          }
837       }
838       catch(Exception JavaDoc e) {
839          throw new RootException(e);
840       }
841       return am;
842    }
843
844    /**
845     * Method getDBTransaction create DODS DBTransaction.
846     * @param t ApplicationMappingTransaction
847     * @return a DBTransaction
848     *
849     */

850    private DBTransaction getDBTransaction(ApplicationMappingTransaction t) {
851       try {
852          if( t instanceof DODSApplicationMappingTransaction )
853             return ((DODSApplicationMappingTransaction)t).getDODSTransaction();
854       }catch(Exception JavaDoc e) {
855       }
856       //error
857
return null;
858    }
859
860    /**
861     * Method getMapFromDO transfer DO object to application map object.
862     * @param amDO an ApplicationMappingsDO
863     * @return an ApplicationMap
864     * @exception Exception
865     *
866     */

867 // private ApplicationMap getMapFromDO(ApplicationMappingsDO amDO) throws Exception {
868
// DODSApplicationMap am = (DODSApplicationMap)this.createApplicationMap();
869
// try {
870

871 /*
872          if( amDO.getAPP_MODE() != null )
873             am.setApplicationMode( new Integer( amDO.getAPP_MODE().intValue() ) );
874          else
875             am.setApplicationMode(null);
876          am.setApplicationName( amDO.getAPP_NAME() );
877          am.setUsername( amDO.getUSERNAME() );
878          am.setPassword( amDO.getTHE_PASSWORD() );
879          am.setPackageId(amDO.getPACKAGE_ID());
880          String pDefId = amDO.getPROCESS_DEFINITION_ID();
881          if( pDefId.equalsIgnoreCase(DODSUtilities.NULL_VALUE_FOR_PROCID))
882             pDefId = null;
883          am.setProcessDefinitionId( pDefId );
884          am.setToolAgentClassName( amDO.getTOOL_AGENT_NAME() );
885          am.setApplicationDefinitionId( amDO.getAPPLICATION_DEFINITION_ID() );
886 */

887
888 // }catch(Exception e) {
889
// throw e;
890
// }
891
// return am;
892
// }
893

894    // private ApplicationMappingsDO getDOfromMap(ApplicationMap am, ApplicationMappingsDO amDO) throws Exception {
895
// try {
896
// amDO.setAPP_MODE( new BigDecimal( am.getApplicationMode().intValue() ) );
897
// amDO.setAPP_NAME( am.getApplicationName() );
898
// amDO.setUSERNAME( am.getUsername() );
899
// amDO.setPASSWORD( am.getPassword() );
900
// amDO.setPACKAGE_ID( new BigDecimal( am.getPackageId().intValue() ));
901
// amDO.setPROCESS_DEFINITION_ID( new BigDecimal( am.getProcessDefinitionId().intValue() ) );
902
// amDO.setTOOL_AGENT_NAME( am.getToolAgentClassName() );
903
// amDO.setAPPLICATION_DEFINITION_ID( new BigDecimal( am.getApplicationDefinitionId().intValue() ));
904
// }catch(Exception e) {
905
// throw e;
906
// }
907
// }
908

909
910    /**
911     * Checks validity of application mapping.
912     * @param am an ApplicationMapping
913     * @return a boolean
914     *
915     */

916    public boolean checkValidity (ApplicationMap am) {
917       if (am==null ||
918           am.getPackageId()==null || am.getPackageId().trim().equals("") ||
919           am.getApplicationDefinitionId()==null || am.getApplicationDefinitionId().trim().equals("") ||
920           am.getToolAgentClassName()==null || am.getToolAgentClassName().trim().equals("") ||
921           am.getApplicationName()==null || am.getApplicationName().trim().equals("")) {
922          return false;
923       } else {
924          return true;
925       }
926    }
927
928    /**
929     * Gets application mapping transaction.
930     * @return an ApplicationMappingTransaction
931     * @exception TransactionException
932     *
933     */

934    public ApplicationMappingTransaction getApplicationMappingTransaction() throws TransactionException {
935        try {
936          return new DODSApplicationMappingTransaction(DODS.getDatabaseManager().createTransaction());
937        } catch (Exception JavaDoc ex) {
938          throw new TransactionException(ex);
939        }
940     }
941
942
943     private ProcLevelXPDLAppDO checkProcLevelXPDLApp(
944       ApplicationMappingTransaction trans,
945       ApplicationMap am)
946       throws RootException {
947       try {
948          DBTransaction dbTrans = this.getDBTransaction(trans);
949
950          ProcLevelXPDLAppQuery procLevelXPDLAppQuery =
951             new ProcLevelXPDLAppQuery(dbTrans);
952          ProcLevelXPDLAppDO procLevelXPDLAppDO = null;
953
954          XPDLApplicationProcessDO procDO = this.checkProcess(trans, am);
955
956          procLevelXPDLAppQuery.setQueryAPPLICATION_ID(am.getApplicationDefinitionId());
957          procLevelXPDLAppQuery.setQueryPROCESSOID(procDO);
958          procLevelXPDLAppQuery.requireUniqueInstance();
959          procLevelXPDLAppDO = procLevelXPDLAppQuery.getNextDO();
960          if (procLevelXPDLAppDO == null) {
961             procLevelXPDLAppDO = ProcLevelXPDLAppDO.createVirgin(dbTrans);
962             procLevelXPDLAppDO.setAPPLICATION_ID(am.getApplicationDefinitionId());
963             procLevelXPDLAppDO.setPROCESSOID(procDO);
964             procLevelXPDLAppDO.save();
965             dbTrans.write();
966          }
967          return procLevelXPDLAppDO;
968       } catch (Exception JavaDoc e) {
969          throw new RootException(e);
970       }
971    }
972
973    private PackLevelXPDLAppDO checkPackLevelXPDLApp(
974       ApplicationMappingTransaction trans,
975       ApplicationMap am)
976       throws RootException {
977       try {
978          DBTransaction dbTrans = this.getDBTransaction(trans);
979
980          PackLevelXPDLAppQuery packLevelXPDLAppQuery =
981             new PackLevelXPDLAppQuery(dbTrans);
982          PackLevelXPDLAppDO packLevelXPDLAppDO = null;
983
984          XPDLApplicationPackageDO packDO = this.checkPackage(trans, am);
985
986          packLevelXPDLAppQuery.setQueryAPPLICATION_ID(am.getApplicationDefinitionId());
987          packLevelXPDLAppQuery.setQueryPACKAGEOID(packDO);
988          packLevelXPDLAppQuery.requireUniqueInstance();
989          packLevelXPDLAppDO = packLevelXPDLAppQuery.getNextDO();
990          if (packLevelXPDLAppDO == null) {
991             packLevelXPDLAppDO = PackLevelXPDLAppDO.createVirgin(dbTrans);
992             packLevelXPDLAppDO.setAPPLICATION_ID(am.getApplicationDefinitionId());
993             packLevelXPDLAppDO.setPACKAGEOID(packDO);
994             packLevelXPDLAppDO.save();
995             dbTrans.write();
996          }
997          return packLevelXPDLAppDO;
998       } catch (Exception JavaDoc e) {
999          throw new RootException(e);
1000      }
1001   }
1002
1003   private ToolAgentAppDetailUserDO checkToolAgentAppDetailUser (
1004      ApplicationMappingTransaction trans,
1005      ApplicationMap am)
1006      throws RootException {
1007      try {
1008         DBTransaction dbTrans = this.getDBTransaction(trans);
1009
1010         ToolAgentAppDetailUserQuery toolAgentAppDetailUserQuery =
1011            new ToolAgentAppDetailUserQuery(dbTrans);
1012         ToolAgentAppDetailUserDO toolAgentAppDetailUserDO = null;
1013
1014         ToolAgentAppDetailDO toolAgentAppDetailDO = this.checkToolAgentAppDetail(trans, am);
1015         ToolAgentUserDO userDO = this.checkUser(trans, am);
1016
1017         toolAgentAppDetailUserQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDetailDO);
1018         toolAgentAppDetailUserQuery.setQueryUSEROID(userDO);
1019         toolAgentAppDetailUserQuery.requireUniqueInstance();
1020         toolAgentAppDetailUserDO = toolAgentAppDetailUserQuery.getNextDO();
1021         if (toolAgentAppDetailUserDO == null) {
1022            toolAgentAppDetailUserDO = ToolAgentAppDetailUserDO.createVirgin(dbTrans);
1023            toolAgentAppDetailUserDO.setTOOLAGENT_APPOID(toolAgentAppDetailDO);
1024            toolAgentAppDetailUserDO.setUSEROID(userDO);
1025            toolAgentAppDetailUserDO.save();
1026            dbTrans.write();
1027         }
1028         return toolAgentAppDetailUserDO;
1029      } catch (Exception JavaDoc e) {
1030         throw new RootException(e);
1031      }
1032   }
1033
1034   private ToolAgentAppDetailDO checkToolAgentAppDetail (
1035      ApplicationMappingTransaction trans,
1036      ApplicationMap am)
1037      throws RootException {
1038      try {
1039         DBTransaction dbTrans = this.getDBTransaction(trans);
1040
1041         ToolAgentAppDetailQuery toolAgentAppDetailQuery =
1042            new ToolAgentAppDetailQuery(dbTrans);
1043         ToolAgentAppDetailDO toolAgentAppDetailDO = null;
1044
1045         ToolAgentAppDO toolAgentAppDO = this.checkToolAgentApp(trans, am);
1046
1047         toolAgentAppDetailQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1048         toolAgentAppDetailQuery.setQueryAPP_MODE( new BigDecimal JavaDoc(am.getApplicationMode().intValue()));
1049         toolAgentAppDetailQuery.requireUniqueInstance();
1050         toolAgentAppDetailDO = toolAgentAppDetailQuery.getNextDO();
1051         if (toolAgentAppDetailDO == null) {
1052            toolAgentAppDetailDO = ToolAgentAppDetailDO.createVirgin(dbTrans);
1053            toolAgentAppDetailDO.setTOOLAGENT_APPOID(toolAgentAppDO);
1054            toolAgentAppDetailDO.setAPP_MODE( new BigDecimal JavaDoc(am.getApplicationMode().intValue()));
1055            toolAgentAppDetailDO.save();
1056            dbTrans.write();
1057         }
1058         return toolAgentAppDetailDO;
1059      } catch (Exception JavaDoc e) {
1060         throw new RootException(e);
1061      }
1062   }
1063
1064   private ToolAgentAppUserDO checkToolAgentAppUser (
1065      ApplicationMappingTransaction trans,
1066      ApplicationMap am)
1067      throws RootException {
1068      try {
1069         DBTransaction dbTrans = this.getDBTransaction(trans);
1070
1071         ToolAgentAppUserQuery toolAgentAppUserQuery =
1072            new ToolAgentAppUserQuery(dbTrans);
1073         ToolAgentAppUserDO toolAgentAppUserDO = null;
1074
1075         ToolAgentAppDO toolAgentAppDO = this.checkToolAgentApp(trans, am);
1076         ToolAgentUserDO userDO = this.checkUser(trans, am);
1077
1078         toolAgentAppUserQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1079         toolAgentAppUserQuery.setQueryUSEROID(userDO);
1080         toolAgentAppUserQuery.requireUniqueInstance();
1081         toolAgentAppUserDO = toolAgentAppUserQuery.getNextDO();
1082         if (toolAgentAppUserDO == null) {
1083            toolAgentAppUserDO = ToolAgentAppUserDO.createVirgin(dbTrans);
1084            toolAgentAppUserDO.setTOOLAGENT_APPOID(toolAgentAppDO);
1085            toolAgentAppUserDO.setUSEROID(userDO);
1086            toolAgentAppUserDO.save();
1087            dbTrans.write();
1088         }
1089         return toolAgentAppUserDO;
1090      } catch (Exception JavaDoc e) {
1091         throw new RootException(e);
1092      }
1093   }
1094
1095   private ToolAgentAppDO checkToolAgentApp (
1096      ApplicationMappingTransaction trans,
1097      ApplicationMap am)
1098      throws RootException {
1099      try {
1100         DBTransaction dbTrans = this.getDBTransaction(trans);
1101
1102         ToolAgentAppQuery toolAgentAppQuery =
1103            new ToolAgentAppQuery(dbTrans);
1104         ToolAgentAppDO toolAgentAppDO = null;
1105
1106         toolAgentAppQuery.setQueryTOOL_AGENT_NAME(am.getToolAgentClassName());
1107         toolAgentAppQuery.setQueryAPP_NAME(am.getApplicationName());
1108         toolAgentAppQuery.requireUniqueInstance();
1109         toolAgentAppDO = toolAgentAppQuery.getNextDO();
1110         if (toolAgentAppDO == null) {
1111            toolAgentAppDO = ToolAgentAppDO.createVirgin(dbTrans);
1112            toolAgentAppDO.setTOOL_AGENT_NAME(am.getToolAgentClassName());
1113            toolAgentAppDO.setAPP_NAME(am.getApplicationName());
1114            toolAgentAppDO.save();
1115            dbTrans.write();
1116         }
1117         return toolAgentAppDO;
1118      } catch (Exception JavaDoc e) {
1119         throw new RootException(e);
1120      }
1121   }
1122
1123   private XPDLApplicationProcessDO checkProcess(ApplicationMappingTransaction trans, ApplicationMap am)
1124      throws RootException {
1125      try {
1126         DBTransaction dbTrans = this.getDBTransaction(trans);
1127
1128         XPDLApplicationProcessDO processDO = null;
1129
1130         String JavaDoc processID = am.getProcessDefinitionId();
1131
1132         if (processID != null) {
1133            XPDLApplicationPackageQuery pckgQuery = new XPDLApplicationPackageQuery(dbTrans);
1134            XPDLApplicationPackageDO pckgDO = this.checkPackage(trans, am);
1135
1136            XPDLApplicationProcessQuery procQuery = new XPDLApplicationProcessQuery(dbTrans);
1137            procQuery.setQueryPROCESS_ID(processID);
1138            procQuery.setQueryPACKAGEOID(pckgDO);
1139            procQuery.requireUniqueInstance();
1140            processDO = procQuery.getNextDO();
1141            if (processDO == null) {
1142               //insert new process
1143
processDO = XPDLApplicationProcessDO.createVirgin(dbTrans);
1144               processDO.setPROCESS_ID(am.getProcessDefinitionId());
1145               processDO.setPACKAGEOID(pckgDO);
1146               processDO.save();
1147               dbTrans.write();
1148            }
1149         }
1150         return processDO;
1151      } catch (Exception JavaDoc e) {
1152         throw new RootException(e);
1153      }
1154   }
1155
1156   private XPDLApplicationPackageDO checkPackage(ApplicationMappingTransaction trans, ApplicationMap am)
1157      throws RootException {
1158      try {
1159         DBTransaction dbTrans = this.getDBTransaction(trans);
1160
1161         XPDLApplicationPackageQuery packQuery = new XPDLApplicationPackageQuery(dbTrans);
1162         XPDLApplicationPackageDO packageDO = null;
1163         packQuery.setQueryPACKAGE_ID(am.getPackageId());
1164         packQuery.requireUniqueInstance();
1165         packageDO = packQuery.getNextDO();
1166         if (packageDO == null) {
1167            //insert new package
1168
packageDO = XPDLApplicationPackageDO.createVirgin(dbTrans);
1169            packageDO.setPACKAGE_ID(am.getPackageId());
1170            packageDO.save();
1171            dbTrans.write();
1172         }
1173         return packageDO;
1174      } catch (Exception JavaDoc e) {
1175         throw new RootException(e);
1176      }
1177   }
1178
1179   private ToolAgentUserDO checkUser(ApplicationMappingTransaction trans, ApplicationMap am)
1180      throws RootException {
1181      try {
1182         DBTransaction dbTrans = this.getDBTransaction(trans);
1183
1184         ToolAgentUserQuery userQuery = new ToolAgentUserQuery(dbTrans);
1185         ToolAgentUserDO userDO = null;
1186
1187         userQuery.setQueryUSERNAME(am.getUsername());
1188         userQuery.setQueryPWD(am.getPassword());
1189         userQuery.requireUniqueInstance();
1190         userDO = userQuery.getNextDO();
1191
1192         if (userDO == null) {
1193            userDO = ToolAgentUserDO.createVirgin(dbTrans);
1194            userDO.setUSERNAME(am.getUsername());
1195            userDO.setPWD(am.getPassword());
1196            userDO.save();
1197            dbTrans.write();
1198         }
1199         return userDO;
1200      } catch (Exception JavaDoc e) {
1201         throw new RootException(e);
1202      }
1203   }
1204
1205    private void deleteProcLevelXPDLAppToolAgentAppDetailUser(
1206      ApplicationMap am,
1207      DBTransaction dbTrans)
1208      throws RootException {
1209      try {
1210         String JavaDoc packageId = am.getPackageId();
1211         String JavaDoc processId = am.getProcessDefinitionId();
1212         String JavaDoc applicationId = am.getApplicationDefinitionId();
1213
1214         String JavaDoc toolagent = am.getToolAgentClassName();
1215         String JavaDoc username = am.getUsername();
1216         String JavaDoc password = am.getPassword();
1217         String JavaDoc appName = am.getApplicationName();
1218         Integer JavaDoc appMode = am.getApplicationMode();
1219
1220         // package
1221
XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
1222         packageQuery.setQueryPACKAGE_ID(packageId);
1223         packageQuery.requireUniqueInstance();
1224         XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
1225
1226         // process
1227
XPDLApplicationProcessQuery processQuery = new XPDLApplicationProcessQuery(dbTrans);
1228         processQuery.setQueryPROCESS_ID(processId);
1229         processQuery.setQueryPACKAGEOID(packageDO);
1230         processQuery.requireUniqueInstance();
1231         XPDLApplicationProcessDO processDO = processQuery.getNextDO();
1232
1233         // procLevelXPDLApp
1234
ProcLevelXPDLAppQuery procLevelXPDLAppQuery = new ProcLevelXPDLAppQuery(dbTrans);
1235         procLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationId);
1236         procLevelXPDLAppQuery.setQueryPROCESSOID(processDO);
1237         procLevelXPDLAppQuery.requireUniqueInstance();
1238         ProcLevelXPDLAppDO procLevelXPDLAppDO = procLevelXPDLAppQuery.getNextDO();
1239
1240         // user
1241
ToolAgentUserQuery userQuery = new ToolAgentUserQuery(dbTrans);
1242         userQuery.setQueryUSERNAME(username);
1243         userQuery.setQueryPWD(password);
1244         userQuery.requireUniqueInstance();
1245         ToolAgentUserDO userDO = userQuery.getNextDO();
1246
1247         // toolagentApp
1248
ToolAgentAppQuery toolAgentAppQuery = new ToolAgentAppQuery(dbTrans);
1249         toolAgentAppQuery.setQueryTOOL_AGENT_NAME(toolagent);
1250         toolAgentAppQuery.setQueryAPP_NAME(appName);
1251         toolAgentAppQuery.requireUniqueInstance();
1252         ToolAgentAppDO toolAgentAppDO = toolAgentAppQuery.getNextDO();
1253
1254         // toolagentAppDetail
1255
ToolAgentAppDetailQuery toolAgentAppDetailQuery = new ToolAgentAppDetailQuery(dbTrans);
1256         toolAgentAppDetailQuery.setQueryAPP_MODE(new BigDecimal JavaDoc(appMode.intValue()));
1257         toolAgentAppDetailQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1258         toolAgentAppDetailQuery.requireUniqueInstance();
1259         ToolAgentAppDetailDO toolAgentAppDetailDO = toolAgentAppDetailQuery.getNextDO();
1260
1261         // toolAgentAppDetailUser
1262
ToolAgentAppDetailUserQuery toolAgentAppDetailUserQuery = new ToolAgentAppDetailUserQuery(dbTrans);
1263         toolAgentAppDetailUserQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDetailDO);
1264         toolAgentAppDetailUserQuery.setQueryUSEROID(userDO);
1265         toolAgentAppDetailUserQuery.requireUniqueInstance();
1266         ToolAgentAppDetailUserDO toolAgentAppDetailUserDO = toolAgentAppDetailUserQuery.getNextDO();
1267
1268         // ProcLevelXPDLAppToolAgentAppDetailUser
1269
ProcLevelXPDLAppTAAppDetailUsrQuery procLevelXPDLAppToolAgentAppDetailUserQuery =
1270            new ProcLevelXPDLAppTAAppDetailUsrQuery(dbTrans);
1271         procLevelXPDLAppToolAgentAppDetailUserQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
1272         procLevelXPDLAppToolAgentAppDetailUserQuery.setQueryTOOLAGENTOID(toolAgentAppDetailUserDO);
1273
1274         ProcLevelXPDLAppTAAppDetailUsrDO[] procLevelXPDLAppToolAgentAppDetailUserDOArr =
1275            procLevelXPDLAppToolAgentAppDetailUserQuery.getDOArray();
1276         for (int i = 0; i < procLevelXPDLAppToolAgentAppDetailUserDOArr.length; i++) {
1277            procLevelXPDLAppToolAgentAppDetailUserDOArr[i].delete();
1278         }
1279         dbTrans.write();
1280
1281         //delete unnecessairly data
1282
// ToolAgentAppDetailUser
1283
this.deleteToolAgentAppDetailUser(toolAgentAppDetailUserDO, dbTrans);
1284         // ToolagentAppDetail
1285
this.deleteToolAgentAppDetail(toolAgentAppDetailDO, dbTrans);
1286         // ToolAgentApp
1287
this.deleteToolAgentApp(toolAgentAppDO, dbTrans);
1288         // user
1289
this.deleteUser(userDO, dbTrans);
1290         // procLevelXPDLApp
1291
this.deleteProcLevelXPDLApp(procLevelXPDLAppDO, dbTrans);
1292         // process
1293
this.deleteProcess(processDO, dbTrans);
1294         // package
1295
this.deletePackage(packageDO, dbTrans);
1296      } catch (Exception JavaDoc e) {
1297         throw new RootException(e);
1298      }
1299   }
1300
1301   private void deleteProcLevelXPDLAppToolAgentAppDetail (
1302      ApplicationMap am,
1303      DBTransaction dbTrans)
1304      throws RootException {
1305      try {
1306         String JavaDoc packageId = am.getPackageId();
1307         String JavaDoc processId = am.getProcessDefinitionId();
1308         String JavaDoc applicationId = am.getApplicationDefinitionId();
1309
1310         String JavaDoc toolagent = am.getToolAgentClassName();
1311         String JavaDoc appName = am.getApplicationName();
1312         Integer JavaDoc appMode = am.getApplicationMode();
1313
1314         // package
1315
XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
1316         packageQuery.setQueryPACKAGE_ID(packageId);
1317         packageQuery.requireUniqueInstance();
1318         XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
1319
1320         // process
1321
XPDLApplicationProcessQuery processQuery = new XPDLApplicationProcessQuery(dbTrans);
1322         processQuery.setQueryPROCESS_ID(processId);
1323         processQuery.setQueryPACKAGEOID(packageDO);
1324         processQuery.requireUniqueInstance();
1325         XPDLApplicationProcessDO processDO = processQuery.getNextDO();
1326
1327         // procLevelXPDLApp
1328
ProcLevelXPDLAppQuery procLevelXPDLAppQuery = new ProcLevelXPDLAppQuery(dbTrans);
1329         procLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationId);
1330         procLevelXPDLAppQuery.setQueryPROCESSOID(processDO);
1331         procLevelXPDLAppQuery.requireUniqueInstance();
1332         ProcLevelXPDLAppDO procLevelXPDLAppDO = procLevelXPDLAppQuery.getNextDO();
1333
1334         // toolagentApp
1335
ToolAgentAppQuery toolAgentAppQuery = new ToolAgentAppQuery(dbTrans);
1336         toolAgentAppQuery.setQueryTOOL_AGENT_NAME(toolagent);
1337         toolAgentAppQuery.setQueryAPP_NAME(appName);
1338         toolAgentAppQuery.requireUniqueInstance();
1339         ToolAgentAppDO toolAgentAppDO = toolAgentAppQuery.getNextDO();
1340
1341         // toolAgentAppDetail
1342
ToolAgentAppDetailQuery toolAgentAppDetailQuery = new ToolAgentAppDetailQuery(dbTrans);
1343         toolAgentAppDetailQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1344         toolAgentAppDetailQuery.setQueryAPP_MODE( new BigDecimal JavaDoc(appMode.intValue()));
1345         toolAgentAppDetailQuery.requireUniqueInstance();
1346         ToolAgentAppDetailDO toolAgentAppDetailDO = toolAgentAppDetailQuery.getNextDO();
1347
1348         // ProcLevelXPDLAppToolAgentAppDetail
1349
ProcLevelXPDLAppTAAppDetailQuery procLevelXPDLAppToolAgentAppDetailQuery =
1350            new ProcLevelXPDLAppTAAppDetailQuery(dbTrans);
1351         procLevelXPDLAppToolAgentAppDetailQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
1352         procLevelXPDLAppToolAgentAppDetailQuery.setQueryTOOLAGENTOID(toolAgentAppDetailDO);
1353
1354         ProcLevelXPDLAppTAAppDetailDO[] procLevelXPDLAppToolAgentAppDetailDOArr =
1355            procLevelXPDLAppToolAgentAppDetailQuery.getDOArray();
1356         for (int i = 0; i < procLevelXPDLAppToolAgentAppDetailDOArr.length; i++) {
1357            procLevelXPDLAppToolAgentAppDetailDOArr[i].delete();
1358         }
1359         dbTrans.write();
1360
1361         //delete unnecessairly data
1362
// ToolagentAppDetail
1363
this.deleteToolAgentAppDetail(toolAgentAppDetailDO, dbTrans);
1364         // ToolAgentApp
1365
this.deleteToolAgentApp(toolAgentAppDO, dbTrans);
1366         // procLevelXPDLApp
1367
this.deleteProcLevelXPDLApp(procLevelXPDLAppDO, dbTrans);
1368         // process
1369
this.deleteProcess(processDO, dbTrans);
1370         // package
1371
this.deletePackage(packageDO, dbTrans);
1372      } catch (Exception JavaDoc e) {
1373         throw new RootException(e);
1374      }
1375   }
1376
1377   private void deleteProcLevelXPDLAppToolAgentAppUser(
1378      ApplicationMap am,
1379      DBTransaction dbTrans)
1380      throws RootException {
1381      try {
1382         String JavaDoc packageId = am.getPackageId();
1383         String JavaDoc processId = am.getProcessDefinitionId();
1384         String JavaDoc applicationId = am.getApplicationDefinitionId();
1385
1386         String JavaDoc toolagent = am.getToolAgentClassName();
1387         String JavaDoc username = am.getUsername();
1388         String JavaDoc password = am.getPassword();
1389         String JavaDoc appName = am.getApplicationName();
1390
1391         // package
1392
XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
1393         packageQuery.setQueryPACKAGE_ID(packageId);
1394         packageQuery.requireUniqueInstance();
1395         XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
1396
1397         // process
1398
XPDLApplicationProcessQuery processQuery = new XPDLApplicationProcessQuery(dbTrans);
1399         processQuery.setQueryPROCESS_ID(processId);
1400         processQuery.setQueryPACKAGEOID(packageDO);
1401         processQuery.requireUniqueInstance();
1402         XPDLApplicationProcessDO processDO = processQuery.getNextDO();
1403
1404         // procLevelXPDLApp
1405
ProcLevelXPDLAppQuery procLevelXPDLAppQuery = new ProcLevelXPDLAppQuery(dbTrans);
1406         procLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationId);
1407         procLevelXPDLAppQuery.setQueryPROCESSOID(processDO);
1408         procLevelXPDLAppQuery.requireUniqueInstance();
1409         ProcLevelXPDLAppDO procLevelXPDLAppDO = procLevelXPDLAppQuery.getNextDO();
1410
1411         // user
1412
ToolAgentUserQuery userQuery = new ToolAgentUserQuery(dbTrans);
1413         userQuery.setQueryUSERNAME(username);
1414         userQuery.setQueryPWD(password);
1415         userQuery.requireUniqueInstance();
1416         ToolAgentUserDO userDO = userQuery.getNextDO();
1417
1418         // toolagentApp
1419
ToolAgentAppQuery toolAgentAppQuery = new ToolAgentAppQuery(dbTrans);
1420         toolAgentAppQuery.setQueryTOOL_AGENT_NAME(toolagent);
1421         toolAgentAppQuery.setQueryAPP_NAME(appName);
1422         toolAgentAppQuery.requireUniqueInstance();
1423         ToolAgentAppDO toolAgentAppDO = toolAgentAppQuery.getNextDO();
1424
1425         // toolAgentAppUser
1426
ToolAgentAppUserQuery toolAgentAppUserQuery = new ToolAgentAppUserQuery(dbTrans);
1427         toolAgentAppUserQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1428         toolAgentAppUserQuery.setQueryUSEROID(userDO);
1429         toolAgentAppUserQuery.requireUniqueInstance();
1430         ToolAgentAppUserDO toolAgentAppUserDO = toolAgentAppUserQuery.getNextDO();
1431
1432         // ProcLevelXPDLAppToolAgentAppUser
1433
ProcLevelXPDLAppTAAppUserQuery procLevelXPDLAppToolAgentAppUserQuery =
1434            new ProcLevelXPDLAppTAAppUserQuery(dbTrans);
1435         procLevelXPDLAppToolAgentAppUserQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
1436         procLevelXPDLAppToolAgentAppUserQuery.setQueryTOOLAGENTOID(toolAgentAppUserDO);
1437
1438         ProcLevelXPDLAppTAAppUserDO[] procLevelXPDLAppToolAgentAppUserDOArr =
1439            procLevelXPDLAppToolAgentAppUserQuery.getDOArray();
1440         for (int i = 0; i < procLevelXPDLAppToolAgentAppUserDOArr.length; i++) {
1441            procLevelXPDLAppToolAgentAppUserDOArr[i].delete();
1442         }
1443         dbTrans.write();
1444
1445         //delete unnecessairly data
1446
// ToolAgentAppUser
1447
this.deleteToolAgentAppUser(toolAgentAppUserDO, dbTrans);
1448         // ToolAgentApp
1449
this.deleteToolAgentApp(toolAgentAppDO, dbTrans);
1450         // user
1451
this.deleteUser(userDO, dbTrans);
1452         // procLevelXPDLApp
1453
this.deleteProcLevelXPDLApp(procLevelXPDLAppDO, dbTrans);
1454         // process
1455
this.deleteProcess(processDO, dbTrans);
1456         // package
1457
this.deletePackage(packageDO, dbTrans);
1458      } catch (Exception JavaDoc e) {
1459         throw new RootException(e);
1460      }
1461   }
1462
1463   private void deleteProcLevelXPDLAppToolAgentApp(
1464      ApplicationMap am,
1465      DBTransaction dbTrans)
1466      throws RootException {
1467      try {
1468         String JavaDoc packageId = am.getPackageId();
1469         String JavaDoc processId = am.getProcessDefinitionId();
1470         String JavaDoc applicationId = am.getApplicationDefinitionId();
1471
1472         String JavaDoc toolagent = am.getToolAgentClassName();
1473         String JavaDoc appName = am.getApplicationName();
1474
1475         // package
1476
XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
1477         packageQuery.setQueryPACKAGE_ID(packageId);
1478         packageQuery.requireUniqueInstance();
1479         XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
1480
1481         // process
1482
XPDLApplicationProcessQuery processQuery = new XPDLApplicationProcessQuery(dbTrans);
1483         processQuery.setQueryPROCESS_ID(processId);
1484         processQuery.setQueryPACKAGEOID(packageDO);
1485         processQuery.requireUniqueInstance();
1486         XPDLApplicationProcessDO processDO = processQuery.getNextDO();
1487
1488         // procLevelXPDLApp
1489
ProcLevelXPDLAppQuery procLevelXPDLAppQuery = new ProcLevelXPDLAppQuery(dbTrans);
1490         procLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationId);
1491         procLevelXPDLAppQuery.setQueryPROCESSOID(processDO);
1492         procLevelXPDLAppQuery.requireUniqueInstance();
1493         ProcLevelXPDLAppDO procLevelXPDLAppDO = procLevelXPDLAppQuery.getNextDO();
1494
1495         // toolagentApp
1496
ToolAgentAppQuery toolAgentAppQuery = new ToolAgentAppQuery(dbTrans);
1497         toolAgentAppQuery.setQueryTOOL_AGENT_NAME(toolagent);
1498         toolAgentAppQuery.setQueryAPP_NAME(appName);
1499         toolAgentAppQuery.requireUniqueInstance();
1500         ToolAgentAppDO toolAgentAppDO = toolAgentAppQuery.getNextDO();
1501
1502         // ProcLevelXPDLAppToolAgentApp
1503
ProcLevelXPDLAppToolAgentAppQuery procLevelXPDLAppToolAgentAppQuery =
1504            new ProcLevelXPDLAppToolAgentAppQuery(dbTrans);
1505         procLevelXPDLAppToolAgentAppQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
1506         procLevelXPDLAppToolAgentAppQuery.setQueryTOOLAGENTOID(toolAgentAppDO);
1507
1508         ProcLevelXPDLAppToolAgentAppDO[] procLevelXPDLAppToolAgentAppDOArr =
1509            procLevelXPDLAppToolAgentAppQuery.getDOArray();
1510         for (int i = 0; i < procLevelXPDLAppToolAgentAppDOArr.length; i++) {
1511            procLevelXPDLAppToolAgentAppDOArr[i].delete();
1512         }
1513         dbTrans.write();
1514
1515         //delete unnecessairly data
1516
// ToolAgentApp
1517
this.deleteToolAgentApp(toolAgentAppDO, dbTrans);
1518         // procLevelXPDLApp
1519
this.deleteProcLevelXPDLApp(procLevelXPDLAppDO, dbTrans);
1520         // process
1521
this.deleteProcess(processDO, dbTrans);
1522         // package
1523
this.deletePackage(packageDO, dbTrans);
1524      } catch (Exception JavaDoc e) {
1525         throw new RootException(e);
1526      }
1527   }
1528
1529   private void deletePackLevelXPDLAppToolAgentAppDetailUser(
1530      ApplicationMap am,
1531      DBTransaction dbTrans)
1532      throws RootException {
1533      try {
1534         String JavaDoc packageId = am.getPackageId();
1535         String JavaDoc applicationId = am.getApplicationDefinitionId();
1536
1537         String JavaDoc toolagent = am.getToolAgentClassName();
1538         String JavaDoc username = am.getUsername();
1539         String JavaDoc password = am.getPassword();
1540         String JavaDoc appName = am.getApplicationName();
1541         Integer JavaDoc appMode = am.getApplicationMode();
1542
1543         // package
1544
XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
1545         packageQuery.setQueryPACKAGE_ID(packageId);
1546         packageQuery.requireUniqueInstance();
1547         XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
1548
1549         // packLevelXPDLApp
1550
PackLevelXPDLAppQuery packLevelXPDLAppQuery = new PackLevelXPDLAppQuery(dbTrans);
1551         packLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationId);
1552         packLevelXPDLAppQuery.setQueryPACKAGEOID(packageDO);
1553         packLevelXPDLAppQuery.requireUniqueInstance();
1554         PackLevelXPDLAppDO packLevelXPDLAppDO = packLevelXPDLAppQuery.getNextDO();
1555
1556         // user
1557
ToolAgentUserQuery userQuery = new ToolAgentUserQuery(dbTrans);
1558         userQuery.setQueryUSERNAME(username);
1559         userQuery.setQueryPWD(password);
1560         userQuery.requireUniqueInstance();
1561         ToolAgentUserDO userDO = userQuery.getNextDO();
1562
1563         // toolagentApp
1564
ToolAgentAppQuery toolAgentAppQuery = new ToolAgentAppQuery(dbTrans);
1565         toolAgentAppQuery.setQueryTOOL_AGENT_NAME(toolagent);
1566         toolAgentAppQuery.setQueryAPP_NAME(appName);
1567         toolAgentAppQuery.requireUniqueInstance();
1568         ToolAgentAppDO toolAgentAppDO = toolAgentAppQuery.getNextDO();
1569
1570         // toolagentAppDetail
1571
ToolAgentAppDetailQuery toolAgentAppDetailQuery = new ToolAgentAppDetailQuery(dbTrans);
1572         toolAgentAppDetailQuery.setQueryAPP_MODE( new BigDecimal JavaDoc(appMode.intValue()));
1573         toolAgentAppDetailQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1574         toolAgentAppDetailQuery.requireUniqueInstance();
1575         ToolAgentAppDetailDO toolAgentAppDetailDO = toolAgentAppDetailQuery.getNextDO();
1576
1577         // toolAgentAppDetailUser
1578
ToolAgentAppDetailUserQuery toolAgentAppDetailUserQuery = new ToolAgentAppDetailUserQuery(dbTrans);
1579         toolAgentAppDetailUserQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDetailDO);
1580         toolAgentAppDetailUserQuery.setQueryUSEROID(userDO);
1581         toolAgentAppDetailUserQuery.requireUniqueInstance();
1582         ToolAgentAppDetailUserDO toolAgentAppDetailUserDO = toolAgentAppDetailUserQuery.getNextDO();
1583
1584         // PackLevelXPDLAppToolAgentAppDetailUser
1585
PackLevelXPDLAppTAAppDetailUsrQuery packLevelXPDLAppToolAgentAppDetailUserQuery =
1586            new PackLevelXPDLAppTAAppDetailUsrQuery(dbTrans);
1587         packLevelXPDLAppToolAgentAppDetailUserQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
1588         packLevelXPDLAppToolAgentAppDetailUserQuery.setQueryTOOLAGENTOID(toolAgentAppDetailUserDO);
1589
1590         PackLevelXPDLAppTAAppDetailUsrDO[] packLevelXPDLAppToolAgentAppDetailUserDOArr =
1591            packLevelXPDLAppToolAgentAppDetailUserQuery.getDOArray();
1592         for (int i = 0; i < packLevelXPDLAppToolAgentAppDetailUserDOArr.length; i++) {
1593            packLevelXPDLAppToolAgentAppDetailUserDOArr[i].delete();
1594         }
1595         dbTrans.write();
1596
1597         //delete unnecessairly data
1598
// ToolAgentAppDetailUser
1599
this.deleteToolAgentAppDetailUser(toolAgentAppDetailUserDO, dbTrans);
1600         // ToolagentAppDetail
1601
this.deleteToolAgentAppDetail(toolAgentAppDetailDO, dbTrans);
1602         // ToolAgentApp
1603
this.deleteToolAgentApp(toolAgentAppDO, dbTrans);
1604         // user
1605
this.deleteUser(userDO, dbTrans);
1606         // packLevelXPDLApp
1607
this.deletePackLevelXPDLApp(packLevelXPDLAppDO, dbTrans);
1608         // package
1609
this.deletePackage(packageDO, dbTrans);
1610      } catch (Exception JavaDoc e) {
1611         throw new RootException(e);
1612      }
1613   }
1614
1615   private void deletePackLevelXPDLAppToolAgentAppDetail (
1616      ApplicationMap am,
1617      DBTransaction dbTrans)
1618      throws RootException {
1619      try {
1620         String JavaDoc packageId = am.getPackageId();
1621         String JavaDoc applicationId = am.getApplicationDefinitionId();
1622
1623         String JavaDoc toolagent = am.getToolAgentClassName();
1624         String JavaDoc appName = am.getApplicationName();
1625         Integer JavaDoc appMode = am.getApplicationMode();
1626
1627         // package
1628
XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
1629         packageQuery.setQueryPACKAGE_ID(packageId);
1630         packageQuery.requireUniqueInstance();
1631         XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
1632
1633         // packLevelXPDLApp
1634
PackLevelXPDLAppQuery packLevelXPDLAppQuery = new PackLevelXPDLAppQuery(dbTrans);
1635         packLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationId);
1636         packLevelXPDLAppQuery.setQueryPACKAGEOID(packageDO);
1637         packLevelXPDLAppQuery.requireUniqueInstance();
1638         PackLevelXPDLAppDO packLevelXPDLAppDO = packLevelXPDLAppQuery.getNextDO();
1639
1640         // toolagentApp
1641
ToolAgentAppQuery toolAgentAppQuery = new ToolAgentAppQuery(dbTrans);
1642         toolAgentAppQuery.setQueryTOOL_AGENT_NAME(toolagent);
1643         toolAgentAppQuery.setQueryAPP_NAME(appName);
1644         toolAgentAppQuery.requireUniqueInstance();
1645         ToolAgentAppDO toolAgentAppDO = toolAgentAppQuery.getNextDO();
1646
1647         // toolAgentAppDetail
1648
ToolAgentAppDetailQuery toolAgentAppDetailQuery = new ToolAgentAppDetailQuery(dbTrans);
1649         toolAgentAppDetailQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1650         toolAgentAppDetailQuery.setQueryAPP_MODE( new BigDecimal JavaDoc(appMode.intValue()));
1651         toolAgentAppDetailQuery.requireUniqueInstance();
1652         ToolAgentAppDetailDO toolAgentAppDetailDO = toolAgentAppDetailQuery.getNextDO();
1653
1654         // ProcLevelXPDLAppToolAgentAppDetail
1655
PackLevelXPDLAppTAAppDetailQuery packLevelXPDLAppToolAgentAppDetailQuery =
1656            new PackLevelXPDLAppTAAppDetailQuery(dbTrans);
1657         packLevelXPDLAppToolAgentAppDetailQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
1658         packLevelXPDLAppToolAgentAppDetailQuery.setQueryTOOLAGENTOID(toolAgentAppDetailDO);
1659
1660         PackLevelXPDLAppTAAppDetailDO[] packLevelXPDLAppToolAgentAppDetailDOArr =
1661            packLevelXPDLAppToolAgentAppDetailQuery.getDOArray();
1662         for (int i = 0; i < packLevelXPDLAppToolAgentAppDetailDOArr.length; i++) {
1663            packLevelXPDLAppToolAgentAppDetailDOArr[i].delete();
1664         }
1665         dbTrans.write();
1666
1667         //delete unnecessairly data
1668
// ToolAgentAppDetail
1669
this.deleteToolAgentAppDetail(toolAgentAppDetailDO, dbTrans);
1670         // ToolAgentApp
1671
this.deleteToolAgentApp(toolAgentAppDO, dbTrans);
1672         // packLevelXPDLApp
1673
this.deletePackLevelXPDLApp(packLevelXPDLAppDO, dbTrans);
1674         // package
1675
this.deletePackage(packageDO, dbTrans);
1676      } catch (Exception JavaDoc e) {
1677         throw new RootException(e);
1678      }
1679   }
1680
1681   private void deletePackLevelXPDLAppToolAgentAppUser(
1682      ApplicationMap am,
1683      DBTransaction dbTrans)
1684      throws RootException {
1685      try {
1686         String JavaDoc packageId = am.getPackageId();
1687         String JavaDoc applicationId = am.getApplicationDefinitionId();
1688
1689         String JavaDoc toolagent = am.getToolAgentClassName();
1690         String JavaDoc username = am.getUsername();
1691         String JavaDoc password = am.getPassword();
1692         String JavaDoc appName = am.getApplicationName();
1693
1694         // package
1695
XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
1696         packageQuery.setQueryPACKAGE_ID(packageId);
1697         packageQuery.requireUniqueInstance();
1698         XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
1699
1700         // packLevelXPDLApp
1701
PackLevelXPDLAppQuery packLevelXPDLAppQuery = new PackLevelXPDLAppQuery(dbTrans);
1702         packLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationId);
1703         packLevelXPDLAppQuery.setQueryPACKAGEOID(packageDO);
1704         packLevelXPDLAppQuery.requireUniqueInstance();
1705         PackLevelXPDLAppDO packLevelXPDLAppDO = packLevelXPDLAppQuery.getNextDO();
1706
1707         // user
1708
ToolAgentUserQuery userQuery = new ToolAgentUserQuery(dbTrans);
1709         userQuery.setQueryUSERNAME(username);
1710         userQuery.setQueryPWD(password);
1711         userQuery.requireUniqueInstance();
1712         ToolAgentUserDO userDO = userQuery.getNextDO();
1713
1714         // toolagentApp
1715
ToolAgentAppQuery toolAgentAppQuery = new ToolAgentAppQuery(dbTrans);
1716         toolAgentAppQuery.setQueryTOOL_AGENT_NAME(toolagent);
1717         toolAgentAppQuery.setQueryAPP_NAME(appName);
1718         toolAgentAppQuery.requireUniqueInstance();
1719         ToolAgentAppDO toolAgentAppDO = toolAgentAppQuery.getNextDO();
1720
1721         // toolAgentAppUser
1722
ToolAgentAppUserQuery toolAgentAppUserQuery = new ToolAgentAppUserQuery(dbTrans);
1723         toolAgentAppUserQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1724         toolAgentAppUserQuery.setQueryUSEROID(userDO);
1725         toolAgentAppUserQuery.requireUniqueInstance();
1726         ToolAgentAppUserDO toolAgentAppUserDO = toolAgentAppUserQuery.getNextDO();
1727
1728         // ProcLevelXPDLAppToolAgentAppUser
1729
PackLevelXPDLAppTAAppUserQuery packLevelXPDLAppToolAgentAppUserQuery =
1730            new PackLevelXPDLAppTAAppUserQuery(dbTrans);
1731         packLevelXPDLAppToolAgentAppUserQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
1732         packLevelXPDLAppToolAgentAppUserQuery.setQueryTOOLAGENTOID(toolAgentAppUserDO);
1733
1734         PackLevelXPDLAppTAAppUserDO[] packLevelXPDLAppToolAgentAppUserDOArr =
1735            packLevelXPDLAppToolAgentAppUserQuery.getDOArray();
1736         for (int i = 0; i < packLevelXPDLAppToolAgentAppUserDOArr.length; i++) {
1737            packLevelXPDLAppToolAgentAppUserDOArr[i].delete();
1738         }
1739         dbTrans.write();
1740
1741         //delete unnecessairly data
1742
// ToolAgentAppUser
1743
this.deleteToolAgentAppUser(toolAgentAppUserDO, dbTrans);
1744         // ToolAgentApp
1745
this.deleteToolAgentApp(toolAgentAppDO, dbTrans);
1746         // user
1747
this.deleteUser(userDO, dbTrans);
1748         // packLevelXPDLApp
1749
this.deletePackLevelXPDLApp(packLevelXPDLAppDO, dbTrans);
1750         // package
1751
this.deletePackage(packageDO, dbTrans);
1752      } catch (Exception JavaDoc e) {
1753         throw new RootException(e);
1754      }
1755   }
1756
1757   private void deletePackLevelXPDLAppToolAgentApp(
1758      ApplicationMap am,
1759      DBTransaction dbTrans)
1760      throws RootException {
1761      try {
1762         String JavaDoc packageId = am.getPackageId();
1763         String JavaDoc applicationId = am.getApplicationDefinitionId();
1764
1765         String JavaDoc toolagent = am.getToolAgentClassName();
1766         String JavaDoc appName = am.getApplicationName();
1767
1768         // package
1769
XPDLApplicationPackageQuery packageQuery = new XPDLApplicationPackageQuery(dbTrans);
1770         packageQuery.setQueryPACKAGE_ID(packageId);
1771         packageQuery.requireUniqueInstance();
1772         XPDLApplicationPackageDO packageDO = packageQuery.getNextDO();
1773
1774         // packLevelXPDLApp
1775
PackLevelXPDLAppQuery packLevelXPDLAppQuery = new PackLevelXPDLAppQuery(dbTrans);
1776         packLevelXPDLAppQuery.setQueryAPPLICATION_ID(applicationId);
1777         packLevelXPDLAppQuery.setQueryPACKAGEOID(packageDO);
1778         packLevelXPDLAppQuery.requireUniqueInstance();
1779         PackLevelXPDLAppDO packLevelXPDLAppDO = packLevelXPDLAppQuery.getNextDO();
1780
1781         // toolagentApp
1782
ToolAgentAppQuery toolAgentAppQuery = new ToolAgentAppQuery(dbTrans);
1783         toolAgentAppQuery.setQueryTOOL_AGENT_NAME(toolagent);
1784         toolAgentAppQuery.setQueryAPP_NAME(appName);
1785         toolAgentAppQuery.requireUniqueInstance();
1786         ToolAgentAppDO toolAgentAppDO = toolAgentAppQuery.getNextDO();
1787
1788         // PackLevelXPDLAppToolAgentApp
1789
PackLevelXPDLAppToolAgentAppQuery packLevelXPDLAppToolAgentAppQuery =
1790            new PackLevelXPDLAppToolAgentAppQuery(dbTrans);
1791         packLevelXPDLAppToolAgentAppQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
1792         packLevelXPDLAppToolAgentAppQuery.setQueryTOOLAGENTOID(toolAgentAppDO);
1793
1794         PackLevelXPDLAppToolAgentAppDO[] packLevelXPDLAppToolAgentAppDOArr =
1795            packLevelXPDLAppToolAgentAppQuery.getDOArray();
1796         for (int i = 0; i < packLevelXPDLAppToolAgentAppDOArr.length; i++) {
1797            packLevelXPDLAppToolAgentAppDOArr[i].delete();
1798         }
1799         dbTrans.write();
1800
1801         //delete unnecessairly data
1802
// ToolAgentApp
1803
this.deleteToolAgentApp(toolAgentAppDO, dbTrans);
1804         // packLevelXPDLApp
1805
this.deletePackLevelXPDLApp(packLevelXPDLAppDO, dbTrans);
1806         // package
1807
this.deletePackage(packageDO, dbTrans);
1808      } catch (Exception JavaDoc e) {
1809         throw new RootException(e);
1810      }
1811   }
1812
1813   private void deletePackage(XPDLApplicationPackageDO packageDO, DBTransaction dbTrans)
1814      throws RootException {
1815      try {
1816         if( packageDO == null )
1817            return;
1818         XPDLApplicationProcessQuery processQuery = new XPDLApplicationProcessQuery(dbTrans);
1819         processQuery.setQueryPACKAGEOID(packageDO);
1820
1821         PackLevelXPDLAppQuery packLevelXPDLAppQuery =
1822            new PackLevelXPDLAppQuery(dbTrans);
1823         packLevelXPDLAppQuery.setQueryPACKAGEOID(packageDO);
1824
1825         if (processQuery.getDOArray().length == 0
1826            && packLevelXPDLAppQuery.getDOArray().length == 0)
1827            packageDO.delete();
1828         dbTrans.write();
1829      } catch (Exception JavaDoc e) {
1830         throw new RootException(e);
1831      }
1832   }
1833
1834   private void deleteProcess(XPDLApplicationProcessDO processDO, DBTransaction dbTrans)
1835      throws RootException {
1836      try {
1837         if( processDO == null )
1838            return;
1839
1840         ProcLevelXPDLAppQuery procLevelXPDLAppQuery =
1841            new ProcLevelXPDLAppQuery(dbTrans);
1842         procLevelXPDLAppQuery.setQueryPROCESSOID(processDO);
1843
1844         if (procLevelXPDLAppQuery.getDOArray().length == 0)
1845            processDO.delete();
1846         dbTrans.write();
1847      } catch (Exception JavaDoc e) {
1848         throw new RootException(e);
1849      }
1850   }
1851
1852   private void deleteUser(ToolAgentUserDO userDO, DBTransaction dbTrans)
1853      throws RootException {
1854      try {
1855         if( userDO == null )
1856            return;
1857
1858         ToolAgentAppUserQuery toolAgentAppUserQuery =
1859            new ToolAgentAppUserQuery(dbTrans);
1860         toolAgentAppUserQuery.setQueryUSEROID(userDO);
1861
1862         ToolAgentAppDetailUserQuery toolAgentAppDetailUserQuery =
1863            new ToolAgentAppDetailUserQuery (dbTrans);
1864         toolAgentAppDetailUserQuery.setQueryUSEROID(userDO);
1865
1866         if (toolAgentAppUserQuery.getDOArray().length == 0
1867            && toolAgentAppDetailUserQuery.getDOArray().length == 0) {
1868            userDO.delete();
1869         }
1870         dbTrans.write();
1871      } catch (Exception JavaDoc e) {
1872         throw new RootException(e);
1873      }
1874   }
1875
1876   private void deleteToolAgentApp(ToolAgentAppDO toolAgentAppDO, DBTransaction dbTrans)
1877      throws RootException {
1878      try {
1879         if( toolAgentAppDO == null )
1880            return;
1881
1882         ToolAgentAppDetailQuery toolAgentAppDetailQuery =
1883            new ToolAgentAppDetailQuery(dbTrans);
1884         toolAgentAppDetailQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1885
1886         ToolAgentAppUserQuery toolAgentAppUserQuery =
1887            new ToolAgentAppUserQuery (dbTrans);
1888         toolAgentAppUserQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDO);
1889
1890         PackLevelXPDLAppToolAgentAppQuery packLevelXPDLAppToolAgentAppQuery =
1891            new PackLevelXPDLAppToolAgentAppQuery (dbTrans);
1892         packLevelXPDLAppToolAgentAppQuery.setQueryTOOLAGENTOID(toolAgentAppDO);
1893
1894         ProcLevelXPDLAppToolAgentAppQuery procLevelXPDLAppToolAgentAppQuery =
1895            new ProcLevelXPDLAppToolAgentAppQuery (dbTrans);
1896         procLevelXPDLAppToolAgentAppQuery.setQueryTOOLAGENTOID(toolAgentAppDO);
1897
1898         if (toolAgentAppDetailQuery.getDOArray().length == 0
1899            && toolAgentAppUserQuery.getDOArray().length == 0
1900            && packLevelXPDLAppToolAgentAppQuery.getDOArray().length == 0
1901            && procLevelXPDLAppToolAgentAppQuery.getDOArray().length == 0) {
1902            toolAgentAppDO.delete();
1903         }
1904         dbTrans.write();
1905      } catch (Exception JavaDoc e) {
1906         throw new RootException(e);
1907      }
1908   }
1909
1910   private void deleteToolAgentAppUser (ToolAgentAppUserDO toolAgentAppUserDO, DBTransaction dbTrans)
1911      throws RootException {
1912      try {
1913         if( toolAgentAppUserDO == null )
1914            return;
1915
1916         PackLevelXPDLAppTAAppUserQuery packLevelXPDLAppToolAgentAppUserQuery =
1917            new PackLevelXPDLAppTAAppUserQuery (dbTrans);
1918         packLevelXPDLAppToolAgentAppUserQuery.setQueryTOOLAGENTOID(toolAgentAppUserDO);
1919
1920         ProcLevelXPDLAppTAAppUserQuery procLevelXPDLAppToolAgentAppUserQuery =
1921            new ProcLevelXPDLAppTAAppUserQuery (dbTrans);
1922         procLevelXPDLAppToolAgentAppUserQuery.setQueryTOOLAGENTOID(toolAgentAppUserDO);
1923
1924         if (packLevelXPDLAppToolAgentAppUserQuery.getDOArray().length == 0
1925            && procLevelXPDLAppToolAgentAppUserQuery.getDOArray().length == 0) {
1926            toolAgentAppUserDO.delete();
1927         }
1928         dbTrans.write();
1929      } catch (Exception JavaDoc e) {
1930         throw new RootException(e);
1931      }
1932   }
1933
1934   private void deleteToolAgentAppDetail (ToolAgentAppDetailDO toolAgentAppDetailDO, DBTransaction dbTrans)
1935      throws RootException {
1936      try {
1937         if( toolAgentAppDetailDO == null )
1938            return;
1939
1940         ToolAgentAppDetailUserQuery toolAgentAppDetailUserQuery =
1941            new ToolAgentAppDetailUserQuery (dbTrans);
1942         toolAgentAppDetailUserQuery.setQueryTOOLAGENT_APPOID(toolAgentAppDetailDO);
1943
1944         PackLevelXPDLAppTAAppDetailQuery packLevelXPDLAppToolAgentAppDetailQuery =
1945            new PackLevelXPDLAppTAAppDetailQuery (dbTrans);
1946         packLevelXPDLAppToolAgentAppDetailQuery.setQueryTOOLAGENTOID(toolAgentAppDetailDO);
1947
1948         ProcLevelXPDLAppTAAppDetailQuery procLevelXPDLAppToolAgentAppDetailQuery =
1949            new ProcLevelXPDLAppTAAppDetailQuery (dbTrans);
1950         procLevelXPDLAppToolAgentAppDetailQuery.setQueryTOOLAGENTOID(toolAgentAppDetailDO);
1951
1952         if (toolAgentAppDetailUserQuery.getDOArray().length == 0
1953            && packLevelXPDLAppToolAgentAppDetailQuery.getDOArray().length == 0
1954            && procLevelXPDLAppToolAgentAppDetailQuery.getDOArray().length == 0) {
1955            toolAgentAppDetailDO.delete();
1956         }
1957         dbTrans.write();
1958      } catch (Exception JavaDoc e) {
1959         throw new RootException(e);
1960      }
1961   }
1962
1963   private void deleteToolAgentAppDetailUser (ToolAgentAppDetailUserDO toolAgentAppDetailUserDO, DBTransaction dbTrans)
1964      throws RootException {
1965      try {
1966         if( toolAgentAppDetailUserDO == null )
1967            return;
1968
1969         PackLevelXPDLAppTAAppDetailUsrQuery packLevelXPDLAppToolAgentAppDetailUserQuery =
1970            new PackLevelXPDLAppTAAppDetailUsrQuery (dbTrans);
1971         packLevelXPDLAppToolAgentAppDetailUserQuery.setQueryTOOLAGENTOID(toolAgentAppDetailUserDO);
1972
1973         ProcLevelXPDLAppTAAppDetailUsrQuery procLevelXPDLAppToolAgentAppDetailUserQuery =
1974            new ProcLevelXPDLAppTAAppDetailUsrQuery (dbTrans);
1975         procLevelXPDLAppToolAgentAppDetailUserQuery.setQueryTOOLAGENTOID(toolAgentAppDetailUserDO);
1976
1977         if (packLevelXPDLAppToolAgentAppDetailUserQuery.getDOArray().length == 0
1978            && procLevelXPDLAppToolAgentAppDetailUserQuery.getDOArray().length == 0) {
1979            toolAgentAppDetailUserDO.delete();
1980         }
1981         dbTrans.write();
1982      } catch (Exception JavaDoc e) {
1983         throw new RootException(e);
1984      }
1985   }
1986
1987   private void deletePackLevelXPDLApp (PackLevelXPDLAppDO packLevelXPDLAppDO,
1988       DBTransaction dbTrans) throws RootException {
1989      try {
1990         if( packLevelXPDLAppDO == null )
1991            return;
1992
1993         PackLevelXPDLAppToolAgentAppQuery packLevelXPDLAppToolAgentAppQuery =
1994            new PackLevelXPDLAppToolAgentAppQuery (dbTrans);
1995         packLevelXPDLAppToolAgentAppQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
1996
1997         PackLevelXPDLAppTAAppDetailQuery packLevelXPDLAppToolAgentAppDetailQuery =
1998            new PackLevelXPDLAppTAAppDetailQuery (dbTrans);
1999         packLevelXPDLAppToolAgentAppDetailQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
2000
2001         PackLevelXPDLAppTAAppUserQuery packLevelXPDLAppToolAgentAppUserQuery =
2002            new PackLevelXPDLAppTAAppUserQuery (dbTrans);
2003         packLevelXPDLAppToolAgentAppUserQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
2004
2005         PackLevelXPDLAppTAAppDetailUsrQuery packLevelXPDLAppToolAgentAppDetailUserQuery =
2006            new PackLevelXPDLAppTAAppDetailUsrQuery (dbTrans);
2007         packLevelXPDLAppToolAgentAppDetailUserQuery.setQueryXPDL_APPOID(packLevelXPDLAppDO);
2008
2009         if (packLevelXPDLAppToolAgentAppQuery.getDOArray().length == 0
2010            && packLevelXPDLAppToolAgentAppDetailQuery.getDOArray().length == 0
2011            && packLevelXPDLAppToolAgentAppUserQuery.getDOArray().length == 0
2012            && packLevelXPDLAppToolAgentAppDetailUserQuery.getDOArray().length == 0) {
2013            packLevelXPDLAppDO.delete();
2014         }
2015         dbTrans.write();
2016      } catch (Exception JavaDoc e) {
2017         throw new RootException(e);
2018      }
2019   }
2020
2021   private void deleteProcLevelXPDLApp(ProcLevelXPDLAppDO procLevelXPDLAppDO, DBTransaction dbTrans)
2022      throws RootException {
2023      try {
2024         if( procLevelXPDLAppDO == null )
2025            return;
2026
2027         ProcLevelXPDLAppToolAgentAppQuery procLevelXPDLAppToolAgentAppQuery =
2028            new ProcLevelXPDLAppToolAgentAppQuery (dbTrans);
2029         procLevelXPDLAppToolAgentAppQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
2030
2031         ProcLevelXPDLAppTAAppDetailQuery procLevelXPDLAppToolAgentAppDetailQuery =
2032            new ProcLevelXPDLAppTAAppDetailQuery (dbTrans);
2033         procLevelXPDLAppToolAgentAppDetailQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
2034
2035         ProcLevelXPDLAppTAAppUserQuery procLevelXPDLAppToolAgentAppUserQuery =
2036            new ProcLevelXPDLAppTAAppUserQuery (dbTrans);
2037         procLevelXPDLAppToolAgentAppUserQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
2038
2039         ProcLevelXPDLAppTAAppDetailUsrQuery procLevelXPDLAppToolAgentAppDetailUserQuery =
2040            new ProcLevelXPDLAppTAAppDetailUsrQuery (dbTrans);
2041         procLevelXPDLAppToolAgentAppDetailUserQuery.setQueryXPDL_APPOID(procLevelXPDLAppDO);
2042
2043         if (procLevelXPDLAppToolAgentAppQuery.getDOArray().length == 0
2044            && procLevelXPDLAppToolAgentAppDetailQuery.getDOArray().length == 0
2045            && procLevelXPDLAppToolAgentAppUserQuery.getDOArray().length == 0
2046            && procLevelXPDLAppToolAgentAppDetailUserQuery.getDOArray().length == 0) {
2047            procLevelXPDLAppDO.delete();
2048         }
2049         dbTrans.write();
2050      } catch (Exception JavaDoc e) {
2051         throw new RootException(e);
2052      }
2053   }
2054}
2055
Popular Tags