From 7b1c4e3cdf27f3002348c0d9172fcaea6bd152a9 Mon Sep 17 00:00:00 2001 From: Fabien Date: Tue, 8 Oct 2024 14:55:51 +0200 Subject: [PATCH 1/3] chore: remove deprecated subCategory in document subcat --- .../fr/dossierfacile/api/front/model/tenant/DocumentModel.java | 3 --- .../dossierfacile/common/mapper/DeletedTenantCommonMapper.java | 1 - .../fr/dossierfacile/common/mapper/MapDocumentCategories.java | 3 --- .../common/model/apartment_sharing/DocumentModel.java | 3 --- 4 files changed, 10 deletions(-) diff --git a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/tenant/DocumentModel.java b/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/tenant/DocumentModel.java index fd0654665..fec2afb68 100644 --- a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/tenant/DocumentModel.java +++ b/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/tenant/DocumentModel.java @@ -20,9 +20,6 @@ public class DocumentModel { private Long id; private DocumentCategory documentCategory; - // TODO We should use documentSubCategory - @Deprecated - private DocumentSubCategory subCategory; private DocumentSubCategory documentSubCategory; private Boolean noDocument; private String customText; diff --git a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedTenantCommonMapper.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedTenantCommonMapper.java index b22ec8825..fc4e22d90 100644 --- a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedTenantCommonMapper.java +++ b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedTenantCommonMapper.java @@ -24,7 +24,6 @@ public interface DeletedTenantCommonMapper { public abstract DeletedTenantModel toDeletedTenantModel(Tenant tenant); @Mapping(target = "name", expression = "java((document.getWatermarkFile() != null )? document.getWatermarkFile().getName() : null)") - @Mapping(target = "subCategory", source = "documentSubCategory") public abstract DocumentModel toDocumentModel(Document document); @Named("emailToHashedEmail") diff --git a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/MapDocumentCategories.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/MapDocumentCategories.java index f298a3e82..1c0f167f8 100644 --- a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/MapDocumentCategories.java +++ b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/MapDocumentCategories.java @@ -11,8 +11,5 @@ @Retention(RetentionPolicy.CLASS) @Mapping(target = "documentCategory", expression = "java(categoriesMapper.mapCategory(document.getDocumentCategory(), userApi))") @Mapping(target = "documentSubCategory", expression = "java(categoriesMapper.mapSubCategory(document.getDocumentSubCategory(), userApi))") -// TODO use documentSubCategory -@Deprecated -@Mapping(target = "subCategory", expression = "java(userApi == null ? categoriesMapper.mapSubCategory(document.getDocumentSubCategory(), userApi) : null)") public @interface MapDocumentCategories { } diff --git a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DocumentModel.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DocumentModel.java index c98107d65..300478ad4 100644 --- a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DocumentModel.java +++ b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DocumentModel.java @@ -18,9 +18,6 @@ public class DocumentModel { private Long id; private DocumentCategory documentCategory; - // TODO use DocumentSubCategory field - @Deprecated - private DocumentSubCategory subCategory; private DocumentSubCategory documentSubCategory; private String customText; private Integer monthlySum; From c010d60dc5678cfaa271ad22966e5aab0a944620 Mon Sep 17 00:00:00 2001 From: Fabien Date: Tue, 8 Oct 2024 16:30:59 +0200 Subject: [PATCH 2/3] chore: merge DeletedOwnerModel and mappers --- .../log/DeletedOwnerModel.java | 28 --------- .../log/OwnerLogServiceImpl.java | 2 +- .../mapper/DeletedOwnerCommonMapper.java | 55 ------------------ .../mapper/DeletedTenantCommonMapper.java | 58 ------------------- .../mapper}/log/DeletedOwnerMapper.java | 11 ++-- .../mapper/log/DeletedTenantMapper.java | 36 ++++++++++++ .../DeletedOwnerModel.java | 12 ++-- .../DeletedTenantModel.java | 4 +- .../common/service/LogServiceImpl.java | 12 ++-- .../db/changelog/databaseChangeLog.xml | 2 + ...410070000-update-jsonprofile-owner_log.xml | 34 +++++++++++ 11 files changed, 92 insertions(+), 162 deletions(-) delete mode 100644 dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/DeletedOwnerModel.java delete mode 100644 dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedOwnerCommonMapper.java delete mode 100644 dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedTenantCommonMapper.java rename {dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner => dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper}/log/DeletedOwnerMapper.java (56%) create mode 100644 dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/log/DeletedTenantMapper.java rename dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/{apartment_sharing => log}/DeletedOwnerModel.java (72%) rename dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/{apartment_sharing => log}/DeletedTenantModel.java (90%) create mode 100644 dossierfacile-common-library/src/main/resources/db/migration/202410070000-update-jsonprofile-owner_log.xml diff --git a/dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/DeletedOwnerModel.java b/dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/DeletedOwnerModel.java deleted file mode 100644 index eadf51fa1..000000000 --- a/dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/DeletedOwnerModel.java +++ /dev/null @@ -1,28 +0,0 @@ -package fr.dossierfacile.api.dossierfacileapiowner.log; - -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import fr.dossierfacile.api.dossierfacileapiowner.property.PropertyModel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - -import java.time.LocalDateTime; -import java.util.List; - -@Getter -@Setter -@AllArgsConstructor -public class DeletedOwnerModel { - private Long id; - private String hEmail; - private String hFirstName; - private String hLastName; - private String hPreferredName; - private boolean franceConnect; - @JsonSerialize(using = LocalDateTimeSerializer.class) - @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS") - private LocalDateTime creationDateTime; - private List properties; -} diff --git a/dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/OwnerLogServiceImpl.java b/dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/OwnerLogServiceImpl.java index 6f3167827..f2ba8beb8 100644 --- a/dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/OwnerLogServiceImpl.java +++ b/dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/OwnerLogServiceImpl.java @@ -4,6 +4,7 @@ import fr.dossierfacile.common.entity.Owner; import fr.dossierfacile.common.entity.OwnerLog; import fr.dossierfacile.common.enums.OwnerLogType; +import fr.dossierfacile.common.mapper.log.DeletedOwnerMapper; import fr.dossierfacile.common.utils.MapperUtil; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -17,7 +18,6 @@ public class OwnerLogServiceImpl implements OwnerLogService { private final OwnerLogRepository repository; private final DeletedOwnerMapper deletedOwnerMapper; - private final ObjectMapper objectMapper = MapperUtil.newObjectMapper(); private void saveLog(OwnerLog log) { diff --git a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedOwnerCommonMapper.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedOwnerCommonMapper.java deleted file mode 100644 index 074d6f5bd..000000000 --- a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedOwnerCommonMapper.java +++ /dev/null @@ -1,55 +0,0 @@ -package fr.dossierfacile.common.mapper; - -import com.google.common.hash.Hashing; -import fr.dossierfacile.common.entity.Document; -import fr.dossierfacile.common.entity.Owner; -import fr.dossierfacile.common.entity.Tenant; -import fr.dossierfacile.common.model.apartment_sharing.DeletedOwnerModel; -import fr.dossierfacile.common.model.apartment_sharing.DeletedTenantModel; -import fr.dossierfacile.common.model.apartment_sharing.DocumentModel; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.springframework.stereotype.Component; - -import java.nio.charset.StandardCharsets; - -@Component -@Mapper(componentModel = "spring") -public interface DeletedOwnerCommonMapper { - @Mapping(target = "hashedEmail", source = "email", qualifiedByName = "emailToHashedEmail") - @Mapping(target = "hashedLastname", source = "lastName", qualifiedByName = "lastnameToHashedLastname") - @Mapping(target = "hashedFirstname", source = "firstName", qualifiedByName = "firstnameToHashedFirstname") - @Mapping(target = "hashedPreferredName", source = "preferredName", qualifiedByName = "preferredNameToHashedPreferredName") - public abstract DeletedOwnerModel toDeletedOwnerModel(Owner owner); - - @Named("emailToHashedEmail") - static String emailToHashedEmail(String email) { - if (email == null) { - return ""; - } - return Hashing.sha256().hashString(email, StandardCharsets.UTF_8).toString(); - } - @Named("firstnameToHashedFirstname") - static String firstnameToHashedFirstname(String firstname) { - if (firstname == null) { - return ""; - } - return Hashing.sha256().hashString(firstname, StandardCharsets.UTF_8).toString(); - } - @Named("lastnameToHashedLastname") - static String lastnameToHashedLastname(String lastname) { - if (lastname == null) { - return ""; - } - return Hashing.sha256().hashString(lastname, StandardCharsets.UTF_8).toString(); - } - - @Named("preferredNameToHashedPreferredName") - static String preferredNameToHashedPreferredName(String preferredName) { - if (preferredName == null) { - return ""; - } - return Hashing.sha256().hashString(preferredName, StandardCharsets.UTF_8).toString(); - } -} diff --git a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedTenantCommonMapper.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedTenantCommonMapper.java deleted file mode 100644 index fc4e22d90..000000000 --- a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/DeletedTenantCommonMapper.java +++ /dev/null @@ -1,58 +0,0 @@ -package fr.dossierfacile.common.mapper; - -import com.google.common.hash.Hashing; -import fr.dossierfacile.common.entity.Document; -import fr.dossierfacile.common.entity.Tenant; -import fr.dossierfacile.common.model.apartment_sharing.DeletedTenantModel; -import fr.dossierfacile.common.model.apartment_sharing.DocumentModel; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.Named; -import org.springframework.stereotype.Component; - -import java.nio.charset.StandardCharsets; - -@Component -@Mapper(componentModel = "spring") -public interface DeletedTenantCommonMapper { - @Mapping(target = "hashedEmail", source = "email", qualifiedByName = "emailToHashedEmail") - @Mapping(target = "hashedLastname", source = "lastName", qualifiedByName = "lastnameToHashedLastname") - @Mapping(target = "hashedFirstname", source = "firstName", qualifiedByName = "firstnameToHashedFirstname") - @Mapping(target = "hashedPreferredName", source = "preferredName", qualifiedByName = "preferredNameToHashedPreferredName") - @Mapping(target = "applicationType", expression = "java((tenant.getApartmentSharing() != null )? tenant.getApartmentSharing().getApplicationType() : null)") - @Mapping(target = "apartmentSharingId", expression = "java((tenant.getApartmentSharing() != null )? tenant.getApartmentSharing().getId() : null)") - public abstract DeletedTenantModel toDeletedTenantModel(Tenant tenant); - - @Mapping(target = "name", expression = "java((document.getWatermarkFile() != null )? document.getWatermarkFile().getName() : null)") - public abstract DocumentModel toDocumentModel(Document document); - - @Named("emailToHashedEmail") - static String emailToHashedEmail(String email) { - if (email == null) { - return ""; - } - return Hashing.sha256().hashString(email, StandardCharsets.UTF_8).toString(); - } - @Named("firstnameToHashedFirstname") - static String firstnameToHashedFirstname(String firstname) { - if (firstname == null) { - return ""; - } - return Hashing.sha256().hashString(firstname, StandardCharsets.UTF_8).toString(); - } - @Named("lastnameToHashedLastname") - static String lastnameToHashedLastname(String lastname) { - if (lastname == null) { - return ""; - } - return Hashing.sha256().hashString(lastname, StandardCharsets.UTF_8).toString(); - } - - @Named("preferredNameToHashedPreferredName") - static String preferredNameToHashedPreferredName(String preferredName) { - if (preferredName == null) { - return ""; - } - return Hashing.sha256().hashString(preferredName, StandardCharsets.UTF_8).toString(); - } -} diff --git a/dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/DeletedOwnerMapper.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/log/DeletedOwnerMapper.java similarity index 56% rename from dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/DeletedOwnerMapper.java rename to dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/log/DeletedOwnerMapper.java index 2c1113ab9..9d2a9e0f6 100644 --- a/dossierfacile-api-owner/src/main/java/fr/dossierfacile/api/dossierfacileapiowner/log/DeletedOwnerMapper.java +++ b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/log/DeletedOwnerMapper.java @@ -1,7 +1,8 @@ -package fr.dossierfacile.api.dossierfacileapiowner.log; +package fr.dossierfacile.common.mapper.log; import com.google.common.hash.Hashing; import fr.dossierfacile.common.entity.Owner; +import fr.dossierfacile.common.model.log.DeletedOwnerModel; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Named; @@ -21,9 +22,9 @@ static String hash(String value) { return Hashing.sha256().hashString(value, StandardCharsets.UTF_8).toString(); } - @Mapping(target = "hEmail", source = "email", qualifiedByName = "hashString") - @Mapping(target = "hFirstName", source = "firstName", qualifiedByName = "hashString") - @Mapping(target = "hLastName", source = "lastName", qualifiedByName = "hashString") - @Mapping(target = "hPreferredName", source = "preferredName", qualifiedByName = "hashString") + @Mapping(target = "hashedEmail", source = "email", qualifiedByName = "hashString") + @Mapping(target = "hashedLastname", source = "lastName", qualifiedByName = "hashString") + @Mapping(target = "hashedFirstname", source = "firstName", qualifiedByName = "hashString") + @Mapping(target = "hashedPreferredName", source = "preferredName", qualifiedByName = "hashString") DeletedOwnerModel toDeletedOwnerModel(Owner owner); } diff --git a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/log/DeletedTenantMapper.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/log/DeletedTenantMapper.java new file mode 100644 index 000000000..7b9aedcec --- /dev/null +++ b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/mapper/log/DeletedTenantMapper.java @@ -0,0 +1,36 @@ +package fr.dossierfacile.common.mapper.log; + +import com.google.common.hash.Hashing; +import fr.dossierfacile.common.entity.Document; +import fr.dossierfacile.common.entity.Tenant; +import fr.dossierfacile.common.model.log.DeletedTenantModel; +import fr.dossierfacile.common.model.apartment_sharing.DocumentModel; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.Named; +import org.springframework.stereotype.Component; + +import java.nio.charset.StandardCharsets; + +@Component +@Mapper(componentModel = "spring") +public interface DeletedTenantMapper { + @Named("hashString") + static String hash(String value) { + if (value == null) { + return ""; + } + return Hashing.sha256().hashString(value, StandardCharsets.UTF_8).toString(); + } + + @Mapping(target = "hashedEmail", source = "email", qualifiedByName = "hashString") + @Mapping(target = "hashedLastname", source = "lastName", qualifiedByName = "hashString") + @Mapping(target = "hashedFirstname", source = "firstName", qualifiedByName = "hashString") + @Mapping(target = "hashedPreferredName", source = "preferredName", qualifiedByName = "hashString") + @Mapping(target = "applicationType", expression = "java((tenant.getApartmentSharing() != null )? tenant.getApartmentSharing().getApplicationType() : null)") + @Mapping(target = "apartmentSharingId", expression = "java((tenant.getApartmentSharing() != null )? tenant.getApartmentSharing().getId() : null)") + DeletedTenantModel toDeletedTenantModel(Tenant tenant); + + @Mapping(target = "name", expression = "java((document.getWatermarkFile() != null )? document.getWatermarkFile().getName() : null)") + DocumentModel toDocumentModel(Document document); +} diff --git a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DeletedOwnerModel.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/log/DeletedOwnerModel.java similarity index 72% rename from dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DeletedOwnerModel.java rename to dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/log/DeletedOwnerModel.java index d96731ad9..dedffd68d 100644 --- a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DeletedOwnerModel.java +++ b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/log/DeletedOwnerModel.java @@ -1,19 +1,15 @@ -package fr.dossierfacile.common.model.apartment_sharing; +package fr.dossierfacile.common.model.log; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import fr.dossierfacile.common.enums.ApplicationType; -import fr.dossierfacile.common.enums.TenantFileStatus; -import fr.dossierfacile.common.enums.TenantType; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import java.time.LocalDateTime; -import java.util.List; @Data @AllArgsConstructor @@ -28,9 +24,9 @@ public class DeletedOwnerModel { private String hashedPreferredName; private Boolean franceConnect; @JsonSerialize(using = LocalDateTimeSerializer.class) - @JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss.SSSSSS") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS") private LocalDateTime creationDateTime; @JsonSerialize(using = LocalDateTimeSerializer.class) - @JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss.SSSSSS") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS") private LocalDateTime lastUpdateDate; -} +} \ No newline at end of file diff --git a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DeletedTenantModel.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/log/DeletedTenantModel.java similarity index 90% rename from dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DeletedTenantModel.java rename to dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/log/DeletedTenantModel.java index 24de1cb06..ccc724719 100644 --- a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/apartment_sharing/DeletedTenantModel.java +++ b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/model/log/DeletedTenantModel.java @@ -1,4 +1,4 @@ -package fr.dossierfacile.common.model.apartment_sharing; +package fr.dossierfacile.common.model.log; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; @@ -7,6 +7,8 @@ import fr.dossierfacile.common.enums.ApplicationType; import fr.dossierfacile.common.enums.TenantFileStatus; import fr.dossierfacile.common.enums.TenantType; +import fr.dossierfacile.common.model.apartment_sharing.DocumentModel; +import fr.dossierfacile.common.model.apartment_sharing.GuarantorModel; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/service/LogServiceImpl.java b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/service/LogServiceImpl.java index 896090c27..8f8518a85 100644 --- a/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/service/LogServiceImpl.java +++ b/dossierfacile-common-library/src/main/java/fr/dossierfacile/common/service/LogServiceImpl.java @@ -11,8 +11,8 @@ import fr.dossierfacile.common.enums.ApplicationType; import fr.dossierfacile.common.enums.LogType; import fr.dossierfacile.common.enums.OwnerLogType; -import fr.dossierfacile.common.mapper.DeletedOwnerCommonMapper; -import fr.dossierfacile.common.mapper.DeletedTenantCommonMapper; +import fr.dossierfacile.common.mapper.log.DeletedOwnerMapper; +import fr.dossierfacile.common.mapper.log.DeletedTenantMapper; import fr.dossierfacile.common.model.log.ApplicationTypeChange; import fr.dossierfacile.common.model.log.EditedDocument; import fr.dossierfacile.common.model.log.EditedStep; @@ -34,8 +34,8 @@ public class LogServiceImpl implements LogService { private final TenantLogRepository repository; private final OwnerLogCommonRepository ownerLogRepository; - private final DeletedTenantCommonMapper deletedTenantCommonMapper; - private final DeletedOwnerCommonMapper deletedOwnerCommonMapper; + private final DeletedTenantMapper deletedTenantMapper; + private final DeletedOwnerMapper deletedOwnerMapper; private final ObjectMapper objectMapper; private void saveLog(TenantLog log) { @@ -65,7 +65,7 @@ public void saveLogWithOwnerData(OwnerLogType logType, Owner owner) { .logType(logType) .ownerId(owner.getId()) .creationDateTime(LocalDateTime.now()) - .jsonProfile(writeAsString(deletedOwnerCommonMapper.toDeletedOwnerModel(owner))) + .jsonProfile(writeAsString(deletedOwnerMapper.toDeletedOwnerModel(owner))) .build() ); } @@ -79,7 +79,7 @@ public void saveLogWithTenantData(LogType logType, Tenant tenant) { .creationDateTime(LocalDateTime.now()) .userApis(tenant.getTenantsUserApi().stream() .mapToLong(tenantUserApi -> tenantUserApi.getUserApi().getId()).toArray()) - .jsonProfile(writeAsString(deletedTenantCommonMapper.toDeletedTenantModel(tenant))) + .jsonProfile(writeAsString(deletedTenantMapper.toDeletedTenantModel(tenant))) .build() ); } diff --git a/dossierfacile-common-library/src/main/resources/db/changelog/databaseChangeLog.xml b/dossierfacile-common-library/src/main/resources/db/changelog/databaseChangeLog.xml index 28a86d216..01f766bda 100644 --- a/dossierfacile-common-library/src/main/resources/db/changelog/databaseChangeLog.xml +++ b/dossierfacile-common-library/src/main/resources/db/changelog/databaseChangeLog.xml @@ -155,5 +155,7 @@ + + diff --git a/dossierfacile-common-library/src/main/resources/db/migration/202410070000-update-jsonprofile-owner_log.xml b/dossierfacile-common-library/src/main/resources/db/migration/202410070000-update-jsonprofile-owner_log.xml new file mode 100644 index 000000000..a89933c99 --- /dev/null +++ b/dossierfacile-common-library/src/main/resources/db/migration/202410070000-update-jsonprofile-owner_log.xml @@ -0,0 +1,34 @@ + + + + + + 'hemail', 'null'::jsonb) + ), + '{hashedLastname}', + COALESCE(json_profile->'hlastName', 'null'::jsonb) + ), + '{hashedFirstname}', + COALESCE(json_profile->'hfirstName', 'null'::jsonb) + ), + '{hashedPreferredName}', + COALESCE(json_profile->'hpreferredName', 'null'::jsonb) + ) + - 'hemail' - 'hlastName' - 'hfirstName' - 'hpreferredName' + WHERE log_type = 'ACCOUNT_DELETED'; + + ]]> + + + + From b48951e7ab31bf30c0f0b486666096038cb9d027 Mon Sep 17 00:00:00 2001 From: Fabien Date: Tue, 8 Oct 2024 16:58:29 +0200 Subject: [PATCH 3/3] chore: delete duplicate models --- .../ApartmentSharingModel.java | 4 +-- .../DocumentDeniedReasonsModel.java | 23 ----------------- .../dfc/apartment_sharing/GuarantorModel.java | 25 ------------------- .../dfc/apartment_sharing/TenantModel.java | 5 ++-- 4 files changed, 5 insertions(+), 52 deletions(-) delete mode 100644 dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/DocumentDeniedReasonsModel.java delete mode 100644 dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/GuarantorModel.java diff --git a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/ApartmentSharingModel.java b/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/ApartmentSharingModel.java index d1e40e03d..32bf6ede5 100644 --- a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/ApartmentSharingModel.java +++ b/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/ApartmentSharingModel.java @@ -11,9 +11,9 @@ import java.util.List; @Data -@AllArgsConstructor -@NoArgsConstructor @Builder +@NoArgsConstructor +@AllArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) public class ApartmentSharingModel { private Long id; diff --git a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/DocumentDeniedReasonsModel.java b/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/DocumentDeniedReasonsModel.java deleted file mode 100644 index 7689df509..000000000 --- a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/DocumentDeniedReasonsModel.java +++ /dev/null @@ -1,23 +0,0 @@ -package fr.dossierfacile.api.front.model.dfc.apartment_sharing; - -import com.fasterxml.jackson.annotation.JsonInclude; -import fr.dossierfacile.api.front.model.tenant.SelectedOption; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -@JsonInclude(JsonInclude.Include.NON_NULL) -public class DocumentDeniedReasonsModel { - private List checkedOptions; - private List checkedOptionsId; - private List selectedOptions; - private boolean messageData; - private String comment; -} diff --git a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/GuarantorModel.java b/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/GuarantorModel.java deleted file mode 100644 index 13261a324..000000000 --- a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/GuarantorModel.java +++ /dev/null @@ -1,25 +0,0 @@ -package fr.dossierfacile.api.front.model.dfc.apartment_sharing; - -import com.fasterxml.jackson.annotation.JsonInclude; -import fr.dossierfacile.api.front.model.tenant.DocumentModel; -import fr.dossierfacile.common.enums.TypeGuarantor; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.List; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -@JsonInclude(JsonInclude.Include.NON_NULL) -public class GuarantorModel { - private Long id; - private String firstName; - private String lastName; - private String legalPersonName; - private TypeGuarantor typeGuarantor; - private List documents; -} diff --git a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/TenantModel.java b/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/TenantModel.java index 8a0d57779..2fdf67372 100644 --- a/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/TenantModel.java +++ b/dossierfacile-api-tenant/src/main/java/fr/dossierfacile/api/front/model/dfc/apartment_sharing/TenantModel.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import fr.dossierfacile.api.front.model.tenant.DocumentModel; +import fr.dossierfacile.api.front.model.tenant.GuarantorModel; import fr.dossierfacile.common.enums.TenantFileStatus; import fr.dossierfacile.common.enums.TenantType; import lombok.AllArgsConstructor; @@ -13,9 +14,9 @@ import java.util.List; @Data +@Builder @AllArgsConstructor @NoArgsConstructor -@Builder @JsonInclude(JsonInclude.Include.NON_NULL) public class TenantModel { private Long id; @@ -33,4 +34,4 @@ public class TenantModel { private List documents; private List guarantors; private boolean franceConnect; -} +} \ No newline at end of file