org.webdocwf.util.loader
Class Loader

java.lang.Object
  extended by org.webdocwf.util.loader.Loader

public class Loader
extends java.lang.Object

Loader class loads data from source database into target database using criteria set in XML file which is used as parameter. Also Loader can execute SQL statements which import from XML file.
All loading rolls are set in XML file. Some capabilities of this loader are: there could be more then one importDefinition and number of them is not limited, source and target database could be different, source database could be ASCII,Excel or Access file too, operator (the person or application which starts Loader) have to define. Restart mode with second parameter (optional).

There are two possible ways to start Loader. The first is as stand alone application, the sintaxs is:
java org.webdocwf.util.loader.Loader [-options] urlOfTheXmlFile.xml
urlOfTheXmlFile.xml is URL of the XML file with loading criteria,

The second way is to start Loader as package, the sintax is:
public Loader(String loadJobFileName, String mode, String userID, String logDirName, String logFileName, boolean restartIndicator, Map variableValues, String vendorFileName, boolean onErrorContinue, String additionalPaths, int commitCount, int returnCode);
ldr.load();

If we want to execute Loader class without last for parameters, we must put null as these arguments

When the Loader is started the log file is generated. Log file is txt file and its name defines date and time when the Loader is started. There are three Log modes: none - report only begining and finishing the application, and exceptions if there are any, normal - add to log importing blocks and full - with detailed report to operator.

Another big adventage of Loader is its possibility to execute any SQL statements in target database. (creating database; creating, modifying and deleting tables...)

XML file is the key part for loading criteria. XML tags define how the loading job will be done.

Author:
Milosevic Sinisa, Radoslav Dutina, Zoran Milakovic

Field Summary
static java.lang.String LOGMODE_FULL
           
static java.lang.String LOGMODE_NONE
           
static java.lang.String LOGMODE_NORMAL
           
 
Constructor Summary
Loader(java.lang.String loadJobFileName)
          Public constructor of Loader class.
Loader(java.lang.String loadJobFileName, java.lang.String confJarStructure)
          Public constructor of Loader class.
Loader(java.lang.String loadJobFileName, java.lang.String mode, java.lang.String userID, java.lang.String logDirName, java.lang.String logFileName, boolean restartIndicator, java.util.Map variableValues, java.lang.String vendorFileName, boolean onErrorContinue, java.lang.String additionalPaths, int commitCount, int returnCode)
          Construct object Loader with an associated parameters.
Loader(java.lang.String loadJobFileName, java.lang.String mode, java.lang.String userID, java.lang.String logDirName, java.lang.String logFileName, boolean restartIndicator, java.util.Map variableValues, java.lang.String vendorFileName, boolean onErrorContinue, java.lang.String additionalPaths, int commitCount, int returnCode, java.lang.String confJarStructure)
          Construct object Loader with an associated parameters.
Loader(java.lang.String loadJobFileName, java.lang.String mode, java.lang.String userID, java.lang.String logDirName, java.lang.String logFileName, boolean restartIndicator, java.util.Map variableValues, java.lang.String vendorFileName, boolean onErrorContinue, java.lang.String additionalPaths, int commitCount, int returnCode, java.lang.String[] includeTables)
          Construct object Loader with an associated parameters.
Loader(java.lang.String loadJobFileName, java.lang.String mode, java.lang.String userID, java.lang.String logDirName, java.lang.String logFileName, boolean restartIndicator, java.util.Map variableValues, java.lang.String vendorFileName, boolean onErrorContinue, java.lang.String additionalPaths, int commitCount, int returnCode, java.lang.String[] includeTables, java.lang.String confJarStructure)
          Construct object Loader with an associated parameters.
 
Method Summary
 java.lang.String getAdditionalPaths()
          Read value of additionalPaths attribute.
 int getCommitCount()
          Read value of commitCount attribute.
 java.lang.String getConfJarStructure()
          This method read value of confJarStructure parameter
