diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/Headline.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/Headline.java index 0adf1538..bb0a337a 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/Headline.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/Headline.java @@ -71,6 +71,11 @@ public class Headline extends AbstractSemanticNode { } + /** + * Extracts the SectionIdentifier from the text of this headline. + * + * @return The SectionIdentifier, with which the headline starts. + */ @Override public SectionIdentifier getSectionIdentifier() { diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/Section.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/Section.java index c79d6e6f..54dab47f 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/Section.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/Section.java @@ -54,6 +54,11 @@ public class Section extends AbstractSemanticNode { } + /** + * Returns the SectionIdentifier from the headline obtained by the getHeadline() method. + * + * @return the SectionIdentifier of the associated Headline + */ @Override public SectionIdentifier getSectionIdentifier() { diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SectionIdentifier.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SectionIdentifier.java index 16ac4c48..dbea02c7 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SectionIdentifier.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SectionIdentifier.java @@ -13,7 +13,8 @@ import lombok.Getter; import lombok.experimental.FieldDefaults; /** - * Represents a unique identifier for a section within a document. + * Represents the textual identifier sometimes present in a Headline. For example, given the headline 3.1 Results, the section identifier is 3.1. + * Keep in mind, this identifier must not be unique in a single document, as there might be multiple headlines starting with the same textual identifier. */ @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @@ -142,7 +143,7 @@ public class SectionIdentifier { /** - * Determines if the current section is the parent of the given section. + * Determines if the current SectionIdentifier is the parent of the given SectionIdentifier. * * @param sectionIdentifier The section identifier to compare against. * @return true if the current section is the parent of the given section, false otherwise. diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SemanticNode.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SemanticNode.java index b3ca8b15..b960363b 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SemanticNode.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SemanticNode.java @@ -164,7 +164,7 @@ public interface SemanticNode { /** - * Returns a SectionIdentifier, such that it acts as a child of the first Headline associated with this SemanticNode. + * Returns the SectionIdentifier as a child of the SectionIdentifier returned by the getHeadline() method. * * @return The SectionIdentifier from the first Headline. */ diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SuperSection.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SuperSection.java index 801190f1..9ee87951 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SuperSection.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/nodes/SuperSection.java @@ -2,7 +2,6 @@ package com.iqser.red.service.redaction.v1.server.model.document.nodes; import lombok.AccessLevel; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.FieldDefaults; @@ -39,6 +38,11 @@ public class SuperSection extends AbstractSemanticNode { } + /** + * Returns the SectionIdentifier from the headline obtained by the getHeadline() method. + * + * @return the SectionIdentifier of the associated Headline + */ @Override public SectionIdentifier getSectionIdentifier() { @@ -46,7 +50,6 @@ public class SuperSection extends AbstractSemanticNode { } - @Override public String toString() { @@ -86,5 +89,4 @@ public class SuperSection extends AbstractSemanticNode { return streamAllSubNodesOfType(NodeType.HEADLINE).anyMatch(h -> h.containsStringIgnoreCase(value)); } - } diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/drools/ComponentDroolsExecutionService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/drools/ComponentDroolsExecutionService.java index ec76583e..a8e6d4e3 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/drools/ComponentDroolsExecutionService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/drools/ComponentDroolsExecutionService.java @@ -61,7 +61,7 @@ public class ComponentDroolsExecutionService { kieSession.setGlobal("componentCreationService", componentCreationService); - if (hasComponentMappingServiceGlobal(kieSession)) { + if (hasGlobalWithName(kieSession, COMPONENT_MAPPING_SERVICE_GLOBAL)) { kieSession.setGlobal(COMPONENT_MAPPING_SERVICE_GLOBAL, componentMappingService); } @@ -141,13 +141,13 @@ public class ComponentDroolsExecutionService { } - private static boolean hasComponentMappingServiceGlobal(KieSession kieSession) { + private static boolean hasGlobalWithName(KieSession kieSession, String globalName) { return kieSession.getKieBase().getKiePackages() .stream() .flatMap(kiePackage -> kiePackage.getGlobalVariables() .stream()) - .anyMatch(global -> global.getName().equals(COMPONENT_MAPPING_SERVICE_GLOBAL)); + .anyMatch(global -> global.getName().equals(globalName)); } diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/drools/DroolsValidationService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/drools/DroolsValidationService.java index 6d98ae0c..9b983752 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/drools/DroolsValidationService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/drools/DroolsValidationService.java @@ -73,7 +73,7 @@ public class DroolsValidationService { DroolsValidation customValidation = ruleFileBluePrint.getDroolsValidation(); - addSyntaxDeprecatedWarnings(ruleFileType, ruleFileBluePrint, customValidation); + addSyntaxDeprecatedWarnings(ruleFileBluePrint, customValidation); addSyntaxErrorMessages(ruleFileType, ruleFileBluePrint, customValidation); @@ -85,7 +85,7 @@ public class DroolsValidationService { } - private void addSyntaxDeprecatedWarnings(RuleFileType ruleFileType, RuleFileBluePrint ruleFileBluePrint, DroolsValidation customValidation) { + private void addSyntaxDeprecatedWarnings(RuleFileBluePrint ruleFileBluePrint, DroolsValidation customValidation) { // find deprecated elements in the ruleFileBluePrint DroolsSyntaxDeprecatedWarnings warningMessageForImports = getWarningsForDeprecatedImports(ruleFileBluePrint); @@ -93,25 +93,6 @@ public class DroolsValidationService { customValidation.getDeprecatedWarnings().add(warningMessageForImports); } customValidation.getDeprecatedWarnings().addAll(getWarningsForDeprecatedRules(ruleFileBluePrint)); - - if (ruleFileType.equals(RuleFileType.COMPONENT)) { - if (!ruleFileBluePrint.getGlobals().contains(ComponentDroolsExecutionService.COMPONENT_MAPPING_SERVICE_GLOBAL)) { - customValidation.getDeprecatedWarnings().add(buildComponentMappingServiceMissingMessage(ruleFileBluePrint)); - } - - } - } - - - private static DroolsSyntaxDeprecatedWarnings buildComponentMappingServiceMissingMessage(RuleFileBluePrint ruleFileBluePrint) { - - return DroolsSyntaxDeprecatedWarnings.builder() - .message("global ComponentMappingService " - + ComponentDroolsExecutionService.COMPONENT_MAPPING_SERVICE_GLOBAL - + "\n is missing from the rules, consider adding it, as it will be required in future versions!") - .line(ruleFileBluePrint.getGlobalsLine()) - .column(0) - .build(); } @@ -284,7 +265,7 @@ public class DroolsValidationService { private DroolsBlacklistErrorMessage checkAndGetBlackListedMessages(SearchImplementation blacklistedKeywordSearchImplementation, String stringToCheck, int lineIndexStart) { String nonWhitespaceRuleText = StringUtils.deleteWhitespace(stringToCheck); - String sanitizedRuleText= nonWhitespaceRuleText.replaceAll("\"(\\\\.|[^\"\\\\])*\"|'(\\\\.|[^'\\\\])*'" ,""); + String sanitizedRuleText = nonWhitespaceRuleText.replaceAll("\"(\\\\.|[^\"\\\\])*\"|'(\\\\.|[^'\\\\])*'", ""); List matches = blacklistedKeywordSearchImplementation.getMatches(sanitizedRuleText);