Pull request #28: Highlight N in vertebrate study tables and fixed rule order

Merge in RED/redaction-service from tableRules to master

* commit 'afa26895c8e78f261ec3700c515f412d8cf605ce':
  Fixed test problem
  Fixed pmd
  Highlight N in vertebrate study tables and fixed rule order
This commit is contained in:
Thierry Goeckel 2020-08-24 13:15:11 +02:00
commit 92f0af9d21
3 changed files with 30 additions and 22 deletions

View File

@ -37,15 +37,19 @@ public class Section {
public boolean isVertebrateStudy() {
return tabularData != null
&& tabularData.containsKey("Vertebrate study Y/N")
&& tabularData.get("Vertebrate study Y/N").getText().equals("Y");
&& (tabularData.containsKey("Vertebrate study Y/N")
&& 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"));
}
public boolean isNotVertebrateStudy() {
return tabularData != null
&& tabularData.containsKey("Vertebrate study Y/N")
&& tabularData.get("Vertebrate study Y/N").getText().equals("N");
&& (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"));
}
@ -176,13 +180,13 @@ public class Section {
}
public void highlightCell(String cellHeader, int ruleNumber) {
public void highlightCell(String cellHeader, int ruleNumber, String type) {
TextBlock value = tabularData.get(cellHeader);
if (value == null) {
log.warn("Could not find any data for {}.", cellHeader);
} else {
Entity entity = new Entity(value.getText(), "must_redact", 0, value.getText().length(), headline, sectionNumber);
Entity entity = new Entity(value.getText(), type, 0, value.getText().length(), headline, sectionNumber);
entity.setRedaction(false);
entity.setMatchedRule(ruleNumber);
entity.setRedactionReason(cellHeader);

View File

@ -232,7 +232,7 @@ public class EntityRedactionServiceTest {
" then\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.highlightCell(\"Vertebrate study Y/N\", 9);\n" +
" section.highlightCell(\"Vertebrate study Y/N\", 9, \"must_redact\");\n" +
" end";
when(rulesClient.getVersion()).thenReturn(1L);
when(rulesClient.getRules()).thenReturn(new RulesResponse(tableRules));

View File

@ -90,28 +90,32 @@ rule "7: Redact contact information, if Producer is found"
section.redactBetween("No:", "Fax", "address", 7, "Producer was found");
end
rule "8: Redact Authors and Addresses in Reference Table, if it is a Vertebrate study"
when
Section(isVertebrateStudy())
then
section.redact("name", 8, "Redacted because row is a vertebrate study");
section.redact("address", 8, "Redacted because row is a vertebrate study");
section.highlightCell("Vertebrate study Y/N", 9);
end
rule "9: Not redacted because Vertebrate Study = N"
rule "8: Not redacted because Vertebrate Study = N"
when
Section(isNotVertebrateStudy())
then
section.redactNot("name", 9, "Not redacted because row is not a vertebrate study");
section.redactNot("address", 9, "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.highlightCell("Vertebrate study Y/N", 8, "hint_only");
section.highlightCell("Verte brate study Y/N", 8, "hint_only");
end
rule "10: Redact if must redact entry is found"
rule "9: Redact if must redact entry is found"
when
eval(section.contains("must_redact")==true);
then
section.redact("name", 10, "must_redact entry was found.");
section.redact("address", 10, "must_redact entry was found.");
end
section.redact("name", 9, "must_redact entry was found.");
section.redact("address", 9, "must_redact entry was found.");
end
rule "10: Redact Authors and Addresses in Reference Table, if it is a Vertebrate study"
when
Section(isVertebrateStudy())
then
section.redact("name", 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("Verte brate study Y/N", 10, "must_redact");
end