Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions dhis-2/dhis-api/src/main/java/org/hisp/dhis/note/Note.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@
public class Note extends BaseIdentifiableObject {
private String noteText;

private String creator;

// -------------------------------------------------------------------------
// Constructor
// -------------------------------------------------------------------------

public Note() {}

public Note(String noteText, String creator) {
public Note(String noteText) {
this.noteText = noteText;
this.creator = creator;
}

// -------------------------------------------------------------------------
Expand All @@ -68,14 +65,4 @@ public String getNoteText() {
public void setNoteText(String noteText) {
this.noteText = noteText;
}

@JsonProperty
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0)
public String getCreator() {
return creator;
}

public void setCreator(String creator) {
this.creator = creator;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@

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

<property name="creator" column="creator" />

</class>
</hibernate-mapping>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table note drop column if exists creator;
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,6 @@ void shouldReturnEmptyListWhenRequestingEnrollmentsAndTheyAreNotAccessible()
@Test
void shouldNotDeleteNoteWhenDeletingEnrollment() {
Note note = new Note();
note.setCreator(CodeGenerator.generateUid());
note.setNoteText("text");
manager.save(note);
enrollmentA.getNotes().add(note);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void setUp() {
eventA.setCompletedDate(parseDate("2021-02-27T11:05:00.000"));
eventA.setCompletedBy("herb");
eventA.setAssignedUser(user);
Note note = new Note("note1", "ant");
Note note = new Note("note1");
note.setUid(generateUid());
note.setCreated(new Date());
note.setLastUpdated(new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ private void assertNotes(
.orElse(null);
assertNotNull(dbNote);
assertEquals(note.getValue(), dbNote.getNoteText());
assertEquals(note.getStoredBy(), dbNote.getCreator());
assertEquals(updatedBy.getUid(), dbNote.getLastUpdatedBy().getUid());
assertEquals(updatedBy.getUsername(), dbNote.getLastUpdatedBy().getUsername());
assertEquals(updatedBy.getFirstName(), dbNote.getLastUpdatedBy().getFirstName());
Expand All @@ -236,10 +235,6 @@ private void assertNotes(
}

private Note note() {
return Note.builder()
.note(UID.generate())
.storedBy("This is the creator")
.value("This is a note")
.build();
return Note.builder().note(UID.generate()).value("This is a note").build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import static org.hisp.dhis.tracker.imports.validation.ValidationCode.E1102;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

Expand Down Expand Up @@ -357,7 +356,6 @@ void testValidateAndAddNotesToEvent() throws IOException {
Note note = getByNote(event.getNotes(), t);
assertTrue(CodeGenerator.isValidUid(note.getUid()));
assertTrue(note.getCreated().getTime() > now.getTime());
assertNull(note.getCreator());
assertEquals(importUser.getUid(), note.getLastUpdatedBy().getUid());
});
}
Expand All @@ -380,7 +378,6 @@ void testValidateAndAddNotesToUpdatedEvent() throws IOException {
Note note = getByNote(event.getNotes(), t);
assertTrue(CodeGenerator.isValidUid(note.getUid()));
assertTrue(note.getCreated().getTime() > now.getTime());
assertNull(note.getCreator());
assertEquals(importUser.getUid(), note.getLastUpdatedBy().getUid());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,11 @@ class EventsExportControllerTest extends PostgresControllerIntegrationTestBase {
private TrackedEntityType trackedEntityType;

private EventDataValue dv;
private EventDataValue dvMultiText;

private DataElement de;

private DataElement deMultiText;

private TrackerEvent eventRBG;
private TrackerEvent eventRWY;
private TrackerEvent eventNoValue;

@BeforeEach
Expand Down Expand Up @@ -212,8 +209,8 @@ void setUp() {
dv.setStoredBy("user");
dv.setValue(DATA_ELEMENT_VALUE);

eventRBG = createEvent(createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_RBG), orgUnit, EVENT_RBG);
eventRWY = createEvent(createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_RWY), orgUnit, EVENT_RWY);
createEvent(createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_RBG), orgUnit, EVENT_RBG);
createEvent(createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_RWY), orgUnit, EVENT_RWY);
eventNoValue =
createEvent(
createDataValue(MULTI_TEXT_DATA_ELEMENT_VALUE_NO_VALUE), orgUnit, EVENT_NO_VALUE);
Expand All @@ -223,7 +220,7 @@ void setUp() {
void getEventByPathIsIdenticalToQueryParam() {
TrackedEntity to = trackedEntity();
TrackerEvent event = event(enrollment(to));
event.setNotes(List.of(note("oqXG28h988k", "my notes", owner.getUid())));
event.setNotes(List.of(note("oqXG28h988k", "my notes")));
manager.update(event);
relationship(event, to);
switchContextToUser(user);
Expand Down Expand Up @@ -273,7 +270,7 @@ void getEventByIdWithFields() {
@Test
void getEventByIdWithNotes() {
TrackerEvent event = event(enrollment(trackedEntity()));
event.setNotes(List.of(note("oqXG28h988k", "my notes", owner.getUid())));
event.setNotes(List.of(note("oqXG28h988k", "my notes")));
manager.update(event);
switchContextToUser(user);

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

@Test
Expand Down Expand Up @@ -1228,8 +1224,8 @@ private TrackerEvent createEvent(
return event;
}

private Note note(String uid, String value, String storedBy) {
Note note = new Note(value, storedBy);
private Note note(String uid, String value) {
Note note = new Note(value);
note.setUid(uid);
manager.save(note, false);
return note;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ void shouldGetRelationshipsByEventWithNotes() {
"expected to find relationship " + relationship1.getUID());

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

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private void addLeftJoinOnNotes(StringBuilder sql) {
"""
left join lateral (
select json_agg(json_build_object('uid', n.uid, 'text', n.notetext,
'creator', n.creator, 'created', n.created, 'updatedByUid', u.uid,
'created', n.created, 'updatedByUid', u.uid,
'updatedByUsername', u.username, 'updatedByFirstname', u.firstname,
'updatedBySurname', u.surname, 'updatedByName', u.name)) as jsonnotes
from enrollment_notes en
Expand Down Expand Up @@ -725,7 +725,6 @@ private List<Note> mapEnrollmentNotes(String jsonNotes) {
Note note = new Note();
note.setUid(jdbcNote.getUid());
note.setNoteText(jdbcNote.getText());
note.setCreator(jdbcNote.getCreator());
note.setCreated(DateUtils.safeParseDate(jdbcNote.getCreated()));
User user = new User();
user.setUid(jdbcNote.getUpdatedByUid());
Expand Down Expand Up @@ -791,7 +790,6 @@ public Set<String> getOrderableFields() {
private static class JdbcNote {
private String uid;
private String text;
private String creator;
private String created;
private String updatedByUid;
private String updatedByUsername;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,5 @@ Set<TrackedEntityAttributeValue> mapTrackedEntityAttributeValues(
@Mapping(target = "created")
@Mapping(target = "noteText")
@Mapping(target = "lastUpdatedBy")
@Mapping(target = "creator")
Note map(Note note);
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class JdbcSingleEventStore {
n.noteid as note_id,\
n.notetext as note_text,\
n.created as note_created,\
n.creator as note_creator,\
n.uid as note_uid,\
userinfo.userinfoid as note_user_id,\
userinfo.code as note_user_code,\
Expand Down Expand Up @@ -340,7 +339,6 @@ private List<SingleEvent> fetchEvents(SingleEventQueryParams queryParams, PagePa
note.setUid(resultSet.getString("note_uid"));
note.setNoteText(resultSet.getString("note_text"));
note.setCreated(resultSet.getTimestamp("note_created"));
note.setCreator(resultSet.getString("note_creator"));

if (resultSet.getObject("note_user_id") != null) {
User noteLastUpdatedBy = new User();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class JdbcTrackerEventStore {
n.noteid as note_id,\
n.notetext as note_text,\
n.created as note_created,\
n.creator as note_creator,\
n.uid as note_uid,\
userinfo.userinfoid as note_user_id,\
userinfo.code as note_user_code,\
Expand Down Expand Up @@ -362,7 +361,6 @@ private List<TrackerEvent> fetchEvents(
note.setUid(resultSet.getString("note_uid"));
note.setNoteText(resultSet.getString("note_text"));
note.setCreated(resultSet.getTimestamp("note_created"));
note.setCreator(resultSet.getString("note_creator"));

if (resultSet.getObject("note_user_id") != null) {
User noteLastUpdatedBy = new User();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ private TrackerObjectsMapper() {
dbNote.setUid(note.getNote().getValue());
dbNote.setCreated(now);
dbNote.setLastUpdatedBy(user);
dbNote.setCreator(note.getStoredBy());
dbNote.setNoteText(note.getValue());

return dbNote;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,4 @@ public class Note implements Serializable {
@Nonnull @JsonProperty private UID note;

@JsonProperty private String value;

@JsonProperty private String storedBy;
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ boolean exists(@Nonnull UID note) {
private long saveNote(@Nonnull Note note, @Nonnull UserDetails user) {
String sql =
"""
INSERT INTO public.note(noteid, notetext, creator, lastupdatedby, uid, created)
INSERT INTO public.note(noteid, notetext, lastupdatedby, uid, created)
VALUES (nextVal('note_sequence'),
:text,
:creator,
(select userinfoid from userinfo where uid = :lastUpdatedBy),
:uid,
:created)
Expand All @@ -127,7 +126,6 @@ private long saveNote(@Nonnull Note note, @Nonnull UserDetails user) {

MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("text", note.getValue());
params.addValue("creator", note.getStoredBy());
params.addValue("lastUpdatedBy", user.getUid());
params.addValue("uid", note.getNote().getValue());
params.addValue("created", new Date());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,6 @@ public static void assertNotes(List<Note> expected, List<Note> actual) {
expectedNote.getNoteText(),
actualNote.getNoteText(),
"noteText"),
() ->
assertEquals(
expectedNote.getCreator(),
actualNote.getCreator(),
"creator"),
() ->
assertEquals(
expectedNote.getCreated(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void shouldMapEnrollmentWhenItIsACreation() {
.occurredAt(YESTERDAY.toInstant())
.status(ACTIVE)
.storedBy(creatingUser.getUsername())
.notes(notes(creatingUser))
.notes(notes())
.attributeOptionCombo(MetadataIdentifier.EMPTY_UID)
.build();

Expand All @@ -235,7 +235,7 @@ void shouldMapEnrollmentWhenItIsACreationAndOccurredDateIsNull() {
.enrolledAt(NOW.toInstant())
.status(ACTIVE)
.storedBy(creatingUser.getUsername())
.notes(notes(creatingUser))
.notes(notes())
.attributeOptionCombo(MetadataIdentifier.EMPTY_UID)
.build();

Expand Down Expand Up @@ -263,7 +263,7 @@ void shouldMapEnrollmentWhenItIsAnUpdateAndEnrollmentGetCompleted() {
.enrolledAt(NOW.toInstant())
.status(EnrollmentStatus.COMPLETED)
.storedBy(creatingUser.getUsername())
.notes(notes(creatingUser))
.notes(notes())
.attributeOptionCombo(MetadataIdentifier.EMPTY_UID)
.build();

Expand Down Expand Up @@ -291,7 +291,7 @@ void shouldMapEnrollmentWhenItIsAnUpdateAndEnrollmentGetCancelled() {
.enrolledAt(NOW.toInstant())
.status(EnrollmentStatus.CANCELLED)
.storedBy(creatingUser.getUsername())
.notes(notes(creatingUser))
.notes(notes())
.attributeOptionCombo(MetadataIdentifier.EMPTY_UID)
.build();

Expand Down Expand Up @@ -319,7 +319,7 @@ void shouldMapEnrollmentWhenItIsAnUpdateAndEnrollmentGetUncompleted() {
.enrolledAt(NOW.toInstant())
.status(ACTIVE)
.storedBy(creatingUser.getUsername())
.notes(notes(creatingUser))
.notes(notes())
.attributeOptionCombo(MetadataIdentifier.EMPTY_UID)
.build();

Expand Down Expand Up @@ -367,7 +367,7 @@ void shouldMapEventWithNullCompletedDataWhenStatusIsActive() {
.program(MetadataIdentifier.ofUid(PROGRAM_UID))
.orgUnit(MetadataIdentifier.ofUid(ORGANISATION_UNIT_UID))
.attributeOptionCombo(MetadataIdentifier.EMPTY_UID)
.notes(notes(creatingUser))
.notes(notes())
.build();

TrackerEvent result = TrackerObjectsMapper.map(preheat, event, updatingUser);
Expand All @@ -393,7 +393,7 @@ void shouldMapEventWhenStatusIsCompleted() {
.program(MetadataIdentifier.ofUid(PROGRAM_UID))
.orgUnit(MetadataIdentifier.ofUid(ORGANISATION_UNIT_UID))
.attributeOptionCombo(MetadataIdentifier.EMPTY_UID)
.notes(notes(creatingUser))
.notes(notes())
.build();

TrackerEvent result = TrackerObjectsMapper.map(preheat, event, updatingUser);
Expand Down Expand Up @@ -424,7 +424,7 @@ void shouldMapEventWhenAssignedUserIsPresent() {
.program(MetadataIdentifier.ofUid(PROGRAM_UID))
.orgUnit(MetadataIdentifier.ofUid(ORGANISATION_UNIT_UID))
.attributeOptionCombo(MetadataIdentifier.EMPTY_UID)
.notes(notes(creatingUser))
.notes(notes())
.assignedUser(user)
.build();

Expand Down Expand Up @@ -455,7 +455,7 @@ void shouldMapEventWhenCategoryOptionComboIsPresent() {
.program(MetadataIdentifier.ofUid(PROGRAM_UID))
.orgUnit(MetadataIdentifier.ofUid(ORGANISATION_UNIT_UID))
.attributeOptionCombo(MetadataIdentifier.EMPTY_UID)
.notes(notes(creatingUser))
.notes(notes())
.assignedUser(user)
.attributeOptionCombo(MetadataIdentifier.ofUid(COC_UID))
.build();
Expand Down Expand Up @@ -635,7 +635,6 @@ private void assertNotes(
.orElse(null);
assertNotNull(dbNote);
assertEquals(note.getValue(), dbNote.getNoteText());
assertEquals(note.getStoredBy(), dbNote.getCreator());
assertEquals(updatedBy.getUid(), dbNote.getLastUpdatedBy().getUid());
}
}
Expand Down Expand Up @@ -698,12 +697,11 @@ private TrackerEvent event(EventStatus status) {
return dbEvent;
}

private List<org.hisp.dhis.tracker.imports.domain.Note> notes(UserDetails user) {
private List<org.hisp.dhis.tracker.imports.domain.Note> notes() {
return List.of(
org.hisp.dhis.tracker.imports.domain.Note.builder()
.note(NOTE_UID)
.value("This is a note")
.storedBy(user.getUsername())
.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ public interface NoteMapper {
@Mapping(target = "storedAt", source = "created")
@Mapping(target = "value", source = "noteText")
@Mapping(target = "createdBy", source = "lastUpdatedBy")
@Mapping(target = "storedBy", source = "creator")
Note map(org.hisp.dhis.note.Note note);
}
Loading
Loading