Skip to content

Commit

Permalink
one week data
Browse files Browse the repository at this point in the history
  • Loading branch information
cameroncaci committed Dec 9, 2023
1 parent 68aedd4 commit e92d0d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>com.milmove.trdmlambda</groupId>
<artifactId>trdm-lambda</artifactId>
<version>1.0.1.0</version>
<version>1.0.1.1</version>
<name>trdm java spring interface</name>
<description>Project for deploying a Java TRDM interfacer for TGET data.</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ private XMLGregorianCalendar getOurLastTGETUpdate(String tableName)
return DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar);
}

public static XMLGregorianCalendar addOneWeek(XMLGregorianCalendar originalDate) throws DatatypeConfigurationException {
GregorianCalendar calendar = originalDate.toGregorianCalendar();
calendar.add(GregorianCalendar.WEEK_OF_YEAR, 1);

SimpleDateFormat xmlFriendlyLastUpdateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
xmlFriendlyLastUpdateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String xmlGregorianCalendarString = xmlFriendlyLastUpdateFormat.format(calendar.getTime());

return DatatypeFactory.newInstance().newXMLGregorianCalendar(xmlGregorianCalendarString);
}

private boolean isTGETDataOutOfDate(XMLGregorianCalendar ourLastUpdate, XMLGregorianCalendar trdmLastUpdate) {
return ourLastUpdate.compare(trdmLastUpdate) < 0;
}
Expand All @@ -135,11 +146,15 @@ private void updateTGETData(XMLGregorianCalendar ourLastUpdate, String trdmTable
throw new IllegalArgumentException("Invalid table name");
}
logger.info("table {} is allowed, proceeding", trdmTable);

XMLGregorianCalendar oneWeekLater = addOneWeek(ourLastUpdate);

// Request all TGET data from TRDM since our last update
GetTableRequest getTableRequestBody = new GetTableRequest();
getTableRequestBody.setPhysicalName(trdmTable);
getTableRequestBody.setContentUpdatedSinceDateTime(ourLastUpdate.toString());
getTableRequestBody.setReturnContent(true);
getTableRequestBody.setContentUpdatedOnOrBeforeDateTime(oneWeekLater.toString());
logger.info("calling TRDM getTable with provided body {}", getTableRequestBody);
GetTableResponse getTableResponse = getTableService.getTableRequest(getTableRequestBody);
logger.info("received response back from TRDM getTable, beginning to parse..");
Expand Down

0 comments on commit e92d0d1

Please sign in to comment.