public class DataLoadHelper
extends java.lang.Object
This class contains static helper methods for data load.
Modifier and Type | Method and Description |
---|---|
static void | addParameter(java.lang.String nvp)
Parse the name value pair and add it to the parameters.
|
static java.lang.String[] | addParameter(java.lang.String nvp, java.util.Map parameters)
Parse the name value pair and add it to the parameters.
|
static java.lang.String | addQuote(java.lang.String valueString)
It adds single quote for the string value in a where clause.
|
static java.lang.String | appendToFilePath(java.lang.String filePath, java.lang.String suffix)
Appends a suffix to a file name
|
static java.lang.String | buildWhereClause(com.ibm.commerce.foundation.dataload.database.ColumnMetaData columnMetaData)
Builds a where clause based on the column is nullable or not.
|
static boolean | checkId(java.lang.String tableName, java.util.Map primaryKeyMap)
Check the primary key to see if the row exists in the database or not.
|
static java.lang.Float | convertMillisecondsToSeconds(long time)
This method converts milliseconds to seconds
|
static java.lang.String | encrypt(java.lang.String value, java.lang.String customKeyConfigFilename, java.lang.String instanceXMLFilename)
Encrypts the value using WC encryption algorithm.
|
static TableDataObject | findByPrimaryKey(java.lang.String tableName, java.util.Map primaryKeyData)
Find a row from the table by primary key and return the populated TableDataObject.
|
static TableDataObject | findByUniqueIndex(java.lang.String tableName, java.util.Map uniqueIndexDataMap)
Finds the row of a table by unique index data and returns it as a table data object.
|
static java.lang.String | formatDecimalString(java.lang.String decimalValue, int decimalDigits)
Pads the "0" at the end of the decimalValue if the decimal digits in the decimalValue is less than the decimalDigits.
|
static java.lang.String | formatTimestampString(java.lang.Object timestampObject)
Format the timestamp object to an ISO standard format with default 6 digits of nanoseconds.
|
static java.lang.String | formatTimestampString(java.lang.Object timestampObject, int nanoSecondDigits)
Format the timestamp object to an ISO standard format with nanoSecondDigits.
|
static java.lang.String | generateDataLoaderUniqueName(java.lang.String dataLoaderName)
Generate a unique data loader name by appending a date time string at the end of the data loader name.
|
static java.lang.String | generateDateTimeString()
Generate a date time string in the format of yyyy.MM.dd_HH.mm.ss.nnn
|
static java.lang.String | getBaseSchema()
Get the base schema name in the workspace environment.
|
static int | getBatchSize(ConfigProperties configProperties)
Gets the batch size from the configuration properties.
|
static java.lang.Integer | getColumnSize(java.lang.String tableName, java.lang.String columnName)
Gets the column size
|
static int[] | getColumnTypes(java.lang.String aTableName, java.util.List columnNames)
Get the column types for a list of column names in the table.
|
static java.lang.String | getCSVInputDataLine(java.lang.Object inputData, java.lang.String uniqueId, java.lang.String tokenDelimiter)
Gets the CSV line from the input Data.
|
static java.io.File | getInputFile(java.lang.String loadItemName)
Gets the input file from the configuration file.
|
static java.lang.String | getLocalizedMessage(java.lang.String messageKey, java.lang.Object[] params)
This method returns the localized message from resource bundle associated with the Logger.
|
static java.lang.String | getLocalizedMessage(java.lang.String messageKey, java.lang.Object[] params, java.util.logging.Logger logger)
This method returns the localized message from resource bundle associated with the Logger.
|
static java.lang.Long | getNextKey(java.lang.String aTableName)
Get the next key from key manager.
|
static java.lang.Long | getNextKey(java.lang.String aTableName, long startKey, long endKey)
Get the next key with the fixed key range.
|
static java.lang.String | getParameter(java.lang.String parameterName)
Get the parameter value from the Environment.
|
static QueryProperties | getQuery(java.util.List<QueryProperties> queryList, java.lang.String queryName)
Returns the query from the list which has the specified name
|
static java.lang.String | getReadSchema()
Get the read schema name in the workspace environment.
|
static long | getTableRowCount(java.lang.String aTableName)
Get the number of rows in the table.
|
static java.lang.String | getTask()
Get the task identifier in the workspace environment.
|
static java.lang.String | getTaskGroup()
Get the task group identifier in the workspace environment.
|
static java.lang.Long | getTaskGroupId(java.lang.String taskGroupIdentifier)
This method will return the task group ID given the external identifier.
|
static java.lang.Long | getTaskId(java.lang.String taskIdentifier)
This method will return the task ID given the external identifier.
|
static java.util.List | getUniqueIndexCoulumnsNames(java.lang.String tableName)
Get the unique-Index columns name for a table.
|
static java.lang.String | getWorkspace()
Get the workspace identifier in the workspace environment.
|
static java.lang.Long | getWorkspaceId(java.lang.String workspaceIdentifier)
This method will return the workspace ID given the external identifier.
|
static java.lang.String | getWriteSchema()
Get the write schema name in the workspace environment.
|
static java.io.BufferedWriter | initCSVFileWriter(java.lang.String loadItemName, java.lang.String appendName, java.lang.String filePath, java.lang.Object inputData, java.lang.String uniqueIdCSVColumnName, java.lang.String lineSeparator, java.lang.String encoding, java.lang.String tokenDelimiter)
Initializes the CSV file writer.
|
static boolean | isBatchEnabled(ConfigProperties configProperties)
Check from the configuration properties to see if the jdbc batch update is enabled.
|
static boolean | isCloudscape()
The method will check the database set in the command line argument is cloudscape or derby.
|
static boolean | isDataExtract()
Checks if its the DataExtract utility being executed.
|
static boolean | isDBConnectionOptional()
Checks if the dbConnectionOptional = true parameter is specified on the command line.
|
static boolean | isJ2SE()
Checks if the dataload is running in J2SE environment and returns a flag accordingly
|
static boolean | isNumericType(int columnType)
Check if the columnType is a numeric type based on the constants defined in the java.sql.Types.
|
static boolean | isOracle()
The method will check the database set in the command line argument is oracle.
|
static boolean | isStorePublish()
Checks if it is running inside the store publish.
|
static boolean | isValidXmlFile(java.lang.String filePath)
Checks to see if the file is an XML file.
|
static java.lang.String | printDataGraph(commonj.sdo.DataGraph dataGraph)
Prints the contents of a data graph.
|
static java.lang.String | printDataObject(commonj.sdo.DataObject dataObject)
This method prints a data object.
|
static java.lang.String | printDataObject(java.lang.Object dataObject)
This method prints a data object.
|
static void | printSQLException(java.sql.SQLException ex)
Print the detailed exception information including the sql state and error code.
|
static java.lang.String | rebuildSQLWithMultipleQuestionMarks(java.lang.String sql, int position, int numberOfQuestionMarks)
Rebuilds the SQL and change a single question mark to multiple question marks.
|
static java.lang.String | resolveId(java.lang.String tableName, java.util.Map uniqueIndexValueMap, boolean bGenerateNewKey, java.lang.Long startKey, java.lang.Long endKey)
This method will call resolveIds() to get the primary key map and then get the primary key value from the map.
|
static java.util.Map | resolveIds(java.lang.String tableName, java.util.Map uniqueIndexValueMap, boolean generateNewKey, java.lang.Long startKey, java.lang.Long endKey)
It just calls: resolveIds(tableName, uniqueIndexValueMap, generateNewKey, startKey, endKey, null).
|
static java.util.Map | resolveIds(java.lang.String tableName, java.util.Map uniqueIndexValueMap, boolean generateNewKey, java.lang.Long startKey, java.lang.Long endKey, TableDataObject tableDataObject)
This method will resolve identifiers for a physical object with multiple primary key columns.
|
static void | setCurrentSchema(java.lang.String schemaName)
Change the current schema to the schemaName
|
static void | setParameter(java.lang.String parameterName, java.lang.String parameterValue)
Set the parameter name and value to the Environment.
|
static void | setParameterValue(com.ibm.commerce.foundation.dataload.database.DBPreparedStatement statement, java.lang.String tableName, java.util.List whereClauseColumnNames, java.util.Map whereClauseDataMap)
Sets the parameter value in the prepared statement.
|
static int | setWhereClauseColumnValue(com.ibm.commerce.foundation.dataload.database.DBPreparedStatement statement, com.ibm.commerce.foundation.dataload.database.ColumnMetaData columnMetaData, java.lang.Object columnValue, int parameterIndex)
Sets the where clause column value in the prepared statement.
|
static java.util.List<java.lang.String> | tokenizeToList(java.lang.String value, java.lang.String delimiter)
Tokenizes the value string with the delimiter and convert it into a list.
|
static void | updateLoggerLevel()
Update the logger level
|
static void | validateTaskGroupAndTaskStatus(com.ibm.commerce.foundation.dataload.database.DBPreparedStatement taskGroupStatusPS, com.ibm.commerce.foundation.dataload.database.DBPreparedStatement taskStatusPS, java.lang.String taskGroupIdentifier, java.lang.String taskIdentifier)
This method will validate that the task group and task in a correct status.
|
static void | validateTaskGroupTaskRelationship(java.lang.String taskGroupIdentifier, java.lang.String taskIdentifier)
This method will validate that the task group and task identifier provided in the configuration are associated with each other.
|
static java.lang.String | validateUniqueTaskGroupName(java.lang.String taskGroupName)
This method will validate that the task group name provided in the configuration is unique and in the correct state.
|
static java.lang.String | validateUniqueTaskName(java.lang.String taskName)
This method will validate that the task name provided in the configuration is unique and in the correct state.
|
static void | validateWorkspace(java.lang.String workspaceIdentifier, java.lang.String taskGroupIdentifier, java.lang.String taskIdentifier)
This method will validate the workspace information provided.
|
static void | validateWorkspaceTaskGroupRelationship(java.lang.String workspaceIdentifier, java.lang.String taskGroupIdentifier)
This method will validate that the workspace and task group identifier provided in the configuration are associated with each other.
|
static void | warn(java.lang.String messageKey, java.lang.Object[] params, java.util.ResourceBundle resourceBundle)
Warns the user and prompts the user whether to continue or not.
|
static void | warn(java.lang.String messageKey, java.util.ResourceBundle resourceBundle)
Warns the user and prompts the user whether to continue or not.
|
static boolean | workspaceEnabled()
Check if the workspace is enabled by check if the workspace is in the context.
|
public static long getTableRowCount(java.lang.String aTableName) throws DataLoadException
public static java.lang.String addQuote(java.lang.String valueString)
public static boolean isNumericType(int columnType)
public static int[] getColumnTypes(java.lang.String aTableName, java.util.List columnNames) throws DataLoadException
public static java.lang.Integer getColumnSize(java.lang.String tableName, java.lang.String columnName)
public static java.lang.Long getNextKey(java.lang.String aTableName) throws DataLoadException
public static java.lang.Long getNextKey(java.lang.String aTableName, long startKey, long endKey) throws DataLoadException
public static java.lang.String printDataObject(java.lang.Object dataObject)
This method prints a data object.
public static java.lang.String printDataObject(commonj.sdo.DataObject dataObject)
This method prints a data object.
public static java.lang.String printDataGraph(commonj.sdo.DataGraph dataGraph)
Prints the contents of a data graph.
public static void printSQLException(java.sql.SQLException ex)
public static boolean isJ2SE()
public static boolean isDataExtract()
public static java.lang.String getParameter(java.lang.String parameterName)
public static void setParameter(java.lang.String parameterName, java.lang.String parameterValue)
public static void addParameter(java.lang.String nvp)
public static java.lang.String[] addParameter(java.lang.String nvp, java.util.Map parameters)
public static java.lang.String appendToFilePath(java.lang.String filePath, java.lang.String suffix)
public static void updateLoggerLevel()
public static java.lang.String formatTimestampString(java.lang.Object timestampObject, int nanoSecondDigits)
public static java.lang.String formatTimestampString(java.lang.Object timestampObject)
public static java.lang.String formatDecimalString(java.lang.String decimalValue, int decimalDigits)
public static java.lang.String generateDataLoaderUniqueName(java.lang.String dataLoaderName)
Generate a unique data loader name by appending a date time string at the end of the data loader name.
public static java.lang.String generateDateTimeString()
public static java.lang.String getLocalizedMessage(java.lang.String messageKey, java.lang.Object[] params, java.util.logging.Logger logger)
This method returns the localized message from resource bundle associated with the Logger.
public static java.lang.String getLocalizedMessage(java.lang.String messageKey, java.lang.Object[] params)
This method returns the localized message from resource bundle associated with the Logger.
public static java.lang.Float convertMillisecondsToSeconds(long time)
This method converts milliseconds to seconds
public static int getBatchSize(ConfigProperties configProperties)
public static boolean isBatchEnabled(ConfigProperties configProperties)
public static void validateWorkspace(java.lang.String workspaceIdentifier, java.lang.String taskGroupIdentifier, java.lang.String taskIdentifier) throws DataLoadException
This method will validate the workspace information provided.
The following information will be validated:
public static java.lang.String validateUniqueTaskGroupName(java.lang.String taskGroupName) throws DataLoadException
This method will validate that the task group name provided in the configuration is unique and in the correct state. If it is unique the task group identifier will be returned otherwise an exception will be thrown.
public static java.lang.String validateUniqueTaskName(java.lang.String taskName) throws DataLoadException
This method will validate that the task name provided in the configuration is unique and in the correct state. If it is unique the task identifier will be returned otherwise an exception will be thrown.
public static void validateTaskGroupAndTaskStatus(com.ibm.commerce.foundation.dataload.database.DBPreparedStatement taskGroupStatusPS, com.ibm.commerce.foundation.dataload.database.DBPreparedStatement taskStatusPS, java.lang.String taskGroupIdentifier, java.lang.String taskIdentifier) throws DataLoadException
public static java.lang.Long getWorkspaceId(java.lang.String workspaceIdentifier) throws DataLoadException
This method will return the workspace ID given the external identifier.
public static java.lang.Long getTaskGroupId(java.lang.String taskGroupIdentifier) throws DataLoadException
This method will return the task group ID given the external identifier.
public static java.lang.Long getTaskId(java.lang.String taskIdentifier) throws DataLoadException
This method will return the task ID given the external identifier.
public static void validateWorkspaceTaskGroupRelationship(java.lang.String workspaceIdentifier, java.lang.String taskGroupIdentifier) throws DataLoadException
This method will validate that the workspace and task group identifier provided in the configuration are associated with each other.
public static void validateTaskGroupTaskRelationship(java.lang.String taskGroupIdentifier, java.lang.String taskIdentifier) throws DataLoadException
This method will validate that the task group and task identifier provided in the configuration are associated with each other.
public static java.lang.String getBaseSchema()
Get the base schema name in the workspace environment. If it is not in the workspace environment, it returns null.
public static java.lang.String getWriteSchema()
Get the write schema name in the workspace environment. If it is not in the workspace environment, it returns null.
public static java.lang.String getReadSchema()
Get the read schema name in the workspace environment. If it is not in the workspace environment, it returns null.
public static boolean workspaceEnabled()
Check if the workspace is enabled by check if the workspace is in the context.
public static java.lang.String getWorkspace()
Get the workspace identifier in the workspace environment. If it is not in the workspace environment, it returns null.
public static java.lang.String getTaskGroup()
Get the task group identifier in the workspace environment. If it is not in the workspace environment, it returns null.
public static java.lang.String getTask()
Get the task identifier in the workspace environment. If it is not in the workspace environment, it returns null.
public static void setCurrentSchema(java.lang.String schemaName) throws DataLoadException
public static java.util.List getUniqueIndexCoulumnsNames(java.lang.String tableName) throws DataLoadException
public static void warn(java.lang.String messageKey, java.lang.Object[] params, java.util.ResourceBundle resourceBundle) throws DataLoadException
public static void warn(java.lang.String messageKey, java.util.ResourceBundle resourceBundle) throws DataLoadException
public static boolean isCloudscape()
public static boolean isOracle()
public static java.util.List<java.lang.String> tokenizeToList(java.lang.String value, java.lang.String delimiter)
public static TableDataObject findByPrimaryKey(java.lang.String tableName, java.util.Map primaryKeyData) throws DataLoadException
public static TableDataObject findByUniqueIndex(java.lang.String tableName, java.util.Map uniqueIndexDataMap) throws DataLoadException
public static void setParameterValue(com.ibm.commerce.foundation.dataload.database.DBPreparedStatement statement, java.lang.String tableName, java.util.List whereClauseColumnNames, java.util.Map whereClauseDataMap) throws DataLoadException
public static java.lang.String buildWhereClause(com.ibm.commerce.foundation.dataload.database.ColumnMetaData columnMetaData)
public static int setWhereClauseColumnValue(com.ibm.commerce.foundation.dataload.database.DBPreparedStatement statement, com.ibm.commerce.foundation.dataload.database.ColumnMetaData columnMetaData, java.lang.Object columnValue, int parameterIndex) throws DataLoadException
public static boolean isStorePublish()
public static java.lang.String resolveId(java.lang.String tableName, java.util.Map uniqueIndexValueMap, boolean bGenerateNewKey, java.lang.Long startKey, java.lang.Long endKey) throws DataLoadException
This method will call resolveIds() to get the primary key map and then get the primary key value from the map. It can only be called if the primary key only contains one column. If the primary key contains multiple columns, it will return null.
public static java.util.Map resolveIds(java.lang.String tableName, java.util.Map uniqueIndexValueMap, boolean generateNewKey, java.lang.Long startKey, java.lang.Long endKey, TableDataObject tableDataObject) throws DataLoadException
This method will resolve identifiers for a physical object with multiple primary key columns.
public static java.util.Map resolveIds(java.lang.String tableName, java.util.Map uniqueIndexValueMap, boolean generateNewKey, java.lang.Long startKey, java.lang.Long endKey) throws DataLoadException
public static boolean checkId(java.lang.String tableName, java.util.Map primaryKeyMap) throws DataLoadException
public static java.lang.String encrypt(java.lang.String value, java.lang.String customKeyConfigFilename, java.lang.String instanceXMLFilename) throws DataLoadException
public static java.io.File getInputFile(java.lang.String loadItemName)
public static java.io.BufferedWriter initCSVFileWriter(java.lang.String loadItemName, java.lang.String appendName, java.lang.String filePath, java.lang.Object inputData, java.lang.String uniqueIdCSVColumnName, java.lang.String lineSeparator, java.lang.String encoding, java.lang.String tokenDelimiter) throws DataLoadException
public static java.lang.String getCSVInputDataLine(java.lang.Object inputData, java.lang.String uniqueId, java.lang.String tokenDelimiter)
public static boolean isValidXmlFile(java.lang.String filePath) throws DataLoadException
public static QueryProperties getQuery(java.util.List<QueryProperties> queryList, java.lang.String queryName)
public static java.lang.String rebuildSQLWithMultipleQuestionMarks(java.lang.String sql, int position, int numberOfQuestionMarks) throws DataLoadException
public static boolean isDBConnectionOptional()