Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSADT1-961: Code reviews #671

Merged
merged 5 commits into from
Dec 11, 2023
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
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -62,6 +59,7 @@ private Json convertTo(EmailLogEntity entity) {

}

@SuppressWarnings("unchecked")
private Map<String, Object> convertFrom(EmailLogEntity entity) {
return
Optional
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -60,12 +59,12 @@ private Json convertTo(SubmissionMatchDetailEntity entity) {

}

@SuppressWarnings("unchecked")
private Map<String, Object> 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);
Expand All @@ -77,4 +76,5 @@ private Map<String, Object> convertFrom(SubmissionMatchDetailEntity entity) {
.map(value -> (Map<String, Object>) value)
.orElse(Map.of());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
}


}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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
Expand Down
Loading