DM-285: Entity to component mappings with new ruleset

* refactoring structure
* added custom syntax validation, such that rule files may not be corrupted
* added component drools preparations
* deprecated redactionLog
* integrated entityLog
* integrated new getRules with ruleFileType
* renamed service.graph package -> service.document
* fixed tests
* update layout parser version
* initial component drools file - wip
* disabled some tests due to OOM Error

Signed-off-by: Kilian Schuettler <kilian.schuettler@knecon.com>
This commit is contained in:
Kilian Schuettler 2023-09-11 11:47:07 +02:00
parent 49629f9325
commit 5b2877ea3c
12 changed files with 139 additions and 207 deletions

View File

@ -1,7 +0,0 @@
package com.iqser.red.service.redaction.v1.model;
public enum RuleFileType {
ENTITY,
COMPONENT
}

View File

@ -7,9 +7,8 @@ import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class Rules { public class RuleValidationModel {
RuleFileType ruleFileType; String ruleFileType;
String rulesString; String rulesString;
} }

View File

@ -5,11 +5,11 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import com.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation; import com.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation;
import com.iqser.red.service.redaction.v1.model.Rules; import com.iqser.red.service.redaction.v1.model.RuleValidationModel;
public interface RedactionResource { public interface RedactionResource {
@PostMapping(value = "/rules/test", consumes = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/rules/test", consumes = MediaType.APPLICATION_JSON_VALUE)
DroolsSyntaxValidation testRules(@RequestBody Rules rules); DroolsSyntaxValidation testRules(@RequestBody RuleValidationModel rules);
} }

View File

@ -4,7 +4,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation; import com.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation;
import com.iqser.red.service.redaction.v1.model.Rules; import com.iqser.red.service.redaction.v1.model.RuleValidationModel;
import com.iqser.red.service.redaction.v1.resources.RedactionResource; import com.iqser.red.service.redaction.v1.resources.RedactionResource;
import com.iqser.red.service.redaction.v1.server.service.drools.DroolsSyntaxValidationService; import com.iqser.red.service.redaction.v1.server.service.drools.DroolsSyntaxValidationService;
import com.iqser.red.service.redaction.v1.server.utils.exception.RulesValidationException; import com.iqser.red.service.redaction.v1.server.utils.exception.RulesValidationException;
@ -21,7 +21,7 @@ public class RedactionController implements RedactionResource {
@Override @Override
public DroolsSyntaxValidation testRules(@RequestBody Rules rules) { public DroolsSyntaxValidation testRules(@RequestBody RuleValidationModel rules) {
try { try {
return droolsSyntaxValidationService.testRules(rules); return droolsSyntaxValidationService.testRules(rules);

View File

@ -31,7 +31,7 @@ public class ComponentCreationService {
String transformation = String.format("First found value or else '%s'", fallback); String transformation = String.format("First found value or else '%s'", fallback);
String value = entities.stream().min(EntityComparators.start()).map(Entity::getValue).orElse(fallback); String value = entities.stream().min(EntityComparators.start()).map(Entity::getValue).orElse(fallback);
createComponent(ruleIdentifier, category, value, transformation, entities); create(ruleIdentifier, category, value, transformation, entities);
} }
@ -45,7 +45,7 @@ public class ComponentCreationService {
String transformation = String.format("Joining all values with '%s'", delimiter); String transformation = String.format("Joining all values with '%s'", delimiter);
String value = entities.stream().sorted(EntityComparators.start()).map(Entity::getValue).collect(Collectors.joining(delimiter)); String value = entities.stream().sorted(EntityComparators.start()).map(Entity::getValue).collect(Collectors.joining(delimiter));
createComponent(ruleIdentifier, category, value, transformation, entities); create(ruleIdentifier, category, value, transformation, entities);
} }
@ -59,7 +59,7 @@ public class ComponentCreationService {
String transformation = String.format("Joining all values with '%s'", delimiter); String transformation = String.format("Joining all values with '%s'", delimiter);
String value = entities.stream().sorted(EntityComparators.start()).map(Entity::getValue).distinct().collect(Collectors.joining(delimiter)); String value = entities.stream().sorted(EntityComparators.start()).map(Entity::getValue).distinct().collect(Collectors.joining(delimiter));
createComponent(ruleIdentifier, category, value, transformation, entities); create(ruleIdentifier, category, value, transformation, entities);
} }
@ -73,17 +73,17 @@ public class ComponentCreationService {
String transformation = "Convert values of type to dd/MM/yyyy joined with ', '"; String transformation = "Convert values of type to dd/MM/yyyy joined with ', '";
String date = entities.stream().map(Entity::getValue).map(value -> DateConverter.convertDate(value, resultFormat)).collect(Collectors.joining(", ")); String date = entities.stream().map(Entity::getValue).map(value -> DateConverter.convertDate(value, resultFormat)).collect(Collectors.joining(", "));
createComponent(ruleIdentifier, category, date, transformation, entities); create(ruleIdentifier, category, date, transformation, entities);
} }
public void createComponentsForUnMappedEntities(String ruleIdentifier, Collection<Entity> entities) { public void createComponentsForUnMappedEntities(String ruleIdentifier, Collection<Entity> entities) {
entities.forEach(entity -> createComponent(ruleIdentifier, entity.getType(), entity.getValue(), "Unmapped Entity", List.of(entity))); entities.forEach(entity -> create(ruleIdentifier, entity.getType(), entity.getValue(), "Unmapped Entity", List.of(entity)));
} }
public void createComponent(String ruleIdentifier, String category, String value, String transformation, Collection<Entity> references) { public void create(String ruleIdentifier, String category, String value, String transformation, Collection<Entity> references) {
referencedEntities.addAll(references); referencedEntities.addAll(references);
@ -96,7 +96,7 @@ public class ComponentCreationService {
} }
public void createComponent(String ruleIdentifier, String category, String value, String transformation, Entity reference) { public void create(String ruleIdentifier, String category, String value, String transformation, Entity reference) {
referencedEntities.add(reference); referencedEntities.add(reference);
List<Entity> referenceList = new LinkedList<>(); List<Entity> referenceList = new LinkedList<>();
@ -111,13 +111,13 @@ public class ComponentCreationService {
} }
public void createComponent(String ruleIdentifier, String category, String value, String transformation) { public void create(String ruleIdentifier, String category, String value, String transformation) {
createComponent(ruleIdentifier, category, value, transformation, Collections.emptyList()); create(ruleIdentifier, category, value, transformation, Collections.emptyList());
} }
public void createComponent(String ruleIdentifier, String category, String value) { public void create(String ruleIdentifier, String category, String value) {
kieSession.insert(Component.builder() kieSession.insert(Component.builder()
.matchedRule(RuleIdentifier.fromString(ruleIdentifier)) .matchedRule(RuleIdentifier.fromString(ruleIdentifier))

View File

@ -7,10 +7,10 @@ import org.kie.api.builder.KieBuilder;
import org.kie.api.builder.Message; import org.kie.api.builder.Message;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileType;
import com.iqser.red.service.redaction.v1.model.DroolsSyntaxErrorMessage; import com.iqser.red.service.redaction.v1.model.DroolsSyntaxErrorMessage;
import com.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation; import com.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation;
import com.iqser.red.service.redaction.v1.model.RuleFileType; import com.iqser.red.service.redaction.v1.model.RuleValidationModel;
import com.iqser.red.service.redaction.v1.model.Rules;
import com.iqser.red.service.redaction.v1.server.model.drools.BasicRule; import com.iqser.red.service.redaction.v1.server.model.drools.BasicRule;
import com.iqser.red.service.redaction.v1.server.model.drools.RuleFileBluePrint; import com.iqser.red.service.redaction.v1.server.model.drools.RuleFileBluePrint;
import com.iqser.red.service.redaction.v1.server.storage.RuleManagementResources; import com.iqser.red.service.redaction.v1.server.storage.RuleManagementResources;
@ -26,9 +26,9 @@ public class DroolsSyntaxValidationService {
@SneakyThrows @SneakyThrows
public DroolsSyntaxValidation testRules(Rules rules) { public DroolsSyntaxValidation testRules(RuleValidationModel rules) {
DroolsSyntaxValidation customDroolsSyntaxValidation = buildCustomDroolsSyntaxValidation(rules.getRulesString(), rules.getRuleFileType()); DroolsSyntaxValidation customDroolsSyntaxValidation = buildCustomDroolsSyntaxValidation(rules.getRulesString(), RuleFileType.valueOf(rules.getRuleFileType()));
DroolsSyntaxValidation droolsCompilerSyntaxValidation = buildDroolsCompilerSyntaxValidation(rules); DroolsSyntaxValidation droolsCompilerSyntaxValidation = buildDroolsCompilerSyntaxValidation(rules);
droolsCompilerSyntaxValidation.getDroolsSyntaxErrorMessages().addAll(customDroolsSyntaxValidation.getDroolsSyntaxErrorMessages()); droolsCompilerSyntaxValidation.getDroolsSyntaxErrorMessages().addAll(customDroolsSyntaxValidation.getDroolsSyntaxErrorMessages());
return droolsCompilerSyntaxValidation; return droolsCompilerSyntaxValidation;
@ -89,26 +89,17 @@ public class DroolsSyntaxValidationService {
} }
private DroolsSyntaxValidation buildDroolsCompilerSyntaxValidation(Rules rules) { private DroolsSyntaxValidation buildDroolsCompilerSyntaxValidation(RuleValidationModel rules) {
var versionId = System.currentTimeMillis(); var versionId = System.currentTimeMillis();
var testRules = "test-rules"; var testRules = "test-rules";
KieBuilder kieBuilder = kieContainerCreationService.registerNewKieContainerVersion(testRules, KieBuilder kieBuilder = kieContainerCreationService.registerNewKieContainerVersion(testRules,
versionId, versionId,
rules.getRulesString(), rules.getRulesString(), RuleFileType.valueOf(rules.getRuleFileType()));
toPersistenceRuleFileType(rules.getRuleFileType()));
return buildDroolsCompilerSyntaxValidation(kieBuilder); return buildDroolsCompilerSyntaxValidation(kieBuilder);
} }
private com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileType toPersistenceRuleFileType(RuleFileType ruleFileType) {
return switch (ruleFileType) {
case ENTITY -> com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileType.ENTITY;
case COMPONENT -> com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileType.COMPONENT;
};
}
private DroolsSyntaxValidation buildDroolsCompilerSyntaxValidation(KieBuilder kieBuilder) { private DroolsSyntaxValidation buildDroolsCompilerSyntaxValidation(KieBuilder kieBuilder) {

View File

@ -12,55 +12,23 @@ import java.util.Collection;
import java.util.stream.Stream; import java.util.stream.Stream;
import java.util.Optional; import java.util.Optional;
import com.iqser.red.service.redaction.v1.server.model.document.*; import com.iqser.red.service.redaction.v1.server.model.component.Component;
import com.iqser.red.service.redaction.v1.server.model.document.TextRange; import com.iqser.red.service.redaction.v1.server.model.component.Entity;
import com.iqser.red.service.redaction.v1.server.model.document.entity.*; import com.iqser.red.service.redaction.v1.server.service.document.ComponentCreationService;
import com.iqser.red.service.redaction.v1.server.model.document.entity.EntityType;
import com.iqser.red.service.redaction.v1.server.model.document.entity.MatchedRule; import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Change;
import com.iqser.red.service.redaction.v1.server.model.document.entity.TextEntity import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Engine;
import com.iqser.red.service.redaction.v1.server.model.document.entity.MatchedRule import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryState;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.*; import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryType;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Section; import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.ManualChange;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Table; import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.SemanticNode;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Document;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Paragraph;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Image;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.ImageType;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Page;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Headline;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.SectionIdentifier;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Footer;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.Header;
import com.iqser.red.service.redaction.v1.server.model.document.nodes.NodeType;
import com.iqser.red.service.redaction.v1.server.model.document.textblock.*;
import com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlock;
import com.iqser.red.service.redaction.v1.server.model.document.textblock.TextBlockCollector;
import com.iqser.red.service.redaction.v1.server.model.document.textblock.AtomicTextBlock;
import com.iqser.red.service.redaction.v1.server.model.document.textblock.ConcatenatedTextBlock;
import com.iqser.red.service.redaction.v1.server.model.NerEntities;
import com.iqser.red.service.redaction.v1.server.model.dictionary.Dictionary;
import com.iqser.red.service.redaction.v1.server.model.dictionary.DictionaryModel;
import com.iqser.red.service.redaction.v1.server.service.document.EntityCreationService;
import com.iqser.red.service.redaction.v1.server.service.ManualChangesApplicationService;
import com.iqser.red.service.redaction.v1.server.utils.RedactionSearchUtility;
import com.iqser.red.service.persistence.service.v1.api.shared.model.FileAttribute; import com.iqser.red.service.persistence.service.v1.api.shared.model.FileAttribute;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Engine;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualResizeRedaction; global ComponentCreationService componentCreationService
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.IdRemoval;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualForceRedaction;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRecategorization;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualLegalBasisChange;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;
global Document document
global EntityCreationService entityCreationService
global ManualChangesApplicationService manualChangesApplicationService
global Dictionary dictionary
/** /**
This file contains all the rules that are in the templates. The imports, globals, queries and rules from this file are required for any component rule file.
The Imports from this file are all that are possible and will be imported for all entity files.
Since customers may edit their rules we need to ensure they can't change the imports to prevent malicious code execution! Since customers may edit their rules we need to ensure they can't change the imports to prevent malicious code execution!
*/ */
@ -70,20 +38,6 @@ query "getFileAttributes"
$fileAttribute: FileAttribute() $fileAttribute: FileAttribute()
end end
//------------------------------------ Local dictionary search rules ------------------------------------ query "getComponents"
$component: Component()
// Rule unit: LocalDictionarySearch.0
rule "LDS.0.0: run local dictionary search"
agenda-group "LOCAL_DICTIONARY_ADDS"
salience -999
when
$dictionaryModel: DictionaryModel(!localEntriesWithMatchedRules.isEmpty()) from dictionary.getDictionaryModels()
then
entityCreationService.bySearchImplementation($dictionaryModel.getLocalSearch(), $dictionaryModel.getType(), EntityType.RECOMMENDATION, document)
.forEach(entity -> {
Collection<MatchedRule> matchedRules = $dictionaryModel.getLocalEntriesWithMatchedRules().get(entity.getValue());
entity.addMatchedRules(matchedRules);
});
end end
// Everything above this comment will be prepended to any entity rule file before execution.

View File

@ -60,8 +60,7 @@ global ManualChangesApplicationService manualChangesApplicationService
global Dictionary dictionary global Dictionary dictionary
/** /**
This file contains all the rules that are in the templates. The imports, globals, queries and rules from this file are required for any entity rule file.
The Imports from this file are all that are possible and will be imported for all entity files.
Since customers may edit their rules we need to ensure they can't change the imports to prevent malicious code execution! Since customers may edit their rules we need to ensure they can't change the imports to prevent malicious code execution!
*/ */
@ -86,5 +85,3 @@ rule "LDS.0.0: run local dictionary search"
entity.addMatchedRules(matchedRules); entity.addMatchedRules(matchedRules);
}); });
end end
// Everything above this comment will be prepended to any entity rule file before execution.

View File

@ -61,18 +61,20 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.iqser.red.service.dictionarymerge.commons.DictionaryEntry; import com.iqser.red.service.dictionarymerge.commons.DictionaryEntry;
import com.iqser.red.service.persistence.service.v1.api.shared.model.AnalyzeRequest; import com.iqser.red.service.persistence.service.v1.api.shared.model.AnalyzeRequest;
import com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileType; import com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileType;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Change;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogEntry;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogLegalBasis;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryState;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntryType;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.ManualChange;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position;
import com.iqser.red.service.persistence.service.v1.api.shared.model.common.JSONPrimitive; import com.iqser.red.service.persistence.service.v1.api.shared.model.common.JSONPrimitive;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.configuration.Colors; import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.configuration.Colors;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType; import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type; import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.Type;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.Change;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.Engine; import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.Engine;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.ManualChange;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.Rectangle;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog; import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogComment;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogEntry;
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogLegalBasis;
import com.iqser.red.service.redaction.v1.server.client.DictionaryClient; import com.iqser.red.service.redaction.v1.server.client.DictionaryClient;
import com.iqser.red.service.redaction.v1.server.client.LegalBasisClient; import com.iqser.red.service.redaction.v1.server.client.LegalBasisClient;
import com.iqser.red.service.redaction.v1.server.client.RulesClient; import com.iqser.red.service.redaction.v1.server.client.RulesClient;
@ -95,8 +97,6 @@ import com.knecon.fforesight.tenantcommons.TenantsClient;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Disabled
@Slf4j @Slf4j
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ -431,24 +431,23 @@ public class RulesTest {
analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER); analyzeDocumentStructure(LayoutParsingType.REDACT_MANAGER);
analyzeService.analyze(request); analyzeService.analyze(request);
RedactionLog redactionLog = redactionStorageService.getRedactionLog(TEST_DOSSIER_ID, TEST_FILE_ID); EntityLog entityLog = redactionStorageService.getEntityLog(TEST_DOSSIER_ID, TEST_FILE_ID);
// All timestamps are ignored, because they are for sure different // All timestamps are ignored, because they are for sure different
assertThat(redactionLog.getAnalysisVersion()).isEqualTo(savedRedactionLog.getAnalysisVersion()); assertThat(entityLog.getAnalysisVersion()).isEqualTo(savedRedactionLog.getAnalysisVersion());
assertThat(redactionLog.getAnalysisNumber()).isEqualTo(savedRedactionLog.getAnalysisNumber()); assertThat(entityLog.getAnalysisNumber()).isEqualTo(savedRedactionLog.getAnalysisNumber());
assertThat(redactionLog.getDictionaryVersion()).isEqualTo(savedRedactionLog.getDictionaryVersion()); assertThat(entityLog.getDictionaryVersion()).isEqualTo(savedRedactionLog.getDictionaryVersion());
assertThat(redactionLog.getDossierDictionaryVersion()).isEqualTo(savedRedactionLog.getDossierDictionaryVersion()); assertThat(entityLog.getDossierDictionaryVersion()).isEqualTo(savedRedactionLog.getDossierDictionaryVersion());
assertThat(redactionLog.getRulesVersion()).isEqualTo(savedRedactionLog.getRulesVersion()); assertThat(entityLog.getRulesVersion()).isEqualTo(savedRedactionLog.getRulesVersion());
assertThat(redactionLog.getLegalBasisVersion()).isEqualTo(savedRedactionLog.getLegalBasisVersion()); assertThat(entityLog.getLegalBasisVersion()).isEqualTo(savedRedactionLog.getLegalBasisVersion());
assertThat(redactionLog.getRedactionLogEntry() assertThat(entityLog.getEntityLogEntry()
.stream() .stream().filter(r -> !r.getEntryType().equals(EntryType.FALSE_POSITIVE)).filter(r -> !r.getEntryType().equals(EntryType.FALSE_RECOMMENDATION))
.filter(r -> !r.isFalsePositive())
.collect(Collectors.toSet()) .collect(Collectors.toSet())
.size()).isEqualTo(savedRedactionLog.getRedactionLogEntry().stream().filter(r -> !r.isFalsePositive()).collect(Collectors.toSet()).size()); .size()).isEqualTo(savedRedactionLog.getRedactionLogEntry().stream().filter(r -> !r.isFalsePositive()).collect(Collectors.toSet()).size());
assertThat(redactionLog.getLegalBasis().size()).isEqualTo(savedRedactionLog.getLegalBasis().size()); assertThat(entityLog.getLegalBasis().size()).isEqualTo(savedRedactionLog.getLegalBasis().size());
for (RedactionLogLegalBasis redactionLegalBasis : redactionLog.getLegalBasis()) { for (EntityLogLegalBasis redactionLegalBasis : entityLog.getLegalBasis()) {
var savedRedactionLegalBasis = savedRedactionLog.getLegalBasis() var savedRedactionLegalBasis = savedRedactionLog.getLegalBasis()
.stream() .stream()
.filter(lb -> lb.getName().equalsIgnoreCase(redactionLegalBasis.getName())) .filter(lb -> lb.getName().equalsIgnoreCase(redactionLegalBasis.getName()))
@ -458,7 +457,7 @@ public class RulesTest {
assertThat(savedRedactionLegalBasis).isPresent(); assertThat(savedRedactionLegalBasis).isPresent();
} }
for (RedactionLogEntry redactionLogEntry : redactionLog.getRedactionLogEntry()) { for (EntityLogEntry redactionLogEntry : entityLog.getEntityLogEntry()) {
var savedRedactionLogEntry = savedRedactionLog.getRedactionLogEntry().stream().filter(r -> r.getId().equalsIgnoreCase(redactionLogEntry.getId())).findFirst(); var savedRedactionLogEntry = savedRedactionLog.getRedactionLogEntry().stream().filter(r -> r.getId().equalsIgnoreCase(redactionLogEntry.getId())).findFirst();
assertThat(savedRedactionLogEntry).isPresent(); assertThat(savedRedactionLogEntry).isPresent();
assertThat(savedRedactionLogEntry.get().getId()).isEqualTo(redactionLogEntry.getId()); assertThat(savedRedactionLogEntry.get().getId()).isEqualTo(redactionLogEntry.getId());
@ -469,10 +468,10 @@ public class RulesTest {
assertThat(savedRedactionLogEntry.get().isRectangle()).isEqualTo(redactionLogEntry.isRectangle()); assertThat(savedRedactionLogEntry.get().isRectangle()).isEqualTo(redactionLogEntry.isRectangle());
assertThat(savedRedactionLogEntry.get().getLegalBasis()).isEqualTo(redactionLogEntry.getLegalBasis()); assertThat(savedRedactionLogEntry.get().getLegalBasis()).isEqualTo(redactionLogEntry.getLegalBasis());
assertThat(savedRedactionLogEntry.get().isImported()).isEqualTo(redactionLogEntry.isImported()); assertThat(savedRedactionLogEntry.get().isImported()).isEqualTo(redactionLogEntry.isImported());
assertThat(savedRedactionLogEntry.get().isRedacted()).isEqualTo(redactionLogEntry.isRedacted()); assertThat(savedRedactionLogEntry.get().isRedacted()).isEqualTo(redactionLogEntry.getState().equals(EntryState.APPLIED));
assertThat(savedRedactionLogEntry.get().isHint()).isEqualTo(redactionLogEntry.isHint()); assertThat(savedRedactionLogEntry.get().isHint()).isEqualTo(redactionLogEntry.getEntryType().equals(EntryType.HINT));
assertThat(savedRedactionLogEntry.get().isRecommendation()).isEqualTo(redactionLogEntry.isRecommendation()); assertThat(savedRedactionLogEntry.get().isRecommendation()).isEqualTo(redactionLogEntry.getEntryType().equals(EntryType.RECOMMENDATION));
assertThat(savedRedactionLogEntry.get().isFalsePositive()).isEqualTo(redactionLogEntry.isFalsePositive()); assertThat(savedRedactionLogEntry.get().isFalsePositive()).isEqualTo(redactionLogEntry.getEntryType().equals(EntryType.FALSE_POSITIVE));
assertThat(savedRedactionLogEntry.get().getSection()).isEqualTo(redactionLogEntry.getSection()); assertThat(savedRedactionLogEntry.get().getSection()).isEqualTo(redactionLogEntry.getSection());
assertThat(savedRedactionLogEntry.get().getColor()).isEqualTo(redactionLogEntry.getColor()); assertThat(savedRedactionLogEntry.get().getColor()).isEqualTo(redactionLogEntry.getColor());
assertThat(savedRedactionLogEntry.get().getSectionNumber()).isEqualTo(redactionLogEntry.getSectionNumber()); assertThat(savedRedactionLogEntry.get().getSectionNumber()).isEqualTo(redactionLogEntry.getSectionNumber());
@ -480,43 +479,31 @@ public class RulesTest {
assertThat(savedRedactionLogEntry.get().getTextAfter()).isEqualTo(redactionLogEntry.getTextAfter()); assertThat(savedRedactionLogEntry.get().getTextAfter()).isEqualTo(redactionLogEntry.getTextAfter());
assertThat(savedRedactionLogEntry.get().getStartOffset()).isEqualTo(redactionLogEntry.getStartOffset()); assertThat(savedRedactionLogEntry.get().getStartOffset()).isEqualTo(redactionLogEntry.getStartOffset());
assertThat(savedRedactionLogEntry.get().getEndOffset()).isEqualTo(redactionLogEntry.getEndOffset()); assertThat(savedRedactionLogEntry.get().getEndOffset()).isEqualTo(redactionLogEntry.getEndOffset());
assertThat(savedRedactionLogEntry.get().isImage()).isEqualTo(redactionLogEntry.isImage()); assertThat(savedRedactionLogEntry.get().isImage()).isEqualTo(redactionLogEntry.getEntryType().equals(EntryType.IMAGE));
assertThat(savedRedactionLogEntry.get().isImageHasTransparency()).isEqualTo(redactionLogEntry.isImageHasTransparency()); assertThat(savedRedactionLogEntry.get().isImageHasTransparency()).isEqualTo(redactionLogEntry.isImageHasTransparency());
assertThat(savedRedactionLogEntry.get().isDictionaryEntry()).isEqualTo(redactionLogEntry.isDictionaryEntry()); assertThat(savedRedactionLogEntry.get().isDictionaryEntry()).isEqualTo(redactionLogEntry.isDictionaryEntry());
assertThat(savedRedactionLogEntry.get().isDossierDictionaryEntry()).isEqualTo(redactionLogEntry.isDossierDictionaryEntry()); assertThat(savedRedactionLogEntry.get().isDossierDictionaryEntry()).isEqualTo(redactionLogEntry.isDossierDictionaryEntry());
assertThat(savedRedactionLogEntry.get().isExcluded()).isEqualTo(redactionLogEntry.isExcluded()); assertThat(savedRedactionLogEntry.get().isExcluded()).isEqualTo(redactionLogEntry.isExcluded());
assertThat(savedRedactionLogEntry.get().getSourceId()).isEqualTo(redactionLogEntry.getSourceId()); assertThat(savedRedactionLogEntry.get().getSourceId()).isEqualTo(redactionLogEntry.getSourceId());
for (Rectangle rectangle : redactionLogEntry.getPositions()) { for (Position position : redactionLogEntry.getPositions()) {
var savedRectangle = savedRedactionLogEntry.get() var savedRectangle = savedRedactionLogEntry.get()
.getPositions() .getPositions()
.stream() .stream()
.filter(r -> r.getPage() == rectangle.getPage()) .filter(r -> r.getPage() == position.getPageNumber())
.filter(r -> r.getTopLeft().getX() == rectangle.getTopLeft().getX()) .filter(r -> r.getTopLeft().getX() == position.getRectangle()[0])
.filter(r -> r.getTopLeft().getY() == rectangle.getTopLeft().getY()) .filter(r -> r.getTopLeft().getY() == position.getRectangle()[1])
.filter(r -> r.getHeight() == rectangle.getHeight()) .filter(r -> r.getHeight() == position.getRectangle()[3])
.filter(r -> r.getWidth() == rectangle.getWidth()) .filter(r -> r.getWidth() == position.getRectangle()[2])
.findFirst(); .findFirst();
assertThat(savedRectangle).isPresent(); assertThat(savedRectangle).isPresent();
} }
for (RedactionLogComment comment : redactionLogEntry.getComments()) {
var savedComment = savedRedactionLogEntry.get().getComments().stream().filter(c -> c.getId() == comment.getId()).findFirst();
assertThat(savedComment).isPresent();
assertThat(savedComment.get().getId()).isEqualTo(comment.getId());
assertThat(savedComment.get().getUser()).isEqualTo(comment.getUser());
assertThat(savedComment.get().getText()).isEqualTo(comment.getText());
assertThat(savedComment.get().getAnnotationId()).isEqualTo(comment.getAnnotationId());
assertThat(savedComment.get().getFileId()).isEqualTo(comment.getFileId());
}
for (Change change : redactionLogEntry.getChanges()) { for (Change change : redactionLogEntry.getChanges()) {
var savedChange = savedRedactionLogEntry.get() var savedChange = savedRedactionLogEntry.get()
.getChanges() .getChanges()
.stream() .stream()
.filter(c -> c.getAnalysisNumber() == change.getAnalysisNumber()) .filter(c -> c.getAnalysisNumber() == change.getAnalysisNumber()).filter(c -> c.getType().name().equals(change.getType().name()))
.filter(c -> c.getType() == change.getType())
.findFirst(); .findFirst();
assertThat(savedChange).isPresent(); assertThat(savedChange).isPresent();
} }
@ -526,7 +513,7 @@ public class RulesTest {
.getManualChanges() .getManualChanges()
.stream() .stream()
.filter(m -> m.getAnnotationStatus() == manualChange.getAnnotationStatus()) .filter(m -> m.getAnnotationStatus() == manualChange.getAnnotationStatus())
.filter(m -> m.getManualRedactionType() == manualChange.getManualRedactionType()) .filter(m -> m.getManualRedactionType().name().equals(manualChange.getManualRedactionType().name()))
.filter(m -> m.getUserId().equalsIgnoreCase(manualChange.getUserId())) .filter(m -> m.getUserId().equalsIgnoreCase(manualChange.getUserId()))
.filter(m -> m.getPropertyChanges() == manualChange.getPropertyChanges()) .filter(m -> m.getPropertyChanges() == manualChange.getPropertyChanges())
.findFirst(); .findFirst();

View File

@ -14,9 +14,9 @@ import org.mockito.MockitoAnnotations;
import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileType;
import com.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation; import com.iqser.red.service.redaction.v1.model.DroolsSyntaxValidation;
import com.iqser.red.service.redaction.v1.model.RuleFileType; import com.iqser.red.service.redaction.v1.model.RuleValidationModel;
import com.iqser.red.service.redaction.v1.model.Rules;
import com.iqser.red.service.redaction.v1.server.client.RulesClient; import com.iqser.red.service.redaction.v1.server.client.RulesClient;
import com.iqser.red.service.redaction.v1.server.model.drools.RuleFileBluePrint; import com.iqser.red.service.redaction.v1.server.model.drools.RuleFileBluePrint;
import com.iqser.red.service.redaction.v1.server.service.document.EntityEnrichmentService; import com.iqser.red.service.redaction.v1.server.service.document.EntityEnrichmentService;
@ -51,7 +51,7 @@ class DroolsSyntaxValidationServiceTest {
String rulesString = new String(rulesFile.getInputStream().readAllBytes()); String rulesString = new String(rulesFile.getInputStream().readAllBytes());
DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new Rules(RuleFileType.ENTITY, rulesString)); DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new RuleValidationModel(RuleFileType.ENTITY.name(), rulesString));
droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println); droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println);
assertTrue(droolsSyntaxValidation.isCompiled()); assertTrue(droolsSyntaxValidation.isCompiled());
} }
@ -66,7 +66,7 @@ class DroolsSyntaxValidationServiceTest {
String rulesString = new String(rulesFile.getInputStream().readAllBytes()); String rulesString = new String(rulesFile.getInputStream().readAllBytes());
DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new Rules(RuleFileType.ENTITY, rulesString)); DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new RuleValidationModel(RuleFileType.ENTITY.name(), rulesString));
droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println); droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println);
assertTrue(droolsSyntaxValidation.isCompiled()); assertTrue(droolsSyntaxValidation.isCompiled());
} }
@ -81,7 +81,7 @@ class DroolsSyntaxValidationServiceTest {
String rulesString = new String(rulesFile.getInputStream().readAllBytes()); String rulesString = new String(rulesFile.getInputStream().readAllBytes());
DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new Rules(RuleFileType.ENTITY, rulesString)); DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new RuleValidationModel(RuleFileType.ENTITY.name(), rulesString));
droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println); droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println);
assertTrue(droolsSyntaxValidation.isCompiled()); assertTrue(droolsSyntaxValidation.isCompiled());
} }
@ -96,7 +96,7 @@ class DroolsSyntaxValidationServiceTest {
String rulesString = new String(rulesFile.getInputStream().readAllBytes()); String rulesString = new String(rulesFile.getInputStream().readAllBytes());
DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new Rules(RuleFileType.ENTITY, rulesString)); DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new RuleValidationModel(RuleFileType.ENTITY.name(), rulesString));
droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println); droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println);
assertTrue(droolsSyntaxValidation.isCompiled()); assertTrue(droolsSyntaxValidation.isCompiled());
} }
@ -111,7 +111,7 @@ class DroolsSyntaxValidationServiceTest {
String rulesString = new String(rulesFile.getInputStream().readAllBytes()); String rulesString = new String(rulesFile.getInputStream().readAllBytes());
DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new Rules(RuleFileType.ENTITY, rulesString)); DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new RuleValidationModel(RuleFileType.ENTITY.name(), rulesString));
droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println); droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println);
assertTrue(droolsSyntaxValidation.isCompiled()); assertTrue(droolsSyntaxValidation.isCompiled());
} }
@ -126,7 +126,7 @@ class DroolsSyntaxValidationServiceTest {
String rulesString = new String(rulesFile.getInputStream().readAllBytes()); String rulesString = new String(rulesFile.getInputStream().readAllBytes());
DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new Rules(RuleFileType.ENTITY, rulesString)); DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new RuleValidationModel(RuleFileType.ENTITY.name(), rulesString));
droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println); droolsSyntaxValidation.getDroolsSyntaxErrorMessages().forEach(System.out::println);
assertTrue(droolsSyntaxValidation.isCompiled()); assertTrue(droolsSyntaxValidation.isCompiled());
} }
@ -142,7 +142,7 @@ class DroolsSyntaxValidationServiceTest {
String rulesString = new String(rulesFile.getInputStream().readAllBytes()); String rulesString = new String(rulesFile.getInputStream().readAllBytes());
String corruptedRules = rulesString.replaceAll(";", ""); String corruptedRules = rulesString.replaceAll(";", "");
DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new Rules(RuleFileType.ENTITY, corruptedRules)); DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new RuleValidationModel(RuleFileType.ENTITY.name(), corruptedRules));
assertFalse(droolsSyntaxValidation.isCompiled()); assertFalse(droolsSyntaxValidation.isCompiled());
} }
@ -157,7 +157,7 @@ class DroolsSyntaxValidationServiceTest {
String rulesString = new String(rulesFile.getInputStream().readAllBytes()); String rulesString = new String(rulesFile.getInputStream().readAllBytes());
String corruptedRules = rulesString.replaceAll("import com.iqser.red.service.redaction.v1.server.model.document.nodes.ImageType;", ""); String corruptedRules = rulesString.replaceAll("import com.iqser.red.service.redaction.v1.server.model.document.nodes.ImageType;", "");
DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new Rules(RuleFileType.ENTITY, corruptedRules)); DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new RuleValidationModel(RuleFileType.ENTITY.name(), corruptedRules));
assertFalse(droolsSyntaxValidation.isCompiled()); assertFalse(droolsSyntaxValidation.isCompiled());
} }
@ -178,7 +178,7 @@ class DroolsSyntaxValidationServiceTest {
for (String ruleFile : ruleFiles) { for (String ruleFile : ruleFiles) {
var rulesFile = new ClassPathResource(ruleFile); var rulesFile = new ClassPathResource(ruleFile);
String rulesString = new String(rulesFile.getInputStream().readAllBytes()); String rulesString = new String(rulesFile.getInputStream().readAllBytes());
DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new Rules(RuleFileType.ENTITY, rulesString)); DroolsSyntaxValidation droolsSyntaxValidation = droolsSyntaxValidationService.testRules(new RuleValidationModel(RuleFileType.ENTITY.name(), rulesString));
if (droolsSyntaxValidation.isCompiled()) { if (droolsSyntaxValidation.isCompiled()) {
continue; continue;
} }

View File

@ -1247,20 +1247,31 @@ rule "MAN.2.1: Apply force redaction to images"
rule "MAN.3.0: Apply entity recategorization" rule "MAN.3.0: Apply entity recategorization"
salience 128 salience 128
when when
$recategorization: ManualRecategorization($id: annotationId, status == AnnotationStatus.APPROVED, $requestDate: requestDate) $recategorization: ManualRecategorization($id: annotationId, $type: type, status == AnnotationStatus.APPROVED, $requestDate: requestDate)
not ManualRecategorization($id == annotationId, requestDate.isBefore($requestDate)) not ManualRecategorization($id == annotationId, requestDate.isBefore($requestDate))
$entityToBeRecategorized: TextEntity(matchesAnnotationId($id)) $entityToBeRecategorized: TextEntity(matchesAnnotationId($id), type != $type)
then then
if (!$recategorization.getType().equals($entityToBeRecategorized.getType())) {
$entityToBeRecategorized.getIntersectingNodes().forEach(node -> update(node)); $entityToBeRecategorized.getIntersectingNodes().forEach(node -> update(node));
manualChangesApplicationService.recategorize($entityToBeRecategorized, $recategorization); manualChangesApplicationService.recategorize($entityToBeRecategorized, $recategorization);
retract($recategorization);
// Entity is copied and inserted, so the old entity needs to be retracted to avoid duplication. // Entity is copied and inserted, so the old entity needs to be retracted to avoid duplication.
retract($entityToBeRecategorized); retract($entityToBeRecategorized);
} end
rule "MAN.3.1: Apply entity recategorization of same type"
salience 128
when
$recategorization: ManualRecategorization($id: annotationId, $type: type, status == AnnotationStatus.APPROVED, $requestDate: requestDate)
not ManualRecategorization($id == annotationId, requestDate.isBefore($requestDate))
$entityToBeRecategorized: TextEntity(matchesAnnotationId($id), type == $type)
then
$entityToBeRecategorized.getManualOverwrite().addChange($recategorization);
retract($recategorization); retract($recategorization);
end end
rule "MAN.3.1: Apply image recategorization"
rule "MAN.3.2: Apply image recategorization"
salience 128 salience 128
when when
$recategorization: ManualRecategorization($id: annotationId, status == AnnotationStatus.APPROVED, $requestDate: requestDate) $recategorization: ManualRecategorization($id: annotationId, status == AnnotationStatus.APPROVED, $requestDate: requestDate)
@ -1273,6 +1284,7 @@ rule "MAN.3.1: Apply image recategorization"
retract($recategorization); retract($recategorization);
end end
// Rule unit: MAN.4 // Rule unit: MAN.4
rule "MAN.4.0: Apply legal basis change" rule "MAN.4.0: Apply legal basis change"
salience 128 salience 128

View File

@ -23,7 +23,6 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.ManualChange; import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.ManualChange;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position; import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position;
import com.iqser.red.service.persistence.service.v1.api.shared.model.FileAttribute; import com.iqser.red.service.persistence.service.v1.api.shared.model.FileAttribute;
global ComponentCreationService componentCreationService global ComponentCreationService componentCreationService
@ -56,7 +55,7 @@ rule "PerformingLaboratory.0.0: Performing Laboratory"
not Entity(type == "laboratory_country", Math.abs($laboratoryName.startOffset - startOffset) < $distance) not Entity(type == "laboratory_country", Math.abs($laboratoryName.startOffset - startOffset) < $distance)
eval($distance < 80) eval($distance < 80)
then then
componentCreationService.createComponent("PerformingLaboratory.0.0", "Performing_Laboratory", $laboratoryName.getValue() + ", " + $laboratoryCountry.getValue(), "Laboratory name and country found!"); componentCreationService.create("PerformingLaboratory.0.0", "Performing_Laboratory", $laboratoryName.getValue() + ", " + $laboratoryCountry.getValue(), "Laboratory name and country found!");
end end
rule "PerformingLaboratory.0.1: Performing Laboratory" rule "PerformingLaboratory.0.1: Performing Laboratory"
@ -64,7 +63,7 @@ rule "PerformingLaboratory.0.1: Performing Laboratory"
$laboratoryName: Entity(type == "laboratory_name") $laboratoryName: Entity(type == "laboratory_name")
not Entity(type == "laboratory_country", Math.abs($laboratoryName.startOffset - startOffset) < 80) not Entity(type == "laboratory_country", Math.abs($laboratoryName.startOffset - startOffset) < 80)
then then
componentCreationService.createComponent("DefaultComponents.0.1", "Performing_Laboratory", $laboratoryName.getValue(), "Only laboratory name found!"); componentCreationService.create("DefaultComponents.0.1", "Performing_Laboratory", $laboratoryName.getValue(), "Only laboratory name found!");
end end
rule "PerformingLaboratory.0.2: Performing Laboratory" rule "PerformingLaboratory.0.2: Performing Laboratory"
@ -72,7 +71,7 @@ rule "PerformingLaboratory.0.2: Performing Laboratory"
when when
not Component(category == "Performing_Laboratory") not Component(category == "Performing_Laboratory")
then then
componentCreationService.createComponent("PerformingLaboratory.0.2", "Performing_Laboratory", "n-a", "fallback"); componentCreationService.create("PerformingLaboratory.0.2", "Performing_Laboratory", "n-a", "fallback");
end end
@ -88,14 +87,14 @@ rule "GLPStudy.0.0: GLP Study"
when when
$glpStudy: Entity(type() == "glp_study") $glpStudy: Entity(type() == "glp_study")
then then
componentCreationService.createComponent("GLPStudy.0.0", "GLP_study", "Yes", "Yes if present, No if not", $glpStudy); componentCreationService.create("GLPStudy.0.0", "GLP_study", "Yes", "Yes if present, No if not", $glpStudy);
end end
rule "GLPStudy.1.0: GLP Study" rule "GLPStudy.1.0: GLP Study"
when when
not Entity(type() == "glp_study") not Entity(type() == "glp_study")
then then
componentCreationService.createComponent("GLPStudy.1.0", "GLP_study", "No", "Yes if present, No if not"); componentCreationService.create("GLPStudy.1.0", "GLP_study", "No", "Yes if present, No if not");
end end
rule "GLPStudy.2.0: GLP Study" rule "GLPStudy.2.0: GLP Study"
@ -113,7 +112,7 @@ rule "DefaultComponents.4.0: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number") $guidelineNumber: Entity(type == "oecd_guideline_number")
not Entity(type == "oecd_guideline_year") not Entity(type == "oecd_guideline_year")
then then
componentCreationService.createComponent("DefaultComponents.4.0", "Test_Guidelines_1", $guidelineNumber.getValue(), "Only OECD Number found!"); componentCreationService.create("DefaultComponents.4.0", "Test_Guidelines_1", $guidelineNumber.getValue(), "Only OECD Number found!");
end end
rule "DefaultComponents.4.1: Test Guideline 1" rule "DefaultComponents.4.1: Test Guideline 1"
@ -121,7 +120,7 @@ rule "DefaultComponents.4.1: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2015") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2015")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "404") $guidelineYear: Entity(type == "oecd_guideline_year", value == "404")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.1", "DefaultComponents.4.1",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 404: Acute Dermal Irritation/Corrosion (28/07/2015)", "Nº 404: Acute Dermal Irritation/Corrosion (28/07/2015)",
@ -134,7 +133,7 @@ rule "DefaultComponents.4.2: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "1981") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "1981")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "403") $guidelineYear: Entity(type == "oecd_guideline_year", value == "403")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.2", "DefaultComponents.4.2",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 403: Acute Inhalation Toxicity (12/05/1981)", "Nº 403: Acute Inhalation Toxicity (12/05/1981)",
@ -147,7 +146,7 @@ rule "DefaultComponents.4.3: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2018") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2018")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "442B") $guidelineYear: Entity(type == "oecd_guideline_year", value == "442B")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.3", "DefaultComponents.4.3",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 442B: Skin Sensitization (27/06/2018)", "Nº 442B: Skin Sensitization (27/06/2018)",
@ -160,7 +159,7 @@ rule "DefaultComponents.4.4: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2016") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2016")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "487") $guidelineYear: Entity(type == "oecd_guideline_year", value == "487")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.4", "DefaultComponents.4.4",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 487: Micronucleus Human Lymphocytes (2016)", "Nº 487: Micronucleus Human Lymphocytes (2016)",
@ -173,7 +172,7 @@ rule "DefaultComponents.4.5: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2004") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2004")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "428") $guidelineYear: Entity(type == "oecd_guideline_year", value == "428")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.5", "DefaultComponents.4.5",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 428: Split-Thickness Skin test (2004)", "Nº 428: Split-Thickness Skin test (2004)",
@ -186,7 +185,7 @@ rule "DefaultComponents.4.6: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2018") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2018")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "442A") $guidelineYear: Entity(type == "oecd_guideline_year", value == "442A")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.6", "DefaultComponents.4.6",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 442A: Skin Sensitization (23/07/2018)", "Nº 442A: Skin Sensitization (23/07/2018)",
@ -199,7 +198,7 @@ rule "DefaultComponents.4.7: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2002") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2002")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "404") $guidelineYear: Entity(type == "oecd_guideline_year", value == "404")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.7", "DefaultComponents.4.7",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 404: Acute Dermal Irritation/Corrosion (24/04/2002)", "Nº 404: Acute Dermal Irritation/Corrosion (24/04/2002)",
@ -212,7 +211,7 @@ rule "DefaultComponents.4.8: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "1992") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "1992")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "406") $guidelineYear: Entity(type == "oecd_guideline_year", value == "406")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.8", "DefaultComponents.4.8",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 406: Skin Sensitisation (1992)", "Nº 406: Skin Sensitisation (1992)",
@ -225,7 +224,7 @@ rule "DefaultComponents.4.9: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2018") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2018")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "438") $guidelineYear: Entity(type == "oecd_guideline_year", value == "438")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.9", "DefaultComponents.4.9",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 438: Eye Irritation (26/06/2018)", "Nº 438: Eye Irritation (26/06/2018)",
@ -238,7 +237,7 @@ rule "DefaultComponents.4.10: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2009") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2009")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "436") $guidelineYear: Entity(type == "oecd_guideline_year", value == "436")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.10", "DefaultComponents.4.10",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 436: Acute Inhalation Toxicity Acute Toxic Class Method (08/09/2009)", "Nº 436: Acute Inhalation Toxicity Acute Toxic Class Method (08/09/2009)",
@ -251,7 +250,7 @@ rule "DefaultComponents.4.11: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2002") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2002")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "429") $guidelineYear: Entity(type == "oecd_guideline_year", value == "429")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.11", "DefaultComponents.4.11",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 429: Skin Sensitisation: Local Lymph Node Assay (24/04/2002)", "Nº 429: Skin Sensitisation: Local Lymph Node Assay (24/04/2002)",
@ -264,7 +263,7 @@ rule "DefaultComponents.4.12: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2020") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2020")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "471") $guidelineYear: Entity(type == "oecd_guideline_year", value == "471")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.12", "DefaultComponents.4.12",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 471: Bacterial Reverse Mutation Test (26/06/2020)", "Nº 471: Bacterial Reverse Mutation Test (26/06/2020)",
@ -277,7 +276,7 @@ rule "DefaultComponents.4.13: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "1987") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "1987")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "405") $guidelineYear: Entity(type == "oecd_guideline_year", value == "405")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.13", "DefaultComponents.4.13",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 405: Acute Eye Irritation/Corrosion (24/02/1987)", "Nº 405: Acute Eye Irritation/Corrosion (24/02/1987)",
@ -290,7 +289,7 @@ rule "DefaultComponents.4.14: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "1997") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "1997")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "471") $guidelineYear: Entity(type == "oecd_guideline_year", value == "471")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.14", "DefaultComponents.4.14",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 471: Bacterial Reverse Mutation Test (21/07/1997)", "Nº 471: Bacterial Reverse Mutation Test (21/07/1997)",
@ -303,7 +302,7 @@ rule "DefaultComponents.4.15: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2009") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2009")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "403") $guidelineYear: Entity(type == "oecd_guideline_year", value == "403")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.15", "DefaultComponents.4.15",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 403: Acute Inhalation Toxicity (08/09/2009)", "Nº 403: Acute Inhalation Toxicity (08/09/2009)",
@ -316,7 +315,7 @@ rule "DefaultComponents.4.16: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2018") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2018")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "433") $guidelineYear: Entity(type == "oecd_guideline_year", value == "433")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.16", "DefaultComponents.4.16",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 433: Acute Inhalation Toxicity: Fixed Concentration Procedure (27/06/2018)", "Nº 433: Acute Inhalation Toxicity: Fixed Concentration Procedure (27/06/2018)",
@ -329,7 +328,7 @@ rule "DefaultComponents.4.17: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2019") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2019")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "439") $guidelineYear: Entity(type == "oecd_guideline_year", value == "439")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.17", "DefaultComponents.4.17",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 439: Skin Irritation (2019)", "Nº 439: Skin Irritation (2019)",
@ -342,7 +341,7 @@ rule "DefaultComponents.4.18: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2001") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2001")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "425") $guidelineYear: Entity(type == "oecd_guideline_year", value == "425")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.18", "DefaultComponents.4.18",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 425: Acute oral Toxicity - Up-and-Down Procedure (17/12/2001)", "Nº 425: Acute oral Toxicity - Up-and-Down Procedure (17/12/2001)",
@ -355,7 +354,7 @@ rule "DefaultComponents.4.19: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2017") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2017")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "402") $guidelineYear: Entity(type == "oecd_guideline_year", value == "402")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.19", "DefaultComponents.4.19",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 402: Acute Dermal Toxicity (09/10/2017)", "Nº 402: Acute Dermal Toxicity (09/10/2017)",
@ -368,7 +367,7 @@ rule "DefaultComponents.4.20: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "1981") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "1981")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "404") $guidelineYear: Entity(type == "oecd_guideline_year", value == "404")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.20", "DefaultComponents.4.20",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 404: Acute Dermal Irritation/Corrosion (12/05/1981)", "Nº 404: Acute Dermal Irritation/Corrosion (12/05/1981)",
@ -381,7 +380,7 @@ rule "DefaultComponents.4.21: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2016") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2016")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "474") $guidelineYear: Entity(type == "oecd_guideline_year", value == "474")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.21", "DefaultComponents.4.21",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 474: Micronucleus Bone Marrow Cells Rat (2016)", "Nº 474: Micronucleus Bone Marrow Cells Rat (2016)",
@ -394,7 +393,7 @@ rule "DefaultComponents.4.22: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2017") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2017")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "433") $guidelineYear: Entity(type == "oecd_guideline_year", value == "433")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.22", "DefaultComponents.4.22",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 433: Acute Inhalation Toxicity: Fixed Concentration Procedure (09/10/2017)", "Nº 433: Acute Inhalation Toxicity: Fixed Concentration Procedure (09/10/2017)",
@ -407,7 +406,7 @@ rule "DefaultComponents.4.23: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "1992") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "1992")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "404") $guidelineYear: Entity(type == "oecd_guideline_year", value == "404")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.23", "DefaultComponents.4.23",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 404: Acute Dermal Irritation/Corrosion (17/07/1992)", "Nº 404: Acute Dermal Irritation/Corrosion (17/07/1992)",
@ -420,7 +419,7 @@ rule "DefaultComponents.4.24: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2010") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2010")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "429") $guidelineYear: Entity(type == "oecd_guideline_year", value == "429")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.24", "DefaultComponents.4.24",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 429: Skin Sensitisation (23/07/2010)", "Nº 429: Skin Sensitisation (23/07/2010)",
@ -433,7 +432,7 @@ rule "DefaultComponents.4.25: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2017") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2017")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "405") $guidelineYear: Entity(type == "oecd_guideline_year", value == "405")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.25", "DefaultComponents.4.25",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 405: Acute Eye Irritation/Corrosion (09/10/2017)", "Nº 405: Acute Eye Irritation/Corrosion (09/10/2017)",
@ -446,7 +445,7 @@ rule "DefaultComponents.4.26: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "1987") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "1987")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "402") $guidelineYear: Entity(type == "oecd_guideline_year", value == "402")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.26", "DefaultComponents.4.26",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 402: Acute Dermal Toxicity (24/02/1987)", "Nº 402: Acute Dermal Toxicity (24/02/1987)",
@ -459,7 +458,7 @@ rule "DefaultComponents.4.27: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2012") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2012")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "405") $guidelineYear: Entity(type == "oecd_guideline_year", value == "405")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.27", "DefaultComponents.4.27",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 405: Acute Eye Irritation/Corrosion (02/10/2012)", "Nº 405: Acute Eye Irritation/Corrosion (02/10/2012)",
@ -472,7 +471,7 @@ rule "DefaultComponents.4.28: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2002") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2002")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "405") $guidelineYear: Entity(type == "oecd_guideline_year", value == "405")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.28", "DefaultComponents.4.28",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 405: Acute Eye Irritation/Corrosion (24/04/2002)", "Nº 405: Acute Eye Irritation/Corrosion (24/04/2002)",
@ -485,7 +484,7 @@ rule "DefaultComponents.4.29: Test Guideline 1"
$guidelineNumber: Entity(type == "oecd_guideline_number", value == "2008") $guidelineNumber: Entity(type == "oecd_guideline_number", value == "2008")
$guidelineYear: Entity(type == "oecd_guideline_year", value == "425") $guidelineYear: Entity(type == "oecd_guideline_year", value == "425")
then then
componentCreationService.createComponent( componentCreationService.create(
"DefaultComponents.4.29", "DefaultComponents.4.29",
"Test_Guidelines_1", "Test_Guidelines_1",
"Nº 425: Acute oral Toxicity - Up-and-Down Procedure (03/10/2008)", "Nº 425: Acute oral Toxicity - Up-and-Down Procedure (03/10/2008)",
@ -537,7 +536,7 @@ rule "DefaultComponents.8.0: Certificate of analysis batch identification"
rule "DefaultComponents.999.0: Create components for all unmapped entities." rule "DefaultComponents.999.0: Create components for all unmapped entities."
salience -999 salience -999
when when
$allEntities: List(!isEmpty()) from collect (Entity() $allEntities: List(!isEmpty()) from collect (Entity())
then then
componentCreationService.createComponentsForUnMappedEntities("DefaultComponents.999.0", $allEntities); componentCreationService.createComponentsForUnMappedEntities("DefaultComponents.999.0", $allEntities);
end end