public class ContractsParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.sql.Connection |
_dbConnection
The _db connection.
|
protected org.apache.log4j.Logger |
_logger
The _logger.
|
static java.util.Map<java.lang.String,java.lang.String> |
columnMap
The Constant columnMap.
|
private java.lang.String |
database
The database.
|
private java.lang.String |
driver
The driver.
|
private java.lang.String |
host
The host.
|
static java.util.List<java.lang.String> |
NULLABLE_COLUMNS
The Constant NULLABLE_COLUMNS.
|
static java.util.Map<java.lang.String,java.lang.String> |
OBLIGATIONS_COLUMN_MAP
The Constant OBLIGATIONS_COLUMN_MAP.
|
static java.lang.String |
OBLIGATIONS_TABLE_NAME
The Constant OBLIGATIONS_TABLE_NAME.
|
private java.lang.String[] |
obligationsBlackList
The obligations black list.
|
private java.lang.String[] |
obligationsWhiteList
The obligations white list.
|
private java.lang.String[] |
obligationsWhiteListColumnNames
The obligations white list column names.
|
static java.util.Map<java.lang.String,java.lang.String> |
OUTLAYS_COLUMN_MAP
The Constant OUTLAYS_COLUMN_MAP.
|
static java.lang.String |
OUTLAYS_TABLE_NAME
The Constant OUTLAYS_TABLE_NAME.
|
private java.lang.String[] |
outlaysBlackList
The outlays black list.
|
private java.lang.String[] |
outlaysWhiteList
The outlays white list.
|
private java.lang.String[] |
outlaysWhiteListColumnNames
The outlays white list column names.
|
private java.lang.String |
password
The password.
|
private static java.lang.String |
PROP_FILE
The Constant PROP_FILE.
|
private java.lang.String |
user
The user.
|
Constructor and Description |
---|
ContractsParser()
Instantiates a new contracts parser.
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String[] |
buildFindSql(java.lang.String[] whiteList,
java.util.Map columnsMap)
build a list of sqls to used for finding duplicates in the table.
|
private java.lang.Boolean |
checkForFields(java.util.Map row,
java.util.Map columnsMap)
check row against the columnMap
1.
|
private void |
closeDBConnection()
Close db connection.
|
private java.lang.Boolean |
findDuplicateRow(java.util.Map row,
java.lang.String tableName,
java.lang.String[] columnNames,
java.lang.String[] columnValues)
look for duplicate row in the database table.
|
private java.sql.Connection |
getDBConnection()
Gets the DB connection.
|
private int |
getSqlType(java.lang.String columnName)
Budget Center = budget_center java.sql.Types.VARCHAR
Sub-Budget Center = sub_budget_center java.sql.Types.VARCHAR
Executing Budget Center = executing_budget_center java.sql.Types.VARCHAR
Appropriation Year = appropriation_year java.sql.Types.DECIMAL
Appropriation = appropriation java.sql.Types.VARCHAR
Requisition ID = requisition_id java.sql.Types.VARCHAR
PO Reference = po_reference java.sql.Types.VARCHAR
ACR = acr java.sql.Types.VARCHAR
Obligation Date = obligation_date java.sql.Types.DATE
Obligated Amount = obligated_amount java.sql.Types.DECIMAL
Expensed Amount = expensed_amount java.sql.Types.DECIMAL
Expensed Date = expensed_date java.sql.Types.DATE
Voucher ID = voucher_id java.sql.Types.VARCHAR
|
private void |
initDBConnection()
Inits the database connection.
|
static void |
main(java.lang.String[] args)
The main method.
|
java.lang.String |
parseCognosXLSXFile(java.lang.String filename)
main interface to the client
parses XLSX file and stores in the database.
|
private java.util.ArrayList |
parseCOGNOSXLSXFile(java.lang.String filename)
parses XLXS file and stores key/value pair in ArrayList.
|
static void |
printMap(java.util.Map mp)
util function to print key/value pairs in the mao.
|
private java.lang.String |
saveCOGNOSData(java.lang.String tableName,
java.util.ArrayList data,
java.lang.String[] whiteListColumnNames,
java.lang.String[] whiteList,
java.util.Map columnsMap)
Saves COGNOS data into database table using whitelists 1000 at a time using batch function.
|
private java.lang.String |
saveDataToTable(java.util.ArrayList dataToSave,
java.lang.String tableName,
java.util.Map columnsMap)
save data to table using columnsMap and batching 1000 at a time.
|
private void |
setVarchar(java.sql.PreparedStatement stmt,
int col,
java.lang.String var,
int type)
set type of column specified in the parameter.
|
protected org.apache.log4j.Logger _logger
private static final java.lang.String PROP_FILE
public static final java.lang.String OBLIGATIONS_TABLE_NAME
public static final java.lang.String OUTLAYS_TABLE_NAME
public static final java.util.Map<java.lang.String,java.lang.String> columnMap
public static final java.util.Map<java.lang.String,java.lang.String> OBLIGATIONS_COLUMN_MAP
public static final java.util.Map<java.lang.String,java.lang.String> OUTLAYS_COLUMN_MAP
public static final java.util.List<java.lang.String> NULLABLE_COLUMNS
private java.lang.String[] obligationsWhiteList
private java.lang.String[] obligationsWhiteListColumnNames
private java.lang.String[] obligationsBlackList
private java.lang.String[] outlaysWhiteList
private java.lang.String[] outlaysWhiteListColumnNames
private java.lang.String[] outlaysBlackList
private java.sql.Connection _dbConnection
private java.lang.String host
private java.lang.String database
private java.lang.String driver
private java.lang.String user
private java.lang.String password
private void initDBConnection() throws java.sql.SQLException
java.sql.SQLException
- the SQL exceptionprivate java.lang.String[] buildFindSql(java.lang.String[] whiteList, java.util.Map columnsMap)
whiteList
- the white listcolumnsMap
- the columns mapprivate java.sql.Connection getDBConnection() throws java.sql.SQLException
java.sql.SQLException
- the SQL exceptionprivate void closeDBConnection() throws java.sql.SQLException
java.sql.SQLException
- the SQL exceptionpublic java.lang.String parseCognosXLSXFile(java.lang.String filename)
filename
- the filenameprivate java.lang.Boolean checkForFields(java.util.Map row, java.util.Map columnsMap)
row
- the rowcolumnsMap
- the columns mapprivate java.lang.String saveCOGNOSData(java.lang.String tableName, java.util.ArrayList data, java.lang.String[] whiteListColumnNames, java.lang.String[] whiteList, java.util.Map columnsMap)
tableName
- the table namedata
- the datawhiteListColumnNames
- the white list column nameswhiteList
- the white listcolumnsMap
- the columns mapprivate java.lang.String saveDataToTable(java.util.ArrayList dataToSave, java.lang.String tableName, java.util.Map columnsMap)
dataToSave
- the data to savetableName
- the table namecolumnsMap
- the columns mappublic static void printMap(java.util.Map mp)
mp
- the mpprivate java.util.ArrayList parseCOGNOSXLSXFile(java.lang.String filename)
filename
- the filenameprivate int getSqlType(java.lang.String columnName)
columnName
- the column nameprivate java.lang.Boolean findDuplicateRow(java.util.Map row, java.lang.String tableName, java.lang.String[] columnNames, java.lang.String[] columnValues)
row
- the rowtableName
- the table namecolumnNames
- the column namescolumnValues
- the column valuesprivate void setVarchar(java.sql.PreparedStatement stmt, int col, java.lang.String var, int type) throws java.sql.SQLException
stmt
- the stmtcol
- the colvar
- the vartype
- the typejava.sql.SQLException
- the SQL exceptionpublic static void main(java.lang.String[] args)
args
- the arguments