KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2   Loader - tool for transfering data from one JDBC source to another and
3   doing transformations during copy.
4     Copyright (C) 2002-2003 Together
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12     Lesser General Public License for more details.
13     You should have received a copy of the GNU Lesser General Public
14     License along with this library; if not, write to the Free Software
15     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  Loader.java
17  Date: 03.03.2003.
18  @version 2.1 alpha
19  @authors:
20  Milosevic Sinisa sinisa@prozone.yu
21  Radoslav Dutina rale@prozone.co.yu
22  */

23
24 package org.webdocwf.util.loader;
25
26 import java.io.ByteArrayInputStream JavaDoc;
27 import java.io.ByteArrayOutputStream JavaDoc;
28 import java.io.File JavaDoc;
29 import java.io.IOException JavaDoc;
30 import java.io.InputStream JavaDoc;
31 import java.math.BigDecimal JavaDoc;
32 import java.net.URL JavaDoc;
33 import java.sql.Connection JavaDoc;
34 import java.sql.DriverManager JavaDoc;
35 import java.sql.PreparedStatement JavaDoc;
36 import java.sql.ResultSet JavaDoc;
37 import java.sql.ResultSetMetaData JavaDoc;
38 import java.sql.SQLException JavaDoc;
39 import java.sql.Statement JavaDoc;
40 import java.text.DateFormat JavaDoc;
41 import java.text.SimpleDateFormat JavaDoc;
42 import java.util.ArrayList JavaDoc;
43 import java.util.Date JavaDoc;
44 import java.util.HashMap JavaDoc;
45 import java.util.Hashtable JavaDoc;
46 import java.util.Iterator JavaDoc;
47 import java.util.List JavaDoc;
48 import java.util.Map JavaDoc;
49 import java.util.StringTokenizer JavaDoc;
50 import java.util.Vector JavaDoc;
51
52 import javax.xml.parsers.DocumentBuilder JavaDoc;
53 import javax.xml.parsers.DocumentBuilderFactory JavaDoc;
54
55 import org.w3c.dom.Document JavaDoc;
56 import org.w3c.dom.Element JavaDoc;
57 import org.w3c.dom.NamedNodeMap JavaDoc;
58 import org.w3c.dom.Node JavaDoc;
59 import org.w3c.dom.NodeList JavaDoc;
60 import org.webdocwf.util.loader.logging.Logger;
61 import org.webdocwf.util.loader.logging.StandardLogger;
62 import org.webdocwf.util.loader.transformation.QueryTransformationSet;
63 import org.webdocwf.util.loader.transformation.Transformation;
64 import org.webdocwf.util.loader.transformation.Transformations;
65 import org.xml.sax.SAXException JavaDoc;
66
67 /**
68  * <p>
69  * Loader class loads data from source database into target database using criteria
70  * set in XML file which is used as parameter. Also Loader can execute SQL statements
71  * which import from XML file. <br>
72  * All loading rolls are set in XML file. Some capabilities of this loader are:
73  * there could be more then one importDefinition and number of them is not limited, source
74  * and target database could be different, source database could be ASCII,Excel or Access file too,
75  * operator (the person or application which starts Loader) have to define.
76  * Restart mode with second parameter (optional).
77  * </p>
78  * <p>
79  * There are two possible ways to start Loader. The first is as stand alone application,
80  * the sintaxs is: <br>
81  * <code><B>java org.webdocwf.util.loader.Loader [-options] urlOfTheXmlFile.xml</B></code> <br>
82  * urlOfTheXmlFile.xml is URL of the XML file with loading criteria,<br>
83  * </p>
84  * <p>
85  * The second way is to start Loader as package, the sintax is:<br>
86  * <code><B>public Loader(String loadJobFileName, String mode, String userID, String logDirName,
87  * String logFileName, boolean restartIndicator, Map variableValues, String vendorFileName,
88  * boolean onErrorContinue, String additionalPaths, int commitCount, int returnCode);
89  * </code><br>
90  * ldr.load();</B>
91  * <br>
92  * If we want to execute Loader class without last for parameters, we must put null as these arguments
93  * </p>
94  * <p>
95  * When the Loader is started the log file is generated. Log file is txt file and its
96  * name defines date and time when the Loader is started. There are three Log modes:
97  * none - report only begining and finishing the application, and exceptions if there
98  * are any, normal - add to log importing blocks and full - with detailed report to
99  * operator.
100  * </p>
101  * <p>
102  * Another big adventage of Loader is its possibility to execute any SQL statements in target database.
103  * (creating database; creating, modifying and deleting tables...)
104  * </p>
105  * <p>
106  * XML file is the key part for loading criteria. XML tags define how the loading job will
107  * be done.
108  * </p>
109  */

