KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > ImportDefinitionElement


1 /**
2   ImportDefinitionElement - ImportDefinition element in xml file.
3
4     Copyright (C) 2002-2003 Together
5
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Lesser General Public
8     License as published by the Free Software Foundation; either
9     version 2.1 of the License, or (at your option) any later version.
10
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14     Lesser General Public License for more details.
15
16     You should have received a copy of the GNU Lesser General Public
17     License along with this library; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20  */

21
22 package org.webdocwf.util.loader;
23
24 import java.util.Vector JavaDoc;
25
26 import org.w3c.dom.Document JavaDoc;
27 import org.webdocwf.util.loader.logging.Logger;
28
29 /**
30  * Class is wrapper for ImportDefinitionElement tag in XML file.
31  *
32  * @author Zoran Milakovic
33  * @version 1.1
34  */

35 public class ImportDefinitionElement {
36
37   private Logger logger;
38   private LoaderJobAttrReader loaderJobReader;
39   private CounterColumns counterColumns;
40
41   String JavaDoc strImportDefinitionName = "";
42   String JavaDoc strImportDefinitionTableName = "";
43   int iImportDefinitionCommitCount;
44   //String strImportDefinitionLogMode = "normal";
45
String JavaDoc strImportDefinitionSelectStatement = "";
46   String JavaDoc strRestartCounterTableName = "";
47   String JavaDoc strRestartCounterImportDefinitionName = "";
48   String JavaDoc strRestartCounterValue = "";
49   boolean bRestartAutoCreate = false;
50   Vector JavaDoc vecRestartCounterSortColumn = new Vector JavaDoc();
51
52   int iObjectID = 0;
53   int iObjectIDCT = 0;
54   String JavaDoc strObjectIDTableName = "";
55   String JavaDoc strObjectIDColumnName = "";
56
57 // TOS
58
String JavaDoc strObjectIDNameColumnName = "";
59   String JavaDoc strObjectIDNameColumnValue = "";
60
61   boolean bObjectIDAutoCreate;
62   int iObjectIDStartValue;
63 // String strLogMode = "";
64
int iCommitCount = 0;
65
66   //importDefinition copy table
67
String JavaDoc strOnErrorContinueXml="";
68   String JavaDoc strDefaultCutOffData="";
69
70   //copyTable
71
//String strCopyTableLogMode = "normal";
72
String JavaDoc strCopyTableName = "";
73   String JavaDoc strCopyTableSourceTableName = "";
74   String JavaDoc strCopyTableTargetTableName = "";
75   String JavaDoc strCopyTableOidLogic="false";
76   String JavaDoc strCopyTableOnErrorContinue="";
77
78   String JavaDoc strCopyTableCommitCount;
79   int iCopyTableCommitCount;
80
81   String JavaDoc setFetchSizeID="";
82   String JavaDoc setCursorNameID="";
83   String JavaDoc setFetchSizeCT="";
84   String JavaDoc setCursorNameCT="";
85
86
87   /**
88    * Method importXMLFile is used for setting of global variables
89    * during importing values from XML file.
90    * This method validates the imported data from XML file.
91    * If there is an error Exception "NullPointerException" or "Exception" is thrown.
92    * @param doc Parsed imports XML file.
93    * @param iJobNumber Number of ImportJob tag which is processed.
94    * @throws NullPointerException Constructs a NullPointerException with the specified detail message.
95    * @throws Exception Constructs an Exception with the specified detail message.
96    */

97   public void importXMLFile (Document JavaDoc doc, int iJobNumber) throws NullPointerException JavaDoc,
98   Exception JavaDoc {
99     this.logger.write("full", "\timportXMLFile method is started.");
100     //onErrorContinue
101
this.strOnErrorContinueXml=OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
102         "onErrorContinue", iJobNumber);
103     this.strDefaultCutOffData=OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
104         "dataCutOff", iJobNumber);
105     //importDefinitionName
106
this.strImportDefinitionName = OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
107         "name", iJobNumber);
108     //importDefinitionTableName
109
this.strImportDefinitionTableName = OctopusXMLUtil.importAttributeValue(doc,
110         "importDefinition", "tableName", iJobNumber);
111     //commitCount
112
String JavaDoc strCommitCount = OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
113         "commitCount", iJobNumber);
114     if (!strCommitCount.equals(""))
115       this.iImportDefinitionCommitCount = Integer.parseInt(strCommitCount);
116     else {
117       if (loaderJobReader.getLoaderJobCommitCount()!= 0){
118         this.iImportDefinitionCommitCount = loaderJobReader.getLoaderJobCommitCount();
119       }else{
120         if(this.iCommitCount!=0)
121           this.iImportDefinitionCommitCount = this.iCommitCount;
122         else
123           this.iImportDefinitionCommitCount=loaderJobReader.getDefaultCommitCount();
124       }
125     }
126     //copyTable
127
/*
128     this.strCopyTableLogMode = OctopusXMLUtil.importAttributeValue(doc,
129         "copyTable", "logMode", iJobNumber);
130     if (this.strCopyTableLogMode.equals("")) {
131         this.strCopyTableLogMode = loaderJobReader.getDefaultLogMode();
132     }
133 */

