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/converters/SubmissionMatchDetailEntityBeforeConvert.java b/backend/src/main/java/ca/bc/gov/app/converters/SubmissionMatchDetailEntityBeforeConvert.java index 9236b3f99f..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 @@ -1,16 +1,15 @@ 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; import io.r2dbc.postgresql.codec.Json; import java.util.Map; +import java.util.Objects; import java.util.Optional; 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,12 +59,12 @@ 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 -> Objects.toString(value, "{}")) .map(value -> { try { return mapper.readValue(value, Map.class); @@ -77,4 +76,5 @@ private Map convertFrom(SubmissionMatchDetailEntity entity) { .map(value -> (Map) value) .orElse(Map.of()); } + } \ No newline at end of file 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(); } - } 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