110 public class Loader {
111 //-u admin -r -v defaultsprache=DE_AT ObjectLoader\DataCleaningExample.xml
112
int iValueColumns;
113   Vector JavaDoc vecValueColumnsTargetTables = new Vector JavaDoc();
114   //Vector vecTransformColumnsTargetTables = new Vector();
115
Vector JavaDoc vecSourceColumnName = new Vector JavaDoc();
116   Vector JavaDoc vecTargetColumnName = new Vector JavaDoc();
117   Vector JavaDoc vecValueMode = new Vector JavaDoc();
118   Vector JavaDoc vecTargetColumnValue = new Vector JavaDoc();
119   Vector JavaDoc vecTargetKeyColumnName = new Vector JavaDoc();
120   Vector JavaDoc vecVariableUseIDTableName = new Vector JavaDoc();
121   Vector JavaDoc vecVariableUseIDTableID = new Vector JavaDoc();
122   Vector JavaDoc vecVariableUseIDColumnName = new Vector JavaDoc();
123   Vector JavaDoc vecVariableUseIDValueMode = new Vector JavaDoc();
124   Vector JavaDoc vecVariableColumnName = new Vector JavaDoc();
125   Vector JavaDoc vecVariableColumnTargetTableName = new Vector JavaDoc();
126   Vector JavaDoc vecVariableColumnTargetTableID = new Vector JavaDoc();
127   Vector JavaDoc vecVariableColumnTargetColumnName = new Vector JavaDoc();
128   Vector JavaDoc vecVariableColumnValueMode = new Vector JavaDoc();
129   Vector JavaDoc vecVariableColumnTypes = new Vector JavaDoc();
130   Vector JavaDoc vecVariableTimesTableName = new Vector JavaDoc();
131   Vector JavaDoc vecVariableTimesTableID = new Vector JavaDoc();
132   Vector JavaDoc vecVariableTimesColumnName = new Vector JavaDoc();
133   Vector JavaDoc vecVariableTimesValueMode = new Vector JavaDoc();
134   int iConstantColumns;
135   Vector JavaDoc vecConstantTargetColumnName = new Vector JavaDoc();
136   Vector JavaDoc vecConstantValueMode = new Vector JavaDoc();
137   Vector JavaDoc vecConstantConstantValue = new Vector JavaDoc();
138   Vector JavaDoc vecConstantColumnTargetTableName = new Vector JavaDoc();
139   Vector JavaDoc vecConstantColumnTargetTableID = new Vector JavaDoc();
140   int iRelationColumns;
141   Vector JavaDoc vecRelationColumnSourceTableName = new Vector JavaDoc();
142   Vector JavaDoc vecRelationColumnSourceTableID = new Vector JavaDoc();
143   Vector JavaDoc vecRelationColumnSourceColumnName = new Vector JavaDoc();
144   Vector JavaDoc vecRelationColumnTargetTableName = new Vector JavaDoc();
145   Vector JavaDoc vecRelationColumnTargetColumnName = new Vector JavaDoc();
146   Vector JavaDoc vecRelationColumnTargetTableID = new Vector JavaDoc();
147   Vector JavaDoc vecRelationColumnRelationMode = new Vector JavaDoc();
148   int iTables;
149   Vector JavaDoc vecTableTableName = new Vector JavaDoc();
150   Vector JavaDoc vecTableTableID = new Vector JavaDoc();
151   Vector JavaDoc vecTableInsert = new Vector JavaDoc();
152   Vector JavaDoc vecTableTableMode = new Vector JavaDoc();
153   Vector JavaDoc vecTableOidLogic = new Vector JavaDoc();
154   Vector JavaDoc vecRelationSourceValue = new Vector JavaDoc();
155   Vector JavaDoc vecRelationSourceType = new Vector JavaDoc();
156   Vector JavaDoc vecTargetColumnType = new Vector JavaDoc();
157   Vector JavaDoc vecConstantColumnType = new Vector JavaDoc();
158   BigDecimal JavaDoc bdecOidNumber = new BigDecimal JavaDoc(0);
159   BigDecimal JavaDoc bdecOidNumber2000 = new BigDecimal JavaDoc(0);
160   String JavaDoc strLoaderJobFileName = "";
161   boolean bRestartIndicator;
162   Map JavaDoc mapVariableValues = new HashMap JavaDoc();
163   boolean bOnErrorContinue;
164   String JavaDoc strUserID = "";
165   String JavaDoc strLogDirName = "";
166   String JavaDoc strLogFileName = "";
167   String JavaDoc strVendorFileName = "";
168   String JavaDoc strAdditionalPaths = "";
169   String JavaDoc confJarStructure = "";
170
171   //interne Sinisa
172
boolean hasRestartCounter;
173   boolean hasUserID;
174   Vector JavaDoc vecRelationKeyColumns = new Vector JavaDoc();
175   Vector JavaDoc vecRelationKeyTypes = new Vector JavaDoc();
176   Vector JavaDoc vecSortValues = new Vector JavaDoc();
177
178   Vector JavaDoc vecSqlStmt = new Vector JavaDoc();
179   String JavaDoc strSourceDriverName = "";
180   String JavaDoc strTargetDriverName = "";
181
182   //conf file default
183
int iFirstColumnResult = 1;
184   int iTargetFirstColumnResult = 1;
185   //
186
Vector JavaDoc vecVariableName = new Vector JavaDoc();
187   Vector JavaDoc vecVariableValue = new Vector JavaDoc();
188   Vector JavaDoc vecVariablePrefix = new Vector JavaDoc();
189   Vector JavaDoc vecVariableSufix = new Vector JavaDoc();
190   Vector JavaDoc vecVariableOverride = new Vector JavaDoc();
191   Vector JavaDoc vecReplaceInConstants = new Vector JavaDoc();
192   Vector JavaDoc vecReplaceInSQL = new Vector JavaDoc();
193   Vector JavaDoc vecReplaceInData = new Vector JavaDoc();
194   Vector JavaDoc vecReplaceInJDBC = new Vector JavaDoc();
195   public static final String JavaDoc LOGMODE_NONE = "none";
196   public static final String JavaDoc LOGMODE_NORMAL = "normal";
197   public static final String JavaDoc LOGMODE_FULL = "full";
198   ByteArrayOutputStream JavaDoc foStreamTmp = new ByteArrayOutputStream JavaDoc();
199   boolean bReplaceInData = false;
200   int iColumnsInSourceTable = 0;
201   boolean isDefaultJdbc = false;
202   private String JavaDoc defaultLogMode = LOGMODE_NORMAL;
203   ArrayList JavaDoc logModes = new ArrayList JavaDoc();
204
205   private Cache cacheValues;
206 // private EchoElement echo;
207
private Logger logger;
208   private CounterColumns counterColumns;
209   private TimeWatch timeCounter;
210   private Transformations transformations;
211
212   //NEW CLASSES
213
private JdbcParametersElement jdbcParametersElement = new JdbcParametersElement();
214   private SqlElement sqlElement = new SqlElement();
215   private ConfigReader configReaderSource = new ConfigReader();
216   private ConfigReader configReaderTarget = new ConfigReader();
217   private LoaderJobAttrReader loaderJobReader = new LoaderJobAttrReader();
218   private ImportDefinitionElement importDefinitionElement = new ImportDefinitionElement();
219   private DataCleaning dataCleaning = new DataCleaning(configReaderTarget);
220
221   //rale
222
private String JavaDoc strQuerySet = "";
223   QueryWhereSet queryWhereSet = null;
224   QueryConstantSet queryConstantSet = null;
225   QueryTransformationSet queryTransformationSet = null;
226   
227   Hashtable JavaDoc queryStatement = new Hashtable JavaDoc();
228   Hashtable JavaDoc indexDValue = new Hashtable JavaDoc();
229   Hashtable JavaDoc indexDRelationValue = new Hashtable JavaDoc();
230   Hashtable JavaDoc indexConstantDValue = new Hashtable JavaDoc();
231   Hashtable JavaDoc indexDVariableValue = new Hashtable JavaDoc();
232   Hashtable JavaDoc indexDTransformationValue = new Hashtable JavaDoc();
233
234   Hashtable JavaDoc updateStatement = new Hashtable JavaDoc();
235   Hashtable JavaDoc indexDOverwrite = new Hashtable JavaDoc();
236   Hashtable JavaDoc indexDSetNull = new Hashtable JavaDoc();
237
238   Hashtable JavaDoc updateConstantStatement = new Hashtable JavaDoc();
239   Hashtable JavaDoc indexDConstantOver = new Hashtable JavaDoc();
240   Hashtable JavaDoc indexDConstantNull = new Hashtable JavaDoc();
241   //zk added this
242
Hashtable JavaDoc resultVector = new Hashtable JavaDoc();
243   Hashtable JavaDoc updateTransformationStatement = new Hashtable JavaDoc();
244   Hashtable JavaDoc indexDTransformationOver = new Hashtable JavaDoc();
245   Hashtable JavaDoc indexDTransformationNull = new Hashtable JavaDoc();
246   Hashtable JavaDoc indexDTransformationUpdate = new Hashtable JavaDoc();
247   //insert row
248
Hashtable JavaDoc queryInsertRow = new Hashtable JavaDoc();
249   Hashtable JavaDoc indexIsNotRelationsColumns = new Hashtable JavaDoc();
250   Hashtable JavaDoc pstmtForInsert = new Hashtable JavaDoc();
251   Hashtable JavaDoc pstmtColumnNames = new Hashtable JavaDoc();
252 // Hashtable pstmtColumnTypes = new Hashtable();
253

254   Vector JavaDoc pstmtKeys = new Vector JavaDoc();
255
256   //default value
257
Vector JavaDoc vecDefaultValue = new Vector JavaDoc();
258   Vector JavaDoc vecDefaultVariableValue = new Vector JavaDoc();
259   Vector JavaDoc vecDefaultVariableName = new Vector JavaDoc();
260   Vector JavaDoc vecDefaultRelationValue = new Vector JavaDoc();
261   Vector JavaDoc vecTempUserID = new Vector JavaDoc();
262   boolean userIDExists = false;
263   private int currentRow = 0;
264
265   //coy table
266
//source data which are not maped in to target data
267
Hashtable JavaDoc allSourceColumnNameNoMap = new Hashtable JavaDoc();
268   Hashtable JavaDoc allSourceColumnValueNoMap = new Hashtable JavaDoc();
269   Hashtable JavaDoc allSourceColumnTypeNoMap = new Hashtable JavaDoc();
270   Vector JavaDoc ImportDefinitionSourceColumnName = new Vector JavaDoc();
271   Vector JavaDoc ImportDefinitionTargetColumnName = new Vector JavaDoc();
272   private String JavaDoc currentJobName = "";
273   Vector JavaDoc vecCTAutoMapp = new Vector JavaDoc();
274   Vector JavaDoc vecCTDefaultMode = new Vector JavaDoc();
275   Vector JavaDoc vecBlobVector = new Vector JavaDoc();
276   Vector JavaDoc vecToHex = new Vector JavaDoc();
277   Vector JavaDoc vecFromHex = new Vector JavaDoc();
278
279   //caching the relations
280
RelationsCache relationsCache = new RelationsCache();
281   private Vector JavaDoc includeTables = new Vector JavaDoc();
282
283   //caching the 'row check' query
284
CheckRowCache checkRowCache = new CheckRowCache();
285
286   //restart counter
287
DataTransmition dataTransmition = new DataTransmition(importDefinitionElement);
288
289   //oid and version column name
290
private String JavaDoc currentOidColumnName = "oid";
291   private String JavaDoc currentVersionColumnName = "version";
292
293 // private PreparedStatementMethods pstmtMethods=new PreparedStatementMethods();
294
private Vector JavaDoc transformationsColumnNames = new Vector JavaDoc();
295   private Vector JavaDoc transformationsValueModes = new Vector JavaDoc();
296   private Vector JavaDoc transformationsColumnValueMode = new Vector JavaDoc();
297   private Vector JavaDoc transformationsColumnTypes = new Vector JavaDoc();
298   private Vector JavaDoc transformationsResultVectorTypes = new Vector JavaDoc();
299   private Vector JavaDoc resultVectorTypes = new Vector JavaDoc();
300   //ValidateSelectStmt validStmt = new ValidateSelectStmt();
301

302   //number of columns before transformation values from source query
303
private int iOffsetForTransColumns = 0;
304     
305   //values for transformations, used from source ResultSet for all transformation
306
//source coulmns
307
Vector JavaDoc transformationValues = new Vector JavaDoc();
308
309  
310   
311
312   /**
313    * Construct object Loader with an associated parameters.
314    * @param loadJobFileName defines xml input file.
315    * @param mode defines the default logmode. Possible values are "none", "normal" (is the default) and "full". Is "normal" otherwise -m none
316    * @param userID String which is name of user. This argument is used for writing userID into variable columns.
317    * If it is 'null' there is no define userID columns.
318    * @param logDirName defines the logfile directory. The default is the current working directory.
319        * @param logFileName defines the logfile name. The default is "LoaderLog-YYYY-MM-DD-HH-mm-SS.txt".
320    * @param restartIndicator which is true if "restart" mode and false if "new" mode.
321    * @param variableValues Map defines variables used in variable columns.
322    * @param vendorFileName the filename of the XML DB-vendor configuration file. The default is "OctopusDBVendors.xml".
323    * @param onErrorContinue defines to set the default of "onErrorContinue" to "true". Is false otherwise.
324    * @param additionalPaths Extend the classpath with additional paths.
325    * @param commitCount Sets the default commit count. System default is "100".
326    * @param returnCode Sets the default error return code. System default is "1".
327    * @param includeTables defines tables which will be processed
328    */

329   public Loader(String JavaDoc loadJobFileName, String JavaDoc mode, String JavaDoc userID,
330       String JavaDoc logDirName, String JavaDoc logFileName, boolean restartIndicator,
331       Map JavaDoc variableValues, String JavaDoc vendorFileName, boolean onErrorContinue,
332       String JavaDoc additionalPaths, int commitCount, int returnCode,
333       String JavaDoc[] includeTables, String JavaDoc confJarStructure) {
334     this.strLoaderJobFileName = loadJobFileName;
335     //defines the log mode,
336
if (mode != null) {
337       if ( mode.equalsIgnoreCase("none") ||
338           mode.equalsIgnoreCase("normal") ||
339            mode.equalsIgnoreCase("full") )
340       {
341 // importDefinitionElement.strLogMode = mode;
342
this.defaultLogMode = mode;
343 // sqlElement.strLogMode = mode;
344
} //else {
345
// importDefinitionElement.strLogMode = "";
346
// sqlElement.strLogMode = "";
347
}
348
349     if (userID != null) {
350       this.strUserID = userID;
351       this.hasUserID = true;
352     } else
353       this.hasUserID = false;
354     if (logDirName != null)
355       this.strLogDirName = logDirName;
356     else {
357       File JavaDoc fCurrent = new File JavaDoc("");
358       this.strLogDirName = fCurrent.getAbsolutePath();
359     }
360     if (logFileName != null) {
361       this.strLogFileName = logFileName;
362     } else
363       this.strLogFileName = "default";
364     this.bRestartIndicator = restartIndicator;
365     if (this.bRestartIndicator == true)
366       this.hasRestartCounter = true;
367     else
368       this.hasRestartCounter = false;
369     this.mapVariableValues = variableValues;
370     if (vendorFileName != null) {
371       this.strVendorFileName = vendorFileName;
372     }
373     this.bOnErrorContinue = onErrorContinue;
374     if (additionalPaths != null) {
375       try {
376         this.strAdditionalPaths = additionalPaths;
377         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(this.strAdditionalPaths, ";");
378         URL JavaDoc[] urls = new URL JavaDoc[st.countTokens()];
379         int count = 0;
380         while (st.hasMoreTokens()) {
381           urls[count] = new File JavaDoc(st.nextElement().toString()).toURL();
382           count++;
383         }
384         for (int i = 0; i < urls.length; i++) {
385           OctopusClassLoader.addURL(urls[i]);
386         }
387       }
388       catch (Exception JavaDoc ne) {
389         ne.printStackTrace();
390       }
391     }
392     if (includeTables != null) {
393       for (int i = 0; i < includeTables.length; i++) {
394         this.includeTables.add(includeTables[i]);
395       }
396     }
397     importDefinitionElement.iCommitCount = commitCount;
398     ReturnCode.setDefaultErrorReturnCode(returnCode);
399     this.confJarStructure = confJarStructure;
400   }
401
402   /**
403    * Construct object Loader with an associated parameters.
404    * @param loadJobFileName defines xml input file.
405    * @param mode defines the default logmode. Possible values are "none", "normal" (is the default) and "full". Is "normal" otherwise -m none
406    * @param userID String which is name of user. This argument is used for writing userID into variable columns.
407    * If it is 'null' there is no define userID columns.
408    * @param logDirName defines the logfile directory. The default is the current working directory.
409        * @param logFileName defines the logfile name. The default is "LoaderLog-YYYY-MM-DD-HH-mm-SS.txt".
410    * @param restartIndicator which is true if "restart" mode and false if "new" mode.
411    * @param variableValues Map defines variables used in variable columns.
412    * @param vendorFileName the filename of the XML DB-vendor configuration file. The default is "OctopusDBVendors.xml".
413    * @param onErrorContinue defines to set the default of "onErrorContinue" to "true". Is false otherwise.
414    * @param additionalPaths Extend the classpath with additional paths.
415    * @param commitCount Sets the default commit count. System default is "100".
416    * @param returnCode Sets the default error return code. System default is "1".
417    */

418   public Loader(String JavaDoc loadJobFileName, String JavaDoc mode, String JavaDoc userID,
419       String JavaDoc logDirName,
420       String JavaDoc logFileName, boolean restartIndicator,
421       Map JavaDoc variableValues,
422       String JavaDoc vendorFileName, boolean onErrorContinue,
423       String JavaDoc additionalPaths,
424       int commitCount, int returnCode) {
425
426     this(loadJobFileName, mode, userID, logDirName, logFileName, restartIndicator,
427         variableValues, vendorFileName, onErrorContinue, additionalPaths,
428         commitCount, returnCode, null, null);
429
430   }
431
432   /**
433    * Construct object Loader with an associated parameters.
434    * @param loadJobFileName defines xml input file.
435    * @param mode defines the default logmode. Possible values are "none", "normal" (is the default) and "full". Is "normal" otherwise -m none
436    * @param userID String which is name of user. This argument is used for writing userID into variable columns.
437    * If it is 'null' there is no define userID columns.
438    * @param logDirName defines the logfile directory. The default is the current working directory.
439        * @param logFileName defines the logfile name. The default is "LoaderLog-YYYY-MM-DD-HH-mm-SS.txt".
440    * @param restartIndicator which is true if "restart" mode and false if "new" mode.
441    * @param variableValues Map defines variables used in variable columns.
442    * @param vendorFileName the filename of the XML DB-vendor configuration file. The default is "OctopusDBVendors.xml".
443    * @param onErrorContinue defines to set the default of "onErrorContinue" to "true". Is false otherwise.
444    * @param additionalPaths Extend the classpath with additional paths.
445    * @param commitCount Sets the default commit count. System default is "100".
446    * @param returnCode Sets the default error return code. System default is "1".
447    */

448   public Loader(String JavaDoc loadJobFileName, String JavaDoc mode, String JavaDoc userID,
449       String JavaDoc logDirName,
450       String JavaDoc logFileName, boolean restartIndicator,
451       Map JavaDoc variableValues,
452       String JavaDoc vendorFileName, boolean onErrorContinue,
453       String JavaDoc additionalPaths,
454       int commitCount, int returnCode, String JavaDoc[] includeTables) {
455
456     this(loadJobFileName, mode, userID, logDirName, logFileName, restartIndicator,
457         variableValues, vendorFileName, onErrorContinue, additionalPaths,
458         commitCount, returnCode, includeTables, null);
459
460   }
461
462   /**
463    * Construct object Loader with an associated parameters.
464    * @param loadJobFileName defines xml input file.
465    * @param mode defines the default logmode. Possible values are "none", "normal" (is the default) and "full". Is "normal" otherwise -m none
466    * @param userID String which is name of user. This argument is used for writing userID into variable columns.
467    * If it is 'null' there is no define userID columns.
468    * @param logDirName defines the logfile directory. The default is the current working directory.
469        * @param logFileName defines the logfile name. The default is "LoaderLog-YYYY-MM-DD-HH-mm-SS.txt".
470    * @param restartIndicator which is true if "restart" mode and false if "new" mode.
471    * @param variableValues Map defines variables used in variable columns.
472    * @param vendorFileName the filename of the XML DB-vendor configuration file. The default is "OctopusDBVendors.xml".
473    * @param onErrorContinue defines to set the default of "onErrorContinue" to "true". Is false otherwise.
474    * @param additionalPaths Extend the classpath with additional paths.
475    * @param commitCount Sets the default commit count. System default is "100".
476    * @param returnCode Sets the default error return code. System default is "1".
477    */

478   public Loader(String JavaDoc loadJobFileName, String JavaDoc mode, String JavaDoc userID,
479       String JavaDoc logDirName,
480       String JavaDoc logFileName, boolean restartIndicator,
481       Map JavaDoc variableValues,
482       String JavaDoc vendorFileName, boolean onErrorContinue,
483       String JavaDoc additionalPaths,
484       int commitCount, int returnCode, String JavaDoc confJarStructure) {
485
486     this(loadJobFileName, mode, userID, logDirName, logFileName, restartIndicator,
487         variableValues, vendorFileName, onErrorContinue, additionalPaths,
488         commitCount, returnCode, null, confJarStructure);
489
490   }
491
492   /**
493    * Method addClassPath adds additional class paths into system classpath property
494    * @param oldClassPath - System classpath;
495    * @param add - additional class paths.
496    * @return value of parameter classPath
497    */

498   private String JavaDoc addClassPath(String JavaDoc oldClassPath, String JavaDoc add) {
499
500     String JavaDoc classPath = oldClassPath;
501     if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
502       if (!classPath.trim().endsWith(";"))
503         classPath += ";";
504       add = add.replace('\n', '\\');
505       add = add.replace('\t', '\\');
506       add = add.replace('\b', '\\');
507       add = add.replace('\r', '\\');
508       add = add.replace('\f', '\\');
509       classPath = classPath.concat(add);
510     } else {
511       if (!classPath.trim().endsWith(":"))
512         classPath += ":";
513       add = add.replace('\n', '/');
514       add = add.replace('\t', '/');
515       add = add.replace('\b', '/');
516       add = add.replace('\r', '/');
517       add = add.replace('\f', '/');
518       classPath = classPath.concat(add);
519
520     }
521     return classPath;
522   }
523
524   /**
525    * Public constructor of Loader class. Constructor set value for loadJobFileName attribute.
526    * Class set all other attributes to the default values.
527    * @param loadJobFileName Name of loadJob import XML file.
528    *
529    */