protected  java.util.Date getDateFromString(java.lang.String date)
           
 java.lang.String getDefaultLogMode()
          This method read value of defaultLogMode parameter
 int getDefaultReturnCode()
          Read value of default error return code attribute.
 java.lang.String[] getIncludedJobs()
          This method read value of includeJobs parameter
 java.lang.String getLoadJobFileName()
          Read value of loadJobFileName attribute.
 java.lang.String getLogDirName()
          Read value of logDirName attribute
 java.lang.String getLogFileName()
          Read value of logFileName attribute.
 boolean getOnErrorContinue()
          read value of onErrorContinue attribute.
 boolean getRestartIndicator()
          Read value of restartIndicator attribute.
protected  java.lang.String getSQLRelationString(java.sql.ResultSet rs)
           
 java.lang.String getUserID()
          Read value of userID attribute.
 java.util.Map getVariableValues()
          Read value of variableValues attribute.
 java.lang.String getVendorFileName()
          Read value of vendorFileName.
 java.lang.String inputToString()
          This method write values for all input parameters to log file when log level is full
 void load()
          Method load is main method in class Loader.
static void main(java.lang.String[] argv)
          Main method Loader with an associated XML, restart mode (optional) i user (optional).
 void parseInputData(java.lang.Object readValueObject, java.util.Vector vecVektor, java.sql.ResultSet rsetSource, int i, java.lang.String columnName, int blobCount, boolean isMicrosoftDriver, java.util.Hashtable columnValuesMicrosoft, java.util.Hashtable sourceColumnTypes)
          This method read data from source table
 void setAdditionalPaths(java.lang.String additionalPaths)
          This method sets value of additionalPaths attribute.
 void setCommitCount(int commitCount)
          This method sets value of commitCount attribute.
 void setDefaultReturnCode(int code)
          This method sets value of default error return code attribute.
 void setIncludedJobs(java.lang.String[] include_Tables)
          This method set value of includeJobs parameter
 void setLoadJobFileName(java.lang.String loadJobFileName)
          This method sets value of loadJobFileName attribute.
 void setLogDirName(java.lang.String logDirName)
          This method sets value of logDirName attribute.
 void setLogFileName(java.lang.String logFileName)
          This method sets value of logFileName attribute.
 void setOnErrorContinue(boolean onErrorContinue)
          This method sets value of onErrorContinue attribute.
 void setRestartIndicator(boolean restartIndicator)
          This method sets value of restartIndicator attribute.
 void setUserID(java.lang.String userID)
          This method sets value of userID attribute.
protected  void setValueOnStatement(java.lang.String value, int javaTypeInt, int i, java.sql.PreparedStatement pstmt)
           
 void setVariableValues(java.util.Map variableValue)
          This method sets value of variableValues attribute.
 void setVendorFileName(java.lang.String vendorFileName)
          This method sets value of vendorFileName attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGMODE_NONE

public static final java.lang.String LOGMODE_NONE
See Also:
Constant Field Values

LOGMODE_NORMAL

public static final java.lang.String LOGMODE_NORMAL
See Also:
Constant Field Values

LOGMODE_FULL

public static final java.lang.String LOGMODE_FULL
See Also:
Constant Field Values
Constructor Detail

Loader

public Loader(java.lang.String loadJobFileName,
              java.lang.String mode,
              java.lang.String userID,
              java.lang.String logDirName,
              java.lang.String logFileName,
              boolean restartIndicator,
              java.util.Map variableValues,
              java.lang.String vendorFileName,
              boolean onErrorContinue,
              java.lang.String additionalPaths,
              int commitCount,
              int returnCode,
              java.lang.String[] includeTables,
              java.lang.String confJarStructure)
Construct object Loader with an associated parameters.

