Skip to content

Commit

Permalink
fix download_start_date initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
carcari committed Mar 15, 2018
1 parent 7b1a66a commit 7d716a8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cop-tools/src/main/java/eu/serco/tools/DHuSProductDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,18 @@ public Boolean getProducts() throws NoSuchAlgorithmException, KeyStoreException,

RestTemplate template = templateBuilder.requestFactory(requestFactory).basicAuthorization(username,password).build();
String sqlSelect = "SELECT startdate\n" +
"\tFROM dias.download_start_date LIMIT 1;";
"\tFROM dias.download_start_date where source='DHUS' LIMIT 1;";
//get start date
String startDate = jdbcTemplate.queryForObject(sqlSelect, String.class);
String startDate = null;
try {
startDate = jdbcTemplate.queryForObject(sqlSelect, String.class);

} catch (Exception e) {
logger.error("No start date found, initialize table download_start_date...");
jdbcTemplate.update("INSERT INTO dias.download_start_date(\n" +
"\tstartdate, source)\n" +
"\tVALUES (?, ?);", startdate, "DHUS");
}
logger.info("Product list start date is: " + startDate);
String beginPosition = (startDate != null) ? startDate : startdate;
int i=0;
Expand Down

0 comments on commit 7d716a8

Please sign in to comment.