Commit 2f51744c authored by Kristel Meikas's avatar Kristel Meikas
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Kristel Meikas

See merge request teis/riskassessments-service!146
parents 0a588f3e 57638fa1
# Changelog
## [1.5.0] - 2021-09-27
* TEIS-2422: updated risk assessment pdf texts
* TEIS-2394: updated risk assessment pdf generation based on review
* TEIS-2379: added methods to get risk statements by risk factor id
* TEIS-2378: updated getRiskFactors method to include optional parameter businessTypeId
* TEIS-2300: removed privilege validation from getBusinessTypes request
* TEIS-2380: updated risk assessment pdf generation
## [1.4.1] - 2021-09-14
* TEIS-2420: TEIS-2420: created_at and modified_at indexes for risk assessment related tables due to queries from odata
......
......@@ -53,8 +53,4 @@ allprojects {
}
apply from: this.getClass().getClassLoader().getResource('teis.test-sonar.gradle')
dependencies {
implementation "org.springframework.boot:spring-boot-starter-cache:2.4.3"
}
}
theGroup=ee.sm.ti.teis
theVersion=1.4.1
commonsVersion=1.23.0
officeApiGatewayVersion=1.23.0
filesVersion=1.19.0
theVersion=1.5.0
commonsVersion=1.27.0
officeApiGatewayVersion=1.27.0
filesVersion=1.21.0
pluginVersion=1.3.0
......@@ -18,6 +18,7 @@ dependencies {
implementation "ee.sm.ti.teis:office-api-gateway-lib:${officeApiGatewayVersion}"
implementation "ee.sm.ti.teis:files-client-lib:${commonsVersion}"
implementation "ee.sm.ti.teis:files-service-lib:${filesVersion}"
implementation "org.springframework.boot:spring-boot-starter-cache:2.4.3"
integTestImplementation "ee.sm.ti.teis:domain-cache-lib:${commonsVersion}"
integTestImplementation "ee.sm.ti.teis:service-common-lib:${commonsVersion}"
......
......@@ -20,7 +20,6 @@ import static ee.sm.ti.teis.types.enums.ObjectStatus.CURRENT;
import static ee.sm.ti.teis.types.enums.RolePrivilegeCode.EX_VIEW_RISK_ASSESSMENTS;
import static ee.sm.ti.teis.types.enums.RolePrivilegeCode.TI_VIEW_RISK_ASSESSMENTS;
import static ee.sm.ti.teis.types.enums.classifier.RiskSettingsStatus.ACTIVE;
import static ee.sm.ti.teis.utils.TestUtils.assertResponseForbidden;
import static ee.sm.ti.teis.utils.TestUtils.createRequestMeta;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
......@@ -74,26 +73,6 @@ public class BusinessTypesPublicGwListenerTest extends RiskAssessmentsAppTestBas
assertThat(dto.getObjectStatus()).isEqualTo(CURRENT);
}
@Test
public void getBusinessTypes_isPersonType_wrongPrivilege_forbidden() {
request.getRequestMetaDTO().setUserType(PERSON);
request.getRequestMetaDTO().setPrivileges(List.of(TI_VIEW_RISK_ASSESSMENTS.name()));
BusinessTypesPublicResponse response = listener.getBusinessTypes(request);
assertResponseForbidden(response.getError());
}
@Test
public void getBusinessTypes_isOfficialType_wrongPrivilege_forbidden() {
request.getRequestMetaDTO().setUserType(OFFICIAL_USER);
request.getRequestMetaDTO().setPrivileges(List.of(EX_VIEW_RISK_ASSESSMENTS.name()));
BusinessTypesPublicResponse response = listener.getBusinessTypes(request);
assertResponseForbidden(response.getError());
}
@Test
public void getBusinessTypes_includeInactive_success() {
request.getRequestMetaDTO().setUserType(PERSON);
......
......@@ -2,13 +2,13 @@ package ee.sm.ti.teis.riskassessments.riskassessment;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.RiskAssessmentsAppTestBase;
import ee.sm.ti.teis.cache.person.PersonService;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.RiskAssessmentPublicDto;
import ee.sm.ti.teis.domain.person.Person;
import ee.sm.ti.teis.officegateway.riskassessments.riskassessment.dto.CreateRiskAssessmentOfficeDto;
import ee.sm.ti.teis.officegateway.riskassessments.riskassessment.request.CreateRiskAssessmentOfficeRequest;
import ee.sm.ti.teis.officegateway.riskassessments.riskassessment.response.CreateRiskAssessmentOfficeResponse;
import ee.sm.ti.teis.riskassessments.riskassessment.listener.RiskAssessmentOfficeGwListener;
import ee.sm.ti.teis.riskassessments.serviceclient.PersonServiceClient;
import ee.sm.ti.teis.servicecommon.test.ListenerCreateRequestTestBase;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.BeforeEach;
......@@ -66,7 +66,7 @@ public class CreateRiskAssessmentOfficeGwListenerTest extends RiskAssessmentsApp
@Test
@Transactional
public void create_minimumData_success() {
PersonServiceClient.PersonResponseMessage personResponse = new PersonServiceClient.PersonResponseMessage();
PersonService.PersonResponse personResponse = new PersonService.PersonResponse();
Person person = Person.builder().id(employerId).build();
personResponse.setPayload(person, new RequestMetaDTO());
doReturn(personResponse)
......@@ -152,7 +152,7 @@ public class CreateRiskAssessmentOfficeGwListenerTest extends RiskAssessmentsApp
@Test
public void createRiskAssessment_employerIdNotExists_notFound() {
PersonServiceClient.PersonResponseMessage personResponse = new PersonServiceClient.PersonResponseMessage();
PersonService.PersonResponse personResponse = new PersonService.PersonResponse();
ErrorDTO errorDTO = new ErrorDTO();
errorDTO.setCode(RESOURCE_NOT_FOUND.getCode());
personResponse.setError(errorDTO);
......
package ee.sm.ti.teis.riskassessments.riskassessment;
import ee.sm.ti.teis.RiskAssessmentsAppTestBase;
import ee.sm.ti.teis.cache.person.PersonService;
import ee.sm.ti.teis.commongateway.docgen.dto.GeneratedDocumentDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.RiskAssessmentPdfDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.request.RiskAssessmentPDFRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.response.GetRiskAssessmentPDFResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.response.GetRiskAssessmentPDFTestResponse;
import ee.sm.ti.teis.domain.docgen.GeneratedDocument;
import ee.sm.ti.teis.domain.person.LegalPerson;
import ee.sm.ti.teis.domain.person.Person;
import ee.sm.ti.teis.domain.signing.SignFileStream;
import ee.sm.ti.teis.riskassessments.riskassessment.listener.RiskAssessmentPublicGwListener;
import ee.sm.ti.teis.riskassessments.serviceclient.DocGenServiceClient;
import ee.sm.ti.teis.riskassessments.serviceclient.SigningServiceClient;
import ee.sm.ti.teis.servicecommon.test.ListenerGetObjectRequestTestBase;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.UUID;
import static ee.sm.ti.teis.servicerequest.UserType.PERSON;
import static ee.sm.ti.teis.types.enums.RolePrivilegeCode.EX_MANAGE_ACCIDENT;
import static ee.sm.ti.teis.types.enums.RolePrivilegeCode.EX_MANAGE_RISK_ASSESSMENTS;
import static ee.sm.ti.teis.utils.TestUtils.*;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
public class GetRiskAssessmentPdfPublicGwListenerTest extends RiskAssessmentsAppTestBase implements ListenerGetObjectRequestTestBase {
private static final UUID RISK_ASSESSMENT_ID = UUID.fromString("faf5868f-00ae-4d41-a3c1-d8738d5ae624");
private static final UUID EMPLOYER_ID = UUID.fromString("69a31369-f74d-404d-a221-ba7d30bf3455");
private static final String DOMAIN_GET_PERSON = "domain.Person.request";
private static final String ASICE_CONTENT_TYPE = "application/vnd.etsi.asic-e+zip";
@Autowired
RiskAssessmentPublicGwListener listener;
@Autowired
RabbitTemplate msRabbitTemplate;
RiskAssessmentPDFRequest pdfRequest;
RequestMetaDTO requestMetaDTO;
@BeforeEach
void setUp() {
pdfRequest = new RiskAssessmentPDFRequest();
requestMetaDTO = createRequestMeta(randomUUID().toString(), PERSON, EMPLOYER_ID.toString(),
List.of(EX_MANAGE_RISK_ASSESSMENTS.name()));
pdfRequest.setRequestMetaDTO(requestMetaDTO);
PersonService.PersonResponse personResponse = new PersonService.PersonResponse();
LegalPerson legalPerson = LegalPerson.builder().name("Subaru Auto AS").regCode("12197746").build();
Person person = Person.builder().legalPerson(legalPerson).id(EMPLOYER_ID).build();
personResponse.setPayload(person, new RequestMetaDTO());
doReturn(personResponse)
.when(msRabbitTemplate).convertSendAndReceiveAsType(eq(DOMAIN_GET_PERSON), any(Object.class), any());
}
@Test
public void getObjectData_success() {
pdfRequest.setPayload(RISK_ASSESSMENT_ID, requestMetaDTO);
GetRiskAssessmentPDFTestResponse response = listener.getPDFTest(pdfRequest);
RiskAssessmentPdfDto payload = response.getPayload();
assertThat(payload.getTitle()).isEqualTo("Subaru risk assessment (in_progress)");
assertThat(payload.getEmployerName()).isEqualTo("Subaru Auto AS");
assertThat(payload.getRegCode()).isEqualTo("12197746");
assertThat(payload.getStatus()).isEqualTo("Pooleli");
assertThat(payload.getArchivedDate()).isNull();
assertThat(payload.getPublishedDate()).isNull();
assertThat(payload.getPrimaryBusinessType()).isEqualTo("TEST shop");
assertThat(payload.getSecondaryBusinessTypes()).isEqualTo("TEST y-demolition");
assertThat(payload.getCategories()).isNotEmpty();
assertThat(payload.getCategories().get(0).getRiskFactors()).isNotEmpty();
assertThat(payload.getCategories().get(0).getName()).isEqualTo("Täiendavad ohud");
assertThat(payload.getCategories().get(0).getRiskFactors().get(1).getName()).isEqualTo("TEST risk statements test name");
}
@Test
@Override
public void getObject_success() {
GeneratedDocument generatedDocument = GeneratedDocument.builder()
.docName("doc.pdf")
.templateId("RISK_ASSESSMENT_PDF")
.contentType("application/pdf")
.content("content".getBytes(StandardCharsets.UTF_8))
.build();
DocGenServiceClient.PreviewDocumentMsResponse documentResponse = new DocGenServiceClient.PreviewDocumentMsResponse();
documentResponse.setPayload(generatedDocument, requestMetaDTO);
doReturn(documentResponse)
.when(msRabbitTemplate)
.convertSendAndReceiveAsType(eq("domain.GenerateDocument.generatedPreview"), any(Object.class), any());
SignFileStream signedDocument = SignFileStream.builder()
.fileName("doc.asice")
.contentType(ASICE_CONTENT_TYPE)
.content("content".getBytes(StandardCharsets.UTF_8))
.build();
SigningServiceClient.FileStreamSignedMsResponse fileSignedResponse = new SigningServiceClient.FileStreamSignedMsResponse();
fileSignedResponse.setPayload(signedDocument, requestMetaDTO);
doReturn(fileSignedResponse)
.when(msRabbitTemplate)
.convertSendAndReceiveAsType(eq("domain.SignFileStream.create"), any(Object.class), any());
pdfRequest.setPayload(RISK_ASSESSMENT_ID, requestMetaDTO);
GetRiskAssessmentPDFResponse response = listener.getPDF(pdfRequest);
GeneratedDocumentDto payload = response.getPayload();
assertThat(payload.getTemplateId()).isEqualTo("RISK_ASSESSMENT_PDF");
assertThat(payload.getDocName()).isEqualTo("doc.asice");
assertThat(payload.getContent()).isNotEmpty();
}
@Override
@Test
public void getObject_idNotExists_notFound() {
pdfRequest.setPayload(UUID.randomUUID(), requestMetaDTO);
GetRiskAssessmentPDFTestResponse response = listener.getPDFTest(pdfRequest);
assertResponseNotFound(response.getError());
}
@Override
public void getObject_objectStatusDeleted_success() {
// not applicable
}
@Override
@Test
public void missingPrivilege_forbidden() {
requestMetaDTO.setPrivileges(List.of(EX_MANAGE_ACCIDENT.name()));
pdfRequest.setPayload(RISK_ASSESSMENT_ID, requestMetaDTO);
GetRiskAssessmentPDFResponse response = listener.getPDF(pdfRequest);
assertResponseForbidden(response.getError());
}
@Override
public void wrongUserType_forbidden() {
// not applicable
}
}
package ee.sm.ti.teis.riskassessments.riskfactor;
import ee.sm.ti.teis.RiskAssessmentsAppTestBase;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactor.dto.GetRiskFactorsPublicRequestDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactor.dto.RiskFactorPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactor.request.RiskFactorsPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactor.response.RiskFactorsPublicResponse;
......@@ -37,9 +38,12 @@ public class RiskFactorsPublicGwListenerTest extends RiskAssessmentsAppTestBase
RiskFactorsPublicRequest request;
RequestMetaDTO requestMetaDTO;
GetRiskFactorsPublicRequestDto requestDto;
RiskFactorsPublicResponse response;
@BeforeEach
void setUp() {
requestDto = GetRiskFactorsPublicRequestDto.builder().build();
request = new RiskFactorsPublicRequest();
requestMetaDTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER, randomUUID().toString(),
List.of(TI_VIEW_RISK_ASSESSMENTS.name()));
......@@ -48,7 +52,8 @@ public class RiskFactorsPublicGwListenerTest extends RiskAssessmentsAppTestBase
@Test
public void getRiskFactors_success() {
RiskFactorsPublicResponse response = listener.getRiskFactors(request);
request.setPayload(requestDto, requestMetaDTO);
response = listener.getRiskFactors(request);
List<RiskFactorPublicDto> dtoList = response.getPayload();
......@@ -86,8 +91,9 @@ public class RiskFactorsPublicGwListenerTest extends RiskAssessmentsAppTestBase
@Test
public void getRiskFactors_includeInactive_success() {
request.setPayload(true, requestMetaDTO);
RiskFactorsPublicResponse response = listener.getRiskFactors(request);
requestDto.setIncludeInactive(true);
request.setPayload(requestDto, requestMetaDTO);
response = listener.getRiskFactors(request);
List<RiskFactorPublicDto> dtoList = response.getPayload();
......@@ -97,4 +103,36 @@ public class RiskFactorsPublicGwListenerTest extends RiskAssessmentsAppTestBase
.extracting("id")
.contains(UUID.fromString("e8e6ce28-010b-4715-bad5-cbd7e8384294"));
}
@Test
public void getActiveRiskFactors_byBusinessTypeId_success() {
requestDto.setIncludeInactive(false);
requestDto.setBusinessTypeId(UUID.fromString("ab5fee67-85e0-410a-a1b4-1dd12c9ab730"));
request.setPayload(requestDto, requestMetaDTO);
response = listener.getRiskFactors(request);
List<RiskFactorPublicDto> dtoList = response.getPayload();
assertThat(dtoList.size()).isGreaterThanOrEqualTo(1);
assertThat(dtoList.stream()
.filter(dto -> INACTIVE.getCode().equals(dto.getStatus().getCode()))
.count()).isEqualTo(0);
}
@Test
public void getAllRiskFactors_byBusinessTypeId_success() {
requestDto.setIncludeInactive(true);
requestDto.setBusinessTypeId(UUID.fromString("ab5fee67-85e0-410a-a1b4-1dd12c9ab730"));
request.setPayload(requestDto, requestMetaDTO);
response = listener.getRiskFactors(request);
List<RiskFactorPublicDto> dtoList = response.getPayload();
assertThat(dtoList.size()).isGreaterThanOrEqualTo(1);
assertThat(dtoList.stream()
.filter(dto -> INACTIVE.getCode().equals(dto.getStatus().getCode()))
.count()).isGreaterThan(0);
}
}
package ee.sm.ti.teis.riskassessments.riskstatement;
import ee.sm.ti.teis.RiskAssessmentsAppTestBase;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatement.RiskStatementPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatement.request.GetRiskStatementsByRiskFactorPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatement.response.GetRiskStatementsByRiskFactorPublicResponse;
import ee.sm.ti.teis.servicecommon.test.ListenerGetListRequestTestBase;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.UUID;
import static ee.sm.ti.teis.servicerequest.UserType.OFFICIAL_USER;
import static ee.sm.ti.teis.types.enums.RolePrivilegeCode.TI_MANAGE_RISK_ASSESSMENTS;
import static ee.sm.ti.teis.types.enums.classifier.RiskSettingsStatus.INACTIVE;
import static ee.sm.ti.teis.utils.TestUtils.assertResponseNotFound;
import static ee.sm.ti.teis.utils.TestUtils.createRequestMeta;
import static java.util.UUID.randomUUID;
import static org.assertj.core.api.Assertions.assertThat;
public class GetRiskStatementPublicGwListenerTest extends RiskAssessmentsAppTestBase implements ListenerGetListRequestTestBase {
private static final UUID ACTIVE_RISK_FACTOR_ID = UUID.fromString("06480220-b90d-492b-ac6e-745949039b1a");
private static final UUID NO_RISK_STATEMENTS_RISK_FACTOR_ID = UUID.fromString("a17282ef-012c-4360-a999-f75bd199d06c");
@Autowired
RiskStatementPublicGwListener listener;
GetRiskStatementsByRiskFactorPublicRequest request;
GetRiskStatementsByRiskFactorPublicResponse response;
RequestMetaDTO requestMetaDTO;
@BeforeEach
void setUp() {
request = new GetRiskStatementsByRiskFactorPublicRequest();
requestMetaDTO = createRequestMeta(randomUUID().toString(), OFFICIAL_USER, randomUUID().toString(),
List.of(TI_MANAGE_RISK_ASSESSMENTS.name()));
}
@Override
public void getObjects_deletedRelatedObjectsExcluded_success() {
//not applicable
}
@Override
@Test
public void getObjects_success() {
request.setPayload(ACTIVE_RISK_FACTOR_ID, requestMetaDTO);
response = listener.getRiskStatementSByRiskFactorId(request);
List<RiskStatementPublicDto> payload = response.getPayload();
assertThat(payload).isNotEmpty();
assertThat(payload.stream()
.filter(dto -> INACTIVE.getCode().equals(dto.getStatus().getCode()))
.count()).isEqualTo(0);
}
@Override
@Test
public void getObjects_noResult_success() {
request.setPayload(NO_RISK_STATEMENTS_RISK_FACTOR_ID, requestMetaDTO);
response = listener.getRiskStatementSByRiskFactorId(request);
List<RiskStatementPublicDto> payload = response.getPayload();
assertThat(payload).isEmpty();
}
@Test
public void getObjects_invalidId_notFound() {
request.setPayload(UUID.randomUUID(), requestMetaDTO);
response = listener.getRiskStatementSByRiskFactorId(request);
assertResponseNotFound(response.getError());
}
@Override
public void missingPrivilege_forbidden() {
//not applicable
}
@Override
public void wrongUserType_forbidden() {
//not applicable
}
}
......@@ -30,7 +30,6 @@ import static ee.sm.ti.teis.logging.LoggingHelper.logAdminAlertMessage;
import static ee.sm.ti.teis.servicerequest.UserType.SYSTEM;
import static ee.sm.ti.teis.types.enums.FileScanStatusType.CLEAN;
import static ee.sm.ti.teis.types.enums.FileStatusType.*;
import static ee.sm.ti.teis.types.enums.ObjectStatus.CURRENT;
import static java.util.Collections.emptyList;
import static java.util.UUID.randomUUID;
import static liquibase.util.file.FilenameUtils.getBaseName;
......@@ -72,7 +71,7 @@ public class InitialFileUploadService {
filesInFolder.forEach(file -> {
UUID fileId = UUID.fromString(getBaseName(file.getName()));
fileReferenceRepository.findByFileIdAndObjectTypeAndObjectStatus(fileId, objectType.getId(), CURRENT)
fileReferenceRepository.findByIdAndObjectType(fileId, objectType.getId())
.ifPresentOrElse(
fileReference -> {
if (PENDING.equals(fileReference.getFileStatus()) || ACTIVE.equals(fileReference.getFileStatus())) {
......
......@@ -19,7 +19,7 @@ import static java.util.Collections.emptyList;
@Component
@Aspect
@RequiredArgsConstructor
@Profile("local & !integtest")
@Profile("!local & !integtest")
public class RiskAssessmentEnabledAspect {
private static final String RISK_ASSESSMENTS_FEATURE_FLAG = "riskassessments";
......@@ -40,4 +40,4 @@ public class RiskAssessmentEnabledAspect {
}
}
}
\ No newline at end of file
}
......@@ -26,8 +26,6 @@ public class BusinessTypePublicGwListener {
private final BusinessTypePublicBusinessService service;
@RabbitListener(queues = {GW_BUSINESS_TYPES_QUEUE})
@PreAuthorize("@accessController.hasAnyPrivilege('TI_VIEW_RISK_ASSESSMENTS', #request.requestMetaDTO.companyId, " +
"'EX_VIEW_RISK_ASSESSMENTS', null)")
public BusinessTypesPublicResponse getBusinessTypes(BusinessTypesPublicRequest request) {
RequestMetaDTO requestMetaDTO = request.getRequestMetaDTO();
List<BusinessTypePublicLightDto> dtoList = service.getBusinessTypes(request.getPayload(), requestMetaDTO);
......
......@@ -8,6 +8,8 @@ import ee.sm.ti.teis.cache.classifier.ClassifierItemCacheUpdateService.Classifie
import ee.sm.ti.teis.cache.classifier.ClassifierItemCacheUpdateService.ClassifierItemCreatedDTO;
import ee.sm.ti.teis.cache.classifier.ClassifierItemCacheUpdateService.ClassifierItemReinitializeDTO;
import ee.sm.ti.teis.cache.classifier.ClassifierItemCacheUpdateService.ClassifierItemUpdatedDTO;
import ee.sm.ti.teis.cache.person.IndividualPersonCacheUpdateService;
import ee.sm.ti.teis.cache.person.LegalPersonCacheUpdateService;
import ee.sm.ti.teis.configuration.DomainCacheList;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
......@@ -23,11 +25,15 @@ public class RiskAssessmentDomainCacheConfig implements DomainCacheList {
private final ClassifierItemCacheUpdateService classifierItemCacheUpdateService;
private final ClassifierDefinitionCacheUpdateService classifierDefinitionCacheUpdateService;
private final LegalPersonCacheUpdateService legalPersonCacheUpdateService;
private final IndividualPersonCacheUpdateService individualPersonCacheUpdateService;
@Override
public Set<BaseCacheUpdateService> cacheUpdateServices() {
return Set.of(classifierItemCacheUpdateService,
classifierDefinitionCacheUpdateService);
classifierDefinitionCacheUpdateService,
legalPersonCacheUpdateService,
individualPersonCacheUpdateService);
}
@RabbitListener(queues = "#{@classifierItemCacheUpdateService.cacheResponseQueueName}")
......@@ -64,4 +70,57 @@ public class RiskAssessmentDomainCacheConfig implements DomainCacheList {
public void classifierItemDeletedEvent(ClassifierItemCacheUpdateService.ClassifierItemDeletedDTO updatedDTO) {
classifierItemCacheUpdateService.deleted(updatedDTO.getPayload().getId(), updatedDTO.getPayload());
}
@RabbitListener(queues = "#{@legalPersonCacheUpdateService.createdEventsQueueName}")
public void legalPersonCreatedEvent(LegalPersonCacheUpdateService.LegalPersonCreatedDTO createdDTO) {
legalPersonCacheUpdateService.created(createdDTO.getPayload());
}
@RabbitListener(queues = "#{@legalPersonCacheUpdateService.updatedEventsQueueName}")
public void legalPersonUpdatedEvent(LegalPersonCacheUpdateService.LegalPersonUpdatedDTO updatedDTO) {
legalPersonCacheUpdateService.updated(updatedDTO.getPayload().getId(), updatedDTO.getPayload());
}
@RabbitListener(queues = "#{@legalPersonCacheUpdateService.deletedEventsQueueName}")
public void legalPersonDeletedEvent(LegalPersonCacheUpdateService.LegalPersonDeletedDTO deletedDTO) {
legalPersonCacheUpdateService.deleted(deletedDTO.getPayload().getId(), deletedDTO.getPayload());
}
@RabbitListener(queues = "#{@individualPersonCacheUpdateService.createdEventsQueueName}")
public void individualPersonCreatedEvent(IndividualPersonCacheUpdateService.IndividualPersonCreatedDTO createdDTO) {
individualPersonCacheUpdateService.created(createdDTO.getPayload());
}
@RabbitListener(queues = "#{@individualPersonCacheUpdateService.updatedEventsQueueName}")
public void individualPersonUpdatedEvent(IndividualPersonCacheUpdateService.IndividualPersonUpdatedDTO updatedDTO) {
individualPersonCacheUpdateService.updated(updatedDTO.getPayload().getId(), updatedDTO.getPayload());
}
@RabbitListener(queues = "#{@individualPersonCacheUpdateService.deletedEventsQueueName}")
public void individualPersonDeletedEvent(IndividualPersonCacheUpdateService.IndividualPersonDeletedDTO deletedDTO) {
individualPersonCacheUpdateService.deleted(deletedDTO.getPayload().getId(), deletedDTO.getPayload());
}
@RabbitListener(queues = "#{@legalPersonCacheUpdateService.cacheResponseQueueName}")
public void legalPersonCacheResponseEvent(
LegalPersonCacheUpdateService.LegalPersonCacheResponseDTO cacheResponseDTO) {
legalPersonCacheUpdateService.processSnapshot(cacheResponseDTO.getPayload(), cacheResponseDTO.getRequestMetaDTO());
}
@RabbitListener(queues = "#{@legalPersonCacheUpdateService.cacheReinitializeQueueName}")
public void legalPersonReinitializeEvent(LegalPersonCacheUpdateService.LegalPersonReinitializeDTO reinitializeDTO) {
legalPersonCacheUpdateService.reinitialize();
}
@RabbitListener(queues = "#{@individualPersonCacheUpdateService.cacheResponseQueueName}")
public void individualPersonCacheResponseEvent(
IndividualPersonCacheUpdateService.IndividualPersonCacheResponseDTO cacheResponseDTO) {
individualPersonCacheUpdateService.processSnapshot(cacheResponseDTO.getPayload(), cacheResponseDTO.getRequestMetaDTO());
}
@RabbitListener(queues = "#{@individualPersonCacheUpdateService.cacheReinitializeQueueName}")
public void individualPersonReinitializeEvent(
IndividualPersonCacheUpdateService.IndividualPersonReinitializeDTO reinitializeDTO) {
individualPersonCacheUpdateService.reinitialize();