Parameters:
loadJobFileName - defines xml input file.
mode - defines the default logmode. Possible values are "none", "normal" (is the default) and "full". Is "normal" otherwise -m none
userID - String which is name of user. This argument is used for writing userID into variable columns. If it is 'null' there is no define userID columns.
logDirName - defines the logfile directory. The default is the current working directory.
logFileName - defines the logfile name. The default is "LoaderLog-YYYY-MM-DD-HH-mm-SS.txt".
restartIndicator - which is true if "restart" mode and false if "new" mode.
variableValues - Map defines variables used in variable columns.
vendorFileName - the filename of the XML DB-vendor configuration file. The default is "OctopusDBVendors.xml".
onErrorContinue - defines to set the default of "onErrorContinue" to "true". Is false otherwise.
additionalPaths - Extend the classpath with additional paths.
commitCount - Sets the default commit count. System default is "100".
returnCode - Sets the default error return code. System default is "1".
includeTables - defines tables which will be processed

Loader

public Loader(java.lang.String loadJobFileName,
              java.lang.String mode,
              java.lang.String userID,
              java.lang.String logDirName,
              java.lang.String logFileName,
              boolean restartIndicator,
              java.util.Map variableValues,
              java.lang.String vendorFileName,
              boolean onErrorContinue,
              java.lang.String additionalPaths,
              int commitCount,
              int returnCode)
Construct object Loader with an associated parameters.

Parameters:
loadJobFileName - defines xml input file.
mode - defines the default logmode. Possible values are "none", "normal" (is the default) and "full". Is "normal" otherwise -m none
userID - String which is name of user. This argument is used for writing userID into variable columns. If it is 'null' there is no define userID columns.
logDirName - defines the logfile directory. The default is the current working directory.
logFileName - defines the logfile name. The default is "LoaderLog-YYYY-MM-DD-HH-mm-SS.txt".
restartIndicator - which is true if "restart" mode and false if "new" mode.
variableValues - Map defines variables used in variable columns.
vendorFileName - the filename of the XML DB-vendor configuration file. The default is "OctopusDBVendors.xml".
onErrorContinue - defines to set the default of "onErrorContinue" to "true". Is false otherwise.
additionalPaths - Extend the classpath with additional paths.
commitCount - Sets the default commit count. System default is "100".
returnCode - Sets the default error return code. System default is "1".

Loader

public Loader(java.lang.String loadJobFileName,
              java.lang.String mode,
              java.lang.String userID,
              java.lang.String logDirName,
              java.lang.String logFileName,
              boolean restartIndicator,
              java.util.Map variableValues,
              java.lang.String vendorFileName,
              boolean onErrorContinue,
              java.lang.String additionalPaths,
              int commitCount,
              int returnCode,
              java.lang.String[] includeTables)
Construct object Loader with an associated parameters.

Parameters:
loadJobFileName - defines xml input file.
mode - defines the default logmode. Possible values are "none", "normal" (is the default) and "full". Is "normal" otherwise -m none
userID - String which is name of user. This argument is used for writing userID into variable columns. If it is 'null' there is no define userID columns.
logDirName - defines the logfile directory. The default is the current working directory.
logFileName - defines the logfile name. The default is "LoaderLog-YYYY-MM-DD-HH-mm-SS.txt".
restartIndicator - which is true if "restart" mode and false if "new" mode.
variableValues - Map defines variables used in variable columns.
vendorFileName - the filename of the XML DB-vendor configuration file. The default is "OctopusDBVendors.xml".
onErrorContinue - defines to set the default of "onErrorContinue" to "true". Is false otherwise.
additionalPaths - Extend the classpath with additional paths.
commitCount - Sets the default commit count. System default is "100".
returnCode - Sets the default error return code. System default is "1".

Loader

public Loader(java.lang.String loadJobFileName,
              java.lang.String mode,
              java.lang.String userID,
              java.lang.String logDirName,
              java.lang.String logFileName,
              boolean restartIndicator,
              java.util.Map variableValues,
              java.lang.String vendorFileName,
              boolean onErrorContinue,
              java.lang.String additionalPaths,
              int commitCount,
              int returnCode,
              java.lang.String confJarStructure)
Construct object Loader with an associated parameters.

