Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use prepared statements in coeus connector #70

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading