Skip to content

Commit

Permalink
Use prepared statements in coeus connector
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoet-jh committed Nov 6, 2023
1 parent df168d6 commit 759594b
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 437 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_COULD_NOT_APPEND_UPDATE_TIMESTAMP;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_COULD_NOT_OPEN_CONFIGURATION_FILE;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_DATA_FILE_CANNOT_READ;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_DIRECTORY_LOOKUP_ERROR;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_HOME_DIRECTORY_NOT_FOUND;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_HOME_DIRECTORY_NOT_READABLE_AND_WRITABLE;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_INVALID_COMMAND_LINE_DATE;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_INVALID_COMMAND_LINE_TIMESTAMP;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_INVALID_TIMESTAMP;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_MODE_NOT_VALID;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_ORACLE_DRIVER_NOT_FOUND;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_REQUIRED_CONFIGURATION_FILE_MISSING;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_REQUIRED_DATA_FILE_MISSING;
import static org.eclipse.pass.support.grant.cli.DataLoaderErrors.ERR_RESULT_SET_NULL;
Expand Down Expand Up @@ -238,24 +236,12 @@ void run() throws PassCliException {
}

GrantConnector connector = configureConnector(connectionProperties, policyProperties);
String queryString = connector.buildQueryString(startDate, awardEndDate, mode, grant);

//special case for when we process funders, but do not want to consult COEUS -
//just use local properties file to map funders to policies
if (mode.equals("funder") && local) {
queryString = null;
}

try {
resultSet = connector.retrieveUpdates(queryString, mode);
} catch (ClassNotFoundException e) {
throw processException(ERR_ORACLE_DRIVER_NOT_FOUND, e);
resultSet = connector.retrieveUpdates(startDate, awardEndDate, mode, grant);
} catch (SQLException e) {
throw processException(ERR_SQL_EXCEPTION, e);
} catch (RuntimeException e) {
throw processException("Runtime Exception", e);
} catch (IOException e) {
throw processException(ERR_DIRECTORY_LOOKUP_ERROR, e);
}
} else { //just doing a PASS load, must have results set in the data file
try (FileInputStream fis = new FileInputStream(dataFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ private DataLoaderErrors() {
static String ERR_COULD_NOT_APPEND_UPDATE_TIMESTAMP = "The updated succeeded, but could not append last modified " +
"date %s to update timestamp file";
static String ERR_SQL_EXCEPTION = "An SQL error occurred querying the grant data source";
static String ERR_ORACLE_DRIVER_NOT_FOUND = "Could not find the oracle db driver on classpath.";
static String ERR_MODE_NOT_VALID = "%s is not a valid mode - must be either \"grant\" or \"user\"";
static String ERR_ACTION_NOT_VALID = "%s is not a valid action - must be either \"pull\" or \"load\"";
static String ERR_DIRECTORY_LOOKUP_ERROR = "Error looking up Hopkins ID from employee ID";
static String ERR_RESULT_SET_NULL = "The result set was null - either the data pull failed, or there was an error" +
" reading the result set from the data file";
}
Loading

0 comments on commit 759594b

Please sign in to comment.