RED-2439: Enabled to find surrounding text for manual redactions via queue
This commit is contained in:
parent
3f153c1df5
commit
e4cf3bfa60
@ -19,6 +19,8 @@ import java.util.Set;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AnalyzeRequest {
|
public class AnalyzeRequest {
|
||||||
|
|
||||||
|
private MessageType messageType;
|
||||||
|
|
||||||
private String dossierId;
|
private String dossierId;
|
||||||
private String fileId;
|
private String fileId;
|
||||||
private String dossierTemplateId;
|
private String dossierTemplateId;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.iqser.red.service.redaction.v1.model;
|
package com.iqser.red.service.redaction.v1.model;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualRedactions;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -11,6 +13,8 @@ import lombok.NoArgsConstructor;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AnalyzeResult {
|
public class AnalyzeResult {
|
||||||
|
|
||||||
|
private MessageType messageType;
|
||||||
|
|
||||||
private String dossierId;
|
private String dossierId;
|
||||||
private String fileId;
|
private String fileId;
|
||||||
private long duration;
|
private long duration;
|
||||||
@ -25,6 +29,8 @@ public class AnalyzeResult {
|
|||||||
|
|
||||||
private int analysisVersion;
|
private int analysisVersion;
|
||||||
|
|
||||||
|
private ManualRedactions manualRedactions;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,7 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.model;
|
||||||
|
|
||||||
|
public enum MessageType {
|
||||||
|
|
||||||
|
FULL_ANALYSE, REANALYSE, SURROUNDING_TEXT
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,6 +7,7 @@ import com.iqser.red.service.redaction.v1.model.AnalyzeResult;
|
|||||||
import com.iqser.red.service.redaction.v1.model.StructureAnalyzeRequest;
|
import com.iqser.red.service.redaction.v1.model.StructureAnalyzeRequest;
|
||||||
import com.iqser.red.service.redaction.v1.server.client.FileStatusProcessingUpdateClient;
|
import com.iqser.red.service.redaction.v1.server.client.FileStatusProcessingUpdateClient;
|
||||||
import com.iqser.red.service.redaction.v1.server.redaction.service.AnalyzeService;
|
import com.iqser.red.service.redaction.v1.server.redaction.service.AnalyzeService;
|
||||||
|
import com.iqser.red.service.redaction.v1.server.redaction.service.ManualRedactionSurroundingTextService;
|
||||||
import com.iqser.red.service.redaction.v1.server.redaction.service.NerAnalyserService;
|
import com.iqser.red.service.redaction.v1.server.redaction.service.NerAnalyserService;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -28,6 +29,7 @@ public class RedactionMessageReceiver {
|
|||||||
private final AnalyzeService analyzeService;
|
private final AnalyzeService analyzeService;
|
||||||
private final FileStatusProcessingUpdateClient fileStatusProcessingUpdateClient;
|
private final FileStatusProcessingUpdateClient fileStatusProcessingUpdateClient;
|
||||||
private final NerAnalyserService nerAnalyserService;
|
private final NerAnalyserService nerAnalyserService;
|
||||||
|
private final ManualRedactionSurroundingTextService manualRedactionSurroundingTextService;
|
||||||
|
|
||||||
|
|
||||||
@RabbitHandler
|
@RabbitHandler
|
||||||
@ -36,22 +38,37 @@ public class RedactionMessageReceiver {
|
|||||||
|
|
||||||
var analyzeRequest = objectMapper.readValue(in, AnalyzeRequest.class);
|
var analyzeRequest = objectMapper.readValue(in, AnalyzeRequest.class);
|
||||||
log.info("Processing analyze request for file: {}", analyzeRequest.getFileId());
|
log.info("Processing analyze request for file: {}", analyzeRequest.getFileId());
|
||||||
AnalyzeResult result;
|
AnalyzeResult result = null;
|
||||||
if (analyzeRequest.isReanalyseOnlyIfPossible()) {
|
|
||||||
result = analyzeService.reanalyze(analyzeRequest);
|
|
||||||
log.info("Successfully reanalyzed dossier {} file {} took: {}", analyzeRequest.getDossierId(), analyzeRequest.getFileId(), result.getDuration());
|
|
||||||
} else {
|
|
||||||
// TODO Seperate stucture analysis by other queue
|
|
||||||
analyzeService.analyzeDocumentStructure(new StructureAnalyzeRequest(analyzeRequest.getDossierId(), analyzeRequest.getFileId()));
|
|
||||||
|
|
||||||
// TODO NerEntities should be computed and stored in entity-recognition-service, should be triggered by a seperate queue after structure analysis
|
switch (analyzeRequest.getMessageType()){
|
||||||
nerAnalyserService.computeNerEntities(analyzeRequest.getDossierId(), analyzeRequest.getFileId());
|
|
||||||
|
|
||||||
result = analyzeService.analyze(analyzeRequest);
|
case REANALYSE:
|
||||||
log.info("Successfully analyzed dossier {} file {} took: {}", analyzeRequest.getDossierId(), analyzeRequest.getFileId(), result
|
result = analyzeService.reanalyze(analyzeRequest);
|
||||||
.getDuration());
|
log.info("Successfully reanalyzed dossier {} file {} took: {}", analyzeRequest.getDossierId(), analyzeRequest.getFileId(), result.getDuration());
|
||||||
|
break;
|
||||||
|
case FULL_ANALYSE:
|
||||||
|
// TODO Seperate stucture analysis by other queue
|
||||||
|
analyzeService.analyzeDocumentStructure(new StructureAnalyzeRequest(analyzeRequest.getDossierId(), analyzeRequest.getFileId()));
|
||||||
|
|
||||||
|
// TODO NerEntities should be computed and stored in entity-recognition-service, should be triggered by a seperate queue after structure analysis
|
||||||
|
nerAnalyserService.computeNerEntities(analyzeRequest.getDossierId(), analyzeRequest.getFileId());
|
||||||
|
|
||||||
|
result = analyzeService.analyze(analyzeRequest);
|
||||||
|
log.info("Successfully analyzed dossier {} file {} took: {}", analyzeRequest.getDossierId(), analyzeRequest.getFileId(), result
|
||||||
|
.getDuration());
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SURROUNDING_TEXT:
|
||||||
|
var manualRedactions = manualRedactionSurroundingTextService.addSurroundingText(analyzeRequest.getDossierId(), analyzeRequest.getFileId(), analyzeRequest.getManualRedactions());
|
||||||
|
result = AnalyzeResult.builder()
|
||||||
|
.dossierId(analyzeRequest.getDossierId())
|
||||||
|
.fileId(analyzeRequest.getFileId())
|
||||||
|
.manualRedactions(manualRedactions)
|
||||||
|
.build();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fileStatusProcessingUpdateClient.analysisSuccessful(analyzeRequest.getDossierId(), analyzeRequest.getFileId(), result);
|
fileStatusProcessingUpdateClient.analysisSuccessful(analyzeRequest.getDossierId(), analyzeRequest.getFileId(), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user