Merge branch 'DM-305' into 'master'
DM-305: Added new DocuMine transformation for combining all paragraph values... See merge request redactmanager/redaction-report-service!4
This commit is contained in:
commit
c2d8cc7064
@ -170,7 +170,7 @@ public class RSSPoc2Service {
|
||||
|
||||
if (oecdIn(oecd, Set.of("402", "403", "404", "405", "425", "429", "436", "471"))) {
|
||||
|
||||
resultMap.put(STUDY_CONCLUSION, getFirstEntryOrElse(redactionLog, "study_conclusion", ""));
|
||||
resultMap.put(STUDY_CONCLUSION, combineValuesOfFirstFoundSection(redactionLog, "study_conclusion", " ", ""));
|
||||
|
||||
var guidelineDeviationSentences = getAsSentences(redactionLog, "guideline_deviation");
|
||||
int i = 1;
|
||||
@ -363,6 +363,28 @@ public class RSSPoc2Service {
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent combineValuesOfFirstFoundSection(RedactionLog redactionLog, String type, String seperator, String elseValue){
|
||||
|
||||
String transformation = String.format("Combine paragraphs of '%s' with seperator '%s' in first Section found", type, seperator);
|
||||
|
||||
var entries = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals(type)).toList();
|
||||
|
||||
if(entries.isEmpty()){
|
||||
return SCMComponent.builder().originalValue(elseValue).transformation(transformation).build();
|
||||
}
|
||||
|
||||
int firstSectionNr = entries.get(0).getSectionNumber();
|
||||
|
||||
String value = entries.stream().filter(e -> e.getSectionNumber() == firstSectionNr).map(RedactionLogEntry::getValue).collect(Collectors.joining(seperator)).trim();
|
||||
|
||||
return SCMComponent.builder()
|
||||
.originalValue(value)
|
||||
.scmAnnotations(entries.stream().map(this::toScmAnnotations).collect(Collectors.toList()))
|
||||
.transformation(transformation)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
private SCMComponent getFirstEntryOrElse(RedactionLog redactionLog, String type, String elseValue) {
|
||||
|
||||
String transformation = String.format("First found value of type '%s' or else '%s'", type, elseValue);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user