134     this.strCopyTableName=OctopusXMLUtil.importAttributeValue(doc,
135         "copyTable", "name", iJobNumber);
136     this.strCopyTableSourceTableName=OctopusXMLUtil.importAttributeValue(doc,
137         "copyTable", "sourceTableName", iJobNumber);
138     this.strCopyTableTargetTableName=OctopusXMLUtil.importAttributeValue(doc,
139         "copyTable", "targetTableName", iJobNumber);
140     this.strCopyTableOidLogic=OctopusXMLUtil.importAttributeValue(doc,
141         "copyTable", "oidLogic", iJobNumber);
142     this.strCopyTableOnErrorContinue=OctopusXMLUtil.importAttributeValue(doc,
143         "copyTable", "onErrorContinue", iJobNumber);
144     //commitCount
145
String JavaDoc strCopyTableCommitCount = OctopusXMLUtil.importAttributeValue(doc, "copyTable",
146         "commitCount", iJobNumber);
147     if (!strCopyTableCommitCount.equals("")){
148       this.iCopyTableCommitCount = Integer.parseInt(strCopyTableCommitCount);
149     }else {
150       if (loaderJobReader.getLoaderJobCommitCount()!= 0){
151         this.iCopyTableCommitCount = loaderJobReader.getLoaderJobCommitCount();
152       }else{
153         if(this.iCommitCount!=0)
154           this.iCopyTableCommitCount = this.iCommitCount;
155         else
156           this.iCopyTableCommitCount=loaderJobReader.getDefaultCommitCount();
157       }
158     }
159     String JavaDoc strIncrementCT = OctopusXMLUtil.importAttributeValue(doc,
160         "copyTable", "objectIDIncrement", iJobNumber);
161     if (!strIncrementCT.equals(""))
162       this.iObjectIDCT = Integer.parseInt(strIncrementCT);
163     else
164       this.iObjectIDCT = loaderJobReader.getDefaultObjectIDIncrement();
165
166 //setFetchSize and setCursorName (importDefinition)
167
this.setFetchSizeID=OctopusXMLUtil.importAttributeValue(doc,
168         "importDefinition", "setFetchSize", iJobNumber);
169     if(this.setFetchSizeID.equalsIgnoreCase(""))
170       this.setFetchSizeID=this.loaderJobReader.getSetFetchSize();
171
172     this.setCursorNameID=OctopusXMLUtil.importAttributeValue(doc,
173         "importDefinition", "setCursorName", iJobNumber);
174     if(this.setCursorNameID.equalsIgnoreCase(""))
175       this.setCursorNameID=this.loaderJobReader.getSetCursorName();
176
177
178 //setFetchSize and setCursorName (copyTable)
179
this.setFetchSizeCT=OctopusXMLUtil.importAttributeValue(doc,
180         "copyTable", "setFetchSize", iJobNumber);
181     if(this.setFetchSizeCT.equalsIgnoreCase(""))
182       this.setFetchSizeCT=this.loaderJobReader.getSetFetchSize();
183
184     this.setCursorNameCT=OctopusXMLUtil.importAttributeValue(doc,
185         "copyTable", "setCursorName", iJobNumber);
186     if(this.setCursorNameCT.equalsIgnoreCase(""))
187       this.setCursorNameCT=this.loaderJobReader.getSetFetchSize();
188
189
190 //importDefinitonLogMode
191
/*
192     this.strImportDefinitionLogMode = OctopusXMLUtil.importAttributeValue(doc,
193         "importDefinition", "logMode", iJobNumber);
194     if (this.strImportDefinitionLogMode.equals("")) {
195         this.strImportDefinitionLogMode = loaderJobReader.getDefaultLogMode();
196     }
197 */

