From fe7eac0f5a0ef0eb253f112e4eefda3b60089432 Mon Sep 17 00:00:00 2001 From: Enrico Date: Fri, 18 Oct 2024 14:10:29 +0200 Subject: [PATCH] fix: Always use system time for createdAt in events [DHIS2-18252] --- .../org/hisp/dhis/tracker/bundle/persister/EventPersister.java | 2 +- .../dhis/tracker/converter/EventTrackerConverterService.java | 1 - .../src/test/resources/tracker/importer/events/events.json | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/bundle/persister/EventPersister.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/bundle/persister/EventPersister.java index 1304ee52ec72..9fa22eb16cfb 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/bundle/persister/EventPersister.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/bundle/persister/EventPersister.java @@ -300,7 +300,7 @@ private ValuesHolder getAuditAndDateParameters(EventDataValue eventDataValue, Da if (isNewDataValue(eventDataValue, dv)) { eventDataValue = new EventDataValue(); - eventDataValue.setCreated(getFromOrNewDate(dv, DataValue::getCreatedAt)); + eventDataValue.setCreated(new Date()); eventDataValue.setLastUpdated(getFromOrNewDate(dv, DataValue::getUpdatedAt)); persistedValue = dv.getValue(); auditType = AuditType.CREATE; diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/converter/EventTrackerConverterService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/converter/EventTrackerConverterService.java index d29323ec3a0b..152b417b80a1 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/converter/EventTrackerConverterService.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/converter/EventTrackerConverterService.java @@ -270,7 +270,6 @@ private ProgramStageInstance from( for (DataValue dataValue : event.getDataValues()) { EventDataValue eventDataValue = new EventDataValue(); eventDataValue.setValue(dataValue.getValue()); - eventDataValue.setCreated(DateUtils.fromInstant(dataValue.getCreatedAt())); eventDataValue.setLastUpdated(new Date()); eventDataValue.setProvidedElsewhere(dataValue.isProvidedElsewhere()); // ensure dataElement is referred to by UID as multiple diff --git a/dhis-2/dhis-test-e2e/src/test/resources/tracker/importer/events/events.json b/dhis-2/dhis-test-e2e/src/test/resources/tracker/importer/events/events.json index a682f85a6830..71c53fb005a5 100644 --- a/dhis-2/dhis-test-e2e/src/test/resources/tracker/importer/events/events.json +++ b/dhis-2/dhis-test-e2e/src/test/resources/tracker/importer/events/events.json @@ -118,7 +118,6 @@ }, { "updatedAt": "2019-03-04T15:12:59.209", - "createdAt": "2019-03-04T15:01:29.793", "dataElement": "z3Z4TD3oBCP", "value": "true", "providedElsewhere": false