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

Chore/clean models #859

Merged
merged 3 commits into from
Oct 8, 2024
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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,9 +14,9 @@
import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TenantModel {
private Long id;
Expand All @@ -33,4 +34,4 @@ public class TenantModel {
private List<DocumentModel> documents;
private List<GuarantorModel> guarantors;
private boolean franceConnect;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

This file was deleted.

This file was deleted.

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