198     //importDefinitionSelectStatement
199
this.strImportDefinitionSelectStatement = OctopusXMLUtil.importAttributeValue(doc,
200         "importDefinition", "selectStatement", iJobNumber);
201     //increment
202
String JavaDoc strIncrement = OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
203         "objectIDIncrement", iJobNumber);
204     if (!strIncrement.equals(""))
205       this.iObjectID = Integer.parseInt(strIncrement);
206     else
207       this.iObjectID = loaderJobReader.getDefaultObjectIDIncrement();
208     //objectIDTableName
209
this.strObjectIDTableName = OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
210         "objectIDTableName", iJobNumber);
211     if (this.strObjectIDTableName.equals(""))
212       this.strObjectIDTableName = loaderJobReader.getDefaultObjectIDTableName();
213     //objectIDColumnName
214
this.strObjectIDColumnName = OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
215         "objectIDColumnName", iJobNumber);
216     if( this.strObjectIDColumnName.equals("") )
217       this.strObjectIDColumnName = loaderJobReader.getDefaultObjectIDColumnName();
218
219     //TOS
220
this.strObjectIDNameColumnName= OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
221         "objectIDNameColumnName", iJobNumber);
222     this.strObjectIDNameColumnValue= OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
223         "objectIDNameColumnValue", iJobNumber);
224
225     if(this.strObjectIDNameColumnName.equals("")) {
226       this.strObjectIDNameColumnName = loaderJobReader.getDefaultObjectIDNameColumnName();
227     }
228     if(this.strObjectIDNameColumnValue.equals("")) {
229       this.strObjectIDNameColumnValue = loaderJobReader.getDefaultObjectIDNameColumnValue();
230     }
231
232     //objectIDAutoCreate
233
String JavaDoc strObjectIDAutoCreate = OctopusXMLUtil.importAttributeValue(doc, "importDefinition",
234         "objectIDAutoCreate", iJobNumber);
235     if (strObjectIDAutoCreate.equals(""))
236       this.bObjectIDAutoCreate = loaderJobReader.getDefaultObjectIDAutoCreate();
237     else
238       this.bObjectIDAutoCreate = (new Boolean JavaDoc(strObjectIDAutoCreate)).booleanValue();
239     if (this.bObjectIDAutoCreate == true) {
240       String JavaDoc strObjectIDStartValue = OctopusXMLUtil.importAttributeValue(doc,
241           "importDefinition", "objectIDStartValue", iJobNumber);
242       if (strObjectIDStartValue.equals(""))
243         this.iObjectIDStartValue = loaderJobReader.getDefaultObjectIDStartValue();
244       else
245         this.iObjectIDStartValue = Integer.parseInt(strObjectIDStartValue);
246     }
247     String JavaDoc strReturnCode = OctopusXMLUtil.importAttributeValue(doc,
248         "importDefinition", "returnCode", iJobNumber);
249     if(!strReturnCode.equals(""))
250       ReturnCode.setErrorReturnCode(Integer.parseInt(strReturnCode));
251     else
252       ReturnCode.setErrorReturnCode(ReturnCode.getDefaultErrorReturnCode());
253     this.vecRestartCounterSortColumn = OctopusXMLUtil.importValue(doc, "sortColumn",
254         "entry", iJobNumber);
255   }
256
257   /**
258    * Set Logger object
259    * @param logger Logger object which is used for log file
260    */

261   public void setLogger(Logger logger) {
262     this.logger = logger;
263   }
264
265   /**
266    * Set LoaderJobAttrReader object
267    * @param loader LoaderJobAttrReader object,which stores loaderJob tag attributes
268    */

269   public void setLoaderJob(LoaderJobAttrReader loader) {
270     this.loaderJobReader = loader;
271   }
272 }
Popular Tags