From e4e2c8444f5cf7aec7ee478f54aa479bfb157634 Mon Sep 17 00:00:00 2001 From: Jakob Frank Date: Tue, 16 Jul 2024 16:02:49 +0200 Subject: [PATCH] chore(deps): bump openapi-generator-maven-plugin to v7.7.0 --- pom.xml | 16 +++++++++++++++- .../controller/ExternalDataApiV1Controller.java | 2 +- .../transformer/BaseTransformers.java | 12 ------------ .../controller/transformer/DataTransformer.java | 6 ++++-- .../transformer/ParticipantTransformer.java | 2 +- .../transformer/StudyTransformer.java | 6 ++++-- .../data/repository/NotificationRepository.java | 17 +++++++++-------- 7 files changed, 34 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index 933a969..4b1ab82 100644 --- a/pom.xml +++ b/pom.xml @@ -315,7 +315,7 @@ org.openapitools openapi-generator-maven-plugin - 6.6.0 + 7.7.0 data-api @@ -360,6 +360,19 @@ false false + + string+date-time=Instant + string+time=LocalTime + + + Instant=java.time.Instant + LocalTime=java.time.LocalTime + + + Instant=java.time.Instant + LocalTime=java.time.LocalTime + + true src @@ -368,6 +381,7 @@ true false true + api_interface diff --git a/src/main/java/io/redlink/more/data/controller/ExternalDataApiV1Controller.java b/src/main/java/io/redlink/more/data/controller/ExternalDataApiV1Controller.java index d4c5b34..1d0ae97 100644 --- a/src/main/java/io/redlink/more/data/controller/ExternalDataApiV1Controller.java +++ b/src/main/java/io/redlink/more/data/controller/ExternalDataApiV1Controller.java @@ -68,7 +68,7 @@ public ResponseEntity storeExternalBulk(String moreApiToken, EndpointDataB Interval interval = externalService.getIntervalForObservation(apiRoutingInfo.studyId(), apiRoutingInfo.observationId(), participantId); endpointDataBulkDTO.getDataPoints().stream() - .map(datapoint -> datapoint.getTimestamp().toInstant()) + .map(ExternalDataDTO::getTimestamp) .map(timestamp -> timestamp.isBefore(interval.getStart()) || timestamp.isAfter(interval.getEnd())) .filter(v -> v) .findFirst() diff --git a/src/main/java/io/redlink/more/data/controller/transformer/BaseTransformers.java b/src/main/java/io/redlink/more/data/controller/transformer/BaseTransformers.java index 96499ee..8354d5f 100644 --- a/src/main/java/io/redlink/more/data/controller/transformer/BaseTransformers.java +++ b/src/main/java/io/redlink/more/data/controller/transformer/BaseTransformers.java @@ -4,8 +4,6 @@ package io.redlink.more.data.controller.transformer; import java.time.Instant; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; public final class BaseTransformers { @@ -16,14 +14,4 @@ public static Long toVersionTag(Instant modified) { return modified.toEpochMilli(); } - public static Instant toInstant(OffsetDateTime dateTime) { - if (dateTime == null) - return null; - return dateTime.toInstant(); - } - - public static OffsetDateTime toOffsetDateTime(Instant instant) { - if (instant == null) return null; - return instant.atOffset(ZoneOffset.UTC); - } } diff --git a/src/main/java/io/redlink/more/data/controller/transformer/DataTransformer.java b/src/main/java/io/redlink/more/data/controller/transformer/DataTransformer.java index c6ce0ea..645b59b 100644 --- a/src/main/java/io/redlink/more/data/controller/transformer/DataTransformer.java +++ b/src/main/java/io/redlink/more/data/controller/transformer/DataTransformer.java @@ -26,13 +26,14 @@ public static List createDataPoints(DataBulkDTO bulk) { } public static DataPoint createDataPoint(ObservationDataDTO dataPoint, Instant recordingTime) { + Instant dateTime = dataPoint.getTimestamp(); return new DataPoint( dataPoint.getDataId(), dataPoint.getObservationId(), dataPoint.getObservationType(), dataPoint.getObservationType(), recordingTime, - BaseTransformers.toInstant(dataPoint.getTimestamp()), + dateTime, dataPoint.getDataValue()); } @@ -44,13 +45,14 @@ public static List createDataPoints(EndpointDataBulkDTO bulk, ApiRout } public static DataPoint createDataPoint(ExternalDataDTO dataPoint, ApiRoutingInfo routingInfo, Instant recordingTime, Integer observationId) { + Instant dateTime = dataPoint.getTimestamp(); return new DataPoint( UUID.randomUUID().toString(), observationId.toString(), routingInfo.observationType(), routingInfo.observationType(), recordingTime, - BaseTransformers.toInstant(dataPoint.getTimestamp()), + dateTime, dataPoint.getDataValue()); } } diff --git a/src/main/java/io/redlink/more/data/controller/transformer/ParticipantTransformer.java b/src/main/java/io/redlink/more/data/controller/transformer/ParticipantTransformer.java index 559063e..af2733d 100644 --- a/src/main/java/io/redlink/more/data/controller/transformer/ParticipantTransformer.java +++ b/src/main/java/io/redlink/more/data/controller/transformer/ParticipantTransformer.java @@ -18,7 +18,7 @@ public static ParticipantDTO toDTO(Participant participant) { participant.alias(), ParticipantStatusDTO.fromValue(participant.status()), toGroupDto(participant), - BaseTransformers.toOffsetDateTime(participant.start()) + participant.start() ); } diff --git a/src/main/java/io/redlink/more/data/controller/transformer/StudyTransformer.java b/src/main/java/io/redlink/more/data/controller/transformer/StudyTransformer.java index ef1ee07..f849b1f 100644 --- a/src/main/java/io/redlink/more/data/controller/transformer/StudyTransformer.java +++ b/src/main/java/io/redlink/more/data/controller/transformer/StudyTransformer.java @@ -84,9 +84,11 @@ public static ObservationDTO toDTO(Observation observation, Instant start, Insta } public static ObservationScheduleDTO toObservationScheduleDTO(Range schedule) { + Instant instant = schedule.getMaximum(); + Instant instant1 = schedule.getMinimum(); return new ObservationScheduleDTO() - .start(BaseTransformers.toOffsetDateTime(schedule.getMinimum())) - .end(BaseTransformers.toOffsetDateTime(schedule.getMaximum())) + .start(instant1) + .end(instant) ; } diff --git a/src/main/java/io/redlink/more/data/repository/NotificationRepository.java b/src/main/java/io/redlink/more/data/repository/NotificationRepository.java index 0bd2606..21de7a5 100644 --- a/src/main/java/io/redlink/more/data/repository/NotificationRepository.java +++ b/src/main/java/io/redlink/more/data/repository/NotificationRepository.java @@ -11,16 +11,17 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.redlink.more.data.api.app.v1.model.PushNotificationDTO; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Optional; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.stereotype.Component; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.util.*; - @Component public class NotificationRepository { @@ -68,10 +69,10 @@ private static RowMapper getRowMapper() { }; } - private static OffsetDateTime getTimestamp(ResultSet rs) { + private static Instant getTimestamp(ResultSet rs) { try { return Optional.ofNullable(rs.getTimestamp("timestamp")) - .map(d -> d.toInstant().atOffset(ZoneOffset.UTC)) + .map(Timestamp::toInstant) .orElse(null); } catch (SQLException e) { return null;