RM-184 && RM-172: update SectionIdentifier javadoc, make ComponentMappingService entirely optional, without warnings
This commit is contained in:
parent
dc48145452
commit
a42b7955fe
@ -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
|
@Override
|
||||||
public SectionIdentifier getSectionIdentifier() {
|
public SectionIdentifier getSectionIdentifier() {
|
||||||
|
|
||||||
|
|||||||
@ -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
|
@Override
|
||||||
public SectionIdentifier getSectionIdentifier() {
|
public SectionIdentifier getSectionIdentifier() {
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,8 @@ import lombok.Getter;
|
|||||||
import lombok.experimental.FieldDefaults;
|
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
|
@AllArgsConstructor
|
||||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
@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.
|
* @param sectionIdentifier The section identifier to compare against.
|
||||||
* @return true if the current section is the parent of the given section, false otherwise.
|
* @return true if the current section is the parent of the given section, false otherwise.
|
||||||
|
|||||||
@ -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.
|
* @return The SectionIdentifier from the first Headline.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package com.iqser.red.service.redaction.v1.server.model.document.nodes;
|
|||||||
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.experimental.FieldDefaults;
|
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
|
@Override
|
||||||
public SectionIdentifier getSectionIdentifier() {
|
public SectionIdentifier getSectionIdentifier() {
|
||||||
|
|
||||||
@ -46,7 +50,6 @@ public class SuperSection extends AbstractSemanticNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
@ -86,5 +89,4 @@ public class SuperSection extends AbstractSemanticNode {
|
|||||||
return streamAllSubNodesOfType(NodeType.HEADLINE).anyMatch(h -> h.containsStringIgnoreCase(value));
|
return streamAllSubNodesOfType(NodeType.HEADLINE).anyMatch(h -> h.containsStringIgnoreCase(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class ComponentDroolsExecutionService {
|
|||||||
|
|
||||||
kieSession.setGlobal("componentCreationService", componentCreationService);
|
kieSession.setGlobal("componentCreationService", componentCreationService);
|
||||||
|
|
||||||
if (hasComponentMappingServiceGlobal(kieSession)) {
|
if (hasGlobalWithName(kieSession, COMPONENT_MAPPING_SERVICE_GLOBAL)) {
|
||||||
kieSession.setGlobal(COMPONENT_MAPPING_SERVICE_GLOBAL, componentMappingService);
|
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()
|
return kieSession.getKieBase().getKiePackages()
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(kiePackage -> kiePackage.getGlobalVariables()
|
.flatMap(kiePackage -> kiePackage.getGlobalVariables()
|
||||||
.stream())
|
.stream())
|
||||||
.anyMatch(global -> global.getName().equals(COMPONENT_MAPPING_SERVICE_GLOBAL));
|
.anyMatch(global -> global.getName().equals(globalName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ public class DroolsValidationService {
|
|||||||
|
|
||||||
DroolsValidation customValidation = ruleFileBluePrint.getDroolsValidation();
|
DroolsValidation customValidation = ruleFileBluePrint.getDroolsValidation();
|
||||||
|
|
||||||
addSyntaxDeprecatedWarnings(ruleFileType, ruleFileBluePrint, customValidation);
|
addSyntaxDeprecatedWarnings(ruleFileBluePrint, customValidation);
|
||||||
|
|
||||||
addSyntaxErrorMessages(ruleFileType, 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
|
// find deprecated elements in the ruleFileBluePrint
|
||||||
DroolsSyntaxDeprecatedWarnings warningMessageForImports = getWarningsForDeprecatedImports(ruleFileBluePrint);
|
DroolsSyntaxDeprecatedWarnings warningMessageForImports = getWarningsForDeprecatedImports(ruleFileBluePrint);
|
||||||
@ -93,25 +93,6 @@ public class DroolsValidationService {
|
|||||||
customValidation.getDeprecatedWarnings().add(warningMessageForImports);
|
customValidation.getDeprecatedWarnings().add(warningMessageForImports);
|
||||||
}
|
}
|
||||||
customValidation.getDeprecatedWarnings().addAll(getWarningsForDeprecatedRules(ruleFileBluePrint));
|
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) {
|
private DroolsBlacklistErrorMessage checkAndGetBlackListedMessages(SearchImplementation blacklistedKeywordSearchImplementation, String stringToCheck, int lineIndexStart) {
|
||||||
|
|
||||||
String nonWhitespaceRuleText = StringUtils.deleteWhitespace(stringToCheck);
|
String nonWhitespaceRuleText = StringUtils.deleteWhitespace(stringToCheck);
|
||||||
String sanitizedRuleText= nonWhitespaceRuleText.replaceAll("\"(\\\\.|[^\"\\\\])*\"|'(\\\\.|[^'\\\\])*'" ,"");
|
String sanitizedRuleText = nonWhitespaceRuleText.replaceAll("\"(\\\\.|[^\"\\\\])*\"|'(\\\\.|[^'\\\\])*'", "");
|
||||||
|
|
||||||
List<SearchImplementation.MatchPosition> matches = blacklistedKeywordSearchImplementation.getMatches(sanitizedRuleText);
|
List<SearchImplementation.MatchPosition> matches = blacklistedKeywordSearchImplementation.getMatches(sanitizedRuleText);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user