Pull request #158: RED-4686 - storage commons update

Merge in RED/redaction-report-service from RED-4686 to master

* commit 'd095ea41a202cb92fbf9b891b9ecd04bd3634202':
  RED-4686 - storage commons update
This commit is contained in:
Timo Bejan 2022-07-25 21:53:21 +02:00
commit 179b4eae62
8 changed files with 37 additions and 35 deletions

View File

@ -22,12 +22,19 @@
<module>redaction-report-service-server-v1</module>
</modules>
<properties>
<persistence-service.version>1.254.0</persistence-service.version>
<redaction-service.version>3.155.0</redaction-service.version>
<dsljson.version>1.9.9</dsljson.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.iqser.red</groupId>
<artifactId>platform-commons-dependency</artifactId>
<version>1.14.0</version>
<version>1.17.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>

View File

@ -13,11 +13,13 @@
<artifactId>redaction-report-service-api-v1</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<persistence-service.version>1.98.0</persistence-service.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.dslplatform/dsl-json-java8 -->
<dependency>
<groupId>com.dslplatform</groupId>
<artifactId>dsl-json-java8</artifactId>
<version>${dsljson.version}</version>
</dependency>
<dependency>
<!-- This dependency contains annotations that are used in specifying REST endpoints. -->
<!-- It is optional since not all users of this API might use Feign. -->

View File

