Skip to content

Commit

Permalink
#813 - more date to instant change
Browse files Browse the repository at this point in the history
  • Loading branch information
petmongrels committed Nov 6, 2024
1 parent 794426c commit c6985a9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -73,7 +73,7 @@ public DateTime getLastModifiedDateTime() {
}

private DateTime toJodaDateTime() {
return new DateTime(lastModifiedDateTime);
return DateTimeUtil.toJodaDateTime(lastModifiedDateTime);
}

public void setLastModifiedDateTime(DateTime lastModifiedDateTime) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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"})
Expand Down Expand Up @@ -39,7 +42,7 @@ public class EntityApprovalStatus extends SyncAttributeEntity {

@Column
@NotNull
private DateTime statusDateTime;
private Instant statusDateTime;

@Column(name = "address_id")
private Long addressId;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class RuleFailureTelemetry {
private User createdBy;

@CreatedDate
private Date createdDateTime;
private Instant createdDateTime;

@JsonIgnore
@JoinColumn(name = "last_modified_by_id")
Expand All @@ -97,7 +97,7 @@ public class RuleFailureTelemetry {
private User lastModifiedBy;

@LastModifiedDate
private Date lastModifiedDateTime;
private Instant lastModifiedDateTime;

@Column(name = "version")
private int version;
Expand All @@ -107,7 +107,7 @@ public User getCreatedBy() {
}

public DateTime getCreatedDateTime() {
return new DateTime(createdDateTime);
return DateTimeUtil.toJodaDateTime(createdDateTime);
}

public User getLastModifiedBy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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() {
}
Expand Down

0 comments on commit c6985a9

Please sign in to comment.