Made rules for table more stabil and flexible
This commit is contained in:
parent
d026f4e1db
commit
559c421542
@ -35,21 +35,11 @@ public class Section {
|
|||||||
private Map<String, TextBlock> tabularData;
|
private Map<String, TextBlock> tabularData;
|
||||||
|
|
||||||
|
|
||||||
public boolean isVertebrateStudy() {
|
public boolean rowEquals(String headerName, String value){
|
||||||
return tabularData != null
|
String cleanHeaderName = headerName.replaceAll("\n", "")
|
||||||
&& (tabularData.containsKey("Vertebrate study Y/N")
|
.replaceAll(" ", "");
|
||||||
&& tabularData.get("Vertebrate study Y/N").getText().equals("Y")
|
|
||||||
|| tabularData.containsKey("Verte brate study Y/N")
|
|
||||||
&& tabularData.get("Verte brate study Y/N").getText().equals("Y"));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return tabularData != null && tabularData.containsKey(cleanHeaderName) && tabularData.get(cleanHeaderName).getText().equals(value);
|
||||||
public boolean isNotVertebrateStudy() {
|
|
||||||
return tabularData != null
|
|
||||||
&& (tabularData.containsKey("Vertebrate study Y/N")
|
|
||||||
&& tabularData.get("Vertebrate study Y/N").getText().equals("N")
|
|
||||||
|| tabularData.containsKey("Verte brate study Y/N")
|
|
||||||
&& tabularData.get("Verte brate study Y/N").getText().equals("N"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -182,7 +172,10 @@ public class Section {
|
|||||||
|
|
||||||
public void highlightCell(String cellHeader, int ruleNumber, String type) {
|
public void highlightCell(String cellHeader, int ruleNumber, String type) {
|
||||||
|
|
||||||
TextBlock value = tabularData.get(cellHeader);
|
String cleanHeaderName = cellHeader.replaceAll("\n", "")
|
||||||
|
.replaceAll(" ", "");
|
||||||
|
|
||||||
|
TextBlock value = tabularData.get(cleanHeaderName);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
log.warn("Could not find any data for {}.", cellHeader);
|
log.warn("Could not find any data for {}.", cellHeader);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -60,9 +60,12 @@ public class EntityRedactionService {
|
|||||||
}
|
}
|
||||||
addSectionToManualRedactions(cell.getTextBlocks(), manualRedactions, table.getHeadline(), sectionNumber);
|
addSectionToManualRedactions(cell.getTextBlocks(), manualRedactions, table.getHeadline(), sectionNumber);
|
||||||
cell.getHeaderCells().forEach(headerCell -> {
|
cell.getHeaderCells().forEach(headerCell -> {
|
||||||
String headerName = headerCell.getTextBlocks().get(0).getText()
|
|
||||||
.replaceAll("\n", " ")
|
StringBuilder headerBuilder = new StringBuilder();
|
||||||
.replaceAll(" ", " ");
|
headerCell.getTextBlocks().forEach(textBlock -> headerBuilder.append(textBlock.getText()));
|
||||||
|
String headerName = headerBuilder.toString()
|
||||||
|
.replaceAll("\n", "")
|
||||||
|
.replaceAll(" ", "");
|
||||||
tabularData.put(headerName, cell.getTextBlocks().get(0));
|
tabularData.put(headerName, cell.getTextBlocks().get(0));
|
||||||
});
|
});
|
||||||
for (TextBlock textBlock : cell.getTextBlocks()) {
|
for (TextBlock textBlock : cell.getTextBlocks()) {
|
||||||
|
|||||||
@ -228,7 +228,7 @@ public class EntityRedactionServiceTest {
|
|||||||
"global Section section\n" +
|
"global Section section\n" +
|
||||||
"rule \"9: Redact Authors and Addresses in Reference Table, if it is a Vertebrate study\"\n" +
|
"rule \"9: Redact Authors and Addresses in Reference Table, if it is a Vertebrate study\"\n" +
|
||||||
" when\n" +
|
" when\n" +
|
||||||
" Section(isVertebrateStudy())\n" +
|
" Section(rowEquals(\"Vertebrate study Y/N\", \"Y\"))\n" +
|
||||||
" then\n" +
|
" then\n" +
|
||||||
" section.redact(\"name\", 9, \"Redacted because row is a vertebrate study\");\n" +
|
" section.redact(\"name\", 9, \"Redacted because row is a vertebrate study\");\n" +
|
||||||
" section.redact(\"address\", 9, \"Redacted because rows is a vertebrate study\");\n" +
|
" section.redact(\"address\", 9, \"Redacted because rows is a vertebrate study\");\n" +
|
||||||
|
|||||||
@ -93,12 +93,11 @@ rule "7: Redact contact information, if Producer is found"
|
|||||||
|
|
||||||
rule "8: Not redacted because Vertebrate Study = N"
|
rule "8: Not redacted because Vertebrate Study = N"
|
||||||
when
|
when
|
||||||
Section(isNotVertebrateStudy())
|
Section(rowEquals("Vertebrate study Y/N", "N"))
|
||||||
then
|
then
|
||||||
section.redactNot("name", 8, "Not redacted because row is not a vertebrate study");
|
section.redactNot("name", 8, "Not redacted because row is not a vertebrate study");
|
||||||
section.redactNot("address", 8, "Not redacted because row is not a vertebrate study");
|
section.redactNot("address", 8, "Not redacted because row is not a vertebrate study");
|
||||||
section.highlightCell("Vertebrate study Y/N", 8, "hint_only");
|
section.highlightCell("Vertebrate study Y/N", 8, "hint_only");
|
||||||
section.highlightCell("Verte brate study Y/N", 8, "hint_only");
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -110,12 +109,12 @@ rule "9: Redact if must redact entry is found"
|
|||||||
section.redact("address", 9, "must_redact entry was found.");
|
section.redact("address", 9, "must_redact entry was found.");
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
rule "10: Redact Authors and Addresses in Reference Table, if it is a Vertebrate study"
|
rule "10: Redact Authors and Addresses in Reference Table, if it is a Vertebrate study"
|
||||||
when
|
when
|
||||||
Section(isVertebrateStudy())
|
Section(rowEquals("Vertebrate study Y/N", "Y"))
|
||||||
then
|
then
|
||||||
section.redact("name", 10, "Redacted because row is a vertebrate study");
|
section.redact("name", 10, "Redacted because row is a vertebrate study");
|
||||||
section.redact("address", 10, "Redacted because row is a vertebrate study");
|
section.redact("address", 10, "Redacted because row is a vertebrate study");
|
||||||
section.highlightCell("Vertebrate study Y/N", 10, "must_redact");
|
section.highlightCell("Vertebrate study Y/N", 10, "must_redact");
|
||||||
section.highlightCell("Verte brate study Y/N", 10, "must_redact");
|
|
||||||
end
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user