@ -1,5 +1,6 @@
package com.iqser.red.service.redaction.report.v1.api.model;
import com.dslplatform.json.CompiledJson;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -7,6 +8,7 @@ import lombok.NoArgsConstructor;
@Data
@Builder
@CompiledJson
@AllArgsConstructor
@NoArgsConstructor
public class StoredFileInformation {

View File

@ -13,11 +13,6 @@
<artifactId>redaction-report-service-server-v1</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<persistence-service.version>1.238.0</persistence-service.version>
<redaction-service.version>3.109.0</redaction-service.version>
</properties>
<dependencies>
<dependency>
<groupId>com.iqser.red.service</groupId>

View File

@ -8,21 +8,18 @@ import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.iqser.red.service.redaction.v1.model.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.legalbasis.LegalBasis;
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
import com.iqser.red.service.redaction.v1.model.ManualRedactionType;
import com.iqser.red.service.redaction.v1.model.Rectangle;
import com.iqser.red.service.redaction.v1.model.RedactionLog;
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
@Service
public class RedactionLogConverterService {
public List<ReportRedactionEntry> convertAndSort(RedactionLog redactionLog, List<LegalBasis> legalBasisMappings, Map<String, String> mapOfEntityDisplayName) {
public List<ReportRedactionEntry> convertAndSort(RedactionLog redactionLog, List<RedactionLogLegalBasis> legalBasisMappings, Map<String, String> mapOfEntityDisplayName) {
List<ReportRedactionEntry> reportEntries = new ArrayList<>();
@ -65,11 +62,11 @@ public class RedactionLogConverterService {
.getY(), getSection(entry, position), entry.getLegalBasis() + " " + legalBasisMappings.stream()
.filter(lbm -> lbm.getReason().equalsIgnoreCase(entry.getLegalBasis()))
.findAny()
.map(LegalBasis::getDescription)
.map(RedactionLogLegalBasis::getDescription)
.orElse(""), entry.getLegalBasis(), legalBasisMappings.stream()
.filter(lbm -> lbm.getReason().equalsIgnoreCase(entry.getLegalBasis()))
.findAny()
.map(LegalBasis::getDescription)
.map(RedactionLogLegalBasis::getDescription)
.orElse(""), checkTextForNull(entry.getTextBefore()) + entry.getValue() + checkTextForNull(entry.getTextAfter()), entry.getValue(), mapOfEntityDisplayName.get(entry.getType())));
}
}

View File

@ -216,8 +216,8 @@ public class ReportGenerationService {
private Map<String, String> fillMapOfTypeAndEntityDisplayName(String dossierId) {
List<Type> typeList = new ArrayList<>();
typeList.addAll(dictionaryClient.getAllTypesForDossier(dossierId));
typeList.addAll(dictionaryClient.getAllTypesForDossierTemplate(dossierClient.getDossierById(dossierId, false, false).getDossierTemplateId()));
typeList.addAll(dictionaryClient.getAllTypesForDossier(dossierId,false));
typeList.addAll(dictionaryClient.getAllTypesForDossierTemplate(dossierClient.getDossierById(dossierId, false, false).getDossierTemplateId(), false));
Map<String, String> mapOfEntityDisplayName = new HashMap<>();

View File

@ -1,14 +1,13 @@
package com.iqser.red.service.redaction.report.v1.server.storage;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
import com.iqser.red.storage.commons.service.StorageService;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
@ -18,12 +17,11 @@ import java.util.UUID;
public class ReportStorageService {
private final StorageService storageService;
private final ObjectMapper objectMapper;
public String storeObject(String downloadId, byte[] data) {
String storageId = StorageIdUtils.getStorageId(downloadId, UUID.randomUUID().toString());
storageService.storeObject(storageId, data);
storageService.storeObject(storageId, new ByteArrayInputStream(data));
return storageId;
}
@ -32,7 +30,7 @@ public class ReportStorageService {
public String storeReportInformation(String downloadId, List<StoredFileInformation> storedFileInformations) {
String storageId = StorageIdUtils.getStorageId(downloadId, "REPORT_INFO.json");
storageService.storeObject(storageId, objectMapper.writeValueAsBytes(storedFileInformations));
storageService.storeJSONObject(storageId, storedFileInformations);
return storageId;
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.iqser.red.service.redaction.v1.model.RedactionLogLegalBasis;
import org.apache.commons.io.IOUtils;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -112,7 +113,7 @@ public class RedactionReportIntegrationTest {
public void testWordJustificationAppendixA1() {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<LegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>());
@ -138,7 +139,7 @@ public class RedactionReportIntegrationTest {
public void testWordJustificationAppendixA2() {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<LegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>());
@ -164,7 +165,7 @@ public class RedactionReportIntegrationTest {
public void testWordIUCLIDFile() {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<LegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>());
@ -190,7 +191,7 @@ public class RedactionReportIntegrationTest {
public void testWordSeedReportSingleFile() {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<LegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>());
@ -216,7 +217,7 @@ public class RedactionReportIntegrationTest {
public void testWordSeedReportMultiFile() {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<LegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>());
@ -247,7 +248,7 @@ public class RedactionReportIntegrationTest {
public void testWord6464JustificationAppendix() {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<LegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, new HashMap<>());
@ -273,7 +274,7 @@ public class RedactionReportIntegrationTest {
public void testExcelTemplateReportGenerationSingleFile() {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLogWithManualRedactions.json").getInputStream(), RedactionLog.class);
List<LegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(redactionLog);
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName);
@ -302,7 +303,7 @@ public class RedactionReportIntegrationTest {
public void testExcelTemplateReportGenerationMultiFile() {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<LegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(redactionLog);
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName);
@ -336,7 +337,7 @@ public class RedactionReportIntegrationTest {
public void testExcelPlaceholders() {
RedactionLog redactionLog = objectMapper.readValue(new ClassPathResource("files/redactionLog.json").getInputStream(), RedactionLog.class);
List<LegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
List<RedactionLogLegalBasis> legalBasisMapping = objectMapper.readValue(new ClassPathResource("files/legalBasisMapping.json").getInputStream(), new TypeReference<>() {
});
Map<String, String> mapOfEntityDisplayName = createEntityDisplayNames(redactionLog);
List<ReportRedactionEntry> reportEntries = redactionLogConverterService.convertAndSort(redactionLog, legalBasisMapping, mapOfEntityDisplayName);
@ -370,8 +371,8 @@ public class RedactionReportIntegrationTest {
Type t3 = new Type();
t3.setLabel("Type 3");
List<Type> ednList = new ArrayList<>(Arrays.asList(t1, t2, t3));
Mockito.when(dictionaryClient.getAllTypesForDossier(Mockito.anyString())).thenReturn(ednList);
Mockito.when(dictionaryClient.getAllTypesForDossierTemplate(Mockito.any())).thenReturn(ednList);
Mockito.when(dictionaryClient.getAllTypesForDossier(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(ednList);
Mockito.when(dictionaryClient.getAllTypesForDossierTemplate(Mockito.any(), Mockito.anyBoolean())).thenReturn(ednList);
Map<String, String> entityDisplayNames = new HashMap<>();
for (var entry : redactionLog.getRedactionLogEntry()) {