RM-184 && RM-172: update SectionIdentifier javadoc, make ComponentMappingService entirely optional, without warnings

This commit is contained in:
Kilian Schuettler 2024-10-09 11:19:21 +02:00
parent dc48145452
commit a42b7955fe
7 changed files with 25 additions and 31 deletions

View File

@ -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() {

View File

@ -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() {

View File

@ -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.

View File

@ -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.
*/

View File

@ -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));
}
}

View File

@ -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));
}

View File

@ -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<SearchImplementation.MatchPosition> matches = blacklistedKeywordSearchImplementation.getMatches(sanitizedRuleText);