RED-9466 - Adding annotation removes all AI based recommendations until forced re-analysis

- fix sonar issues
This commit is contained in:
corinaolariu 2024-06-28 14:54:01 +03:00
parent b9c6af69e2
commit 25c25ecf00
3 changed files with 12 additions and 12 deletions

View File

@ -223,7 +223,6 @@ public class EntityLogCreatorService {
String type = precursorEntity.getManualOverwrite().getType() String type = precursorEntity.getManualOverwrite().getType()
.orElse(precursorEntity.getType()); .orElse(precursorEntity.getType());
boolean isHint = isHint(precursorEntity.getEntityType());
return EntityLogEntry.builder() return EntityLogEntry.builder()
.id(precursorEntity.getId()) .id(precursorEntity.getId())
.reason(precursorEntity.buildReasonWithManualChangeDescriptions()) .reason(precursorEntity.buildReasonWithManualChangeDescriptions())

View File

@ -73,9 +73,10 @@ public class ComponentDroolsExecutionService {
entities.add(Entity.fromEntityLogEntry(entry, document, entry.getStartOffset(), entry.getEndOffset())); entities.add(Entity.fromEntityLogEntry(entry, document, entry.getStartOffset(), entry.getEndOffset()));
if (entry.getDuplicatedTextRanges() != null && !entry.getDuplicatedTextRanges().isEmpty()) { if (entry.getDuplicatedTextRanges() != null && !entry.getDuplicatedTextRanges().isEmpty()) {
entry.getDuplicatedTextRanges() entry.getDuplicatedTextRanges()
.forEach(duplicatedTextRange -> { .forEach(duplicatedTextRange -> entities.add(Entity.fromEntityLogEntry(entry,
entities.add(Entity.fromEntityLogEntry(entry, document, duplicatedTextRange.getStart(), duplicatedTextRange.getEnd())); document,
}); duplicatedTextRange.getStart(),
duplicatedTextRange.getEnd())));
} }
return entities.stream(); return entities.stream();
}) })

View File

@ -178,10 +178,10 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
var publishedInformationEntry1 = findEntityByTypeAndValue(entityLog, "published_information", "Oxford University Press").findFirst() var publishedInformationEntry1 = findEntityByTypeAndValue(entityLog, "published_information", "Oxford University Press").findFirst()
.orElseThrow(); .orElseThrow();
assertThat(publishedInformationEntry1.getSection().startsWith("Paragraph:")); assertThat(publishedInformationEntry1.getSection()).startsWith("Paragraph:");
var asyaLyon1 = findEntityByTypeAndValueAndSectionNumber(entityLog, "CBI_author", "Asya Lyon", publishedInformationEntry1.getContainingNodeId()).findFirst() var asyaLyon1 = findEntityByTypeAndValueAndSectionNumber(entityLog, "CBI_author", "Asya Lyon", publishedInformationEntry1.getContainingNodeId()).findFirst()
.orElseThrow(); .orElseThrow();
assertThat(asyaLyon1.getSection().startsWith("Paragraph:")); assertThat(asyaLyon1.getSection()).startsWith("Paragraph:");
assertEquals(EntryState.SKIPPED, asyaLyon1.getState()); assertEquals(EntryState.SKIPPED, asyaLyon1.getState());
var idRemoval = buildIdRemoval(publishedInformationEntry1.getId()); var idRemoval = buildIdRemoval(publishedInformationEntry1.getId());
@ -232,10 +232,10 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
var publishedInformationEntry1 = findEntityByTypeAndValue(entityLog, "published_information", "Oxford University Press").findFirst() var publishedInformationEntry1 = findEntityByTypeAndValue(entityLog, "published_information", "Oxford University Press").findFirst()
.orElseThrow(); .orElseThrow();
assertThat(publishedInformationEntry1.getSection().startsWith("Paragraph:")); assertThat(publishedInformationEntry1.getSection()).startsWith("Paragraph:");
var asyaLyon1 = findEntityByTypeAndValueAndSectionNumber(entityLog, "CBI_author", "Asya Lyon", publishedInformationEntry1.getContainingNodeId()).findFirst() var asyaLyon1 = findEntityByTypeAndValueAndSectionNumber(entityLog, "CBI_author", "Asya Lyon", publishedInformationEntry1.getContainingNodeId()).findFirst()
.orElseThrow(); .orElseThrow();
assertThat(publishedInformationEntry1.getSection().startsWith("Paragraph:")); assertThat(publishedInformationEntry1.getSection()).startsWith("Paragraph:");
assertEquals(EntryState.SKIPPED, asyaLyon1.getState()); assertEquals(EntryState.SKIPPED, asyaLyon1.getState());
var idRemoval = buildIdRemoval(publishedInformationEntry1.getId()); var idRemoval = buildIdRemoval(publishedInformationEntry1.getId());
@ -388,7 +388,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
@Test @Test
@SneakyThrows @SneakyThrows
public void testNerEntitiesAfterReanalysis() { void testNerEntitiesAfterReanalysis() {
String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl"); String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl");
when(rulesClient.getRules(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.ENTITY)).thenReturn(JSONPrimitive.of(EFSA_SANITISATION_RULES)); when(rulesClient.getRules(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.ENTITY)).thenReturn(JSONPrimitive.of(EFSA_SANITISATION_RULES));
@ -414,7 +414,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
String nerValue = "Osip S."; String nerValue = "Osip S.";
var nerEntity = findEntityByTypeAndValue(entityLog, DICTIONARY_AUTHOR, nerValue).findFirst() var nerEntity = findEntityByTypeAndValue(entityLog, DICTIONARY_AUTHOR, nerValue).findFirst()
.orElseThrow(); .orElseThrow();
assertThat(nerEntity.getEngines().contains(Engine.NER)); assertThat(nerEntity.getEngines()).contains(Engine.NER);
String dictionaryAddValue = "cooperation"; String dictionaryAddValue = "cooperation";
ManualRedactionEntry manualRedactionEntry = ManualRedactionEntry.builder() ManualRedactionEntry manualRedactionEntry = ManualRedactionEntry.builder()
@ -445,11 +445,11 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
.filter(entityLogEntry -> entityLogEntry.getValue().equals(dictionaryAddValue)) .filter(entityLogEntry -> entityLogEntry.getValue().equals(dictionaryAddValue))
.findFirst() .findFirst()
.get(); .get();
assertEquals(entityLogEntryAdded.getState(), EntryState.APPLIED); assertEquals(EntryState.APPLIED, entityLogEntryAdded.getState());
nerEntity = findEntityByTypeAndValue(entityLog, DICTIONARY_AUTHOR, nerValue).findFirst() nerEntity = findEntityByTypeAndValue(entityLog, DICTIONARY_AUTHOR, nerValue).findFirst()
.orElseThrow(); .orElseThrow();
assertThat(nerEntity.getEngines().contains(Engine.NER)); assertThat(nerEntity.getEngines()).contains(Engine.NER);
dossierDictionary.get(DICTIONARY_AUTHOR).remove(dictionaryAddValue); dossierDictionary.get(DICTIONARY_AUTHOR).remove(dictionaryAddValue);
} }