From 4af4d113d17ea8cb4a9f6395c7162fd228acef2e Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 11 Dec 2023 11:15:41 -0800 Subject: [PATCH 1/5] Replaced deprecated function --- ...missionMatchDetailEntityBeforeConvert.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java b/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java index 9236b3f99f..3a5ce5ce7e 100644 --- a/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java +++ b/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java @@ -1,6 +1,5 @@ package ca.bc.gov.app.converters; - import ca.bc.gov.app.entity.client.SubmissionMatchDetailEntity; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -10,7 +9,6 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.reactivestreams.Publisher; import org.springframework.data.r2dbc.mapping.event.AfterConvertCallback; import org.springframework.data.r2dbc.mapping.event.BeforeConvertCallback; @@ -60,21 +58,22 @@ private Json convertTo(SubmissionMatchDetailEntity entity) { } + @SuppressWarnings("unchecked") private Map convertFrom(SubmissionMatchDetailEntity entity) { - return - Optional + return Optional .ofNullable(entity.getMatchingField()) .map(Json::asString) - .map(value -> StringUtils.defaultString(value, "{}")) + .map(value -> (value != null) ? value : "{}") .map(value -> { - try { - return mapper.readValue(value, Map.class); - } catch (JsonProcessingException e) { - log.error("Error while converting matchers to json", e); - return Map.of(); - } + try { + return mapper.readValue(value, Map.class); + } catch (JsonProcessingException e) { + log.error("Error while converting matchers to json", e); + return Map.of(); + } }) .map(value -> (Map) value) .orElse(Map.of()); } + } \ No newline at end of file From e450028a2e62765ba5f399fb9ee87625001de4c6 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 11 Dec 2023 11:18:41 -0800 Subject: [PATCH 2/5] Made code reviews --- .../app/converters/EmailLogEntityJsonConvert.java | 4 +--- .../ca/bc/gov/app/job/ches/ChesEmailResendJob.java | 14 ++++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/converters/EmailLogEntityJsonConvert.java b/backend/src/main/java/ca/bc/gov/app/converters/EmailLogEntityJsonConvert.java index 1d4605bf16..12683f175d 100644 --- a/backend/src/main/java/ca/bc/gov/app/converters/EmailLogEntityJsonConvert.java +++ b/backend/src/main/java/ca/bc/gov/app/converters/EmailLogEntityJsonConvert.java @@ -1,8 +1,6 @@ package ca.bc.gov.app.converters; - import ca.bc.gov.app.entity.client.EmailLogEntity; -import ca.bc.gov.app.entity.client.SubmissionMatchDetailEntity; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import io.r2dbc.postgresql.codec.Json; @@ -12,7 +10,6 @@ import lombok.NonNull; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; import org.reactivestreams.Publisher; import org.springframework.data.r2dbc.mapping.event.AfterConvertCallback; import org.springframework.data.r2dbc.mapping.event.BeforeConvertCallback; @@ -62,6 +59,7 @@ private Json convertTo(EmailLogEntity entity) { } + @SuppressWarnings("unchecked") private Map convertFrom(EmailLogEntity entity) { return Optional diff --git a/backend/src/main/java/ca/bc/gov/app/job/ches/ChesEmailResendJob.java b/backend/src/main/java/ca/bc/gov/app/job/ches/ChesEmailResendJob.java index dd6eb0930b..40a8f64789 100644 --- a/backend/src/main/java/ca/bc/gov/app/job/ches/ChesEmailResendJob.java +++ b/backend/src/main/java/ca/bc/gov/app/job/ches/ChesEmailResendJob.java @@ -2,10 +2,8 @@ import ca.bc.gov.app.repository.client.EmailLogRepository; import ca.bc.gov.app.service.ches.ChesService; -import java.util.concurrent.Executors; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @@ -24,14 +22,14 @@ public void startResendJob() { .doOnNext(emailLogEntity -> log.info("Resending failed email with ID: " + emailLogEntity.getEmailLogId()) ) - .flatMap(emailLogEntity -> chesService.sendEmail(emailLogEntity.getTemplateName(), - emailLogEntity.getEmailAddress(), - emailLogEntity.getEmailSubject(), - emailLogEntity.getVariables(), - emailLogEntity.getEmailLogId() + .flatMap(emailLogEntity -> chesService.sendEmail( + emailLogEntity.getTemplateName(), + emailLogEntity.getEmailAddress(), + emailLogEntity.getEmailSubject(), + emailLogEntity.getVariables(), + emailLogEntity.getEmailLogId() ) ).subscribe(); } - } From 6f86806aac72abbdce0a03bd6870c974e9324203 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 11 Dec 2023 11:29:03 -0800 Subject: [PATCH 3/5] Updated comments on email log table/columns --- .../db/migration/V1__initializing_data.sql | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/src/main/resources/db/migration/V1__initializing_data.sql b/backend/src/main/resources/db/migration/V1__initializing_data.sql index e61eaef4b0..2cadc0df9d 100644 --- a/backend/src/main/resources/db/migration/V1__initializing_data.sql +++ b/backend/src/main/resources/db/migration/V1__initializing_data.sql @@ -1,5 +1,5 @@ -- --- DROPPING TABLES AND SEQUENCES IF EXIST AS THIS IS THE INIT FILE TO CREATE THE DB +-- DROPPING TABLES AND SEQUENCES IF EXIST AS THIS is THE INIT FILE TO CREATE THE DB -- drop table if exists nrfc.submission_detail; drop table if exists nrfc.submission_matching_detail; @@ -335,9 +335,17 @@ create table if not exists nrfc.email_log ( constraint email_log_id_pk primary key (email_log_id) ); -comment on table nrfc.email_log is 'TODO'; +comment on table nrfc.email_log is 'Stores email log information'; comment on column nrfc.email_log.email_log_id is 'Incremental id generated for a submission email log.'; --- TODO: Complete comments +comment on column nrfc.email_log.email_id is 'Identifier for the associated email assigned by CHES (if applicable).'; +comment on column nrfc.email_log.email_sent_ind is 'Indicator for whether the email has been sent (''Y'' for Yes, ''N'' for No).'; +comment on column nrfc.email_log.exception_message is 'Textual message describing any exceptions that occurred during email processing.'; +comment on column nrfc.email_log.template_name is 'Name of the email template used for sending the email.'; +comment on column nrfc.email_log.email_address is 'Email address to which the email is sent.'; +comment on column nrfc.email_log.email_subject is 'Subject of the email.'; +comment on column nrfc.email_log.email_variables is 'JSONB field to store variables related to the email content.'; +comment on column nrfc.email_log.create_timestamp is 'Timestamp indicating when the email log entry was created.'; +comment on column nrfc.email_log.update_timestamp is 'Timestamp indicating when the email log entry was last updated.'; -- -- SEQUENCES From 8d793aea2ae5ae5fe648a98c0d477c58d24c77d3 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 11 Dec 2023 12:00:51 -0800 Subject: [PATCH 4/5] Swtiched to Objects.toString --- .../converters/SubmissionMatchDetailEntityBeforeConvert.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java b/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java index 3a5ce5ce7e..437ec91e15 100644 --- a/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java +++ b/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.r2dbc.postgresql.codec.Json; import java.util.Map; +import java.util.Objects; import java.util.Optional; import lombok.NonNull; import lombok.RequiredArgsConstructor; @@ -63,7 +64,7 @@ private Map convertFrom(SubmissionMatchDetailEntity entity) { return Optional .ofNullable(entity.getMatchingField()) .map(Json::asString) - .map(value -> (value != null) ? value : "{}") + .map(value -> Objects.toString(value, "{}")) .map(value -> { try { return mapper.readValue(value, Map.class); From 1683b4df979eb617940368e8bf96845a31612761 Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 11 Dec 2023 12:04:39 -0800 Subject: [PATCH 5/5] no message --- .../SubmissionMatchDetailEntityBeforeConvert.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java b/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java index 437ec91e15..c62939082c 100644 --- a/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java +++ b/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java @@ -66,12 +66,12 @@ private Map convertFrom(SubmissionMatchDetailEntity entity) { .map(Json::asString) .map(value -> Objects.toString(value, "{}")) .map(value -> { - try { - return mapper.readValue(value, Map.class); - } catch (JsonProcessingException e) { - log.error("Error while converting matchers to json", e); - return Map.of(); - } + try { + return mapper.readValue(value, Map.class); + } catch (JsonProcessingException e) { + log.error("Error while converting matchers to json", e); + return Map.of(); + } }) .map(value -> (Map) value) .orElse(Map.of());