Skip to content

Commit eb9890a

Browse files
muilppclaude
andauthored
task: Remove storedBy from notes [DHIS2-21537] (#23965)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d6d3355 commit eb9890a

20 files changed

Lines changed: 23 additions & 73 deletions

File tree

dhis-2/dhis-api/src/main/java/org/hisp/dhis/note/Note.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,14 @@
4242
public class Note extends BaseIdentifiableObject {
4343
private String noteText;
4444

45-
private String creator;
46-
4745
// -------------------------------------------------------------------------
4846
// Constructor
4947
// -------------------------------------------------------------------------
5048

5149
public Note() {}
5250

53-
public Note(String noteText, String creator) {
51+
public Note(String noteText) {
5452
this.noteText = noteText;
55-
this.creator = creator;
5653
}
5754

5855
// -------------------------------------------------------------------------
@@ -68,14 +65,4 @@ public String getNoteText() {
6865
public void setNoteText(String noteText) {
6966
this.noteText = noteText;
7067
}
71-
72-
@JsonProperty
73-
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
74-
public String getCreator() {
75-
return creator;
76-
}
77-
78-
public void setCreator(String creator) {
79-
this.creator = creator;
80-
}
8168
}

dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/note/hibernate/Note.hbm.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,5 @@
2121

2222
<property name="noteText" column="notetext" type="text" />
2323

24-
<property name="creator" column="creator" />
25-
2624
</class>
2725
</hibernate-mapping>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
alter table note drop column if exists creator;

dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/enrollment/EnrollmentServiceTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,6 @@ void shouldReturnEmptyListWhenRequestingEnrollmentsAndTheyAreNotAccessible()
782782
@Test
783783
void shouldNotDeleteNoteWhenDeletingEnrollment() {
784784
Note note = new Note();
785-
note.setCreator(CodeGenerator.generateUid());
786785
note.setNoteText("text");
787786
manager.save(note);
788787
enrollmentA.getNotes().add(note);

dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/export/trackedentity/TrackedEntityServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ void setUp() {
370370
eventA.setCompletedDate(parseDate("2021-02-27T11:05:00.000"));
371371
eventA.setCompletedBy("herb");
372372
eventA.setAssignedUser(user);
373-
Note note = new Note("note1", "ant");
373+
Note note = new Note("note1");
374374
note.setUid(generateUid());
375375
note.setCreated(new Date());
376376
note.setLastUpdated(new Date());

dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/note/NoteServiceTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ private void assertNotes(
227227
.orElse(null);
228228
assertNotNull(dbNote);
229229
assertEquals(note.getValue(), dbNote.getNoteText());
230-
assertEquals(note.getStoredBy(), dbNote.getCreator());
231230
assertEquals(updatedBy.getUid(), dbNote.getLastUpdatedBy().getUid());
232231
assertEquals(updatedBy.getUsername(), dbNote.getLastUpdatedBy().getUsername());
233232
assertEquals(updatedBy.getFirstName(), dbNote.getLastUpdatedBy().getFirstName());
@@ -236,10 +235,6 @@ private void assertNotes(
236235
}
237236

238237
private Note note() {
239-
return Note.builder()
240-
.note(UID.generate())
241-
.storedBy("This is the creator")
242-
.value("This is a note")
243-
.build();
238+
return Note.builder().note(UID.generate()).value("This is a note").build();
244239
}
245240
}

dhis-2/dhis-test-integration/src/test/java/org/hisp/dhis/tracker/imports/validation/EventImportValidationTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import static org.hisp.dhis.tracker.imports.validation.ValidationCode.E1102;
4343
import static org.junit.jupiter.api.Assertions.assertEquals;
4444
import static org.junit.jupiter.api.Assertions.assertNotNull;
45-
import static org.junit.jupiter.api.Assertions.assertNull;
4645
import static org.junit.jupiter.api.Assertions.assertTrue;
4746
import static org.junit.jupiter.api.Assertions.fail;
4847

@@ -357,7 +356,6 @@ void testValidateAndAddNotesToEvent() throws IOException {
357356
Note note = getByNote(event.getNotes(), t);
358357
assertTrue(CodeGenerator.isValidUid(note.getUid()));
359358
assertTrue(note.getCreated().getTime() > now.getTime());
360-
assertNull(note.getCreator());
361359
assertEquals(importUser.getUid(), note.getLastUpdatedBy().getUid());
362360
});
363361
}
@@ -380,7 +378,6 @@ void testValidateAndAddNotesToUpdatedEvent() throws IOException {
380378
Note note = getByNote(event.getNotes(), t);
381379
assertTrue(CodeGenerator.isValidUid(note.getUid()));
382380
assertTrue(note.getCreated().getTime() > now.getTime());
383-
assertNull(note.getCreator());
384381
assertEquals(importUser.getUid(), note.getLastUpdatedBy().getUid());
385382
});
386383
}

dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventsExportControllerTest.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,11 @@ class EventsExportControllerTest extends PostgresControllerIntegrationTestBase {
148148
private TrackedEntityType trackedEntityType;
149149

150150
private EventDataValue dv;
151-
private EventDataValue dvMultiText;
152151

153152
private DataElement de;
154153

155154
private DataElement deMultiText;
156155

157-
private TrackerEvent eventRBG;
158-
private TrackerEvent eventRWY;
159156
private TrackerEvent eventNoValue;
160157

161158
@BeforeEach
@@ -212,8 +209,8 @@ void setUp() {
212209
dv.setStoredBy("user");
213210
dv.setValue(DATA_ELEMENT_VALUE);
214211

215-
eventRBG = createEvent(createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_RBG), orgUnit, EVENT_RBG);
216-
eventRWY = createEvent(createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_RWY), orgUnit, EVENT_RWY);
212+
createEvent(createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_RBG), orgUnit, EVENT_RBG);
213+
createEvent(createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_RWY), orgUnit, EVENT_RWY);
217214
eventNoValue =
218215
createEvent(
219216
createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_NO_VALUE), orgUnit, EVENT_NO_VALUE);
@@ -223,7 +220,7 @@ void setUp() {
223220
void getEventByPathIsIdenticalToQueryParam() {
224221
TrackedEntity to = trackedEntity();
225222
TrackerEvent event = event(enrollment(to));
226-
event.setNotes(List.of(note("oqXG28h988k", "my notes", owner.getUid())));
223+
event.setNotes(List.of(note("oqXG28h988k", "my notes")));
227224
manager.update(event);
228225
relationship(event, to);
229226
switchContextToUser(user);
@@ -273,7 +270,7 @@ void getEventByIdWithFields() {
273270
@Test
274271
void getEventByIdWithNotes() {
275272
TrackerEvent event = event(enrollment(trackedEntity()));
276-
event.setNotes(List.of(note("oqXG28h988k", "my notes", owner.getUid())));
273+
event.setNotes(List.of(note("oqXG28h988k", "my notes")));
277274
manager.update(event);
278275
switchContextToUser(user);
279276

@@ -285,7 +282,6 @@ void getEventByIdWithNotes() {
285282
JsonNote note = jsonEvent.getNotes().get(0);
286283
assertEquals("oqXG28h988k", note.getNote());
287284
assertEquals("my notes", note.value());
288-
assertEquals(owner.getUid(), note.getStoredBy());
289285
}
290286

291287
@Test
@@ -1228,8 +1224,8 @@ private TrackerEvent createEvent(
12281224
return event;
12291225
}
12301226

1231-
private Note note(String uid, String value, String storedBy) {
1232-
Note note = new Note(value, storedBy);
1227+
private Note note(String uid, String value) {
1228+
Note note = new Note(value);
12331229
note.setUid(uid);
12341230
manager.save(note, false);
12351231
return note;

dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/tracker/export/relationship/RelationshipsExportControllerTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,7 @@ void shouldGetRelationshipsByEventWithNotes() {
354354
"expected to find relationship " + relationship1.getUID());
355355

356356
JsonList<JsonNote> notes = jsonRelationship.getTo().getEvent().getNotes();
357-
notes.forEach(
358-
note -> assertHasOnlyMembers(note, "note", "value", "storedAt", "storedBy", "createdBy"));
357+
notes.forEach(note -> assertHasOnlyMembers(note, "note", "value", "storedAt", "createdBy"));
359358
}
360359

361360
@Test

dhis-2/dhis-tracker/src/main/java/org/hisp/dhis/tracker/export/enrollment/JdbcEnrollmentStore.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private void addLeftJoinOnNotes(StringBuilder sql) {
292292
"""
293293
left join lateral (
294294
select json_agg(json_build_object('uid', n.uid, 'text', n.notetext,
295-
'creator', n.creator, 'created', n.created, 'updatedByUid', u.uid,
295+
'created', n.created, 'updatedByUid', u.uid,
296296
'updatedByUsername', u.username, 'updatedByFirstname', u.firstname,
297297
'updatedBySurname', u.surname, 'updatedByName', u.name)) as jsonnotes
298298
from enrollment_notes en
@@ -725,7 +725,6 @@ private List<Note> mapEnrollmentNotes(String jsonNotes) {
725725
Note note = new Note();
726726
note.setUid(jdbcNote.getUid());
727727
note.setNoteText(jdbcNote.getText());
728-
note.setCreator(jdbcNote.getCreator());
729728
note.setCreated(DateUtils.safeParseDate(jdbcNote.getCreated()));
730729
User user = new User();
731730
user.setUid(jdbcNote.getUpdatedByUid());
@@ -791,7 +790,6 @@ public Set<String> getOrderableFields() {
791790
private static class JdbcNote {
792791
private String uid;
793792
private String text;
794-
private String creator;
795793
private String created;
796794
private String updatedByUid;
797795
private String updatedByUsername;

0 commit comments

Comments
 (0)