Parameters:
loadJobFileName - defines xml input file.
mode - defines the default logmode. Possible values are "none", "normal" (is the default) and "full". Is "normal" otherwise -m none
userID - String which is name of user. This argument is used for writing userID into variable columns. If it is 'null' there is no define userID columns.
logDirName - defines the logfile directory. The default is the current working directory.
logFileName - defines the logfile name. The default is "LoaderLog-YYYY-MM-DD-HH-mm-SS.txt".
restartIndicator - which is true if "restart" mode and false if "new" mode.
variableValues - Map defines variables used in variable columns.
vendorFileName - the filename of the XML DB-vendor configuration file. The default is "OctopusDBVendors.xml".
onErrorContinue - defines to set the default of "onErrorContinue" to "true". Is false otherwise.
additionalPaths - Extend the classpath with additional paths.
commitCount - Sets the default commit count. System default is "100".
returnCode - Sets the default error return code. System default is "1".

Loader

public Loader(java.lang.String loadJobFileName)
Public constructor of Loader class. Constructor set value for loadJobFileName attribute. Class set all other attributes to the default values.

Parameters:
loadJobFileName - Name of loadJob import XML file.

Loader

public Loader(java.lang.String loadJobFileName,
              java.lang.String confJarStructure)
Public constructor of Loader class. Constructor set value for loadJobFileName attribute. Class set all other attributes to the default values.

Parameters:
loadJobFileName - Name of loadJob import XML file.
Method Detail

getLoadJobFileName

public java.lang.String getLoadJobFileName()
Read value of loadJobFileName attribute.

Returns:
String value of loadFileName attribute

setLoadJobFileName

public void setLoadJobFileName(java.lang.String loadJobFileName)
This method sets value of loadJobFileName attribute.

Parameters:
loadJobFileName - loadJob XML file name

getUserID

public java.lang.String getUserID()
Read value of userID attribute.

Returns:
value of attribute.

setUserID

public void setUserID(java.lang.String userID)
This method sets value of userID attribute.

Parameters:
userID - attribute.

getLogDirName

public java.lang.String getLogDirName()
Read value of logDirName attribute

Returns:
value of attribute

setLogDirName

public void setLogDirName(java.lang.String logDirName)
This method sets value of logDirName attribute.

Parameters:
logDirName - value of attribute.

getLogFileName

public java.lang.String getLogFileName()
Read value of logFileName attribute.

Returns:
value of attribute.

setLogFileName

public void setLogFileName(java.lang.String logFileName)
This method sets value of logFileName attribute.

Parameters:
logFileName - value of attribute.

getRestartIndicator

public boolean getRestartIndicator()
Read value of restartIndicator attribute.

Returns:
value of attribute.

setRestartIndicator

public void setRestartIndicator(boolean restartIndicator)
This method sets value of restartIndicator attribute.

Parameters:
restartIndicator - value of attribute.

getVariableValues

public java.util.Map getVariableValues()
Read value of variableValues attribute.

Returns:
value of attribute.

setVariableValues

public void setVariableValues(java.util.Map variableValue)
This method sets value of variableValues attribute.

Parameters:
variableValue - value of attribute.

getVendorFileName

public java.lang.String getVendorFileName()
Read value of vendorFileName.

Returns:
value of attribute.

setVendorFileName

public void setVendorFileName(java.lang.String vendorFileName)
This method sets value of vendorFileName attribute.

Parameters:
vendorFileName - value of attribute.

getOnErrorContinue

public boolean getOnErrorContinue()
read value of onErrorContinue attribute.

Returns:
value of attribute.

setOnErrorContinue

public void setOnErrorContinue(boolean onErrorContinue)
This method sets value of onErrorContinue attribute.

Parameters:
onErrorContinue - value of attribute.

getAdditionalPaths

public java.lang.String getAdditionalPaths()
Read value of additionalPaths attribute.

Returns:
value of attribute.

setAdditionalPaths

public void setAdditionalPaths(java.lang.String additionalPaths)
This method sets value of additionalPaths attribute.

