diff --git a/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/eventchangelog.hiberante/EventChangeLog.hbm.xml b/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/eventchangelog.hiberante/EventChangeLog.hbm.xml
index 7c5376e0273a..830eaab43d77 100644
--- a/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/eventchangelog.hiberante/EventChangeLog.hbm.xml
+++ b/dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/eventchangelog.hiberante/EventChangeLog.hbm.xml
@@ -18,7 +18,7 @@
-
+
diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/DefaultEventChangeLogService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/DefaultEventChangeLogService.java
index e7bb9d8fa0d7..12d76daba7bc 100644
--- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/DefaultEventChangeLogService.java
+++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/DefaultEventChangeLogService.java
@@ -99,7 +99,7 @@ public void addDataValueChangeLog(
@Override
@Transactional
- public void addPropertyChangeLog(
+ public void addFieldChangeLog(
@Nonnull Event currentEvent, @Nonnull Event event, @Nonnull String username) {
logIfChanged(
"occurredAt", Event::getOccurredDate, this::formatDate, currentEvent, event, username);
@@ -133,7 +133,7 @@ public Set>> getFilterableFields() {
}
private void logIfChanged(
- String propertyName,
+ String field,
Function valueExtractor,
Function formatter,
Event currentEvent,
@@ -148,34 +148,27 @@ private void logIfChanged(
EventChangeLog eventChangeLog =
new EventChangeLog(
- event,
- null,
- propertyName,
- currentValue,
- newValue,
- changeLogType,
- new Date(),
- userName);
+ event, null, field, currentValue, newValue, changeLogType, new Date(), userName);
hibernateEventChangeLogStore.addEventChangeLog(eventChangeLog);
}
}
private ChangeLogType getChangeLogType(String oldValue, String newValue) {
- if (isNewProperty(oldValue, newValue)) {
+ if (isFieldCreated(oldValue, newValue)) {
return ChangeLogType.CREATE;
- } else if (isUpdateProperty(oldValue, newValue)) {
+ } else if (isFieldUpdated(oldValue, newValue)) {
return ChangeLogType.UPDATE;
} else {
return ChangeLogType.DELETE;
}
}
- private boolean isNewProperty(String originalValue, String payloadValue) {
+ private boolean isFieldCreated(String originalValue, String payloadValue) {
return originalValue == null && payloadValue != null;
}
- private boolean isUpdateProperty(String originalValue, String payloadValue) {
+ private boolean isFieldUpdated(String originalValue, String payloadValue) {
return originalValue != null && payloadValue != null;
}
diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventChangeLog.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventChangeLog.java
index 676d43e0cee6..31418e879875 100644
--- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventChangeLog.java
+++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventChangeLog.java
@@ -46,7 +46,7 @@ public class EventChangeLog {
private DataElement dataElement;
- private String eventProperty;
+ private String eventField;
private String previousValue;
@@ -63,40 +63,40 @@ public class EventChangeLog {
public EventChangeLog(
Event event,
DataElement dataElement,
- String eventProperty,
+ String eventField,
String previousValue,
String currentValue,
ChangeLogType changeLogType,
Date created,
String createdByUsername) {
- this(event, dataElement, eventProperty, previousValue, currentValue, changeLogType, created);
+ this(event, dataElement, eventField, previousValue, currentValue, changeLogType, created);
this.createdByUsername = createdByUsername;
}
public EventChangeLog(
Event event,
DataElement dataElement,
- String eventProperty,
+ String eventField,
String previousValue,
String currentValue,
ChangeLogType changeLogType,
Date created,
UserInfoSnapshot createdBy) {
- this(event, dataElement, eventProperty, previousValue, currentValue, changeLogType, created);
+ this(event, dataElement, eventField, previousValue, currentValue, changeLogType, created);
this.createdBy = createdBy;
}
private EventChangeLog(
Event event,
DataElement dataElement,
- String eventProperty,
+ String eventField,
String previousValue,
String currentValue,
ChangeLogType changeLogType,
Date created) {
this.event = event;
this.dataElement = dataElement;
- this.eventProperty = eventProperty;
+ this.eventField = eventField;
this.previousValue = previousValue;
this.currentValue = currentValue;
this.changeLogType = changeLogType;
diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventChangeLogService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventChangeLogService.java
index e38ffee19a23..032255fb69e4 100644
--- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventChangeLogService.java
+++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/EventChangeLogService.java
@@ -58,7 +58,7 @@ void addDataValueChangeLog(
ChangeLogType changeLogType,
String userName);
- void addPropertyChangeLog(
+ void addFieldChangeLog(
@Nonnull Event currentEvent, @Nonnull Event event, @Nonnull String userName);
void deleteTrackedEntityDataValueChangeLog(Event event);
diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/HibernateEventChangeLogStore.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/HibernateEventChangeLogStore.java
index b06bf4523e9d..7f762d67f06c 100644
--- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/HibernateEventChangeLogStore.java
+++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/event/HibernateEventChangeLogStore.java
@@ -56,7 +56,7 @@ public class HibernateEventChangeLogStore {
private static final String COLUMN_CHANGELOG_CREATED = "ecl.created";
private static final String COLUMN_CHANGELOG_USER = "ecl.createdByUsername";
private static final String COLUMN_CHANGELOG_DATA_ELEMENT = "d.uid";
- private static final String COLUMN_CHANGELOG_PROPERTY = "ecl.eventProperty";
+ private static final String COLUMN_CHANGELOG_FIELD = "ecl.eventField";
private static final String DEFAULT_ORDER =
COLUMN_CHANGELOG_CREATED + " " + SortDirection.DESC.getValue();
@@ -73,13 +73,13 @@ public class HibernateEventChangeLogStore {
entry("createdAt", COLUMN_CHANGELOG_CREATED),
entry("username", COLUMN_CHANGELOG_USER),
entry("dataElement", COLUMN_CHANGELOG_DATA_ELEMENT),
- entry("property", COLUMN_CHANGELOG_PROPERTY));
+ entry("field", COLUMN_CHANGELOG_FIELD));
private static final Map>, String> FILTERABLE_FIELDS =
Map.ofEntries(
entry(Pair.of("username", String.class), COLUMN_CHANGELOG_USER),
entry(Pair.of("dataElement", UID.class), COLUMN_CHANGELOG_DATA_ELEMENT),
- entry(Pair.of("property", String.class), COLUMN_CHANGELOG_PROPERTY));
+ entry(Pair.of("field", String.class), COLUMN_CHANGELOG_FIELD));
private final EntityManager entityManager;
@@ -102,7 +102,7 @@ public Page getEventChangeLogs(
"""
select ecl.event,
ecl.dataElement,
- ecl.eventProperty,
+ ecl.eventField,
ecl.previousValue,
ecl.currentValue,
ecl.changeLogType,
@@ -147,7 +147,7 @@ public Page getEventChangeLogs(
row -> {
Event e = (Event) row[0];
DataElement dataElement = (DataElement) row[1];
- String eventProperty = (String) row[2];
+ String eventField = (String) row[2];
String previousValue = (String) row[3];
String currentValue = (String) row[4];
ChangeLogType changeLogType = (ChangeLogType) row[5];
@@ -160,7 +160,7 @@ public Page getEventChangeLogs(
return new EventChangeLog(
e,
dataElement,
- eventProperty,
+ eventField,
previousValue,
currentValue,
changeLogType,
diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/DefaultTrackedEntityChangeLogService.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/DefaultTrackedEntityChangeLogService.java
index b8e62d53d466..95e2dbaf6edb 100644
--- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/DefaultTrackedEntityChangeLogService.java
+++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/trackedentity/DefaultTrackedEntityChangeLogService.java
@@ -215,6 +215,6 @@ private Set validateTrackedEntityAttributes(TrackedEntity trackedEntity)
throw new NotFoundException(TrackedEntity.class, trackedEntity.getUid());
}
- return attributes.stream().map(a -> UID.of(a.getUid())).collect(Collectors.toSet());
+ return attributes.stream().map(UID::of).collect(Collectors.toSet());
}
}
diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/EventPersister.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/EventPersister.java
index db746f8c4953..12d9cdcc009e 100644
--- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/EventPersister.java
+++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/imports/bundle/persister/EventPersister.java
@@ -170,7 +170,7 @@ protected void updateDataValues(
Event currentEntity,
UserDetails user) {
handleDataValues(entityManager, preheat, event.getDataValues(), payloadEntity, user);
- eventChangeLogService.addPropertyChangeLog(currentEntity, payloadEntity, user.getUsername());
+ eventChangeLogService.addFieldChangeLog(currentEntity, payloadEntity, user.getUsername());
}
private void handleDataValues(
diff --git a/dhis-2/dhis-support/dhis-support-db-migration/src/main/resources/org/hisp/dhis/db/migration/2.42/V2_42_33__Rename_event_change_log_property_to_field.sql b/dhis-2/dhis-support/dhis-support-db-migration/src/main/resources/org/hisp/dhis/db/migration/2.42/V2_42_33__Rename_event_change_log_property_to_field.sql
new file mode 100644
index 000000000000..524d6c15a009
--- /dev/null
+++ b/dhis-2/dhis-support/dhis-support-db-migration/src/main/resources/org/hisp/dhis/db/migration/2.42/V2_42_33__Rename_event_change_log_property_to_field.sql
@@ -0,0 +1,3 @@
+-- DHIS2-18549
+
+alter table eventchangelog rename eventproperty to eventfield;
\ No newline at end of file
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/event/EventChangeLogServiceTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/event/EventChangeLogServiceTest.java
index b94c64b7a610..4d38c31842b3 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/event/EventChangeLogServiceTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/event/EventChangeLogServiceTest.java
@@ -292,26 +292,25 @@ void shouldReturnOnlyUserNameWhenUserDoesNotExistInDatabase()
}
@Test
- void shouldReturnEventPropertiesChangeLogWhenNewDatePropertyValueAdded()
+ void shouldReturnEventFieldChangeLogWhenNewDateFieldValueAdded()
throws ForbiddenException, NotFoundException {
String event = "QRYjLTiJTrA";
Page changeLogs =
eventChangeLogService.getEventChangeLog(
UID.of(event), defaultOperationParams, defaultPageParams);
- List scheduledAtLogs = getChangeLogsByProperty(changeLogs, "scheduledAt");
- List occurredAtLogs = getChangeLogsByProperty(changeLogs, "occurredAt");
+ List scheduledAtLogs = getChangeLogsByField(changeLogs, "scheduledAt");
+ List occurredAtLogs = getChangeLogsByField(changeLogs, "occurredAt");
assertNumberOfChanges(1, scheduledAtLogs);
assertNumberOfChanges(1, occurredAtLogs);
assertAll(
- () ->
- assertPropertyCreate("scheduledAt", "2022-04-22 06:00:38.343", scheduledAtLogs.get(0)),
- () -> assertPropertyCreate("occurredAt", "2022-04-20 06:00:38.343", occurredAtLogs.get(0)));
+ () -> assertFieldCreate("scheduledAt", "2022-04-22 06:00:38.343", scheduledAtLogs.get(0)),
+ () -> assertFieldCreate("occurredAt", "2022-04-20 06:00:38.343", occurredAtLogs.get(0)));
}
@Test
- void shouldReturnEventPropertiesChangeLogWhenExistingDatePropertyUpdated()
+ void shouldReturnEventFieldChangeLogWhenExistingDateFieldUpdated()
throws IOException, ForbiddenException, NotFoundException {
UID event = UID.of("QRYjLTiJTrA");
LocalDateTime currentTime = LocalDateTime.now();
@@ -320,31 +319,30 @@ void shouldReturnEventPropertiesChangeLogWhenExistingDatePropertyUpdated()
Page changeLogs =
eventChangeLogService.getEventChangeLog(event, defaultOperationParams, defaultPageParams);
- List scheduledAtLogs = getChangeLogsByProperty(changeLogs, "scheduledAt");
- List occurredAtLogs = getChangeLogsByProperty(changeLogs, "occurredAt");
+ List scheduledAtLogs = getChangeLogsByField(changeLogs, "scheduledAt");
+ List occurredAtLogs = getChangeLogsByField(changeLogs, "occurredAt");
assertNumberOfChanges(2, scheduledAtLogs);
assertNumberOfChanges(2, occurredAtLogs);
assertAll(
() ->
- assertPropertyUpdate(
+ assertFieldUpdate(
"scheduledAt",
"2022-04-22 06:00:38.343",
currentTime.toString(formatter),
scheduledAtLogs.get(0)),
+ () -> assertFieldCreate("scheduledAt", "2022-04-22 06:00:38.343", scheduledAtLogs.get(1)),
() ->
- assertPropertyCreate("scheduledAt", "2022-04-22 06:00:38.343", scheduledAtLogs.get(1)),
- () ->
- assertPropertyUpdate(
+ assertFieldUpdate(
"occurredAt",
"2022-04-20 06:00:38.343",
currentTime.toString(formatter),
occurredAtLogs.get(0)),
- () -> assertPropertyCreate("occurredAt", "2022-04-20 06:00:38.343", occurredAtLogs.get(1)));
+ () -> assertFieldCreate("occurredAt", "2022-04-20 06:00:38.343", occurredAtLogs.get(1)));
}
@Test
- void shouldReturnEventPropertiesChangeLogWhenExistingDatePropertyDeleted()
+ void shouldReturnEventFieldChangeLogWhenExistingDateFieldDeleted()
throws ForbiddenException, NotFoundException {
UID event = UID.of("QRYjLTiJTrA");
@@ -352,56 +350,53 @@ void shouldReturnEventPropertiesChangeLogWhenExistingDatePropertyDeleted()
Page changeLogs =
eventChangeLogService.getEventChangeLog(event, defaultOperationParams, defaultPageParams);
- List scheduledAtLogs = getChangeLogsByProperty(changeLogs, "scheduledAt");
- List occurredAtLogs = getChangeLogsByProperty(changeLogs, "occurredAt");
+ List scheduledAtLogs = getChangeLogsByField(changeLogs, "scheduledAt");
+ List occurredAtLogs = getChangeLogsByField(changeLogs, "occurredAt");
assertNumberOfChanges(2, scheduledAtLogs);
assertNumberOfChanges(1, occurredAtLogs);
assertAll(
- () ->
- assertPropertyDelete("scheduledAt", "2022-04-22 06:00:38.343", scheduledAtLogs.get(0)),
- () ->
- assertPropertyCreate("scheduledAt", "2022-04-22 06:00:38.343", scheduledAtLogs.get(1)),
- () -> assertPropertyCreate("occurredAt", "2022-04-20 06:00:38.343", occurredAtLogs.get(0)));
+ () -> assertFieldDelete("scheduledAt", "2022-04-22 06:00:38.343", scheduledAtLogs.get(0)),
+ () -> assertFieldCreate("scheduledAt", "2022-04-22 06:00:38.343", scheduledAtLogs.get(1)),
+ () -> assertFieldCreate("occurredAt", "2022-04-20 06:00:38.343", occurredAtLogs.get(0)));
}
@Test
- void shouldReturnEventPropertiesChangeLogWhenNewGeometryPointPropertyValueAdded()
+ void shouldReturnEventFieldChangeLogWhenNewGeometryPointFieldValueAdded()
throws ForbiddenException, NotFoundException {
String event = "QRYjLTiJTrA";
Page changeLogs =
eventChangeLogService.getEventChangeLog(
UID.of(event), defaultOperationParams, defaultPageParams);
- List geometryChangeLogs = getChangeLogsByProperty(changeLogs, "geometry");
+ List geometryChangeLogs = getChangeLogsByField(changeLogs, "geometry");
assertNumberOfChanges(1, geometryChangeLogs);
assertAll(
- () ->
- assertPropertyCreate("geometry", "(-11.419700, 8.103900)", geometryChangeLogs.get(0)));
+ () -> assertFieldCreate("geometry", "(-11.419700, 8.103900)", geometryChangeLogs.get(0)));
}
@Test
- void shouldReturnEventPropertiesChangeLogWhenNewGeometryPolygonPropertyValueAdded()
+ void shouldReturnEventFieldChangeLogWhenNewGeometryPolygonFieldValueAdded()
throws ForbiddenException, NotFoundException {
String event = "YKmfzHdjUDL";
Page changeLogs =
eventChangeLogService.getEventChangeLog(
UID.of(event), defaultOperationParams, defaultPageParams);
- List geometryChangeLogs = getChangeLogsByProperty(changeLogs, "geometry");
+ List geometryChangeLogs = getChangeLogsByField(changeLogs, "geometry");
assertNumberOfChanges(1, geometryChangeLogs);
assertAll(
() ->
- assertPropertyCreate(
+ assertFieldCreate(
"geometry",
"(-11.416855, 8.132308), (-11.445351, 8.089312), (-11.383896, 8.089652), (-11.416855, 8.132308)",
geometryChangeLogs.get(0)));
}
@Test
- void shouldReturnEventPropertiesChangeLogWhenExistingGeometryPointPropertyUpdated()
+ void shouldReturnEventFieldChangeLogWhenExistingGeometryPointFieldUpdated()
throws ForbiddenException, NotFoundException {
UID event = UID.of("QRYjLTiJTrA");
@@ -410,22 +405,21 @@ void shouldReturnEventPropertiesChangeLogWhenExistingGeometryPointPropertyUpdate
Page changeLogs =
eventChangeLogService.getEventChangeLog(event, defaultOperationParams, defaultPageParams);
- List geometryChangeLogs = getChangeLogsByProperty(changeLogs, "geometry");
+ List geometryChangeLogs = getChangeLogsByField(changeLogs, "geometry");
assertNumberOfChanges(2, geometryChangeLogs);
assertAll(
() ->
- assertPropertyUpdate(
+ assertFieldUpdate(
"geometry",
"(-11.419700, 8.103900)",
"(16.435547, 49.264220)",
geometryChangeLogs.get(0)),
- () ->
- assertPropertyCreate("geometry", "(-11.419700, 8.103900)", geometryChangeLogs.get(1)));
+ () -> assertFieldCreate("geometry", "(-11.419700, 8.103900)", geometryChangeLogs.get(1)));
}
@Test
- void shouldReturnEventPropertiesChangeLogWhenExistingGeometryPointPropertyDeleted()
+ void shouldReturnEventFieldChangeLogWhenExistingGeometryPointFieldDeleted()
throws ForbiddenException, NotFoundException {
UID event = UID.of("QRYjLTiJTrA");
@@ -433,13 +427,12 @@ void shouldReturnEventPropertiesChangeLogWhenExistingGeometryPointPropertyDelete
Page changeLogs =
eventChangeLogService.getEventChangeLog(event, defaultOperationParams, defaultPageParams);
- List geometryChangeLogs = getChangeLogsByProperty(changeLogs, "geometry");
+ List geometryChangeLogs = getChangeLogsByField(changeLogs, "geometry");
assertNumberOfChanges(2, geometryChangeLogs);
assertAll(
- () -> assertPropertyDelete("geometry", "(-11.419700, 8.103900)", geometryChangeLogs.get(0)),
- () ->
- assertPropertyCreate("geometry", "(-11.419700, 8.103900)", geometryChangeLogs.get(1)));
+ () -> assertFieldDelete("geometry", "(-11.419700, 8.103900)", geometryChangeLogs.get(0)),
+ () -> assertFieldCreate("geometry", "(-11.419700, 8.103900)", geometryChangeLogs.get(1)));
}
private void updateDataValue(String event, String dataElementUid, String newValue) {
@@ -554,12 +547,11 @@ private void assertDataElementCreate(
() -> assertDataElementChange(dataElement, null, currentValue, changeLog));
}
- private void assertPropertyCreate(
- String property, String currentValue, EventChangeLog changeLog) {
+ private void assertFieldCreate(String field, String currentValue, EventChangeLog changeLog) {
assertAll(
() -> assertUser(importUser, changeLog),
() -> assertEquals("CREATE", changeLog.getChangeLogType().name()),
- () -> assertPropertyChange(property, null, currentValue, changeLog));
+ () -> assertFieldChange(field, null, currentValue, changeLog));
}
private void assertDataElementUpdate(
@@ -567,14 +559,14 @@ private void assertDataElementUpdate(
assertUpdate(dataElement, null, previousValue, currentValue, changeLog, importUser);
}
- private void assertPropertyUpdate(
- String property, String previousValue, String currentValue, EventChangeLog changeLog) {
- assertUpdate(null, property, previousValue, currentValue, changeLog, importUser);
+ private void assertFieldUpdate(
+ String field, String previousValue, String currentValue, EventChangeLog changeLog) {
+ assertUpdate(null, field, previousValue, currentValue, changeLog, importUser);
}
private void assertUpdate(
String dataElement,
- String property,
+ String field,
String previousValue,
String currentValue,
EventChangeLog changeLog,
@@ -586,7 +578,7 @@ private void assertUpdate(
if (dataElement != null) {
assertDataElementChange(dataElement, previousValue, currentValue, changeLog);
} else {
- assertPropertyChange(property, previousValue, currentValue, changeLog);
+ assertFieldChange(field, previousValue, currentValue, changeLog);
}
});
}
@@ -596,13 +588,12 @@ private void assertDataElementDelete(
assertDelete(dataElement, null, previousValue, changeLog);
}
- private void assertPropertyDelete(
- String property, String previousValue, EventChangeLog changeLog) {
- assertDelete(null, property, previousValue, changeLog);
+ private void assertFieldDelete(String field, String previousValue, EventChangeLog changeLog) {
+ assertDelete(null, field, previousValue, changeLog);
}
private void assertDelete(
- String dataElement, String property, String previousValue, EventChangeLog changeLog) {
+ String dataElement, String field, String previousValue, EventChangeLog changeLog) {
assertAll(
() -> assertUser(importUser, changeLog),
() -> assertEquals("DELETE", changeLog.getChangeLogType().name()),
@@ -610,7 +601,7 @@ private void assertDelete(
if (dataElement != null) {
assertDataElementChange(dataElement, previousValue, null, changeLog);
} else {
- assertPropertyChange(property, previousValue, null, changeLog);
+ assertFieldChange(field, previousValue, null, changeLog);
}
});
}
@@ -624,9 +615,9 @@ private static void assertDataElementChange(
assertEquals(currentValue, changeLog.getCurrentValue());
}
- private static void assertPropertyChange(
- String property, String previousValue, String currentValue, EventChangeLog changeLog) {
- assertEquals(property, changeLog.getEventProperty());
+ private static void assertFieldChange(
+ String field, String previousValue, String currentValue, EventChangeLog changeLog) {
+ assertEquals(field, changeLog.getEventField());
assertEquals(previousValue, changeLog.getPreviousValue());
assertEquals(currentValue, changeLog.getCurrentValue());
}
@@ -652,10 +643,10 @@ private List getDataElementChangeLogs(Page chang
return changeLogs.getItems().stream().filter(cl -> cl.getDataElement() != null).toList();
}
- private List getChangeLogsByProperty(
- Page changeLogs, String propertyName) {
+ private List getChangeLogsByField(
+ Page changeLogs, String fieldName) {
return changeLogs.getItems().stream()
- .filter(cl -> cl.getEventProperty() != null && cl.getEventProperty().equals(propertyName))
+ .filter(cl -> cl.getEventField() != null && cl.getEventField().equals(fieldName))
.toList();
}
diff --git a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/event/OrderAndFilterEventChangeLogTest.java b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/event/OrderAndFilterEventChangeLogTest.java
index 2a8c3b5ca371..943e3318264c 100644
--- a/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/event/OrderAndFilterEventChangeLogTest.java
+++ b/dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/event/OrderAndFilterEventChangeLogTest.java
@@ -198,71 +198,71 @@ void shouldSortChangeLogsWhenOrderingByDataElementDesc()
}
@Test
- void shouldSortChangeLogsWhenOrderingByPropertyAsc()
+ void shouldSortChangeLogsWhenOrderingByFieldAsc()
throws ForbiddenException, NotFoundException, IOException {
EventChangeLogOperationParams params =
- EventChangeLogOperationParams.builder().orderBy("property", SortDirection.ASC).build();
+ EventChangeLogOperationParams.builder().orderBy("field", SortDirection.ASC).build();
UID event = UID.of("QRYjLTiJTrA");
LocalDateTime currentTime = LocalDateTime.now();
updateEventDates(event, currentTime.toDate().toInstant());
List changeLogs =
- getAllPropertyChangeLogs(
+ getAllFieldChangeLogs(
eventChangeLogService.getEventChangeLog(
UID.of("QRYjLTiJTrA"), params, defaultPageParams));
assertNumberOfChanges(5, changeLogs);
assertAll(
- () -> assertPropertyCreate("geometry", "(-11.419700, 8.103900)", changeLogs.get(0)),
+ () -> assertFieldCreate("geometry", "(-11.419700, 8.103900)", changeLogs.get(0)),
() ->
- assertPropertyUpdate(
+ assertFieldUpdate(
"occurredAt",
"2022-04-20 06:00:38.343",
currentTime.toString(formatter),
changeLogs.get(1)),
- () -> assertPropertyCreate("occurredAt", "2022-04-20 06:00:38.343", changeLogs.get(2)),
+ () -> assertFieldCreate("occurredAt", "2022-04-20 06:00:38.343", changeLogs.get(2)),
() ->
- assertPropertyUpdate(
+ assertFieldUpdate(
"scheduledAt",
"2022-04-22 06:00:38.343",
currentTime.toString(formatter),
changeLogs.get(3)),
- () -> assertPropertyCreate("scheduledAt", "2022-04-22 06:00:38.343", changeLogs.get(4)));
+ () -> assertFieldCreate("scheduledAt", "2022-04-22 06:00:38.343", changeLogs.get(4)));
}
@Test
- void shouldSortChangeLogsWhenOrderingByPropertyDesc()
+ void shouldSortChangeLogsWhenOrderingByFieldDesc()
throws ForbiddenException, NotFoundException, IOException {
EventChangeLogOperationParams params =
- EventChangeLogOperationParams.builder().orderBy("property", SortDirection.DESC).build();
+ EventChangeLogOperationParams.builder().orderBy("field", SortDirection.DESC).build();
UID event = UID.of("QRYjLTiJTrA");
LocalDateTime currentTime = LocalDateTime.now();
updateEventDates(event, currentTime.toDate().toInstant());
List changeLogs =
- getAllPropertyChangeLogs(
+ getAllFieldChangeLogs(
eventChangeLogService.getEventChangeLog(
UID.of("QRYjLTiJTrA"), params, defaultPageParams));
assertNumberOfChanges(5, changeLogs);
assertAll(
() ->
- assertPropertyUpdate(
+ assertFieldUpdate(
"scheduledAt",
"2022-04-22 06:00:38.343",
currentTime.toString(formatter),
changeLogs.get(0)),
- () -> assertPropertyCreate("scheduledAt", "2022-04-22 06:00:38.343", changeLogs.get(1)),
+ () -> assertFieldCreate("scheduledAt", "2022-04-22 06:00:38.343", changeLogs.get(1)),
() ->
- assertPropertyUpdate(
+ assertFieldUpdate(
"occurredAt",
"2022-04-20 06:00:38.343",
currentTime.toString(formatter),
changeLogs.get(2)),
- () -> assertPropertyCreate("occurredAt", "2022-04-20 06:00:38.343", changeLogs.get(3)),
- () -> assertPropertyCreate("geometry", "(-11.419700, 8.103900)", changeLogs.get(4)));
+ () -> assertFieldCreate("occurredAt", "2022-04-20 06:00:38.343", changeLogs.get(3)),
+ () -> assertFieldCreate("geometry", "(-11.419700, 8.103900)", changeLogs.get(4)));
}
@Test
@@ -302,28 +302,28 @@ void shouldFilterChangeLogsWhenFilteringByDataElement()
assertContainsOnly(List.of(dataElement), changeLogDataElements);
}
- private Stream provideEventProperties() {
+ private Stream provideEventField() {
return Stream.of(
Arguments.of("occurredAt"), Arguments.of("scheduledAt"), Arguments.of("geometry"));
}
@ParameterizedTest
- @MethodSource("provideEventProperties")
- void shouldFilterChangeLogsWhenFilteringByProperties(String filterValue)
+ @MethodSource("provideEventField")
+ void shouldFilterChangeLogsWhenFilteringByField(String filterValue)
throws ForbiddenException, NotFoundException {
EventChangeLogOperationParams params =
EventChangeLogOperationParams.builder()
- .filterBy("property", new QueryFilter(QueryOperator.EQ, filterValue))
+ .filterBy("field", new QueryFilter(QueryOperator.EQ, filterValue))
.build();
Page changeLogs =
eventChangeLogService.getEventChangeLog(UID.of("QRYjLTiJTrA"), params, defaultPageParams);
- Set changeLogOccurredAtProperties =
+ Set changeLogOccurredAtFields =
changeLogs.getItems().stream()
- .map(EventChangeLog::getEventProperty)
+ .map(EventChangeLog::getEventField)
.collect(Collectors.toSet());
- assertContainsOnly(List.of(filterValue), changeLogOccurredAtProperties);
+ assertContainsOnly(List.of(filterValue), changeLogOccurredAtFields);
}
private void updateDataValue(String event, String dataElementUid, String newValue) {
@@ -385,12 +385,11 @@ private void assertDataElementCreate(
() -> assertDataElementChange(dataElement, null, currentValue, changeLog));
}
- private void assertPropertyCreate(
- String property, String currentValue, EventChangeLog changeLog) {
+ private void assertFieldCreate(String field, String currentValue, EventChangeLog changeLog) {
assertAll(
() -> assertUser(importUser, changeLog),
() -> assertEquals("CREATE", changeLog.getChangeLogType().name()),
- () -> assertPropertyChange(property, null, currentValue, changeLog));
+ () -> assertFieldChange(field, null, currentValue, changeLog));
}
private void assertDataElementUpdate(
@@ -398,14 +397,14 @@ private void assertDataElementUpdate(
assertUpdate(dataElement, null, previousValue, currentValue, changeLog, importUser);
}
- private void assertPropertyUpdate(
- String property, String previousValue, String currentValue, EventChangeLog changeLog) {
- assertUpdate(null, property, previousValue, currentValue, changeLog, importUser);
+ private void assertFieldUpdate(
+ String field, String previousValue, String currentValue, EventChangeLog changeLog) {
+ assertUpdate(null, field, previousValue, currentValue, changeLog, importUser);
}
private void assertUpdate(
String dataElement,
- String property,
+ String field,
String previousValue,
String currentValue,
EventChangeLog changeLog,
@@ -417,7 +416,7 @@ private void assertUpdate(
if (dataElement != null) {
assertDataElementChange(dataElement, previousValue, currentValue, changeLog);
} else {
- assertPropertyChange(property, previousValue, currentValue, changeLog);
+ assertFieldChange(field, previousValue, currentValue, changeLog);
}
});
}
@@ -431,9 +430,9 @@ private static void assertDataElementChange(
assertEquals(currentValue, changeLog.getCurrentValue());
}
- private static void assertPropertyChange(
- String property, String previousValue, String currentValue, EventChangeLog changeLog) {
- assertEquals(property, changeLog.getEventProperty());
+ private static void assertFieldChange(
+ String field, String previousValue, String currentValue, EventChangeLog changeLog) {
+ assertEquals(field, changeLog.getEventField());
assertEquals(previousValue, changeLog.getPreviousValue());
assertEquals(currentValue, changeLog.getCurrentValue());
}
@@ -459,8 +458,8 @@ private List getDataElementChangeLogs(Page chang
return changeLogs.getItems().stream().filter(cl -> cl.getDataElement() != null).toList();
}
- private List getAllPropertyChangeLogs(Page changeLogs) {
- return changeLogs.getItems().stream().filter(cl -> cl.getEventProperty() != null).toList();
+ private List getAllFieldChangeLogs(Page changeLogs) {
+ return changeLogs.getItems().stream().filter(cl -> cl.getEventField() != null).toList();
}
private void updateDataValues(Event event, String dataElementUid, String... values) {
diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/JsonEventChangeLog.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/JsonEventChangeLog.java
index 638a7949365d..1b40f86c4d52 100644
--- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/JsonEventChangeLog.java
+++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/JsonEventChangeLog.java
@@ -49,8 +49,8 @@ default JsonDataValue getDataValue() {
return get("dataValue").as(JsonDataValue.class);
}
- default JsonEventProperty getEventProperty() {
- return get("eventProperty").as(JsonEventProperty.class);
+ default JsonEventField getEventField() {
+ return get("eventField").as(JsonEventField.class);
}
}
@@ -68,9 +68,9 @@ default String getCurrentValue() {
}
}
- interface JsonEventProperty extends JsonObject {
- default String getProperty() {
- return getString("property").string();
+ interface JsonEventField extends JsonObject {
+ default String getField() {
+ return getString("field").string();
}
default String getPreviousValue() {
diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventsExportChangeLogsControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventsExportChangeLogsControllerTest.java
index 6a87881c6a73..99c1a84e95c4 100644
--- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventsExportChangeLogsControllerTest.java
+++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventsExportChangeLogsControllerTest.java
@@ -174,24 +174,23 @@ void shouldGetEventChangeLogInDescOrderByDefault() {
changeLogs.stream()
.filter(log -> log.getChange().getDataValue().getDataElement() != null)
.toList();
- List eventPropertyChangeLogs =
+ List eventFieldChangeLogs =
changeLogs.stream()
- .filter(log -> log.getChange().getEventProperty().getProperty() != null)
+ .filter(log -> log.getChange().getEventField().getField() != null)
.toList();
assertHasSize(3, dataValueChangeLogs);
- assertHasSize(2, eventPropertyChangeLogs);
+ assertHasSize(2, eventFieldChangeLogs);
assertAll(
() -> assertDelete(dataElement, "value 3", dataValueChangeLogs.get(0)),
() -> assertUpdate(dataElement, "value 2", "value 3", dataValueChangeLogs.get(1)),
() -> assertUpdate(dataElement, "value 1", "value 2", dataValueChangeLogs.get(2)),
() ->
- assertPropertyCreateExists(
- "occurredAt", "2023-01-10 00:00:00.000", eventPropertyChangeLogs),
+ assertFieldCreateExists("occurredAt", "2023-01-10 00:00:00.000", eventFieldChangeLogs),
() ->
- assertPropertyCreateExists(
- "scheduledAt", "2023-01-10 00:00:00.000", eventPropertyChangeLogs));
+ assertFieldCreateExists(
+ "scheduledAt", "2023-01-10 00:00:00.000", eventFieldChangeLogs));
}
@Test
@@ -204,41 +203,39 @@ void shouldGetEventChangeLogInAscOrder() {
changeLogs.stream()
.filter(log -> log.getChange().getDataValue().getDataElement() != null)
.toList();
- List eventPropertyChangeLogs =
+ List eventFieldChangeLogs =
changeLogs.stream()
- .filter(log -> log.getChange().getEventProperty().getProperty() != null)
+ .filter(log -> log.getChange().getEventField().getField() != null)
.toList();
assertHasSize(3, dataValueChangeLogs);
- assertHasSize(2, eventPropertyChangeLogs);
+ assertHasSize(2, eventFieldChangeLogs);
assertAll(
() -> assertUpdate(dataElement, "value 1", "value 2", dataValueChangeLogs.get(0)),
() -> assertUpdate(dataElement, "value 2", "value 3", dataValueChangeLogs.get(1)),
() -> assertDelete(dataElement, "value 3", dataValueChangeLogs.get(2)),
() ->
- assertPropertyCreateExists(
- "occurredAt", "2023-01-10 00:00:00.000", eventPropertyChangeLogs),
+ assertFieldCreateExists("occurredAt", "2023-01-10 00:00:00.000", eventFieldChangeLogs),
() ->
- assertPropertyCreateExists(
- "scheduledAt", "2023-01-10 00:00:00.000", eventPropertyChangeLogs));
+ assertFieldCreateExists(
+ "scheduledAt", "2023-01-10 00:00:00.000", eventFieldChangeLogs));
}
@Test
- void shouldGetEventChangeLogsWhenFilteringByProperty() {
+ void shouldGetEventChangeLogsWhenFilteringByField() {
JsonList changeLogs =
- GET("/tracker/events/{id}/changeLogs?filter=property:eq:occurredAt", event.getUid())
+ GET("/tracker/events/{id}/changeLogs?filter=field:eq:occurredAt", event.getUid())
.content(HttpStatus.OK)
.getList("changeLogs", JsonEventChangeLog.class);
- List eventPropertyChangeLogs =
+ List eventFieldChangeLogs =
changeLogs.stream()
- .filter(log -> log.getChange().getEventProperty().getProperty() != null)
+ .filter(log -> log.getChange().getEventField().getField() != null)
.toList();
assertAll(
- () -> assertHasSize(1, eventPropertyChangeLogs),
+ () -> assertHasSize(1, eventFieldChangeLogs),
() ->
- assertPropertyCreateExists(
- "occurredAt", "2023-01-10 00:00:00.000", eventPropertyChangeLogs));
+ assertFieldCreateExists("occurredAt", "2023-01-10 00:00:00.000", eventFieldChangeLogs));
}
@Test
@@ -479,7 +476,7 @@ private static void assertChange(
assertEquals(dataElement.getUid(), actual.getChange().getDataValue().getDataElement()),
() -> assertEquals(previousValue, actual.getChange().getDataValue().getPreviousValue()),
() -> assertEquals(currentValue, actual.getChange().getDataValue().getCurrentValue()),
- () -> JsonAssertions.assertHasNoMember(actual.getChange(), "eventProperty"));
+ () -> JsonAssertions.assertHasNoMember(actual.getChange(), "eventField"));
}
private static void assertPagerLink(String actual, int page, int pageSize, String start) {
@@ -490,12 +487,12 @@ private static void assertPagerLink(String actual, int page, int pageSize, Strin
() -> assertContains("pageSize=" + pageSize, actual));
}
- private static void assertPropertyCreateExists(
- String property, String currentValue, List changeLogs) {
+ private static void assertFieldCreateExists(
+ String field, String currentValue, List changeLogs) {
assertTrue(
- changeLogs.stream().anyMatch(cl -> isEventPropertyCreate(cl, property, currentValue)),
+ changeLogs.stream().anyMatch(cl -> isEventFieldCreate(cl, field, currentValue)),
"Expected a "
- + property
+ + field
+ " change with value "
+ currentValue
+ " among the change log entries.");
@@ -504,11 +501,11 @@ private static void assertPropertyCreateExists(
"Data value change not expected to be present, but it was");
}
- private static boolean isEventPropertyCreate(
- JsonEventChangeLog actual, String property, String currentValue) {
+ private static boolean isEventFieldCreate(
+ JsonEventChangeLog actual, String field, String currentValue) {
return actual.getType().equals(ChangeLogType.CREATE.name())
- && actual.getChange().getEventProperty().getProperty().equals(property)
- && actual.getChange().getEventProperty().getCurrentValue().equals(currentValue)
- && actual.getChange().getEventProperty().getPreviousValue() == null;
+ && actual.getChange().getEventField().getField().equals(field)
+ && actual.getChange().getEventField().getCurrentValue().equals(currentValue)
+ && actual.getChange().getEventField().getPreviousValue() == null;
}
}
diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventChangeLogMapper.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventChangeLogMapper.java
index 9600f3d6d927..96fbf2a93d78 100644
--- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventChangeLogMapper.java
+++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventChangeLogMapper.java
@@ -29,7 +29,7 @@
import org.hisp.dhis.webapi.controller.tracker.view.EventChangeLog;
import org.hisp.dhis.webapi.controller.tracker.view.EventChangeLog.DataValueChange;
-import org.hisp.dhis.webapi.controller.tracker.view.EventChangeLog.PropertyChange;
+import org.hisp.dhis.webapi.controller.tracker.view.EventChangeLog.FieldChange;
import org.hisp.dhis.webapi.controller.tracker.view.UIDMapper;
import org.hisp.dhis.webapi.controller.tracker.view.User;
import org.mapstruct.Mapper;
@@ -47,9 +47,9 @@ public interface EventChangeLogMapper {
source = "eventChangeLog",
qualifiedByName = "mapIfDataValueChangeExists")
@Mapping(
- target = "change.eventProperty",
+ target = "change.eventField",
source = "eventChangeLog",
- qualifiedByName = "mapIfEventPropertyChangeExists")
+ qualifiedByName = "mapIfEventFieldChangeExists")
EventChangeLog map(org.hisp.dhis.tracker.export.event.EventChangeLog eventChangeLog);
@Mapping(target = "uid", source = "createdBy.uid")
@@ -73,18 +73,17 @@ default DataValueChange mapIfDataValueChangeExists(
return mapDataValueChange(eventChangeLog);
}
- @Mapping(target = "property", source = "eventProperty")
+ @Mapping(target = "field", source = "eventField")
@Mapping(target = "previousValue", source = "previousValue")
@Mapping(target = "currentValue", source = "currentValue")
- PropertyChange mapEventPropertyChange(
- org.hisp.dhis.tracker.export.event.EventChangeLog eventChangeLog);
+ FieldChange mapEventFieldChange(org.hisp.dhis.tracker.export.event.EventChangeLog eventChangeLog);
- @Named("mapIfEventPropertyChangeExists")
- default PropertyChange mapIfEventPropertyExists(
+ @Named("mapIfEventFieldChangeExists")
+ default FieldChange mapIfEventFieldExists(
org.hisp.dhis.tracker.export.event.EventChangeLog eventChangeLog) {
- if (eventChangeLog.getEventProperty() == null) {
+ if (eventChangeLog.getEventField() == null) {
return null;
}
- return mapEventPropertyChange(eventChangeLog);
+ return mapEventFieldChange(eventChangeLog);
}
}
diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/view/EventChangeLog.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/view/EventChangeLog.java
index 22cc0fbbf563..73af417eb76b 100644
--- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/view/EventChangeLog.java
+++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/view/EventChangeLog.java
@@ -38,15 +38,15 @@ public record EventChangeLog(
@JsonProperty Change change) {
public record Change(
- @JsonProperty DataValueChange dataValue, @JsonProperty PropertyChange eventProperty) {}
+ @JsonProperty DataValueChange dataValue, @JsonProperty FieldChange eventField) {}
public record DataValueChange(
@JsonProperty UID dataElement,
@JsonProperty String previousValue,
@JsonProperty String currentValue) {}
- public record PropertyChange(
- @JsonProperty String property,
+ public record FieldChange(
+ @JsonProperty String field,
@JsonProperty String previousValue,
@JsonProperty String currentValue) {}
}