Merge branch 'RED-9246-2' into 'master'
RED-9246: Resize on dossier level for dossier-template-level entry becomes skipped Closes RED-9246 See merge request redactmanager/redaction-service!458
This commit is contained in:
commit
3fd98c67f3
@ -31,6 +31,9 @@ public class Dictionary {
|
||||
|
||||
@Getter
|
||||
private List<DictionaryModel> dictionaryModels;
|
||||
// todo: dossier and dossier template level DictionaryModels override each other
|
||||
// at the moment there are no problems because they always have the same rank / hint information
|
||||
// but it should be changed so that the localAccessMap contains all models
|
||||
private Map<String, DictionaryModel> localAccessMap = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
|
||||
@ -1455,11 +1455,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -1598,6 +1598,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -105,8 +105,9 @@ public abstract class AbstractRedactionIntegrationTest {
|
||||
protected final static String TEST_DOSSIER_TEMPLATE_ID = "123";
|
||||
protected final static String TEST_DOSSIER_ID = "123";
|
||||
protected final static String TEST_FILE_ID = "123";
|
||||
public static final String IMPORTED_REDACTION_TYPE_ID = IMPORTED_REDACTION_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
public static final String DOSSIER_REDACTIONS_TYPE_ID = DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
public static final String IMPORTED_REDACTION_TYPE_ID = IMPORTED_REDACTION_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID + ":" + TEST_DOSSIER_ID;
|
||||
public static final String DOSSIER_REDACTIONS_TYPE_ID = DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID + ":" + TEST_DOSSIER_ID;
|
||||
public static final String DOSSIER_AUTHOR_TYPE_ID = DICTIONARY_AUTHOR + ":" + TEST_DOSSIER_TEMPLATE_ID + ":" + TEST_DOSSIER_ID;
|
||||
public static final String ROTATE_SIMPLE_TYPE_ID = ROTATE_SIMPLE_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
public static final String FORMULA_TYPE_ID = FORMULA_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
public static final String SIGNATURE_TYPE_ID = SIGNATURE_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
@ -124,7 +125,6 @@ public abstract class AbstractRedactionIntegrationTest {
|
||||
public static final String NO_REDACTION_TYPE_ID = NO_REDACTION_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
public static final String SPONSOR_TYPE_ID = DICTIONARY_SPONSOR + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
public static final String AUTHOR_TYPE_ID = DICTIONARY_AUTHOR + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
public static final String DOSSIER_AUTHOR_TYPE_ID = AUTHOR_TYPE_ID + ":" + TEST_DOSSIER_ID;
|
||||
public static final String ADDRESS_TYPE_ID = DICTIONARY_ADDRESS + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
public static final String VERTEBRATE_TYPE_ID = VERTEBRATE_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
|
||||
@ -192,7 +192,8 @@ public abstract class AbstractRedactionIntegrationTest {
|
||||
protected final Map<String, Integer> rankTypeMap = new HashMap<>();
|
||||
protected final Colors colors = new Colors();
|
||||
protected final Map<String, Long> reanlysisVersions = new HashMap<>();
|
||||
protected final Set<String> deleted = new HashSet<>();
|
||||
protected final Set<String> deletedInTemplate = new HashSet<>();
|
||||
protected final Set<String> deletedInDossier = new HashSet<>();
|
||||
|
||||
@MockBean
|
||||
protected RulesClient rulesClient;
|
||||
@ -267,8 +268,8 @@ public abstract class AbstractRedactionIntegrationTest {
|
||||
true));
|
||||
when(dictionaryClient.getDictionaryForType(DOSSIER_AUTHOR_TYPE_ID, version)).then((Answer<Type>) invocation -> getDictionaryResponse(DICTIONARY_AUTHOR, true));
|
||||
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, version, true)).then((Answer<List<Type>>)invocation -> (getTypeResponseForTemplate()));
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, version, true)).then((Answer<List<Type>>)invocation -> ((getTypeResponseForDossier())));
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, version, true)).then((Answer<List<Type>>)invocation -> (getTemplateDictionaryTypeResponse()));
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, version, true)).then((Answer<List<Type>>)invocation -> ((getDossierDictionaryTypeResponse())));
|
||||
|
||||
}
|
||||
|
||||
@ -421,6 +422,7 @@ public abstract class AbstractRedactionIntegrationTest {
|
||||
typeColorMap.put(FORMULA_INDICATOR, "#ffe187");
|
||||
typeColorMap.put(SIGNATURE_INDICATOR, "#ffe187");
|
||||
typeColorMap.put(IMPORTED_REDACTION_INDICATOR, "#fcfbe6");
|
||||
typeColorMap.put(DOSSIER_REDACTIONS_INDICATOR, "#ffe187");
|
||||
typeColorMap.put(ROTATE_SIMPLE_INDICATOR, "#66ccff");
|
||||
|
||||
hintTypeMap.put(VERTEBRATE_INDICATOR, true);
|
||||
@ -523,86 +525,56 @@ public abstract class AbstractRedactionIntegrationTest {
|
||||
}
|
||||
|
||||
|
||||
protected List<Type> getTypeResponseForTemplate() {
|
||||
protected List<Type> getTemplateDictionaryTypeResponse() {
|
||||
|
||||
return typeColorMap.entrySet()
|
||||
return dictionary.keySet()
|
||||
.stream()
|
||||
.map(typeColor -> Type.builder()
|
||||
.id(typeColor.getKey() + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(typeColor.getKey())
|
||||
.map(key -> Type.builder()
|
||||
.id(key + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(key)
|
||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||
.hexColor(typeColor.getValue())
|
||||
.isHint(hintTypeMap.get(typeColor.getKey()))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(typeColor.getKey()))
|
||||
.isRecommendation(recommendationTypeMap.get(typeColor.getKey()))
|
||||
.rank(rankTypeMap.get(typeColor.getKey()))
|
||||
.entries(toDictionaryEntry(dictionary.get(typeColor.getKey())))
|
||||
.hexColor(typeColorMap.get(key))
|
||||
.isHint(hintTypeMap.get(key))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(key))
|
||||
.isRecommendation(recommendationTypeMap.get(key))
|
||||
.rank(rankTypeMap.get(key))
|
||||
.entries(toDictionaryEntry(dictionary.get(key), false))
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected List<Type> getDossierDictionaryTypeResponse() {
|
||||
|
||||
return dossierDictionary.keySet()
|
||||
.stream()
|
||||
.map(key -> Type.builder()
|
||||
.id(key + ":" + TEST_DOSSIER_TEMPLATE_ID + ":" + TEST_DOSSIER_ID)
|
||||
.type(key)
|
||||
.dossierId(TEST_DOSSIER_ID)
|
||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||
.hexColor(typeColorMap.get(key))
|
||||
.isHint(hintTypeMap.get(key))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(key))
|
||||
.isRecommendation(recommendationTypeMap.get(key))
|
||||
.rank(rankTypeMap.get(key))
|
||||
.entries(toDictionaryEntry(dossierDictionary.get(key), true))
|
||||
.build())
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
protected List<Type> getTypeResponseForDossier() {
|
||||
|
||||
return List.of(Type.builder()
|
||||
.id(IMPORTED_REDACTION_TYPE_ID)
|
||||
.type(IMPORTED_REDACTION_INDICATOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||
.dossierId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe187")
|
||||
.isHint(hintTypeMap.get(IMPORTED_REDACTION_INDICATOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(IMPORTED_REDACTION_INDICATOR))
|
||||
.isRecommendation(recommendationTypeMap.get(IMPORTED_REDACTION_INDICATOR))
|
||||
.rank(rankTypeMap.get(IMPORTED_REDACTION_INDICATOR))
|
||||
.entries(toDictionaryEntry(dossierDictionary.get(IMPORTED_REDACTION_INDICATOR)))
|
||||
.build(),
|
||||
Type.builder()
|
||||
.id(DOSSIER_REDACTIONS_TYPE_ID)
|
||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||
.dossierId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe187")
|
||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.entries(toDictionaryEntry(dossierDictionary.get(DOSSIER_REDACTIONS_INDICATOR)))
|
||||
.build(),
|
||||
Type.builder()
|
||||
.id(DOSSIER_AUTHOR_TYPE_ID)
|
||||
.type(DICTIONARY_AUTHOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||
.dossierId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe184")
|
||||
.isHint(hintTypeMap.get(DICTIONARY_AUTHOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(DICTIONARY_AUTHOR))
|
||||
.isRecommendation(recommendationTypeMap.get(DICTIONARY_AUTHOR))
|
||||
.rank(rankTypeMap.get(DICTIONARY_AUTHOR))
|
||||
.entries(toDictionaryEntry(dossierDictionary.get(DICTIONARY_AUTHOR)))
|
||||
.build(),
|
||||
Type.builder()
|
||||
.id(DOSSIER_PUBLISHED_INFORMATION_TYPE_ID)
|
||||
.type(PUBLISHED_INFORMATION_INDICATOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||
.dossierId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe180")
|
||||
.isHint(hintTypeMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
||||
.isRecommendation(recommendationTypeMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
||||
.rank(rankTypeMap.get(PUBLISHED_INFORMATION_INDICATOR))
|
||||
.entries(toDictionaryEntry(dossierDictionary.get(PUBLISHED_INFORMATION_INDICATOR)))
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
protected Type getDictionaryResponse(String type, boolean isDossierDictionary) {
|
||||
|
||||
String id = type + ":" + TEST_DOSSIER_TEMPLATE_ID;
|
||||
|
||||
return Type.builder()
|
||||
.id(type + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||
.id(isDossierDictionary ? id + ":" + TEST_DOSSIER_ID : id)
|
||||
.hexColor(typeColorMap.get(type))
|
||||
.entries(isDossierDictionary ? toDictionaryEntry(dossierDictionary.get(type)) : toDictionaryEntry(dictionary.get(type)))
|
||||
.falsePositiveEntries(falsePositive.containsKey(type) ? toDictionaryEntry(falsePositive.get(type)) : new ArrayList<>())
|
||||
.falseRecommendationEntries(falseRecommendation.containsKey(type) ? toDictionaryEntry(falseRecommendation.get(type)) : new ArrayList<>())
|
||||
.entries(isDossierDictionary ? toDictionaryEntry(dossierDictionary.get(type), true) : toDictionaryEntry(dictionary.get(type), false))
|
||||
.falsePositiveEntries(falsePositive.containsKey(type) ? toDictionaryEntry(falsePositive.get(type), isDossierDictionary) : new ArrayList<>())
|
||||
.falseRecommendationEntries(falseRecommendation.containsKey(type) ? toDictionaryEntry(falseRecommendation.get(type), isDossierDictionary) : new ArrayList<>())
|
||||
.isHint(hintTypeMap.get(type))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(type))
|
||||
.isRecommendation(recommendationTypeMap.get(type))
|
||||
@ -617,20 +589,21 @@ public abstract class AbstractRedactionIntegrationTest {
|
||||
}
|
||||
|
||||
|
||||
private List<DictionaryEntry> toDictionaryEntry(List<String> entries) {
|
||||
private List<DictionaryEntry> toDictionaryEntry(List<String> entries, boolean isDossierDictionary) {
|
||||
|
||||
if (entries == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return entries.stream()
|
||||
.map(this::toDictionaryEntry)
|
||||
.map(entry -> toDictionaryEntry(entry, isDossierDictionary))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
|
||||
private DictionaryEntry toDictionaryEntry(String entry) {
|
||||
private DictionaryEntry toDictionaryEntry(String entry, boolean isDossierDictionary) {
|
||||
|
||||
var deleted = isDossierDictionary ? deletedInDossier : deletedInTemplate;
|
||||
return DictionaryEntry.builder().value(entry).version(reanlysisVersions.getOrDefault(entry, 0L)).deleted(deleted.contains(entry)).build();
|
||||
}
|
||||
|
||||
|
||||
@ -101,23 +101,10 @@ public class AnalysisTest extends AbstractRedactionIntegrationTest {
|
||||
loadTypeForTest();
|
||||
loadNerForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), false)).thenReturn(getTypeResponseForTemplate());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), false)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, anyLong(), false)).thenReturn(List.of(Type.builder()
|
||||
.id(DOSSIER_REDACTIONS_INDICATOR
|
||||
+ ":"
|
||||
+ TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe187")
|
||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(
|
||||
DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isRecommendation(recommendationTypeMap.get(
|
||||
DOSSIER_REDACTIONS_INDICATOR))
|
||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.build()));
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, anyLong(), false)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
|
||||
mockDictionaryCalls(null);
|
||||
|
||||
|
||||
@ -217,22 +217,14 @@ public class DocumineFloraTest extends AbstractRedactionIntegrationTest {
|
||||
when(rulesClient.getVersion(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.COMPONENT)).thenReturn(System.currentTimeMillis());
|
||||
when(rulesClient.getRules(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.COMPONENT)).thenReturn(JSONPrimitive.of(COMPONENT_RULES));
|
||||
|
||||
loadDictionaryForTest();
|
||||
loadTypeForTest();
|
||||
loadNerForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(List.of(Type.builder()
|
||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe187")
|
||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.build()));
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
|
||||
mockDictionaryCalls(null);
|
||||
|
||||
|
||||
@ -84,10 +84,10 @@ public class MigrationIntegrationTest extends BuildDocumentIntegrationTest {
|
||||
loadDictionaryForTest();
|
||||
loadTypeForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getTypeResponseForDossier());
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
|
||||
mockDictionaryCalls(null);
|
||||
|
||||
|
||||
@ -99,10 +99,10 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
|
||||
loadTypeForTest();
|
||||
loadNerForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getTypeResponseForDossier());
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
|
||||
mockDictionaryCalls(null);
|
||||
|
||||
@ -273,7 +273,7 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
|
||||
var manualRedactions = ManualRedactions.builder().idsToRemove(Set.of(idRemoval)).build();
|
||||
request.setManualRedactions(manualRedactions);
|
||||
|
||||
deleted.add(publishedInfoValue);
|
||||
deletedInDossier.add(publishedInfoValue);
|
||||
reanlysisVersions.put(publishedInfoValue, 4L);
|
||||
|
||||
when(dictionaryClient.getVersionForDossier(TEST_DOSSIER_ID)).thenReturn(3L);
|
||||
@ -293,8 +293,8 @@ public class RedactionAcceptanceTest extends AbstractRedactionIntegrationTest {
|
||||
assertEquals(EntryState.APPLIED, cbiAuthor.getState());
|
||||
|
||||
// cleanup changes
|
||||
deleted.remove(publishedInfoValue);
|
||||
assertThat(deleted.contains(publishedInfoValue)).isFalse();
|
||||
deletedInTemplate.remove(publishedInfoValue);
|
||||
assertThat(deletedInTemplate.contains(publishedInfoValue)).isFalse();
|
||||
dossierDictionary.put(PUBLISHED_INFORMATION_INDICATOR, new ArrayList<>());
|
||||
assertThat(dossierDictionary.get(PUBLISHED_INFORMATION_INDICATOR).size()).isEqualTo(0);
|
||||
dictionary.get(DICTIONARY_AUTHOR).remove(cbiAuthorValue);
|
||||
|
||||
@ -27,7 +27,10 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.MethodOrderer;
|
||||
import org.junit.jupiter.api.Order;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
@ -85,6 +88,7 @@ import lombok.SneakyThrows;
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@Import(RedactionIntegrationTest.RedactionIntegrationTestConfiguration.class)
|
||||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
|
||||
public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
|
||||
private static final String RULES = loadFromClassPath("drools/rules.drl");
|
||||
@ -118,9 +122,10 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
loadTypeForTest();
|
||||
loadNerForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersionForDossier(TEST_DOSSIER_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getTypeResponseForDossier());
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
|
||||
mockDictionaryCalls(null);
|
||||
|
||||
@ -492,8 +497,8 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
dictionary.get(DICTIONARY_AUTHOR).add("physical");
|
||||
reanlysisVersions.put("physical", 2L);
|
||||
|
||||
deleted.add("David Chubb");
|
||||
deleted.add("mouse");
|
||||
deletedInTemplate.add("David Chubb");
|
||||
deletedInTemplate.add("mouse");
|
||||
|
||||
reanlysisVersions.put("mouse", 3L);
|
||||
|
||||
@ -528,7 +533,7 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
fileOutputStream.write(annotateResponse.getDocument());
|
||||
}
|
||||
|
||||
deleted.remove("mouse");
|
||||
deletedInTemplate.remove("mouse");
|
||||
reanlysisVersions.put("mouse", 4L);
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(4L);
|
||||
@ -544,6 +549,7 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
|
||||
|
||||
@Test
|
||||
@Order(2)
|
||||
public void testChangeComputation() throws IOException {
|
||||
|
||||
String fileName = "files/syngenta/CustomerFiles/SinglePages/test1S1T1.pdf";
|
||||
@ -554,15 +560,15 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER, request);
|
||||
analyzeService.analyze(request);
|
||||
|
||||
dictionary.get(DICTIONARY_AUTHOR).add("report");
|
||||
reanlysisVersions.put("report", 2L);
|
||||
dictionary.get(DICTIONARY_AUTHOR).add("EFSA conclusion");
|
||||
reanlysisVersions.put("EFSA conclusion", 2L);
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(2L);
|
||||
mockDictionaryCalls(0L);
|
||||
|
||||
analyzeService.reanalyze(request);
|
||||
|
||||
dictionary.get(DICTIONARY_AUTHOR).add("assessment report");
|
||||
reanlysisVersions.put("assessment report", 3L);
|
||||
dictionary.get(DICTIONARY_AUTHOR).add("draft EFSA conclusion");
|
||||
reanlysisVersions.put("draft EFSA conclusion", 3L);
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(3L);
|
||||
mockDictionaryCalls(2L);
|
||||
analyzeService.reanalyze(request);
|
||||
@ -575,7 +581,7 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
|
||||
var changes = entityLog.getEntityLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getValue() != null && entry.getValue().equals("report"))
|
||||
.filter(entry -> entry.getValue() != null && entry.getValue().equals("EFSA conclusion"))
|
||||
.findFirst()
|
||||
.get().getChanges();
|
||||
|
||||
@ -648,8 +654,8 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
dictionary.get(DICTIONARY_AUTHOR).add("physical");
|
||||
reanlysisVersions.put("physical", 2L);
|
||||
|
||||
deleted.add("David Chubb");
|
||||
deleted.add("mouse");
|
||||
deletedInTemplate.add("David Chubb");
|
||||
deletedInTemplate.add("mouse");
|
||||
|
||||
reanlysisVersions.put("David Chubb", 3L);
|
||||
|
||||
@ -686,7 +692,7 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
fileOutputStream.write(annotateResponse.getDocument());
|
||||
}
|
||||
|
||||
deleted.remove("mouse");
|
||||
deletedInTemplate.remove("mouse");
|
||||
reanlysisVersions.put("mouse", 4L);
|
||||
mockDictionaryCalls(3L);
|
||||
|
||||
@ -2107,6 +2113,90 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@SneakyThrows
|
||||
@Order(1)
|
||||
public void testShrinkTemplateEntryAndAddToDossierLevel() {
|
||||
|
||||
String EFSA_SANITISATION_RULES = loadFromClassPath("drools/efsa_sanitisation.drl");
|
||||
when(rulesClient.getRules(TEST_DOSSIER_TEMPLATE_ID, RuleFileType.ENTITY)).thenReturn(JSONPrimitive.of(EFSA_SANITISATION_RULES));
|
||||
|
||||
String pdfFile = "files/syngenta/CustomerFiles/SinglePages/test1S1T1.pdf";
|
||||
|
||||
String manualAddId = UUID.randomUUID().toString();
|
||||
|
||||
List<Rectangle> fullPositions = List.of(Rectangle.builder().topLeftX(190.85f).topLeftY(332.5033f).width(228.0134f).height(13.645125f).page(1).build());
|
||||
|
||||
List<Rectangle> shrunkPositions = List.of(Rectangle.builder().topLeftX(305.35f).topLeftY(333.45f).width(71.40744f).height(12.823441f).page(1).build());
|
||||
ManualRedactionEntry manualRedactionEntry = getFullManualRedactionEntry(manualAddId, fullPositions);
|
||||
manualRedactionEntry.setAddToDictionary(true);
|
||||
|
||||
AnalyzeRequest request = uploadFileToStorage(pdfFile);
|
||||
Set<ManualRedactionEntry> entriesToAdd = Set.of(manualRedactionEntry);
|
||||
request.setManualRedactions(ManualRedactions.builder().entriesToAdd(entriesToAdd).build());
|
||||
analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER, request);
|
||||
request.setAnalysisNumber(1);
|
||||
|
||||
String commentsOnTheAssessmentReport = "Comments on the assessment report";
|
||||
dictionary.get(DICTIONARY_AUTHOR).add(commentsOnTheAssessmentReport);
|
||||
reanlysisVersions.put(commentsOnTheAssessmentReport, 0L);
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
mockDictionaryCalls(0L);
|
||||
|
||||
analyzeService.analyze(request);
|
||||
|
||||
var entityLog = redactionStorageService.getEntityLog(TEST_DOSSIER_ID, TEST_FILE_ID);
|
||||
|
||||
assertTrue(entityLog.getEntityLogEntry()
|
||||
.stream()
|
||||
.findFirst()
|
||||
.isPresent());
|
||||
EntityLogEntry entityLogEntry1 = entityLog.getEntityLogEntry()
|
||||
.stream()
|
||||
.filter(entityLogEntry -> entityLogEntry.getValue().equals(commentsOnTheAssessmentReport))
|
||||
.findFirst()
|
||||
.get();
|
||||
String id = entityLogEntry1.getId();
|
||||
|
||||
assertEquals(entityLogEntry1.getState(), EntryState.APPLIED);
|
||||
|
||||
manualRedactionEntry.setProcessedDate(OffsetDateTime.now());
|
||||
Set<ManualResizeRedaction> resizeRedactions = Set.of(getManualResizeRedaction(id, shrunkPositions));
|
||||
|
||||
request.setManualRedactions(ManualRedactions.builder().entriesToAdd(entriesToAdd).resizeRedactions(resizeRedactions).build());
|
||||
request.setAnalysisNumber(2);
|
||||
|
||||
dossierDictionary.get(DICTIONARY_AUTHOR).add(commentsOnTheAssessmentReport);
|
||||
deletedInDossier.add(commentsOnTheAssessmentReport);
|
||||
when(dictionaryClient.getVersionForDossier(TEST_DOSSIER_ID)).thenReturn(1L);
|
||||
String assessment = "assessment";
|
||||
dossierDictionary.get(DICTIONARY_AUTHOR).add(assessment);
|
||||
reanlysisVersions.put(assessment, 1L);
|
||||
when(dictionaryClient.getVersionForDossier(TEST_DOSSIER_ID)).thenReturn(1L);
|
||||
|
||||
analyzeService.reanalyze(request);
|
||||
|
||||
entityLog = redactionStorageService.getEntityLog(TEST_DOSSIER_ID, TEST_FILE_ID);
|
||||
|
||||
assertTrue(entityLog.getEntityLogEntry()
|
||||
.stream()
|
||||
.anyMatch(entityLogEntry -> entityLogEntry.getId().equals(id)));
|
||||
entityLogEntry1 = entityLog.getEntityLogEntry()
|
||||
.stream()
|
||||
.filter(entityLogEntry -> entityLogEntry.getId().equals(id))
|
||||
.findFirst()
|
||||
.get();
|
||||
var entityLogEntry2 = entityLog.getEntityLogEntry()
|
||||
.stream()
|
||||
.filter(entityLogEntry -> entityLogEntry.getValue().equals(assessment))
|
||||
.findFirst()
|
||||
.get();
|
||||
assertEquals(entityLogEntry1.getState(), EntryState.APPLIED);
|
||||
assertEquals(entityLogEntry2.getState(), EntryState.APPLIED);
|
||||
assertThat(entityLogEntry2.getStartOffset() > entityLogEntry1.getEndOffset());
|
||||
}
|
||||
|
||||
|
||||
private IdRemoval getIdRemoval(String id) {
|
||||
|
||||
return IdRemoval.builder()
|
||||
@ -2122,18 +2212,52 @@ public class RedactionIntegrationTest extends RulesIntegrationTest {
|
||||
|
||||
private ManualRedactionEntry getManualRedactionEntry(String id, List<Rectangle> positions, String reason) {
|
||||
|
||||
ManualRedactionEntry manualRedactionEntry2 = new ManualRedactionEntry();
|
||||
manualRedactionEntry2.setAnnotationId(id);
|
||||
manualRedactionEntry2.setFileId("fileId");
|
||||
manualRedactionEntry2.setUser("test");
|
||||
manualRedactionEntry2.setType("manual");
|
||||
manualRedactionEntry2.setRectangle(false);
|
||||
manualRedactionEntry2.setRequestDate(OffsetDateTime.now());
|
||||
manualRedactionEntry2.setValue("assessment");
|
||||
manualRedactionEntry2.setLegalBasis("Article 63(2)(a) of Regulation (EC) No 1107/2009 (making reference to Article 39 of Regulation EC No 178/2002)");
|
||||
manualRedactionEntry2.setReason(reason);
|
||||
manualRedactionEntry2.setPositions(positions);
|
||||
return manualRedactionEntry2;
|
||||
ManualRedactionEntry manualRedactionEntry = new ManualRedactionEntry();
|
||||
manualRedactionEntry.setAnnotationId(id);
|
||||
manualRedactionEntry.setFileId("fileId");
|
||||
manualRedactionEntry.setUser("test");
|
||||
manualRedactionEntry.setType("manual");
|
||||
manualRedactionEntry.setRectangle(false);
|
||||
manualRedactionEntry.setRequestDate(OffsetDateTime.now());
|
||||
manualRedactionEntry.setValue("assessment");
|
||||
manualRedactionEntry.setLegalBasis("Article 63(2)(a) of Regulation (EC) No 1107/2009 (making reference to Article 39 of Regulation EC No 178/2002)");
|
||||
manualRedactionEntry.setReason(reason);
|
||||
manualRedactionEntry.setPositions(positions);
|
||||
return manualRedactionEntry;
|
||||
}
|
||||
|
||||
|
||||
private ManualRedactionEntry getFullManualRedactionEntry(String id, List<Rectangle> positions) {
|
||||
|
||||
ManualRedactionEntry manualRedactionEntry = new ManualRedactionEntry();
|
||||
manualRedactionEntry.setAnnotationId(id);
|
||||
manualRedactionEntry.setFileId("fileId");
|
||||
manualRedactionEntry.setUser("test");
|
||||
manualRedactionEntry.setType("manual");
|
||||
manualRedactionEntry.setRectangle(false);
|
||||
manualRedactionEntry.setRequestDate(OffsetDateTime.now());
|
||||
manualRedactionEntry.setValue("Comments on the assessment report");
|
||||
manualRedactionEntry.setLegalBasis("Article 63(2)(a) of Regulation (EC) No 1107/2009 (making reference to Article 39 of Regulation EC No 178/2002)");
|
||||
manualRedactionEntry.setReason(
|
||||
"the manufacturing or production process, including the method and innovative aspects thereof, as well as other technical and industrial specifications inherent to that process or method, except for information which is relevant to the assessment of safety");
|
||||
manualRedactionEntry.setPositions(positions);
|
||||
return manualRedactionEntry;
|
||||
}
|
||||
|
||||
|
||||
private ManualResizeRedaction getManualResizeRedaction(String id, List<Rectangle> positions) {
|
||||
|
||||
ManualResizeRedaction manualResizeRedaction = new ManualResizeRedaction();
|
||||
manualResizeRedaction.setAnnotationId(id);
|
||||
manualResizeRedaction.setFileId("fileId");
|
||||
manualResizeRedaction.setUser("test");
|
||||
manualResizeRedaction.setRequestDate(OffsetDateTime.now());
|
||||
manualResizeRedaction.setValue("assessment");
|
||||
manualResizeRedaction.setValue("assessment");
|
||||
manualResizeRedaction.setPositions(positions);
|
||||
manualResizeRedaction.setAddToAllDossiers(false);
|
||||
manualResizeRedaction.setUpdateDictionary(true);
|
||||
return manualResizeRedaction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -75,23 +75,10 @@ public class RedactionIntegrationV2Test extends AbstractRedactionIntegrationTest
|
||||
loadTypeForTest();
|
||||
loadNerForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), false)).thenReturn(getTypeResponseForTemplate());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), false)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, any(), false)).thenReturn(List.of(Type.builder()
|
||||
.id(DOSSIER_REDACTIONS_INDICATOR
|
||||
+ ":"
|
||||
+ TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe187")
|
||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(
|
||||
DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isRecommendation(recommendationTypeMap.get(
|
||||
DOSSIER_REDACTIONS_INDICATOR))
|
||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.build()));
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, any(), false)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
|
||||
mockDictionaryCalls(null);
|
||||
|
||||
|
||||
@ -279,19 +279,10 @@ public class RulesTest {
|
||||
loadDictionaryForTest();
|
||||
loadTypeForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, anyLong(), false)).thenReturn(getTypeResponse());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, anyLong(), false)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, anyLong(), false)).thenReturn(List.of(Type.builder()
|
||||
.id(DOSSIER_REDACTIONS + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(DOSSIER_REDACTIONS)
|
||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe187")
|
||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS))
|
||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS))
|
||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS))
|
||||
.build()));
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, anyLong(), false)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
|
||||
mockDictionaryCalls(null);
|
||||
mockDictionaryCalls(0L);
|
||||
@ -784,21 +775,40 @@ public class RulesTest {
|
||||
}
|
||||
|
||||
|
||||
private List<Type> getTypeResponse() {
|
||||
protected List<Type> getTemplateDictionaryTypeResponse() {
|
||||
|
||||
return typeColorMap.entrySet()
|
||||
return dictionary.keySet()
|
||||
.stream()
|
||||
.map(typeColor -> Type.builder()
|
||||
.id(typeColor.getKey() + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(typeColor.getKey())
|
||||
.map(key -> Type.builder()
|
||||
.id(key + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(key)
|
||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||
.hexColor(typeColor.getValue())
|
||||
.isHint(hintTypeMap.get(typeColor.getKey()))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(typeColor.getKey()))
|
||||
.isRecommendation(recommendationTypeMap.get(typeColor.getKey()))
|
||||
.rank(rankTypeMap.get(typeColor.getKey()))
|
||||
.hexColor(typeColorMap.get(key))
|
||||
.isHint(hintTypeMap.get(key))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(key))
|
||||
.isRecommendation(recommendationTypeMap.get(key))
|
||||
.rank(rankTypeMap.get(key))
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected List<Type> getDossierDictionaryTypeResponse() {
|
||||
|
||||
return dossierDictionary.keySet()
|
||||
.stream()
|
||||
.map(key -> Type.builder()
|
||||
.id(key + ":" + TEST_DOSSIER_TEMPLATE_ID + ":" + TEST_DOSSIER_ID)
|
||||
.type(key)
|
||||
.dossierId(TEST_DOSSIER_ID)
|
||||
.dossierTemplateId(TEST_DOSSIER_TEMPLATE_ID)
|
||||
.hexColor(typeColorMap.get(key))
|
||||
.isHint(hintTypeMap.get(key))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(key))
|
||||
.isRecommendation(recommendationTypeMap.get(key))
|
||||
.rank(rankTypeMap.get(key))
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@ -110,19 +110,10 @@ public class DocumentPerformanceIntegrationTest extends BuildDocumentIntegration
|
||||
loadTypeForTest();
|
||||
loadNerForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(List.of(Type.builder()
|
||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe187")
|
||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isRecommendation(recommendationTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.build()));
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
|
||||
mockDictionaryCalls(null);
|
||||
|
||||
|
||||
@ -123,24 +123,11 @@ public class ManualChangesEnd2EndTest extends AbstractRedactionIntegrationTest {
|
||||
loadTypeForTest();
|
||||
loadNerForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), false)).thenReturn(getTypeResponseForTemplate());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), true)).thenReturn(getTypeResponseForTemplate());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), false)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, any(), true)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, any(), false)).thenReturn(List.of(Type.builder()
|
||||
.id(DOSSIER_REDACTIONS_INDICATOR
|
||||
+ ":"
|
||||
+ TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe187")
|
||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(
|
||||
DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isRecommendation(recommendationTypeMap.get(
|
||||
DOSSIER_REDACTIONS_INDICATOR))
|
||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.build()));
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, any(), false)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
|
||||
mockDictionaryCalls(null);
|
||||
|
||||
|
||||
@ -99,22 +99,10 @@ public class UnprocessedChangesServiceTest extends AbstractRedactionIntegrationT
|
||||
loadTypeForTest();
|
||||
loadNerForTest();
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTypeResponseForTemplate());
|
||||
when(dictionaryClient.getAllTypesForDossierTemplate(TEST_DOSSIER_TEMPLATE_ID, null, true)).thenReturn(getTemplateDictionaryTypeResponse());
|
||||
|
||||
when(dictionaryClient.getVersion(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(0L);
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(List.of(Type.builder()
|
||||
.id(DOSSIER_REDACTIONS_INDICATOR + ":" + TEST_DOSSIER_TEMPLATE_ID)
|
||||
.type(DOSSIER_REDACTIONS_INDICATOR)
|
||||
.dossierTemplateId(TEST_DOSSIER_ID)
|
||||
.hexColor("#ffe187")
|
||||
.isHint(hintTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isCaseInsensitive(caseInSensitiveMap.get(
|
||||
DOSSIER_REDACTIONS_INDICATOR))
|
||||
.isRecommendation(recommendationTypeMap.get(
|
||||
DOSSIER_REDACTIONS_INDICATOR))
|
||||
.rank(rankTypeMap.get(DOSSIER_REDACTIONS_INDICATOR))
|
||||
.build()));
|
||||
|
||||
when(dictionaryClient.getAllTypesForDossier(TEST_DOSSIER_ID, null, true)).thenReturn(getDossierDictionaryTypeResponse());
|
||||
mockDictionaryCalls(null);
|
||||
|
||||
when(dictionaryClient.getColors(TEST_DOSSIER_TEMPLATE_ID)).thenReturn(colors);
|
||||
|
||||
@ -63,7 +63,6 @@ global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
global RulesLogger logger
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
query "getFileAttributes"
|
||||
@ -1245,11 +1244,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -1401,6 +1400,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -63,7 +63,6 @@ global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
global RulesLogger logger
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
query "getFileAttributes"
|
||||
@ -733,7 +732,8 @@ rule "CBI.18.0: Expand CBI_author entities with firstname initials"
|
||||
$entityToExpand: TextEntity(type() == "CBI_author",
|
||||
value.matches("[^\\s]+"),
|
||||
textAfter.startsWith(" "),
|
||||
anyMatch(textAfter, "(,? [A-Z]\\.?( ?[A-Z]\\.?)?( ?[A-Z]\\.?)?\\b\\.?)")
|
||||
anyMatch(textAfter, "(,? [A-Z]\\.?( ?[A-Z]\\.?)?( ?[A-Z]\\.?)?\\b\\.?)"),
|
||||
!removed()
|
||||
)
|
||||
then
|
||||
entityCreationService.bySuffixExpansionRegex($entityToExpand, "(,? [A-Z]\\.?( ?[A-Z]\\.?)?( ?[A-Z]\\.?)?\\b\\.?)")
|
||||
@ -1898,11 +1898,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -2054,6 +2054,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -55,7 +55,6 @@ global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
global RulesLogger logger
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
query "getFileAttributes"
|
||||
@ -1310,11 +1309,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -1453,6 +1452,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -63,7 +63,6 @@ global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
global RulesLogger logger
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
query "getFileAttributes"
|
||||
@ -804,11 +803,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -960,6 +959,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -63,7 +63,6 @@ global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
global RulesLogger logger
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
query "getFileAttributes"
|
||||
@ -301,6 +300,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -63,7 +63,6 @@ global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
global RulesLogger logger
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
query "getFileAttributes"
|
||||
@ -504,7 +503,8 @@ rule "CBI.18.0: Expand CBI_author entities with firstname initials"
|
||||
$entityToExpand: TextEntity(type() == "CBI_author",
|
||||
value.matches("[^\\s]+"),
|
||||
textAfter.startsWith(" "),
|
||||
anyMatch(textAfter, "(,? [A-Z]\\.?( ?[A-Z]\\.?)?( ?[A-Z]\\.?)?\\b\\.?)")
|
||||
anyMatch(textAfter, "(,? [A-Z]\\.?( ?[A-Z]\\.?)?( ?[A-Z]\\.?)?\\b\\.?)"),
|
||||
!removed()
|
||||
)
|
||||
then
|
||||
entityCreationService.bySuffixExpansionRegex($entityToExpand, "(,? [A-Z]\\.?( ?[A-Z]\\.?)?( ?[A-Z]\\.?)?\\b\\.?)")
|
||||
@ -1333,11 +1333,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -1489,6 +1489,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -63,7 +63,6 @@ global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
global RulesLogger logger
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
query "getFileAttributes"
|
||||
@ -256,11 +255,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -412,6 +411,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -63,7 +63,6 @@ global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
global RulesLogger logger
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
query "getFileAttributes"
|
||||
@ -380,11 +379,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -547,6 +546,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -63,7 +63,6 @@ global ManualChangesApplicationService manualChangesApplicationService
|
||||
global Dictionary dictionary
|
||||
global RulesLogger logger
|
||||
|
||||
|
||||
//------------------------------------ queries ------------------------------------
|
||||
|
||||
query "getFileAttributes"
|
||||
@ -280,11 +279,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -447,6 +446,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
@ -732,7 +732,8 @@ rule "CBI.18.0: Expand CBI_author entities with firstname initials"
|
||||
$entityToExpand: TextEntity(type() == "CBI_author",
|
||||
value.matches("[^\\s]+"),
|
||||
textAfter.startsWith(" "),
|
||||
anyMatch(textAfter, "(,? [A-Z]\\.?( ?[A-Z]\\.?)?( ?[A-Z]\\.?)?\\b\\.?)")
|
||||
anyMatch(textAfter, "(,? [A-Z]\\.?( ?[A-Z]\\.?)?( ?[A-Z]\\.?)?\\b\\.?)"),
|
||||
!removed()
|
||||
)
|
||||
then
|
||||
entityCreationService.bySuffixExpansionRegex($entityToExpand, "(,? [A-Z]\\.?( ?[A-Z]\\.?)?( ?[A-Z]\\.?)?\\b\\.?)")
|
||||
@ -1893,11 +1894,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -2048,12 +2049,12 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
end
|
||||
|
||||
|
||||
//------------------------------------ File attributes rules ------------------------------------
|
||||
|
||||
// Rule unit: FA.1
|
||||
|
||||
@ -1455,11 +1455,11 @@ rule "X.0.0: Remove Entity contained by Entity of same type"
|
||||
salience 65
|
||||
when
|
||||
$larger: TextEntity($type: type(), $entityType: entityType, !removed())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges())
|
||||
$contained: TextEntity(containedBy($larger), type() == $type, entityType == $entityType, this != $larger, !hasManualChanges(), !removed())
|
||||
then
|
||||
$contained.getIntersectingNodes().forEach(node -> update(node));
|
||||
$contained.remove("X.0.0", "remove Entity contained by Entity of same type");
|
||||
retract($contained);
|
||||
update($contained);
|
||||
end
|
||||
|
||||
|
||||
@ -1598,6 +1598,7 @@ rule "DICT.0.0: Ignore Template Dictionary Entity when contained by Dossier Dict
|
||||
when
|
||||
$dictionaryRemoval: TextEntity($type: type(), entityType == EntityType.DICTIONARY_REMOVAL, engines contains Engine.DOSSIER_DICTIONARY)
|
||||
$entity: TextEntity(getTextRange().equals($dictionaryRemoval.getTextRange()), engines contains Engine.DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
not TextEntity(containedBy($entity), engines contains Engine.DOSSIER_DICTIONARY, type() == $type, (entityType == EntityType.ENTITY || entityType == EntityType.HINT), !hasManualChanges())
|
||||
then
|
||||
$entity.getIntersectingNodes().forEach(node -> update(node));
|
||||
$entity.ignore("DICT.0.0", "Ignore Template Dictionary Entity when contained by Dossier Dictionary DICTIONARY_REMOVAL");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user