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:
commit
92f0af9d21
@ -37,15 +37,19 @@ public class Section {
|
|||||||
|
|
||||||
public boolean isVertebrateStudy() {
|
public boolean isVertebrateStudy() {
|
||||||
return tabularData != null
|
return tabularData != null
|
||||||
&& tabularData.containsKey("Vertebrate study Y/N")
|
&& (tabularData.containsKey("Vertebrate study Y/N")
|
||||||
&& tabularData.get("Vertebrate study Y/N").getText().equals("Y");
|
&& 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() {
|
public boolean isNotVertebrateStudy() {
|
||||||
return tabularData != null
|
return tabularData != null
|
||||||
&& tabularData.containsKey("Vertebrate study Y/N")
|
&& (tabularData.containsKey("Vertebrate study Y/N")
|
||||||
&& tabularData.get("Vertebrate study Y/N").getText().equals("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);
|
TextBlock value = tabularData.get(cellHeader);
|
||||||
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 {
|
||||||
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.setRedaction(false);
|
||||||
entity.setMatchedRule(ruleNumber);
|
entity.setMatchedRule(ruleNumber);
|
||||||
entity.setRedactionReason(cellHeader);
|
entity.setRedactionReason(cellHeader);
|
||||||
|
|||||||
@ -232,7 +232,7 @@ public class EntityRedactionServiceTest {
|
|||||||
" 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" +
|
||||||
" section.highlightCell(\"Vertebrate study Y/N\", 9);\n" +
|
" section.highlightCell(\"Vertebrate study Y/N\", 9, \"must_redact\");\n" +
|
||||||
" end";
|
" end";
|
||||||
when(rulesClient.getVersion()).thenReturn(1L);
|
when(rulesClient.getVersion()).thenReturn(1L);
|
||||||
when(rulesClient.getRules()).thenReturn(new RulesResponse(tableRules));
|
when(rulesClient.getRules()).thenReturn(new RulesResponse(tableRules));
|
||||||
|
|||||||
@ -90,28 +90,32 @@ rule "7: Redact contact information, if Producer is found"
|
|||||||
section.redactBetween("No:", "Fax", "address", 7, "Producer was found");
|
section.redactBetween("No:", "Fax", "address", 7, "Producer was found");
|
||||||
end
|
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
|
when
|
||||||
Section(isNotVertebrateStudy())
|
Section(isNotVertebrateStudy())
|
||||||
then
|
then
|
||||||
section.redactNot("name", 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", 9, "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
|
end
|
||||||
|
|
||||||
|
|
||||||
rule "10: Redact if must redact entry is found"
|
rule "9: Redact if must redact entry is found"
|
||||||
when
|
when
|
||||||
eval(section.contains("must_redact")==true);
|
eval(section.contains("must_redact")==true);
|
||||||
then
|
then
|
||||||
section.redact("name", 10, "must_redact entry was found.");
|
section.redact("name", 9, "must_redact entry was found.");
|
||||||
section.redact("address", 10, "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"
|
||||||
|
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
|
||||||
Loading…
x
Reference in New Issue
Block a user