diff --git a/avni-server-api/src/main/java/org/avni/server/domain/CHSEntity.java b/avni-server-api/src/main/java/org/avni/server/domain/CHSEntity.java index d43111bcf..86ef39922 100644 --- a/avni-server-api/src/main/java/org/avni/server/domain/CHSEntity.java +++ b/avni-server-api/src/main/java/org/avni/server/domain/CHSEntity.java @@ -52,7 +52,7 @@ public void setCreatedBy(User createdBy) { } public DateTime getCreatedDateTime() { - return new DateTime(createdDateTime); + return DateTimeUtil.toJodaDateTime(createdDateTime); } public void setCreatedDateTime(DateTime createdDateTime) { @@ -73,7 +73,7 @@ public DateTime getLastModifiedDateTime() { } private DateTime toJodaDateTime() { - return new DateTime(lastModifiedDateTime); + return DateTimeUtil.toJodaDateTime(lastModifiedDateTime); } public void setLastModifiedDateTime(DateTime lastModifiedDateTime) { diff --git a/avni-server-api/src/main/java/org/avni/server/domain/EntityApprovalStatus.java b/avni-server-api/src/main/java/org/avni/server/domain/EntityApprovalStatus.java index 5d75fb768..68ab2b622 100644 --- a/avni-server-api/src/main/java/org/avni/server/domain/EntityApprovalStatus.java +++ b/avni-server-api/src/main/java/org/avni/server/domain/EntityApprovalStatus.java @@ -1,12 +1,15 @@ package org.avni.server.domain; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import org.avni.server.util.DateTimeUtil; import org.hibernate.annotations.BatchSize; import org.joda.time.DateTime; import jakarta.persistence.*; import jakarta.validation.constraints.NotNull; +import java.time.Instant; + @Entity @BatchSize(size = 100) @JsonIgnoreProperties({"approvalStatus"}) @@ -39,7 +42,7 @@ public class EntityApprovalStatus extends SyncAttributeEntity { @Column @NotNull - private DateTime statusDateTime; + private Instant statusDateTime; @Column(name = "address_id") private Long addressId; @@ -101,11 +104,11 @@ public void setAutoApproved(Boolean autoApproved) { } public DateTime getStatusDateTime() { - return statusDateTime; + return DateTimeUtil.toJodaDateTime(statusDateTime); } public void setStatusDateTime(DateTime statusDateTime) { - this.statusDateTime = statusDateTime; + this.statusDateTime = DateTimeUtil.toInstant(statusDateTime); } public String getEntityTypeUuid() { diff --git a/avni-server-api/src/main/java/org/avni/server/domain/ProgramEnrolment.java b/avni-server-api/src/main/java/org/avni/server/domain/ProgramEnrolment.java index bff86951a..c005d03d9 100644 --- a/avni-server-api/src/main/java/org/avni/server/domain/ProgramEnrolment.java +++ b/avni-server-api/src/main/java/org/avni/server/domain/ProgramEnrolment.java @@ -50,7 +50,7 @@ public class ProgramEnrolment extends SyncAttributeEntity implements Messageable private ObservationCollection observations; @Column(name = ColumnNames.ProgramExitDateTime) - private DateTime programExitDateTime; + private Instant programExitDateTime; @Type(value = PointType.class) @Column @@ -143,11 +143,11 @@ public void setObservations(ObservationCollection observations) { } public DateTime getProgramExitDateTime() { - return programExitDateTime; + return DateTimeUtil.toJodaDateTime(programExitDateTime); } public void setProgramExitDateTime(DateTime programExitDateTime) { - this.programExitDateTime = programExitDateTime; + this.programExitDateTime = DateTimeUtil.toInstant(programExitDateTime); } public ObservationCollection getProgramExitObservations() { diff --git a/avni-server-api/src/main/java/org/avni/server/domain/RuleFailureTelemetry.java b/avni-server-api/src/main/java/org/avni/server/domain/RuleFailureTelemetry.java index 2c346f585..1424aa1f5 100644 --- a/avni-server-api/src/main/java/org/avni/server/domain/RuleFailureTelemetry.java +++ b/avni-server-api/src/main/java/org/avni/server/domain/RuleFailureTelemetry.java @@ -86,7 +86,7 @@ public class RuleFailureTelemetry { private User createdBy; @CreatedDate - private Date createdDateTime; + private Instant createdDateTime; @JsonIgnore @JoinColumn(name = "last_modified_by_id") @@ -97,7 +97,7 @@ public class RuleFailureTelemetry { private User lastModifiedBy; @LastModifiedDate - private Date lastModifiedDateTime; + private Instant lastModifiedDateTime; @Column(name = "version") private int version; @@ -107,7 +107,7 @@ public User getCreatedBy() { } public DateTime getCreatedDateTime() { - return new DateTime(createdDateTime); + return DateTimeUtil.toJodaDateTime(createdDateTime); } public User getLastModifiedBy() { diff --git a/avni-server-api/src/main/java/org/avni/server/domain/VideoTelemetric.java b/avni-server-api/src/main/java/org/avni/server/domain/VideoTelemetric.java index b702eddc2..d6712923d 100644 --- a/avni-server-api/src/main/java/org/avni/server/domain/VideoTelemetric.java +++ b/avni-server-api/src/main/java/org/avni/server/domain/VideoTelemetric.java @@ -28,7 +28,7 @@ public class VideoTelemetric extends CHSBaseEntity { private Instant playerCloseTime; @Column(name = "player_open_time") - private DateTime playerOpenTime; + private Instant playerOpenTime; @ManyToOne(fetch = FetchType.LAZY) @NotNull @@ -44,7 +44,7 @@ public class VideoTelemetric extends CHSBaseEntity { private Long organisationId; @Column(name="created_datetime") - private DateTime createdDatetime; + private Instant createdDatetime; public Double getVideoStartTime() { return videoStartTime; @@ -71,11 +71,11 @@ public void setPlayerCloseTime(DateTime playerCloseTime) { } public DateTime getPlayerOpenTime() { - return playerOpenTime; + return DateTimeUtil.toJodaDateTime(playerOpenTime); } public void setPlayerOpenTime(DateTime playerOpenTime) { - this.playerOpenTime = playerOpenTime; + this.playerOpenTime = DateTimeUtil.toInstant(playerOpenTime); } public Video getVideo() { @@ -103,10 +103,10 @@ public void setOrganisationId(Long organisationId) { } public DateTime getCreatedDatetime() { - return createdDatetime; + return DateTimeUtil.toJodaDateTime(createdDatetime); } public void setCreatedDatetime(DateTime createdDatetime) { - this.createdDatetime = createdDatetime; + this.createdDatetime = DateTimeUtil.toInstant(createdDatetime); } } diff --git a/avni-server-api/src/main/java/org/avni/server/util/ObjectMapperSingleton.java b/avni-server-api/src/main/java/org/avni/server/util/ObjectMapperSingleton.java index ef06b6445..9d383fa0d 100644 --- a/avni-server-api/src/main/java/org/avni/server/util/ObjectMapperSingleton.java +++ b/avni-server-api/src/main/java/org/avni/server/util/ObjectMapperSingleton.java @@ -1,10 +1,13 @@ package org.avni.server.util; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.joda.JodaModule; public final class ObjectMapperSingleton { - private static final ObjectMapper objectMapper = new ObjectMapper().registerModule(new JodaModule()); + private static final ObjectMapper objectMapper = new ObjectMapper() + .registerModule(new JodaModule()) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true); private ObjectMapperSingleton() { }