Merge branch 'RED-7898' into 'master'
RED-7898 - Publish rule is not applied line-wise Closes RED-7898 See merge request redactmanager/redaction-service!190
This commit is contained in:
commit
3a685e5671
@ -172,6 +172,18 @@ public class Table implements SemanticNode {
|
||||
return streamChildrenOfType(NodeType.TABLE_CELL).map(node -> (TableCell) node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Streams all TableCells that contain at least one entity of a given type in this Table row-wise.
|
||||
*
|
||||
* @param type The type of the entity
|
||||
* @return Stream of filtered TableCells
|
||||
*/
|
||||
public Stream<TableCell> streamTableCellsWhichContainType(String type) {
|
||||
|
||||
return streamTableCells()
|
||||
.filter(tableCell -> tableCell.getEntities().stream().filter(TextEntity::active).anyMatch(entity -> entity.getType().equals(type)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Streams all TableCells in this Table which have the provided header row-wise.
|
||||
|
||||
@ -147,9 +147,8 @@ 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"))
|
||||
$tableCell: TableCell() from $table.streamTableCells().toList()
|
||||
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
|
||||
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
|
||||
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
|
||||
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
|
||||
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
|
||||
then
|
||||
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));
|
||||
|
||||
@ -330,9 +330,8 @@ 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"))
|
||||
$tableCell: TableCell() from $table.streamTableCells().toList()
|
||||
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
|
||||
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
|
||||
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
|
||||
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
|
||||
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
|
||||
then
|
||||
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));
|
||||
|
||||
@ -143,9 +143,8 @@ 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"))
|
||||
$tableCell: TableCell() from $table.streamTableCells().toList()
|
||||
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
|
||||
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
|
||||
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
|
||||
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
|
||||
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
|
||||
then
|
||||
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));
|
||||
|
||||
@ -330,9 +330,8 @@ 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"))
|
||||
$tableCell: TableCell() from $table.streamTableCells().toList()
|
||||
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
|
||||
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
|
||||
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
|
||||
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
|
||||
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
|
||||
then
|
||||
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));
|
||||
|
||||
@ -330,9 +330,8 @@ 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"))
|
||||
$tableCell: TableCell() from $table.streamTableCells().toList()
|
||||
$sameRowCell: TableCell(row == $tableCell.row) from $table.streamTableCells().toList()
|
||||
TextEntity(type == "published_information", active()) from $tableCell.getEntities()
|
||||
$cellsWithPublishedInformation: TableCell() from $table.streamTableCellsWhichContainType("published_information").toList()
|
||||
$tableCell: TableCell(row == $cellsWithPublishedInformation.row) from $table.streamTableCells().toList()
|
||||
$author: TextEntity(type == "CBI_author", active()) from $tableCell.getEntities()
|
||||
then
|
||||
$author.skipWithReferences("CBI.7.1", "Published Information found in row", $table.getEntitiesOfTypeInSameRow("published_information", $author));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user