From 1b7a1dcaefe2212bf16f233e354c10ebcb5a166a Mon Sep 17 00:00:00 2001 From: Russell Dodd Date: Mon, 18 Mar 2024 15:22:49 +0000 Subject: [PATCH] Return business unit id in addNote response, when available. --- .../java/uk/gov/hmcts/opal/service/opal/NoteService.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/uk/gov/hmcts/opal/service/opal/NoteService.java b/src/main/java/uk/gov/hmcts/opal/service/opal/NoteService.java index b6e4bf6c9..ec3010148 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/opal/NoteService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/opal/NoteService.java @@ -38,8 +38,9 @@ public NoteDto saveNote(NoteDto noteDto) { String postedBy = Optional.ofNullable(noteDto.getPostedBy()) .map(s -> StringUtils.substring(s, 0, 20)).orElse(null); noteDto.setPostedBy(postedBy); + Short businessUnitId = noteDto.getBusinessUnitId(); - return toNoteDto(noteRepository.save(toNoteEntity(noteDto))); + return toNoteDto(noteRepository.save(toNoteEntity(noteDto)), businessUnitId); } @Override @@ -52,7 +53,7 @@ public List searchNotes(NoteSearchDto criteria) { ffq -> ffq.sortBy(dateSort).page(Pageable.unpaged())); List noteDtos = notesPage.getContent().stream() - .map(this::toNoteDto) + .map(entity -> toNoteDto(entity, null)) .collect(Collectors.toList()); return noteDtos; @@ -70,12 +71,13 @@ public NoteEntity toNoteEntity(NoteDto noteDto) { .build(); } - public NoteDto toNoteDto(NoteEntity entity) { + public NoteDto toNoteDto(NoteEntity entity, Short businessUnitId) { return NoteDto.builder() .noteId(entity.getNoteId()) // This will be the generated ID .noteType(entity.getNoteType()) .associatedRecordType(entity.getAssociatedRecordType()) .associatedRecordId(entity.getAssociatedRecordId()) + .businessUnitId(businessUnitId) .noteText(entity.getNoteText()) .postedDate(entity.getPostedDate()) .postedBy(entity.getPostedBy())