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.String |
convertMapToPropertiesString(java.util.Map parameterMap)
Convert a map to a string which contains all name value pairs and each
separated by &.
|
static java.lang.Float |
convertMillisecondsToSeconds(long time)
This method converts milliseconds to seconds
|
static java.lang.String |
convertStackTraceToString(java.lang.Throwable throwable)
This method converts the stack trace of the
Throwable object to a String for tracing
purposes. |
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.String |
getCatalogIdFromCtx()
Gets the catalog ID from business context.
|
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.lang.String |
getCurrencyFromCtx()
Gets the currency from business context.
|
static java.io.File |
getInputFile(java.lang.String loadItemName)
Gets the input file from the configuration file.
|
static java.lang.String |
getLangIdFromCtx()
Gets the language ID from business context.
|
static java.util.List<java.lang.String> |
getListOfRegistryNameToRefresh(ConfigProperties configProperties)
Gets a list of registry name to be refreshed from the configure properties.
|
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 com.ibm.commerce.foundation.dataload.config.QueryProperties |
getQuery(java.util.List<com.ibm.commerce.foundation.dataload.config.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 java.lang.String |
getStoreIdFromCtx()
Gets the store ID from business context.
|
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 void |
initailizeAssociateQuery(java.util.List<com.ibm.commerce.foundation.dataload.config.QueryProperties> associatedQueryList,
java.util.List<com.ibm.commerce.foundation.dataload.database.DBPreparedStatement> psArray,
java.util.Map idMap)
Initializes the associated query for the list type parameters.
|
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 |
prunedString(java.lang.String string,
int maxUtf8Length)
Gets a string pruned to length bytes.
|
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 java.util.List<java.lang.String> |
tokenizeToList(java.lang.String value,
java.lang.String delimiter,
boolean trimWhiteSpace)
Tokenizes the value string with the delimiter and convert it into a list.
|
static void |
updateLoggerLevel()
Update the logger level
|
static void |
updateParamValueOfListType(int index,
com.ibm.commerce.foundation.dataload.config.QueryProperties query)
Updates the parameter value for the list type
|
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
aTableName
- a table nameDataLoadException
- this exception is thrown if there is a problem to
find out the number of row for the table.public static java.lang.String addQuote(java.lang.String valueString)
valueString
- the input value stringpublic static boolean isNumericType(int columnType)
columnType
- the column type integer.public static int[] getColumnTypes(java.lang.String aTableName, java.util.List columnNames) throws DataLoadException
aTableName
- a table namecolumnNames
- a list of column namesDataLoadException
- if the jdbc throws exception.public static java.lang.Integer getColumnSize(java.lang.String tableName, java.lang.String columnName)
tableName
- a table namecolumnName
- a column namepublic static java.lang.Long getNextKey(java.lang.String aTableName) throws DataLoadException
aTableName
- table nameDataLoadException
- this exception is thrown if there is some error to
get the next key.public static java.lang.Long getNextKey(java.lang.String aTableName, long startKey, long endKey) throws DataLoadException
aTableName
- a table namestartKey
- start keyendKey
- end keyDataLoadException
- this exception is thrown if there is some error to
get the next key.public static java.lang.String printDataObject(java.lang.Object dataObject)
This method prints a data object.
dataObject
- The data object to printpublic static java.lang.String printDataObject(commonj.sdo.DataObject dataObject)
This method prints a data object.
dataObject
- The data object to printpublic static java.lang.String printDataGraph(commonj.sdo.DataGraph dataGraph)
Prints the contents of a data graph.
dataGraph
- The data graph to print.public static void printSQLException(java.sql.SQLException ex)
ex
- an sql exceptionpublic static boolean isJ2SE()
public static boolean isDataExtract()
public static java.lang.String getParameter(java.lang.String parameterName)
parameterName
- the parameter namepublic static void setParameter(java.lang.String parameterName, java.lang.String parameterValue)
parameterName
- parameter nameparameterValue
- parameter valuepublic static void addParameter(java.lang.String nvp)
nvp
- a string in format of -Dname=valuepublic static java.lang.String[] addParameter(java.lang.String nvp, java.util.Map parameters)
nvp
- a string in format of -Dname=valueparameters
- a map of (parameterName, parameterValue) pairs; default to Environment.properties if unspecifiedpublic static java.lang.String appendToFilePath(java.lang.String filePath, java.lang.String suffix)
filePath
- the old file pathsuffix
- a suffix to be appendedpublic static void updateLoggerLevel()
public static java.lang.String formatTimestampString(java.lang.Object timestampObject, int nanoSecondDigits)
timestampObject
- the timestamp objectnanoSecondDigits
- the number of nanosecond digits.public static java.lang.String formatTimestampString(java.lang.Object timestampObject)
timestampObject
- the timestamp objectpublic static java.lang.String formatDecimalString(java.lang.String decimalValue, int decimalDigits)
decimalValue
- a decimal value stringdecimalDigits
- number of decimal digitspublic 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.
dataLoaderName
- The configured name of the data loader.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.
messageKey
- The message key to lookup the localized message.params
- The message parameters to be substituted in into the localized message.logger
- a Logger object.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.
messageKey
- The message key to lookup the localized message.params
- The message parameters to be substituted in into the localized message.public static java.lang.Float convertMillisecondsToSeconds(long time)
This method converts milliseconds to seconds
time
- The time, in milliseconds.public static int getBatchSize(ConfigProperties configProperties)
configProperties
- configuration properties.public static boolean isBatchEnabled(ConfigProperties configProperties)
configProperties
- configuration properties.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:
workspaceIdentifier
- The workspace identifier.taskGroupIdentifier
- The task group identifier.taskIdentifier
- The task identifier.DataLoadException
- A configuration exception will be thrown if the workspace information is invalid.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.
taskGroupName
- The task group name.DataLoadException
- A configuration exception will be thrown if the task group name is not unique.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.
taskName
- The task name.DataLoadException
- A configuration exception will be thrown if the task name is not unique.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
taskGroupStatusPS
- a prepared statement to get task group status.taskStatusPS
- a prepared statement to get task status.taskGroupIdentifier
- a task group identifier.taskIdentifier
- a task identifierDataLoadException
- if getting the status of task group or task is failed, or the validation of the
status is failed.public static java.lang.Long getWorkspaceId(java.lang.String workspaceIdentifier) throws DataLoadException
This method will return the workspace ID given the external identifier.
workspaceIdentifier
- The workspace identifier.DataLoadException
- A configuration exception will be thrown if the was a problem determining the workspace id.public static java.lang.Long getTaskGroupId(java.lang.String taskGroupIdentifier) throws DataLoadException
This method will return the task group ID given the external identifier.
taskGroupIdentifier
- The task group identifier.DataLoadException
- A configuration exception will be thrown if the was a problem determining the task group id.public static java.lang.Long getTaskId(java.lang.String taskIdentifier) throws DataLoadException
This method will return the task ID given the external identifier.
taskIdentifier
- The task identifier.DataLoadException
- A configuration exception will be thrown if the was a problem determining the task id.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.
workspaceIdentifier
- The workspace identifier.taskGroupIdentifier
- The task group identifier.DataLoadException
- A configuration exception will be thrown if the workspace and task group are not related.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.
taskGroupIdentifier
- The task group identifier.taskIdentifier
- The task identifier.DataLoadException
- A configuration exception will be thrown if the task group and task are not related.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
schemaName
- a schema nameDataLoadException
- this exception is thrown if there is a problem to get the database connection.public static java.util.List getUniqueIndexCoulumnsNames(java.lang.String tableName) throws DataLoadException
tableName
- a table nameDataLoadException
- if more than one unique-index are defined for a tablepublic static void warn(java.lang.String messageKey, java.lang.Object[] params, java.util.ResourceBundle resourceBundle) throws DataLoadException
messageKey
- the warning message keyparams
- the message parameters to be substituted in into the localized messageresourceBundle
- the resource bundleDataLoadException
- A system exception will be thrown if the user replied not to continue.public static void warn(java.lang.String messageKey, java.util.ResourceBundle resourceBundle) throws DataLoadException
messageKey
- the warning message keyresourceBundle
- the resource bundleDataLoadException
- A system exception will be thrown if the user replied not to continue.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, boolean trimWhiteSpace)
value
- a value stringdelimiter
- a delimiter stringtrimWhiteSpace
- indicate whether to trim the white pace for each token.public static java.util.List<java.lang.String> tokenizeToList(java.lang.String value, java.lang.String delimiter)
value
- a value stringdelimiter
- a delimiter stringpublic static TableDataObject findByPrimaryKey(java.lang.String tableName, java.util.Map primaryKeyData) throws DataLoadException
tableName
- the table nameprimaryKeyData
- a map containing the primary key name to the value mapDataLoadException
- this error is thrown if the database throws the sql exceptionpublic static TableDataObject findByUniqueIndex(java.lang.String tableName, java.util.Map uniqueIndexDataMap) throws DataLoadException
tableName
- a table nameuniqueIndexDataMap
- a unique index data mapDataLoadException
- if there are some errors.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
statement
- the prepared statementtableName
- a table namewhereClauseColumnNames
- a list of column names in the where clausewhereClauseDataMap
- the column value to be set for these columns in the where clauseDataLoadException
- if there are some errors.public static java.lang.String buildWhereClause(com.ibm.commerce.foundation.dataload.database.ColumnMetaData columnMetaData)
columnMetaData
- a column meta data objectpublic 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
statement
- a prepared statementcolumnMetaData
- a column meta data objectcolumnValue
- a column valueparameterIndex
- a parameter indexDataLoadException
- if there are some errors.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.
tableName
- The table name to check for a key to resolve.uniqueIndexValueMap
- A Map
containing unique index columns and their values.bGenerateNewKey
- A boolean variable to indicate if an identifier should be fetched from the key manager.startKey
- a start key for the key range. If startKey or endKey is null, the key range will be determined by
KEYS table.endKey
- an end key for the key range.DataLoadException
- An application exception will be thrown if there was a problem resolving the identifier.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.
tableName
- The table name to check for a key to resolve.uniqueIndexValueMap
- A Map
containing unique index columns and their values.generateNewKey
- A boolean variable to indicate if an identifier should be fetched from the key manager.startKey
- a start key for the key range. If startKey or endKey is null, the key range will be determined by
KEYS table.endKey
- an end key for the key range.tableDataObject
- an optional table data object. If it is not null, the unique index and the resolve primary will
all be populated into the table data object.DataLoadException
- An application exception will be thrown if there was a problem resolving the identifier.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
tableName
- The table name to check for a key to resolve.uniqueIndexValueMap
- A Map
containing unique index columns and their values.generateNewKey
- A boolean variable to indicate if an identifier should be fetched from the key manager.startKey
- a start key for the key range. If startKey or endKey is null, the key range will be determined by
KEYS table.endKey
- an end key for the key range.
all be populated into the table data object.DataLoadException
- An application exception will be thrown if there was a problem resolving the identifier.public static boolean checkId(java.lang.String tableName, java.util.Map primaryKeyMap) throws DataLoadException
tableName
- the table nameprimaryKeyMap
- a map contains the primary key data.DataLoadException
- this exception is thrown if there are some problems during the check.public static java.lang.String encrypt(java.lang.String value, java.lang.String customKeyConfigFilename, java.lang.String instanceXMLFilename) throws DataLoadException
value
- the value to be encrypted.customKeyConfigFilename
- the file path to custom key configuration fileinstanceXMLFilename
- to file path to the instance XML file.DataLoadException
- if both custom key configuration file and instance XML file are not specified or the encryption
has some errors.public static java.io.File getInputFile(java.lang.String loadItemName)
loadItemName
- a load item namepublic 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
loadItemName
- a load item nameappendName
- a name to be appended to the original CSV file if the new CSV file is not specified.filePath
- a file path specified for the new CSV file.inputData
- the input data from CSV readeruniqueIdCSVColumnName
- a unique ID CSV column name.lineSeparator
- the line separator for the CSV fileencoding
- the encoding for the CSV filetokenDelimiter
- the taken delimiter for the CSV fileDataLoadException
- if the buffered writer cannot be created due to file path or access denied.public static java.lang.String getCSVInputDataLine(java.lang.Object inputData, java.lang.String uniqueId, java.lang.String tokenDelimiter)
inputData
- the input data map from the CSV reader.uniqueId
- a unique IDtokenDelimiter
- a token delimiter.public static boolean isValidXmlFile(java.lang.String filePath) throws DataLoadException
filePath
- a file pathDataLoadException
- if there are some errors.public static com.ibm.commerce.foundation.dataload.config.QueryProperties getQuery(java.util.List<com.ibm.commerce.foundation.dataload.config.QueryProperties> queryList, java.lang.String queryName)
queryList
- a list of queryqueryName
- a specified query namepublic static java.lang.String rebuildSQLWithMultipleQuestionMarks(java.lang.String sql, int position, int numberOfQuestionMarks) throws DataLoadException
sql
- the original SQLposition
- the position of the question mark to be replaced.numberOfQuestionMarks
- the number of question marks to be replaced.DataLoadException
- if there are no question mark specified in the position.public static boolean isDBConnectionOptional()
public static java.lang.String convertMapToPropertiesString(java.util.Map parameterMap)
parameterMap
- a map objectpublic static void initailizeAssociateQuery(java.util.List<com.ibm.commerce.foundation.dataload.config.QueryProperties> associatedQueryList, java.util.List<com.ibm.commerce.foundation.dataload.database.DBPreparedStatement> psArray, java.util.Map idMap) throws DataLoadException
associatedQueryList
- a list of queriespsArray
- a list of prepared satements.idMap
- a map object.DataLoadException
- if there are some errors.public static void updateParamValueOfListType(int index, com.ibm.commerce.foundation.dataload.config.QueryProperties query)
index
- the index in the list value.query
- a query propertiespublic static java.lang.String getCatalogIdFromCtx() throws DataLoadException
DataLoadException
- if there are some errors.public static java.lang.String getStoreIdFromCtx() throws DataLoadException
DataLoadException
- if there are some errors.public static java.lang.String getLangIdFromCtx() throws DataLoadException
DataLoadException
- if there are some errors.public static java.lang.String getCurrencyFromCtx() throws DataLoadException
DataLoadException
- if there are some errors.public static java.lang.String prunedString(java.lang.String string, int maxUtf8Length)
string
- The string to be pruned.maxUtf8Length
- The byte length to prune to. It is usually the size of database column.public static java.lang.String convertStackTraceToString(java.lang.Throwable throwable)
Throwable
object to a String
for tracing
purposes.throwable
- The Throwable
object.String
representation of the stack trace.public static java.util.List<java.lang.String> getListOfRegistryNameToRefresh(ConfigProperties configProperties)
configProperties
- a configure properties