Merge branch 'RED-8586-backport' into 'release/4.244.x'
RED-8586 - Fix confidentiality rules See merge request redactmanager/redaction-service!295
This commit is contained in:
commit
2bc3440a14
@ -56,35 +56,12 @@ public class EntityChangeLogService {
|
|||||||
ChangeType changeType = calculateChangeType(entityLogEntry.getState(), previousEntity.getState());
|
ChangeType changeType = calculateChangeType(entityLogEntry.getState(), previousEntity.getState());
|
||||||
entityLogEntry.getChanges().add(new Change(analysisNumber, changeType, now));
|
entityLogEntry.getChanges().add(new Change(analysisNumber, changeType, now));
|
||||||
}
|
}
|
||||||
|
|
||||||
addManualChanges(entityLogEntry, previousEntity);
|
|
||||||
}
|
}
|
||||||
addRemovedEntriesAsRemoved(previousEntityLogEntries, newEntityLogEntries, manualRedactions, analysisNumber, now);
|
addRemovedEntriesAsRemoved(previousEntityLogEntries, newEntityLogEntries, manualRedactions, analysisNumber, now);
|
||||||
return hasChanges;
|
return hasChanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If a manual change is present in the previous entity but not in the new entity, add it to the new one and
|
|
||||||
// sort them, so they are displayed in the correct order.
|
|
||||||
private void addManualChanges(EntityLogEntry entityLogEntry, EntityLogEntry previousEntity) {
|
|
||||||
|
|
||||||
Comparator<ManualChange> manualChangeComparator =
|
|
||||||
Comparator.comparing(ManualChange::getManualRedactionType)
|
|
||||||
.thenComparing(ManualChange::getRequestedDate);
|
|
||||||
|
|
||||||
previousEntity.getManualChanges().forEach(manualChange -> {
|
|
||||||
boolean contains = entityLogEntry.getManualChanges()
|
|
||||||
.stream()
|
|
||||||
.anyMatch(existingChange -> manualChangeComparator.compare(existingChange, manualChange) == 0);
|
|
||||||
|
|
||||||
if (!contains) {
|
|
||||||
entityLogEntry.getManualChanges().add(manualChange);
|
|
||||||
entityLogEntry.getManualChanges().sort(Comparator.comparing(ManualChange::getRequestedDate));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void addRemovedEntriesAsRemoved(List<EntityLogEntry> previousEntityLogEntries,
|
private void addRemovedEntriesAsRemoved(List<EntityLogEntry> previousEntityLogEntries,
|
||||||
List<EntityLogEntry> newEntityLogEntries,
|
List<EntityLogEntry> newEntityLogEntries,
|
||||||
ManualRedactions manualRedactions,
|
ManualRedactions manualRedactions,
|
||||||
@ -94,7 +71,10 @@ public class EntityChangeLogService {
|
|||||||
Set<String> existingIds = newEntityLogEntries.stream().map(EntityLogEntry::getId).collect(Collectors.toSet());
|
Set<String> existingIds = newEntityLogEntries.stream().map(EntityLogEntry::getId).collect(Collectors.toSet());
|
||||||
List<EntityLogEntry> removedEntries = previousEntityLogEntries.stream()
|
List<EntityLogEntry> removedEntries = previousEntityLogEntries.stream()
|
||||||
.filter(entry -> !existingIds.contains(entry.getId()))
|
.filter(entry -> !existingIds.contains(entry.getId()))
|
||||||
.toList();
|
.collect(Collectors.toList());
|
||||||
|
var removedDossierRedaction = removedEntries.stream().filter(e -> e.getState() == EntryState.REMOVED && e.getType().equals("dossier_redaction")).toList();
|
||||||
|
previousEntityLogEntries.removeAll(removedDossierRedaction);
|
||||||
|
removedEntries.removeAll(removedDossierRedaction);
|
||||||
removedEntries.forEach(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.REMOVED, now)));
|
removedEntries.forEach(entry -> entry.getChanges().add(new Change(analysisNumber, ChangeType.REMOVED, now)));
|
||||||
removedEntries.forEach(entry -> entry.setState(EntryState.REMOVED));
|
removedEntries.forEach(entry -> entry.setState(EntryState.REMOVED));
|
||||||
removedEntries.forEach(entry -> addManualChangeForDictionaryRemovals(entry, manualRedactions));
|
removedEntries.forEach(entry -> addManualChangeForDictionaryRemovals(entry, manualRedactions));
|
||||||
|
|||||||
@ -123,7 +123,7 @@ public class EntityLogCreatorService {
|
|||||||
.stream()
|
.stream()
|
||||||
.filter(entry -> (newEntityIds.contains(entry.getId()) || entry.getContainingNodeId().isEmpty() || sectionsToReanalyseIds.contains(entry.getContainingNodeId()
|
.filter(entry -> (newEntityIds.contains(entry.getId()) || entry.getContainingNodeId().isEmpty() || sectionsToReanalyseIds.contains(entry.getContainingNodeId()
|
||||||
.get(0))))
|
.get(0))))
|
||||||
.toList();
|
.collect(Collectors.toList());
|
||||||
previousEntityLog.getEntityLogEntry().removeAll(previousEntriesFromReAnalyzedSections);
|
previousEntityLog.getEntityLogEntry().removeAll(previousEntriesFromReAnalyzedSections);
|
||||||
|
|
||||||
boolean hasChanges = entityChangeLogService.computeChanges(previousEntriesFromReAnalyzedSections,
|
boolean hasChanges = entityChangeLogService.computeChanges(previousEntriesFromReAnalyzedSections,
|
||||||
|
|||||||
@ -690,13 +690,22 @@ rule "ETC.3.1: Redact logos (vertebrate study)"
|
|||||||
|
|
||||||
|
|
||||||
// Rule unit: ETC.5
|
// Rule unit: ETC.5
|
||||||
rule "ETC.5.0: Ignore dossier_redaction entries if confidentiality is not 'confidential'"
|
rule "ETC.5.0: Skip dossier_redaction entries if confidentiality is 'confidential'"
|
||||||
|
when
|
||||||
|
FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
|
then
|
||||||
|
$dossierRedaction.skip("ETC.5.0", "Ignore dossier_redaction when confidential");
|
||||||
|
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
||||||
|
end
|
||||||
|
|
||||||
|
rule "ETC.5.1: Remove dossier_redaction entries if confidentiality is not 'confidential'"
|
||||||
when
|
when
|
||||||
not FileAttribute(label == "Confidentiality", value == "confidential")
|
not FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
then
|
then
|
||||||
$dossierRedaction.ignore("ETC.5.0", "Ignore dossier redactions, when not confidential");
|
$dossierRedaction.remove("ETC.5.1", "Remove dossier_redaction when not confidential");
|
||||||
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
retract($dossierRedaction);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1148,13 +1148,22 @@ rule "ETC.4.2: Redact dossier dictionary entries"
|
|||||||
|
|
||||||
|
|
||||||
// Rule unit: ETC.5
|
// Rule unit: ETC.5
|
||||||
rule "ETC.5.0: Ignore dossier_redaction entries if confidentiality is not 'confidential'"
|
rule "ETC.5.0: Skip dossier_redaction entries if confidentiality is 'confidential'"
|
||||||
|
when
|
||||||
|
FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
|
then
|
||||||
|
$dossierRedaction.skip("ETC.5.0", "Ignore dossier_redaction when confidential");
|
||||||
|
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
||||||
|
end
|
||||||
|
|
||||||
|
rule "ETC.5.1: Remove dossier_redaction entries if confidentiality is not 'confidential'"
|
||||||
when
|
when
|
||||||
not FileAttribute(label == "Confidentiality", value == "confidential")
|
not FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
then
|
then
|
||||||
$dossierRedaction.ignore("ETC.5.0", "Ignore dossier redactions, when not confidential");
|
$dossierRedaction.remove("ETC.5.1", "Remove dossier_redaction when not confidential");
|
||||||
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
retract($dossierRedaction);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -800,13 +800,22 @@ rule "ETC.4.0: Redact dossier dictionary entries"
|
|||||||
|
|
||||||
|
|
||||||
// Rule unit: ETC.5
|
// Rule unit: ETC.5
|
||||||
rule "ETC.5.0: Ignore dossier_redaction entries if confidentiality is not 'confidential'"
|
rule "ETC.5.0: Skip dossier_redaction entries if confidentiality is 'confidential'"
|
||||||
|
when
|
||||||
|
FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
|
then
|
||||||
|
$dossierRedaction.skip("ETC.5.0", "Ignore dossier_redaction when confidential");
|
||||||
|
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
||||||
|
end
|
||||||
|
|
||||||
|
rule "ETC.5.1: Remove dossier_redaction entries if confidentiality is not 'confidential'"
|
||||||
when
|
when
|
||||||
not FileAttribute(label == "Confidentiality", value == "confidential")
|
not FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
then
|
then
|
||||||
$dossierRedaction.ignore("ETC.5.0", "Ignore dossier redactions, when not confidential");
|
$dossierRedaction.remove("ETC.5.1", "Remove dossier_redaction when not confidential");
|
||||||
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
retract($dossierRedaction);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -449,14 +449,22 @@ rule "ETC.3.1: Redact logos (non vertebrate study)"
|
|||||||
|
|
||||||
|
|
||||||
// Rule unit: ETC.5
|
// Rule unit: ETC.5
|
||||||
rule "ETC.5.0: Ignore dossier_redaction entries if confidentiality is not 'confidential'"
|
rule "ETC.5.0: Skip dossier_redaction entries if confidentiality is 'confidential'"
|
||||||
|
when
|
||||||
|
FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
|
then
|
||||||
|
$dossierRedaction.skip("ETC.5.0", "Ignore dossier_redaction when confidential");
|
||||||
|
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
||||||
|
end
|
||||||
|
|
||||||
|
rule "ETC.5.1: Remove dossier_redaction entries if confidentiality is not 'confidential'"
|
||||||
when
|
when
|
||||||
not FileAttribute(label == "Confidentiality", value == "confidential")
|
not FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
then
|
then
|
||||||
$dossierRedaction.ignore("ETC.5.0", "Ignore dossier redactions, when not confidential");
|
$dossierRedaction.remove("ETC.5.1", "Remove dossier_redaction when not confidential");
|
||||||
update($dossierRedaction);
|
retract($dossierRedaction);
|
||||||
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1157,13 +1157,22 @@ rule "ETC.4.2: Redact dossier dictionary entries"
|
|||||||
|
|
||||||
|
|
||||||
// Rule unit: ETC.5
|
// Rule unit: ETC.5
|
||||||
rule "ETC.5.0: Ignore dossier_redaction entries if confidentiality is not 'confidential'"
|
rule "ETC.5.0: Skip dossier_redaction entries if confidentiality is 'confidential'"
|
||||||
|
when
|
||||||
|
FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
|
then
|
||||||
|
$dossierRedaction.skip("ETC.5.0", "Ignore dossier_redaction when confidential");
|
||||||
|
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
||||||
|
end
|
||||||
|
|
||||||
|
rule "ETC.5.1: Remove dossier_redaction entries if confidentiality is not 'confidential'"
|
||||||
when
|
when
|
||||||
not FileAttribute(label == "Confidentiality", value == "confidential")
|
not FileAttribute(label == "Confidentiality", value == "confidential")
|
||||||
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
$dossierRedaction: TextEntity(type() == "dossier_redaction")
|
||||||
then
|
then
|
||||||
$dossierRedaction.ignore("ETC.5.0", "Ignore dossier redactions, when not confidential");
|
$dossierRedaction.remove("ETC.5.1", "Remove dossier_redaction when not confidential");
|
||||||
$dossierRedaction.getIntersectingNodes().forEach(node -> update(node));
|
retract($dossierRedaction);
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user