diff --git a/avni-server-api/src/main/java/org/avni/server/dao/EntityApprovalStatusRepository.java b/avni-server-api/src/main/java/org/avni/server/dao/EntityApprovalStatusRepository.java index d56d51e0c..7395c946b 100644 --- a/avni-server-api/src/main/java/org/avni/server/dao/EntityApprovalStatusRepository.java +++ b/avni-server-api/src/main/java/org/avni/server/dao/EntityApprovalStatusRepository.java @@ -3,6 +3,7 @@ import org.avni.server.dao.sync.SyncEntityName; import org.avni.server.domain.*; import org.avni.server.framework.security.UserContextHolder; +import org.avni.server.web.request.EntitySyncStatusContract; import org.joda.time.DateTime; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -36,7 +37,7 @@ Page findByLastModifiedDateTimeIsBetweenOrderByLastModifie default Page findEntityApprovalStatuses(EntityApprovalStatusSearchParams searchParams, Pageable pageable) { Specification specification = lastModifiedBetween( - CHSEntity.toDate(searchParams.getLastModifiedDateTime() != null ? searchParams.getLastModifiedDateTime() : new DateTime("1900-01-01T00:00:00.000Z")), + CHSEntity.toDate(searchParams.getLastModifiedDateTime() != null ? searchParams.getLastModifiedDateTime() : EntitySyncStatusContract.REALLY_OLD_DATE), CHSEntity.toDate(searchParams.getNow() != null ? searchParams.getNow() : new DateTime())); if (searchParams.getEntityType() != null) { diff --git a/avni-server-api/src/main/java/org/avni/server/web/api/LocationApiController.java b/avni-server-api/src/main/java/org/avni/server/web/api/LocationApiController.java index ce0d8894b..333d6a231 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/api/LocationApiController.java +++ b/avni-server-api/src/main/java/org/avni/server/web/api/LocationApiController.java @@ -4,6 +4,8 @@ import org.avni.server.dao.LocationRepository; import org.avni.server.domain.AddressLevel; import org.avni.server.service.ConceptService; +import org.avni.server.util.DateTimeUtil; +import org.avni.server.web.request.EntitySyncStatusContract; import org.avni.server.web.response.LocationApiResponse; import org.avni.server.web.response.ResponsePage; import org.joda.time.DateTime; @@ -32,9 +34,12 @@ public LocationApiController(LocationRepository locationRepository, ConceptRepos @RequestMapping(value = "/api/locations", method = RequestMethod.GET) @PreAuthorize(value = "hasAnyAuthority('user')") - public ResponsePage getLocations(@RequestParam(value = "lastModifiedDateTime") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime lastModifiedDateTime, + public ResponsePage getLocations(@RequestParam(value = "lastModifiedDateTime", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime lastModifiedDateTime, @RequestParam(value = "now", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) DateTime now, Pageable pageable) { + if (lastModifiedDateTime == null) { + lastModifiedDateTime = EntitySyncStatusContract.REALLY_OLD_DATE; + } Page addresses = locationRepository.findByLastModifiedDateTimeIsBetweenOrderByLastModifiedDateTimeAscIdAsc(lastModifiedDateTime, now, pageable); ArrayList locationApiResponses = new ArrayList<>(); addresses.forEach(addressLevel -> { diff --git a/avni-server-api/src/main/java/org/avni/server/web/request/EntitySyncStatusContract.java b/avni-server-api/src/main/java/org/avni/server/web/request/EntitySyncStatusContract.java index 14b0aa1d2..5ccdb333b 100644 --- a/avni-server-api/src/main/java/org/avni/server/web/request/EntitySyncStatusContract.java +++ b/avni-server-api/src/main/java/org/avni/server/web/request/EntitySyncStatusContract.java @@ -9,7 +9,7 @@ import java.util.UUID; public class EntitySyncStatusContract { - private static final DateTime REALLY_OLD_DATE = new DateTime("1900-01-01T00:00:00.000Z"); + public static final DateTime REALLY_OLD_DATE = new DateTime("1900-01-01T00:00:00.000Z"); private String uuid; private String entityName; private DateTime loadedSince;