From ebc21c35aa92c98c79134b5fb43530db760ab5e6 Mon Sep 17 00:00:00 2001 From: Marc Date: Wed, 30 Oct 2024 16:29:52 +0100 Subject: [PATCH] feat: Migrate tracker change logs into new table [DHIS2-18014] --- .../dhis/tracker/export/event/JdbcEventChangeLogStore.java | 2 +- .../imports/bundle/persister/AbstractTrackerPersister.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/JdbcEventChangeLogStore.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/JdbcEventChangeLogStore.java index dd7aef353434..be35960d4a57 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/JdbcEventChangeLogStore.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/JdbcEventChangeLogStore.java @@ -168,7 +168,7 @@ public void deleteEventChangeLog(Event event) { public void deleteEventChangeLog(DataElement dataElement) { String sql = """ - DELETE FROM eventchangelog WHERE dataelementio = :dataelementio + DELETE FROM eventchangelog WHERE dataelementid = :dataelementio """; SqlParameterSource params = new MapSqlParameterSource().addValue("dataelementio", dataElement.getId()); diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/AbstractTrackerPersister.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/AbstractTrackerPersister.java index 7c8640e06c73..61d2bf00d30d 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/AbstractTrackerPersister.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/AbstractTrackerPersister.java @@ -128,8 +128,6 @@ public TrackerTypeReport persist(EntityManager entityManager, TrackerBundle bund if (isNew(bundle, trackerDto)) { entityManager.persist(convertedDto); entityManager.flush(); - // TODO Add this in PR description: Needs to update data values after persisting the - // entity, if not the FK constraint to change logs is not satisfied updateDataValues( entityManager, bundle.getPreheat(), trackerDto, convertedDto, bundle.getUser()); typeReport.getStats().incCreated(); @@ -141,8 +139,6 @@ public TrackerTypeReport persist(EntityManager entityManager, TrackerBundle bund typeReport.getStats().incIgnored(); // Relationships are not updated. A warning was already added to the report } else { - // TODO Add this in PR description: Needs to update data values first, if not deleted - // values will not be updated in the event object updateDataValues( entityManager, bundle.getPreheat(), trackerDto, convertedDto, bundle.getUser()); updateAttributes(