diff --git a/redaction-service-v1/redaction-service-api-v1/src/main/java/com/iqser/red/service/redaction/v1/model/RedactionLog.java b/redaction-service-v1/redaction-service-api-v1/src/main/java/com/iqser/red/service/redaction/v1/model/RedactionLog.java index ba2c6abc..eb6203b8 100644 --- a/redaction-service-v1/redaction-service-api-v1/src/main/java/com/iqser/red/service/redaction/v1/model/RedactionLog.java +++ b/redaction-service-v1/redaction-service-api-v1/src/main/java/com/iqser/red/service/redaction/v1/model/RedactionLog.java @@ -1,29 +1,32 @@ package com.iqser.red.service.redaction.v1.model; -import java.util.List; - import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.util.List; + @Data @AllArgsConstructor @NoArgsConstructor public class RedactionLog { - public RedactionLog(List redactionLogEntry, long dictionaryVersion, long rulesVersion) { + private List redactionLogEntry; + + private long dictionaryVersion = -1; + private long rulesVersion = -1; + + private String ruleSetId; + private String filename; + + + public RedactionLog(List redactionLogEntry, long dictionaryVersion, long rulesVersion, String ruleSetId) { this.redactionLogEntry = redactionLogEntry; this.dictionaryVersion = dictionaryVersion; this.rulesVersion = rulesVersion; + this.ruleSetId = ruleSetId; } - private List redactionLogEntry; - - private long dictionaryVersion = -1; - - private long rulesVersion = -1; - - private String filename; } diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/controller/RedactionController.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/controller/RedactionController.java index 51beb4a7..4db4c2fc 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/controller/RedactionController.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/controller/RedactionController.java @@ -55,8 +55,13 @@ public class RedactionController implements RedactionResource { log.info("Redaction analysis successful..."); - return convert(pdDocument, classifiedDoc.getPages() - .size(), classifiedDoc.getRedactionLogEntities(), classifiedDoc.getSectionGrid(), classifiedDoc.getDictionaryVersion(), classifiedDoc.getRulesVersion()); + return convert(pdDocument, + classifiedDoc.getPages().size(), + classifiedDoc.getRedactionLogEntities(), + classifiedDoc.getSectionGrid(), + classifiedDoc.getDictionaryVersion(), + classifiedDoc.getRulesVersion(), + redactionRequest.getRuleSetId()); } catch (IOException e) { throw new RedactionException(e); @@ -74,7 +79,7 @@ public class RedactionController implements RedactionResource { Document classifiedDoc = pdfSegmentationService.parseDocument(pdDocument); pdfVisualisationService.visualizeClassifications(classifiedDoc, pdDocument); - return convert(pdDocument, classifiedDoc.getPages().size()); + return convert(pdDocument, classifiedDoc.getPages().size(), pdfSegmentationRequest.getRuleSetId()); } catch (IOException e) { throw new RedactionException(e); @@ -92,7 +97,7 @@ public class RedactionController implements RedactionResource { Document classifiedDoc = pdfSegmentationService.parseDocument(pdDocument); pdfVisualisationService.visualizeParagraphs(classifiedDoc, pdDocument); - return convert(pdDocument, classifiedDoc.getPages().size()); + return convert(pdDocument, classifiedDoc.getPages().size(), redactionRequest.getRuleSetId()); } catch (IOException e) { throw new RedactionException(e); @@ -135,22 +140,22 @@ public class RedactionController implements RedactionResource { } - private RedactionResult convert(PDDocument document, int numberOfPages) throws IOException { + private RedactionResult convert(PDDocument document, int numberOfPages, String ruleSetId) throws IOException { - return convert(document, numberOfPages, null, null, 0, 0); + return convert(document, numberOfPages, null, null, 0, 0, ruleSetId); } private RedactionResult convert(PDDocument document, int numberOfPages, List redactionLogEntities, - SectionGrid sectionGrid, long dictionaryVersion, long rulesVersion) throws IOException { + SectionGrid sectionGrid, long dictionaryVersion, long rulesVersion, String ruleSetId) throws IOException { try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) { document.save(byteArrayOutputStream); return RedactionResult.builder() .document(byteArrayOutputStream.toByteArray()) .numberOfPages(numberOfPages) - .redactionLog(new RedactionLog(redactionLogEntities, dictionaryVersion, rulesVersion)) + .redactionLog(new RedactionLog(redactionLogEntities, dictionaryVersion, rulesVersion, ruleSetId)) .sectionGrid(sectionGrid) .build(); }