530   public Loader(String JavaDoc loadJobFileName) {
531     this(loadJobFileName, null);
532   }
533
534   /**
535    * Public constructor of Loader class. Constructor set value for loadJobFileName attribute.
536    * Class set all other attributes to the default values.
537    * @param loadJobFileName Name of loadJob import XML file.
538    *
539    */

540   public Loader(String JavaDoc loadJobFileName, String JavaDoc confJarStructure) {
541     this.strLoaderJobFileName = loadJobFileName;
542 // importDefinitionElement.strLogMode = "";
543
this.hasUserID = false;
544     File JavaDoc fCurrent = new File JavaDoc("");
545     this.strLogDirName = fCurrent.getAbsolutePath();
546     this.strLogFileName = "default";
547     this.bRestartIndicator = false;
548     this.hasRestartCounter = false;
549     this.bOnErrorContinue = false;
550     importDefinitionElement.iCommitCount = 100;
551     ReturnCode.setDefaultErrorReturnCode(1);
552     this.confJarStructure = confJarStructure;
553   }
554
555   /**
556    * Read value of loadJobFileName attribute.
557    * @return String value of loadFileName attribute
558    */

559   public String JavaDoc getLoadJobFileName() {
560     return this.strLoaderJobFileName;
561   }
562
563   /**
564    * This method sets value of loadJobFileName attribute.
565    * @param loadJobFileName loadJob XML file name
566    */

