|
27 | 27 | import com.ibm.fhir.persistence.ResourcePayload;
|
28 | 28 | import com.ibm.fhir.persistence.exception.FHIRPersistenceException;
|
29 | 29 | import com.ibm.fhir.persistence.jdbc.exception.FHIRPersistenceDataAccessException;
|
| 30 | +import com.ibm.fhir.persistence.jdbc.util.CalendarHelper; |
30 | 31 |
|
31 | 32 | /**
|
32 | 33 | * DAO to fetch resource ids using a time range and optional current resource id as a filter.
|
|
36 | 37 | public class FetchResourcePayloadsDAO {
|
37 | 38 | private static final Logger logger = Logger.getLogger(FetchResourcePayloadsDAO.class.getName());
|
38 | 39 |
|
39 |
| - private static final Calendar UTC_CALENDAR = Calendar.getInstance(TimeZone.getTimeZone("UTC")); |
40 |
| - |
41 | 40 | // The FHIR data schema name
|
42 | 41 | private final String schemaName;
|
43 | 42 |
|
@@ -118,19 +117,19 @@ public ResourcePayload run(Connection c) throws FHIRPersistenceException {
|
118 | 117 |
|
119 | 118 | // Set the variables marking the start point of the scan
|
120 | 119 | if (this.fromLastUpdated != null) {
|
121 |
| - ps.setTimestamp(a++, Timestamp.from(this.fromLastUpdated), UTC_CALENDAR); |
| 120 | + ps.setTimestamp(a++, Timestamp.from(this.fromLastUpdated), CalendarHelper.getCalendarForUTC()); |
122 | 121 | }
|
123 | 122 |
|
124 | 123 | // And where we want the scan to stop (e.g. exporting a limited time range)
|
125 | 124 | if (this.toLastUpdated != null) {
|
126 |
| - ps.setTimestamp(a++, Timestamp.from(this.toLastUpdated), UTC_CALENDAR); |
| 125 | + ps.setTimestamp(a++, Timestamp.from(this.toLastUpdated), CalendarHelper.getCalendarForUTC()); |
127 | 126 | }
|
128 | 127 |
|
129 | 128 | ResultSet rs = ps.executeQuery();
|
130 | 129 | while (rs.next()) {
|
131 | 130 | // make sure we get the timestamp as a UTC value
|
132 | 131 | String logicalId = rs.getString(1);
|
133 |
| - Instant lastUpdated = rs.getTimestamp(2, UTC_CALENDAR).toInstant(); |
| 132 | + Instant lastUpdated = rs.getTimestamp(2, CalendarHelper.getCalendarForUTC()).toInstant(); |
134 | 133 | long resourceId = rs.getLong(3);
|
135 | 134 | InputStream is = new GZIPInputStream(rs.getBinaryStream(4));
|
136 | 135 | result = new ResourcePayload(logicalId, lastUpdated, resourceId, is);
|
@@ -192,12 +191,12 @@ public int count(Connection c) throws FHIRPersistenceException {
|
192 | 191 |
|
193 | 192 | // Set the variables marking the start point of the scan
|
194 | 193 | if (this.fromLastUpdated != null) {
|
195 |
| - ps.setTimestamp(a++, Timestamp.from(fromLastUpdated), UTC_CALENDAR); |
| 194 | + ps.setTimestamp(a++, Timestamp.from(fromLastUpdated), CalendarHelper.getCalendarForUTC()); |
196 | 195 | }
|
197 | 196 |
|
198 | 197 | // And where we want the scan to stop (e.g. exporting a limited time range)
|
199 | 198 | if (this.toLastUpdated != null) {
|
200 |
| - ps.setTimestamp(a++, Timestamp.from(this.toLastUpdated), UTC_CALENDAR); |
| 199 | + ps.setTimestamp(a++, Timestamp.from(this.toLastUpdated), CalendarHelper.getCalendarForUTC()); |
201 | 200 | }
|
202 | 201 |
|
203 | 202 | ResultSet rs = ps.executeQuery();
|
|
0 commit comments