Pull request #34: RED-267: Return dictionary and rules version in redactionLog
Merge in RED/redaction-service from RED-267 to master * commit 'b5fa771c285554132edc32e1df59836fd7748b9a': RED-267: Return dictionary and rules version in redactionLog
This commit is contained in:
commit
b07ebf78d2
@ -13,4 +13,8 @@ public class RedactionLog {
|
|||||||
|
|
||||||
private List<RedactionLogEntry> redactionLogEntry;
|
private List<RedactionLogEntry> redactionLogEntry;
|
||||||
|
|
||||||
|
private long dictionaryVersion = -1;
|
||||||
|
|
||||||
|
private long rulesVersion = -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,18 +3,21 @@ package com.iqser.red.service.redaction.v1.server.controller;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
||||||
|
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
||||||
import com.iqser.red.service.redaction.v1.model.RedactionRequest;
|
import com.iqser.red.service.redaction.v1.model.RedactionRequest;
|
||||||
import com.iqser.red.service.redaction.v1.model.RedactionResult;
|
import com.iqser.red.service.redaction.v1.model.RedactionResult;
|
||||||
import com.iqser.red.service.redaction.v1.resources.RedactionResource;
|
import com.iqser.red.service.redaction.v1.resources.RedactionResource;
|
||||||
import com.iqser.red.service.redaction.v1.server.classification.model.Document;
|
import com.iqser.red.service.redaction.v1.server.classification.model.Document;
|
||||||
import com.iqser.red.service.redaction.v1.server.classification.model.Page;
|
import com.iqser.red.service.redaction.v1.server.classification.model.Page;
|
||||||
import com.iqser.red.service.redaction.v1.server.exception.RedactionException;
|
import com.iqser.red.service.redaction.v1.server.exception.RedactionException;
|
||||||
|
import com.iqser.red.service.redaction.v1.server.redaction.service.DictionaryService;
|
||||||
import com.iqser.red.service.redaction.v1.server.redaction.service.DroolsExecutionService;
|
import com.iqser.red.service.redaction.v1.server.redaction.service.DroolsExecutionService;
|
||||||
import com.iqser.red.service.redaction.v1.server.redaction.service.EntityRedactionService;
|
import com.iqser.red.service.redaction.v1.server.redaction.service.EntityRedactionService;
|
||||||
import com.iqser.red.service.redaction.v1.server.segmentation.PdfSegmentationService;
|
import com.iqser.red.service.redaction.v1.server.segmentation.PdfSegmentationService;
|
||||||
@ -36,6 +39,7 @@ public class RedactionController implements RedactionResource {
|
|||||||
private final EntityRedactionService entityRedactionService;
|
private final EntityRedactionService entityRedactionService;
|
||||||
private final PdfFlattenService pdfFlattenService;
|
private final PdfFlattenService pdfFlattenService;
|
||||||
private final DroolsExecutionService droolsExecutionService;
|
private final DroolsExecutionService droolsExecutionService;
|
||||||
|
private final DictionaryService dictionaryService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RedactionResult redact(@RequestBody RedactionRequest redactionRequest) {
|
public RedactionResult redact(@RequestBody RedactionRequest redactionRequest) {
|
||||||
@ -49,10 +53,10 @@ public class RedactionController implements RedactionResource {
|
|||||||
|
|
||||||
if (redactionRequest.isFlatRedaction()) {
|
if (redactionRequest.isFlatRedaction()) {
|
||||||
PDDocument flatDocument = pdfFlattenService.flattenPDF(pdDocument);
|
PDDocument flatDocument = pdfFlattenService.flattenPDF(pdDocument);
|
||||||
return convert(flatDocument, classifiedDoc.getPages().size(), new RedactionLog(classifiedDoc.getRedactionLogEntities()));
|
return convert(flatDocument, classifiedDoc.getPages().size(), classifiedDoc.getRedactionLogEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
return convert(pdDocument, classifiedDoc.getPages().size(), new RedactionLog(classifiedDoc.getRedactionLogEntities()));
|
return convert(pdDocument, classifiedDoc.getPages().size(), classifiedDoc.getRedactionLogEntities());
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RedactionException(e);
|
throw new RedactionException(e);
|
||||||
@ -130,14 +134,14 @@ public class RedactionController implements RedactionResource {
|
|||||||
return convert(document, numberOfPages, null);
|
return convert(document, numberOfPages, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RedactionResult convert(PDDocument document, int numberOfPages, RedactionLog redactionLog) throws IOException {
|
private RedactionResult convert(PDDocument document, int numberOfPages, List<RedactionLogEntry> redactionLogEntities) throws IOException {
|
||||||
|
|
||||||
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
|
||||||
document.save(byteArrayOutputStream);
|
document.save(byteArrayOutputStream);
|
||||||
return RedactionResult.builder()
|
return RedactionResult.builder()
|
||||||
.document(byteArrayOutputStream.toByteArray())
|
.document(byteArrayOutputStream.toByteArray())
|
||||||
.numberOfPages(numberOfPages)
|
.numberOfPages(numberOfPages)
|
||||||
.redactionLog(redactionLog)
|
.redactionLog(new RedactionLog(redactionLogEntities, dictionaryService.getDictionaryVersion(), droolsExecutionService.getRulesVersion()))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@ public class DictionaryService {
|
|||||||
|
|
||||||
private final DictionaryClient dictionaryClient;
|
private final DictionaryClient dictionaryClient;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private long dictionaryVersion = -1;
|
private long dictionaryVersion = -1;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import com.iqser.red.service.redaction.v1.server.client.RulesClient;
|
|||||||
import com.iqser.red.service.redaction.v1.server.exception.RulesValidationException;
|
import com.iqser.red.service.redaction.v1.server.exception.RulesValidationException;
|
||||||
import com.iqser.red.service.redaction.v1.server.redaction.model.Section;
|
import com.iqser.red.service.redaction.v1.server.redaction.model.Section;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -29,6 +30,7 @@ public class DroolsExecutionService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private KieContainer kieContainer;
|
private KieContainer kieContainer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private long rulesVersion = -1;
|
private long rulesVersion = -1;
|
||||||
|
|
||||||
public Section executeRules(Section section) {
|
public Section executeRules(Section section) {
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
Batches Produced at
|
Batches Produced at
|
||||||
CTL
|
CTL
|
||||||
for determination of residues
|
determination of residues
|
||||||
Loading…
x
Reference in New Issue
Block a user