dossier and npe cleanup

This commit is contained in:
Timo Bejan 2022-02-17 14:55:36 +02:00
parent c1cf5f05cb
commit 6bc4640b9b
10 changed files with 34 additions and 3 deletions

View File

@ -1,5 +1,5 @@
package com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier;
public enum DossierStatus {
ACTIVE, ARCHIVED, DELETED
ACTIVE, DELETED, ARCHIVED;
}

View File

@ -41,7 +41,8 @@ public class DossierEntity {
@Column(length = 4000)
private String description;
@Column
@Column(name = "dossier_status")
@Enumerated(EnumType.STRING)
private DossierStatus status;
@Column

View File

@ -1,6 +1,5 @@
package com.iqser.red.service.persistence.management.v1.processor.utils;
import com.amazonaws.services.s3.transfer.Download;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.DownloadFileType;
@ -25,6 +24,9 @@ public class JSONDownloadFileTypeConverter implements AttributeConverter<Set<Dow
@SneakyThrows
@Override
public Set<DownloadFileType> convertToEntityAttribute(String data) {
if (data == null) {
return new HashSet<>();
}
TypeReference<HashSet<DownloadFileType>> typeRef = new TypeReference<>() {
};
return objectMapper.readValue(data, typeRef);

View File

@ -23,6 +23,9 @@ public class JSONIntegerSetConverter implements AttributeConverter<Set<Integer>,
@SneakyThrows
@Override
public Set<Integer> convertToEntityAttribute(String data) {
if (data == null) {
return new HashSet<>();
}
TypeReference<HashSet<Integer>> typeRef = new TypeReference<>() {
};
return objectMapper.readValue(data, typeRef);

View File

@ -23,6 +23,9 @@ public class JSONMapConverter implements AttributeConverter<Map<String, Object>,
@SneakyThrows
@Override
public Map<String, Object> convertToEntityAttribute(String data) {
if (data == null) {
return new HashMap<>();
}
TypeReference<HashMap<String, Object>> typeRef = new TypeReference<>() {
};
return objectMapper.readValue(data, typeRef);

View File

@ -23,6 +23,9 @@ public class JSONStringSetConverter implements AttributeConverter<Set<String>, S
@SneakyThrows
@Override
public Set<String> convertToEntityAttribute(String data) {
if (data == null) {
return new HashSet<>();
}
TypeReference<HashSet<String>> typeRef = new TypeReference<>() {
};
return objectMapper.readValue(data, typeRef);

View File

@ -24,6 +24,9 @@ databaseChangeLog:
- column:
name: download_file_types
type: TEXT
- column:
name: dossier_status
type: VARCHAR(30)
tableName: dossier
- changeSet:
id: add-dossier-template-download-file-types-members-approvers

View File

@ -0,0 +1,10 @@
databaseChangeLog:
- changeSet:
id: remove-dossier-status-numeric-column
author: timo
changes:
- removeColumn:
columns:
- column:
name: status
tableName: dossier

View File

@ -15,3 +15,5 @@ databaseChangeLog:
file: db/changelog/7-json-column-mapping.changelog.yaml
- include:
file: db/changelog/sql/7.1-set-json-fields.sql
- include:
file: db/changelog/8-remove-old-dossier-status-column.changelog.yaml

View File

@ -25,3 +25,7 @@ update download_status set download_file_types =
(select '['||STRING_AGG( '"'|| download_file_types || '"', ', ')||']'
from download_status_entity_download_file_types dem where dem.download_status_entity_storage_id = download_status.storage_id
group by dem.download_status_entity_storage_id);
update dossier set dossier_status = 'ACTIVE' where status = 0 or status is null;
update dossier set dossier_status = 'DELETED' where status = 1;
update dossier set dossier_status = 'ARCHIVED' where status = 2;