Pull request #200: RSS-229: Deduplicate sex for scm report

Merge in RED/redaction-report-service from RSS-229 to master

* commit 'a14e1003ce780968c1edc5956439d6ad646c1e21':
  RSS-229: Deduplicate sex for scm report
This commit is contained in:
Dominique Eiflaender 2022-11-28 12:51:13 +01:00
commit 5d67cd80fa

View File

@ -266,7 +266,7 @@ public class RSSPoc2Service {
}
if (oecdIn(oecd, Set.of("405", "429"))) {
resultMap.put(SEX, getJoinedUniqueValues(redactionLog, "sex", ", "));
resultMap.put(SEX, getSex(redactionLog));
resultMap.put(NUMBER_OF_ANIMALS, getNumberOfAnimals(redactionLog));
}
@ -458,6 +458,20 @@ public class RSSPoc2Service {
}
private String getSex(RedactionLog redactionLog){
return redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("sex")).map(RedactionLogEntry::getValue)
.map(String::toLowerCase)
.map(s -> {
if(s.equals("females")){
return "female";
} else if (s.equals("males")){
return "male";
}
return s;
}).collect(Collectors.toSet()).stream().collect(Collectors.joining(", ")).trim();
}
private String getWhatWasTheApproachUsed(RedactionLog redactionLog) {
var approachUsed = redactionLog.getRedactionLogEntry().stream().filter(r -> r.getType().equals("approach_used")).map(RedactionLogEntry::getValue).findFirst();