RED-6411 - extend logic when replacing entities with higher rank
This commit is contained in:
parent
459af9e33b
commit
7644afc3aa
@ -273,14 +273,14 @@ public final class EntitySearchUtils {
|
||||
existing.setLegalBasis(found.getLegalBasis());
|
||||
existing.setMatchedRule(found.getMatchedRule());
|
||||
existing.setRedactionReason(found.getRedactionReason());
|
||||
if (existing.getEntityType().equals(EntityType.RECOMMENDATION) && found.getEntityType().equals(EntityType.ENTITY) || existing.getEntityType()
|
||||
.equals(EntityType.ENTITY) && found.getEntityType().equals(EntityType.RECOMMENDATION)) {
|
||||
if (isOneARecommendationAndTheOtherEntity(found, existing)) {
|
||||
existing.setEntityType(EntityType.ENTITY);
|
||||
if (found.isRedaction()) {
|
||||
existing.setRedaction(true);
|
||||
}
|
||||
}
|
||||
} else if (dictionary.getDictionaryRank(existing.getType()) <= dictionary.getDictionaryRank(found.getType())) {
|
||||
} else if (dictionary.getDictionaryRank(existing.getType()) <= dictionary.getDictionaryRank(found.getType()) &&
|
||||
!(isOneARecommendationAndTheOtherEntity(found, existing) && existing.isRedaction() && found.isRedaction()) ) {
|
||||
entities.remove(found);
|
||||
entities.add(found);
|
||||
}
|
||||
@ -290,6 +290,13 @@ public final class EntitySearchUtils {
|
||||
}
|
||||
|
||||
|
||||
private boolean isOneARecommendationAndTheOtherEntity (Entity found, Entity existing) {
|
||||
|
||||
return existing.getEntityType().equals(EntityType.RECOMMENDATION) && found.getEntityType().equals(EntityType.ENTITY) || existing.getEntityType()
|
||||
.equals(EntityType.ENTITY) && found.getEntityType().equals(EntityType.RECOMMENDATION);
|
||||
}
|
||||
|
||||
|
||||
public void addEntitiesIgnoreRank(Set<Entity> entities, Set<Entity> found) {
|
||||
// HashSet keeps old value but we want the new.
|
||||
entities.removeAll(found);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user