Parameters:
additionalPaths - value of attribute.

getCommitCount

public int getCommitCount()
Read value of commitCount attribute.

Returns:
value of attribute.

setCommitCount

public void setCommitCount(int commitCount)
This method sets value of commitCount attribute.

Parameters:
commitCount - value of attribute.

getDefaultReturnCode

public int getDefaultReturnCode()
Read value of default error return code attribute.

Returns:
value of attribute.

setDefaultReturnCode

public void setDefaultReturnCode(int code)
This method sets value of default error return code attribute.

Parameters:
code - is value of attribute.

setIncludedJobs

public void setIncludedJobs(java.lang.String[] include_Tables)
This method set value of includeJobs parameter

Parameters:
include_Tables - is value of parameter

getIncludedJobs

public java.lang.String[] getIncludedJobs()
This method read value of includeJobs parameter

Returns:
value of parameter

getConfJarStructure

public java.lang.String getConfJarStructure()
This method read value of confJarStructure parameter

Returns:
value of parameter

getDefaultLogMode

public java.lang.String getDefaultLogMode()
This method read value of defaultLogMode parameter

Returns:
value of parameter

main

public static void main(java.lang.String[] argv)
Main method Loader with an associated XML, restart mode (optional) i user (optional). Main method controls parameters, it they are OK starts load method, but if they aren't makes alert. Usage: java org.webdocwf.util.loader.Loader [options] loadJob_xml_filename"); Options: -m defines the default logmode. Possible values are 'none', 'normal' (is the default) and 'full'. -r starts the Loader in restart mode after abnormal termination in a prior execution. -u defines the current UserID used in UserID value columns. -v defines variables used in variable columns. -l defines the logfile directory. The default is the current working directory. -f defines the logfile name. The default is 'LoaderLog-YYYY-MM-DD-HH-mm-SS.txt'. -d the filename of the XML DB-vendor configuration file. The default is 'OctopusDBVendors.xml'. -e defines to set the default of 'onErrorContinue' to 'true'. Is false otherwise. -p Extend the classpath with additional paths. -c Sets the default commit count. System default is '100'. -rc Sets the default error return code. System default is '1'. -it Sets the table names which will be proccesed

Parameters:
argv - represents input parmeters

load

public void load()
          throws LoaderException
Method load is main method in class Loader. It is used to load data from the source table into target tables and(or) execute SQL statements. Loading parameters are set in XML file. During loading, load status is printed on the screen and also put into log file. If there is an error Exception "LoaderException" is thrown.

Throws:
LoaderException

parseInputData

public void parseInputData(java.lang.Object readValueObject,
                           java.util.Vector vecVektor,
                           java.sql.ResultSet rsetSource,
                           int i,
                           java.lang.String columnName,
                           int blobCount,
                           boolean isMicrosoftDriver,
                           java.util.Hashtable columnValuesMicrosoft,
                           java.util.Hashtable sourceColumnTypes)
                    throws LoaderException
This method read data from source table

Parameters:
readValue - is data value which is reed
vecVektor - defines vector
rsetSource - defines ResultSet object
i - is interger
columnName - defines source column name
blobCount - defines counter for blob object
isMicrosoftDriver - defines if we use microsoft driver
columnValuesMicrosoft - defines column values which is read with microsoft driver
Throws:
LoaderException

inputToString

public java.lang.String inputToString()
                               throws LoaderException
This method write values for all input parameters to log file when log level is full

Throws:
LoaderException

getDateFromString

protected java.util.Date getDateFromString(java.lang.String date)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

setValueOnStatement

protected void setValueOnStatement(java.lang.String value,
                                   int javaTypeInt,
                                   int i,
                                   java.sql.PreparedStatement pstmt)
                            throws java.lang.Exception
Throws:
java.lang.Exception

getSQLRelationString

protected java.lang.String getSQLRelationString(java.sql.ResultSet rs)


Copyright © 2002-2007 Together - the Workgroup. All Rights Reserved.