567   public void setLoadJobFileName(String JavaDoc loadJobFileName) {
568     this.strLoaderJobFileName = loadJobFileName;
569   }
570
571   /**
572    * Read value of Mode(LogMode) attribute.
573    * @return value of attribute.
574    */

575 // public String getMode() {
576
// return importDefinitionElement.strLogMode;
577
// }
578

579   /**
580    * This method sets value of Mode attribute.
581    * @param mode define Log mode. Possible values are:
582    * Loader.LOGMODE_NONE, Loader.LOGMODE_NORMAL, Loader.LOGMODE_FULL.
583    */

584 // public void setMode(String mode) {
585
// importDefinitionElement.strLogMode = mode;
586
// }
587

588   /**
589    * Read value of userID attribute.
590    * @return value of attribute.
591    */

592   public String JavaDoc getUserID() {
593     return this.strUserID;
594   }
595
596   /**
597    * This method sets value of userID attribute.
598    * @param userID attribute.
599    */

600   public void setUserID(String JavaDoc userID) {
601     this.strUserID = userID;
602   }
603
604   /**
605    * Read value of logDirName attribute
606    * @return value of attribute
607    */

608   public String JavaDoc getLogDirName() {
609     return this.strLogDirName;
610   }
611
612   /**
613    * This method sets value of logDirName attribute.
614    * @param logDirName value of attribute.
615    */

616   public void setLogDirName(String JavaDoc logDirName) {
617     this.strLogDirName = logDirName;
618   }
619
620   /**
621    * Read value of logFileName attribute.
622    * @return value of attribute.
623    */

624   public String JavaDoc getLogFileName() {
625     return this.strLogFileName;
626   }
627
628   /**
629    * This method sets value of logFileName attribute.
630    * @param logFileName value of attribute.
631    */

632   public void setLogFileName(String JavaDoc logFileName) {
633     this.strLogFileName = logFileName;
634   }
635
636   /**
637    * Read value of restartIndicator attribute.
638    * @return value of attribute.
639    */

640   public boolean getRestartIndicator() {
641     return this.bRestartIndicator;
642   }
643
644   /**
645    * This method sets value of restartIndicator attribute.
646    * @param restartIndicator value of attribute.
647    */

648   public void setRestartIndicator(boolean restartIndicator) {
649     this.bRestartIndicator = restartIndicator;
650   }
651
652   /**
653    * Read value of variableValues attribute.
654    * @return value of attribute.
655    */

656   public Map JavaDoc getVariableValues() {
657  &n