From 908b3ca4b213a1bfd38f590bc02c3c887e581183 Mon Sep 17 00:00:00 2001 From: Andrei Isvoran Date: Wed, 1 Nov 2023 08:59:11 +0100 Subject: [PATCH] RED-7712 - Published information does not always trigger the skip mechanism --- .../test/resources/drools/acceptance_rules.drl | 16 ++++++---------- .../drools/all_redact_manager_rules.drl | 16 ++++++---------- .../EFSA_sanitisation_GFL_v1/rules.drl | 16 ++++++---------- .../main/resources/all_redact_manager_rules.drl | 16 ++++++---------- .../test/resources/all_redact_manager_rules.drl | 16 ++++++---------- 5 files changed, 30 insertions(+), 50 deletions(-) diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl index eb734c98..3f71868c 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/acceptance_rules.drl @@ -146,17 +146,13 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row" when - $table: Table(hasEntitiesOfType("published_information"), - (hasEntitiesOfType("CBI_author") || hasEntitiesOfType("CBI_address"))) + $table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author")) + $tableCell: TableCell() from $table.streamTableCells().toList() + $sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList() + TextEntity(type == "published_information") from $tableCell.getEntities() + $author: TextEntity(type == "CBI_author") from $tableCell.getEntities() then - $table.streamEntitiesWhereRowContainsEntitiesOfType(List.of("CBI_author", "CBI_address")) - .forEach(redactionEntity -> { - redactionEntity.skipWithReferences( - "CBI.7.1", - "Published Information found in row", - $table.getEntitiesOfTypeInSameRow("published_information", redactionEntity) - ); - }); + $author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author)); end diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl index 9fb37ab0..5ae16831 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/drools/all_redact_manager_rules.drl @@ -329,17 +329,13 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row" when - $table: Table(hasEntitiesOfType("published_information"), - (hasEntitiesOfType("CBI_author") || hasEntitiesOfType("CBI_address"))) + $table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author")) + $tableCell: TableCell() from $table.streamTableCells().toList() + $sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList() + TextEntity(type == "published_information") from $tableCell.getEntities() + $author: TextEntity(type == "CBI_author") from $tableCell.getEntities() then - $table.streamEntitiesWhereRowContainsEntitiesOfType(List.of("CBI_author", "CBI_address")) - .forEach(redactionEntity -> { - redactionEntity.skipWithReferences( - "CBI.7.1", - "Published Information found in row", - $table.getEntitiesOfTypeInSameRow("published_information", redactionEntity) - ); - }); + $author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author)); end diff --git a/redaction-service-v1/redaction-service-server-v1/src/test/resources/performance/dictionaries/EFSA_sanitisation_GFL_v1/rules.drl b/redaction-service-v1/redaction-service-server-v1/src/test/resources/performance/dictionaries/EFSA_sanitisation_GFL_v1/rules.drl index 2985b656..27872605 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/test/resources/performance/dictionaries/EFSA_sanitisation_GFL_v1/rules.drl +++ b/redaction-service-v1/redaction-service-server-v1/src/test/resources/performance/dictionaries/EFSA_sanitisation_GFL_v1/rules.drl @@ -142,17 +142,13 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row" when - $table: Table(hasEntitiesOfType("published_information"), - (hasEntitiesOfType("CBI_author") || hasEntitiesOfType("CBI_address"))) + $table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author")) + $tableCell: TableCell() from $table.streamTableCells().toList() + $sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList() + TextEntity(type == "published_information") from $tableCell.getEntities() + $author: TextEntity(type == "CBI_author") from $tableCell.getEntities() then - $table.streamEntitiesWhereRowContainsEntitiesOfType(List.of("CBI_author", "CBI_address")) - .forEach(redactionEntity -> { - redactionEntity.skipWithReferences( - "CBI.7.1", - "Published Information found in row", - $table.getEntitiesOfTypeInSameRow("published_information", redactionEntity) - ); - }); + $author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author)); end diff --git a/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl b/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl index ad8fa6ba..3cfc4031 100644 --- a/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl +++ b/redaction-service-v1/rules-management/src/main/resources/all_redact_manager_rules.drl @@ -329,17 +329,13 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row" when - $table: Table(hasEntitiesOfType("published_information"), - (hasEntitiesOfType("CBI_author") || hasEntitiesOfType("CBI_address"))) + $table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author")) + $tableCell: TableCell() from $table.streamTableCells().toList() + $sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList() + TextEntity(type == "published_information") from $tableCell.getEntities() + $author: TextEntity(type == "CBI_author") from $tableCell.getEntities() then - $table.streamEntitiesWhereRowContainsEntitiesOfType(List.of("CBI_author", "CBI_address")) - .forEach(redactionEntity -> { - redactionEntity.skipWithReferences( - "CBI.7.1", - "Published Information found in row", - $table.getEntitiesOfTypeInSameRow("published_information", redactionEntity) - ); - }); + $author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author)); end diff --git a/redaction-service-v1/rules-management/src/test/resources/all_redact_manager_rules.drl b/redaction-service-v1/rules-management/src/test/resources/all_redact_manager_rules.drl index ad8fa6ba..3cfc4031 100644 --- a/redaction-service-v1/rules-management/src/test/resources/all_redact_manager_rules.drl +++ b/redaction-service-v1/rules-management/src/test/resources/all_redact_manager_rules.drl @@ -329,17 +329,13 @@ rule "CBI.7.0: Do not redact Names and Addresses if published information found rule "CBI.7.1: Do not redact Names and Addresses if published information found in same table row" when - $table: Table(hasEntitiesOfType("published_information"), - (hasEntitiesOfType("CBI_author") || hasEntitiesOfType("CBI_address"))) + $table: Table(hasEntitiesOfType("published_information"), hasEntitiesOfType("CBI_author")) + $tableCell: TableCell() from $table.streamTableCells().toList() + $sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList() + TextEntity(type == "published_information") from $tableCell.getEntities() + $author: TextEntity(type == "CBI_author") from $tableCell.getEntities() then - $table.streamEntitiesWhereRowContainsEntitiesOfType(List.of("CBI_author", "CBI_address")) - .forEach(redactionEntity -> { - redactionEntity.skipWithReferences( - "CBI.7.1", - "Published Information found in row", - $table.getEntitiesOfTypeInSameRow("published_information", redactionEntity) - ); - }); + $author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author)); end