Pull request #92: RedactionLog now stores ruleSetId
Merge in RED/redaction-service from feature/ruleset-integration to master * commit '09069d11add65ae999ac80129d2188c64efaefec': RedactionLog now stores ruleSetId
This commit is contained in:
commit
75127fd1bd
@ -1,29 +1,32 @@
|
|||||||
package com.iqser.red.service.redaction.v1.model;
|
package com.iqser.red.service.redaction.v1.model;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class RedactionLog {
|
public class RedactionLog {
|
||||||
|
|
||||||
public RedactionLog(List<RedactionLogEntry> redactionLogEntry, long dictionaryVersion, long rulesVersion) {
|
private List<RedactionLogEntry> redactionLogEntry;
|
||||||
|
|
||||||
|
private long dictionaryVersion = -1;
|
||||||
|
private long rulesVersion = -1;
|
||||||
|
|
||||||
|
private String ruleSetId;
|
||||||
|
private String filename;
|
||||||
|
|
||||||
|
|
||||||
|
public RedactionLog(List<RedactionLogEntry> redactionLogEntry, long dictionaryVersion, long rulesVersion, String ruleSetId) {
|
||||||
|
|
||||||
this.redactionLogEntry = redactionLogEntry;
|
this.redactionLogEntry = redactionLogEntry;
|
||||||
this.dictionaryVersion = dictionaryVersion;
|
this.dictionaryVersion = dictionaryVersion;
|
||||||
this.rulesVersion = rulesVersion;
|
this.rulesVersion = rulesVersion;
|
||||||
|
this.ruleSetId = ruleSetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RedactionLogEntry> redactionLogEntry;
|
|
||||||
|
|
||||||
private long dictionaryVersion = -1;
|
|
||||||
|
|
||||||
private long rulesVersion = -1;
|
|
||||||
|
|
||||||
private String filename;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,8 +55,13 @@ public class RedactionController implements RedactionResource {
|
|||||||
|
|
||||||
log.info("Redaction analysis successful...");
|
log.info("Redaction analysis successful...");
|
||||||
|
|
||||||
return convert(pdDocument, classifiedDoc.getPages()
|
return convert(pdDocument,
|
||||||
.size(), classifiedDoc.getRedactionLogEntities(), classifiedDoc.getSectionGrid(), classifiedDoc.getDictionaryVersion(), classifiedDoc.getRulesVersion());
|
classifiedDoc.getPages().size(),
|
||||||
|
classifiedDoc.getRedactionLogEntities(),
|
||||||
|
classifiedDoc.getSectionGrid(),
|
||||||
|
classifiedDoc.getDictionaryVersion(),
|
||||||
|
classifiedDoc.getRulesVersion(),
|
||||||
|
redactionRequest.getRuleSetId());
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RedactionException(e);
|
throw new RedactionException(e);
|
||||||
@ -74,7 +79,7 @@ public class RedactionController implements RedactionResource {
|
|||||||
Document classifiedDoc = pdfSegmentationService.parseDocument(pdDocument);
|
Document classifiedDoc = pdfSegmentationService.parseDocument(pdDocument);
|
||||||
pdfVisualisationService.visualizeClassifications(classifiedDoc, pdDocument);
|
pdfVisualisationService.visualizeClassifications(classifiedDoc, pdDocument);
|
||||||
|
|
||||||
return convert(pdDocument, classifiedDoc.getPages().size());
|
return convert(pdDocument, classifiedDoc.getPages().size(), pdfSegmentationRequest.getRuleSetId());
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RedactionException(e);
|
throw new RedactionException(e);
|
||||||
@ -92,7 +97,7 @@ public class RedactionController implements RedactionResource {
|
|||||||
Document classifiedDoc = pdfSegmentationService.parseDocument(pdDocument);
|
Document classifiedDoc = pdfSegmentationService.parseDocument(pdDocument);
|
||||||
pdfVisualisationService.visualizeParagraphs(classifiedDoc, pdDocument);
|
pdfVisualisationService.visualizeParagraphs(classifiedDoc, pdDocument);
|
||||||
|
|
||||||
return convert(pdDocument, classifiedDoc.getPages().size());
|
return convert(pdDocument, classifiedDoc.getPages().size(), redactionRequest.getRuleSetId());
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RedactionException(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,
|
private RedactionResult convert(PDDocument document, int numberOfPages,
|
||||||
List<RedactionLogEntry> redactionLogEntities,
|
List<RedactionLogEntry> redactionLogEntities,
|
||||||
SectionGrid sectionGrid, long dictionaryVersion, long rulesVersion) throws IOException {
|
SectionGrid sectionGrid, long dictionaryVersion, long rulesVersion, String ruleSetId) 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(new RedactionLog(redactionLogEntities, dictionaryVersion, rulesVersion))
|
.redactionLog(new RedactionLog(redactionLogEntities, dictionaryVersion, rulesVersion, ruleSetId))
|
||||||
.sectionGrid(sectionGrid)
|
.sectionGrid(sectionGrid)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user