RED-9139: move document to its own module, add TableOfContents and TableOfContentsItem
* ignore checkstyle and pmd for generated proto files
This commit is contained in:
parent
da13a5a419
commit
95b07e5dd3
@ -65,3 +65,45 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun parseDroolsImports(vararg droolsFilePaths: String): List<String> {
|
||||||
|
val imports = mutableListOf<String>()
|
||||||
|
val importPattern = Regex("^import\\s+(com\\.iqser\\.red\\.service\\.redaction\\.v1\\.[\\w.]+);")
|
||||||
|
val desiredPrefix = "com.iqser.red.service.redaction.v1"
|
||||||
|
|
||||||
|
droolsFilePaths.forEach { filePath ->
|
||||||
|
File(filePath).forEachLine { line ->
|
||||||
|
importPattern.find(line)?.let { matchResult ->
|
||||||
|
val importPath = matchResult.groupValues[1].trim()
|
||||||
|
if (importPath.startsWith(desiredPrefix)) {
|
||||||
|
val formattedPath = importPath.replace('.', '/')
|
||||||
|
imports.add("$formattedPath.java")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return imports
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combine imports from both drools files
|
||||||
|
val droolsImports = parseDroolsImports(
|
||||||
|
"redaction-service-v1/redaction-service-server-v1/src/main/resources/drools/all_rules_documine.drl",
|
||||||
|
"redaction-service-v1/redaction-service-server-v1/src/main/resources/drools/base_component_rules.drl"
|
||||||
|
)
|
||||||
|
|
||||||
|
tasks.register("generateJavaDoc", Javadoc::class) {
|
||||||
|
|
||||||
|
dependsOn("compileJava")
|
||||||
|
dependsOn("delombok")
|
||||||
|
classpath = project.sourceSets["main"].runtimeClasspath
|
||||||
|
source = fileTree("${buildDir}/generated/sources/delombok/java/main") {
|
||||||
|
include(droolsImports)
|
||||||
|
}
|
||||||
|
setDestinationDir(file(project.findProperty("javadocDestinationDir")?.toString() ?: ""))
|
||||||
|
|
||||||
|
options.memberLevel = JavadocMemberLevel.PUBLIC
|
||||||
|
(options as StandardJavadocDocletOptions).apply {
|
||||||
|
title = "API Documentation for Redaction Service ${project.version}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -12,6 +12,8 @@ group = "com.knecon.fforesight"
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.iqser.red.service:persistence-service-internal-api-v1:${persistenceServiceVersion}")
|
implementation("com.iqser.red.service:persistence-service-internal-api-v1:${persistenceServiceVersion}")
|
||||||
api("com.google.protobuf:protobuf-java-util:4.28.3")
|
api("com.google.protobuf:protobuf-java-util:4.28.3")
|
||||||
|
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import lombok.experimental.FieldDefaults;
|
|||||||
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
||||||
public class SectionIdentifier {
|
public class SectionIdentifier {
|
||||||
|
|
||||||
public static Pattern numericalIdentifierPattern = Pattern.compile("^[\\s]?(\\d+)[\\s.,;]?(\\d+)?[\\s.,;]?(\\d+)?[\\s.,;]?(\\d+)?");
|
public static Pattern numericalIdentifierPattern = Pattern.compile("^[\\s]?(\\d{1,2})(?:[\\s.,;](\\d{1,2}))?(?:[\\s.,;](\\d{1,2}))?(?:[\\s.,;](\\d{1,2}))?");
|
||||||
public static Pattern alphanumericIdentifierPattern = Pattern.compile("^[\\s]?[A-Za-z][\\s.,;]?(\\d+)[\\s.,;]?(\\d+)?[\\s.,;]?(\\d+)?[\\s.,;]?(\\d+)?[\\s.,;]?");
|
public static Pattern alphanumericIdentifierPattern = Pattern.compile("^[\\s]?[A-Za-z][\\s.,;]?(\\d+)[\\s.,;]?(\\d+)?[\\s.,;]?(\\d+)?[\\s.,;]?(\\d+)?[\\s.,;]?");
|
||||||
|
|
||||||
protected enum Format {
|
protected enum Format {
|
||||||
|
|||||||
@ -0,0 +1,144 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.server.model.document.nodes;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class SectionIdentifierTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSectionIdentifier() {
|
||||||
|
|
||||||
|
SectionIdentifier identifier = SectionIdentifier.fromSearchText("1.1.2: Headline");
|
||||||
|
assertEquals(SectionIdentifier.Format.NUMERICAL, identifier.getFormat());
|
||||||
|
assertEquals(3, identifier.level());
|
||||||
|
assertEquals(List.of(1, 1, 2), identifier.getIdentifiers());
|
||||||
|
|
||||||
|
SectionIdentifier child = SectionIdentifier.asChildOf(identifier);
|
||||||
|
assertTrue(child.isChildOf(identifier));
|
||||||
|
|
||||||
|
SectionIdentifier parent = SectionIdentifier.fromSearchText("1.1: Headline");
|
||||||
|
assertTrue(parent.isParentOf(identifier));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSectionIdentifier2() {
|
||||||
|
|
||||||
|
SectionIdentifier identifier = SectionIdentifier.fromSearchText("A.1.2: Headline");
|
||||||
|
assertEquals(SectionIdentifier.Format.ALPHANUMERIC, identifier.getFormat());
|
||||||
|
assertEquals(3, identifier.level());
|
||||||
|
assertEquals(List.of(1, 1, 2), identifier.getIdentifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSectionIdentifier3() {
|
||||||
|
|
||||||
|
SectionIdentifier identifier = SectionIdentifier.fromSearchText("D.1.2: Headline");
|
||||||
|
assertEquals(SectionIdentifier.Format.ALPHANUMERIC, identifier.getFormat());
|
||||||
|
assertEquals(3, identifier.level());
|
||||||
|
assertEquals(List.of(4, 1, 2), identifier.getIdentifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSectionIdentifier4() {
|
||||||
|
|
||||||
|
SectionIdentifier identifier = SectionIdentifier.fromSearchText("4.1.2.4: Headline");
|
||||||
|
assertEquals(SectionIdentifier.Format.NUMERICAL, identifier.getFormat());
|
||||||
|
assertEquals(4, identifier.level());
|
||||||
|
assertEquals(List.of(4, 1, 2, 4), identifier.getIdentifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSectionIdentifier5() {
|
||||||
|
|
||||||
|
SectionIdentifier identifier = SectionIdentifier.fromSearchText("D.1.2.4.5: Headline");
|
||||||
|
assertEquals(SectionIdentifier.Format.ALPHANUMERIC, identifier.getFormat());
|
||||||
|
assertEquals(4, identifier.level());
|
||||||
|
assertEquals(List.of(4, 1, 2, 4), identifier.getIdentifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSectionIdentifier6() {
|
||||||
|
|
||||||
|
SectionIdentifier identifier = SectionIdentifier.fromSearchText("d.1.2.4.5: Headline");
|
||||||
|
assertEquals(SectionIdentifier.Format.ALPHANUMERIC, identifier.getFormat());
|
||||||
|
assertEquals(4, identifier.level());
|
||||||
|
assertEquals(List.of(4, 1, 2, 4), identifier.getIdentifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSectionIdentifier7() {
|
||||||
|
|
||||||
|
SectionIdentifier identifier = SectionIdentifier.fromSearchText("4.1.2.4.5: Headline");
|
||||||
|
assertEquals(SectionIdentifier.Format.NUMERICAL, identifier.getFormat());
|
||||||
|
assertEquals(4, identifier.level());
|
||||||
|
assertEquals(List.of(4, 1, 2, 4), identifier.getIdentifiers());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testFalsePositive111() {
|
||||||
|
|
||||||
|
SectionIdentifier identifier = SectionIdentifier.fromSearchText("111: Headline");
|
||||||
|
assertEquals(SectionIdentifier.Format.NUMERICAL, identifier.getFormat());
|
||||||
|
assertEquals(1, identifier.level());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParentOf() {
|
||||||
|
|
||||||
|
var headline = SectionIdentifier.fromSearchText("1 Did you ever hear the tragedy of Darth Plagueis The Wise?");
|
||||||
|
var headline1 = SectionIdentifier.fromSearchText("1.0 I thought not. It’s not a story the Jedi would tell you.");
|
||||||
|
var headline2 = SectionIdentifier.fromSearchText("1.1 It’s a Sith legend. Darth Plagueis was a Dark Lord of the Sith, ");
|
||||||
|
var headline3 = SectionIdentifier.fromSearchText("1.2.3 so powerful and so wise he could use the Force to influence the midichlorians to create life…");
|
||||||
|
var headline4 = SectionIdentifier.fromSearchText("1.2.3.4 He had such a knowledge of the dark side that he could even keep the ones he cared about from dying.");
|
||||||
|
var headline5 = SectionIdentifier.fromSearchText("1.2.3.4.5 The dark side of the Force is a pathway to many abilities some consider to be unnatural.");
|
||||||
|
var headline6 = SectionIdentifier.fromSearchText("2.0 He became so powerful…");
|
||||||
|
var headline7 = SectionIdentifier.fromSearchText("10000.0 the only thing he was afraid of was losing his power,");
|
||||||
|
var headline8 = SectionIdentifier.fromSearchText("A.0 which eventually, of course, he did.");
|
||||||
|
var headline9 = SectionIdentifier.fromSearchText("Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep.");
|
||||||
|
var headline10 = SectionIdentifier.fromSearchText("2.1.2 Ironic.");
|
||||||
|
var headline11 = SectionIdentifier.fromSearchText("2.He could save others from death,");
|
||||||
|
var headline12 = SectionIdentifier.fromSearchText(" 2. but not himself.");
|
||||||
|
|
||||||
|
var paragraph1 = SectionIdentifier.asChildOf(headline);
|
||||||
|
assertTrue(paragraph1.isChildOf(headline));
|
||||||
|
assertTrue(headline.isParentOf(paragraph1));
|
||||||
|
assertFalse(paragraph1.isParentOf(headline));
|
||||||
|
|
||||||
|
assertFalse(headline.isParentOf(headline1));
|
||||||
|
assertTrue(headline.isParentOf(headline2));
|
||||||
|
assertTrue(headline.isParentOf(headline3));
|
||||||
|
assertTrue(headline.isParentOf(headline4));
|
||||||
|
assertTrue(headline.isParentOf(headline5));
|
||||||
|
assertTrue(headline1.isParentOf(headline2));
|
||||||
|
assertFalse(headline1.isParentOf(headline1));
|
||||||
|
assertTrue(headline3.isParentOf(headline4));
|
||||||
|
assertFalse(headline4.isParentOf(headline5));
|
||||||
|
assertFalse(headline2.isParentOf(headline3));
|
||||||
|
assertFalse(headline2.isParentOf(headline4));
|
||||||
|
assertTrue(headline1.isParentOf(headline3));
|
||||||
|
assertTrue(headline1.isParentOf(headline4));
|
||||||
|
assertFalse(headline1.isParentOf(headline6));
|
||||||
|
assertFalse(headline1.isParentOf(headline7));
|
||||||
|
assertFalse(headline8.isParentOf(headline1));
|
||||||
|
assertFalse(headline8.isParentOf(headline2));
|
||||||
|
assertFalse(headline8.isParentOf(headline3));
|
||||||
|
assertFalse(headline8.isParentOf(headline4));
|
||||||
|
assertFalse(headline9.isParentOf(headline9));
|
||||||
|
assertTrue(headline10.isChildOf(headline11));
|
||||||
|
assertTrue(headline10.isChildOf(headline12));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -31,12 +31,6 @@ configurations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
|
||||||
resolutionStrategy {
|
|
||||||
force("com.google.protobuf:protobuf-java:4.27.1")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
implementation(project(":redaction-service-api-v1")) { exclude(group = "com.iqser.red.service", module = "persistence-service-internal-api-v1") }
|
implementation(project(":redaction-service-api-v1")) { exclude(group = "com.iqser.red.service", module = "persistence-service-internal-api-v1") }
|
||||||
@ -68,7 +62,6 @@ dependencies {
|
|||||||
implementation("org.drools:drools-engine:${droolsVersion}")
|
implementation("org.drools:drools-engine:${droolsVersion}")
|
||||||
implementation("org.drools:drools-mvel:${droolsVersion}")
|
implementation("org.drools:drools-mvel:${droolsVersion}")
|
||||||
implementation("org.kie:kie-spring:7.74.1.Final")
|
implementation("org.kie:kie-spring:7.74.1.Final")
|
||||||
implementation("com.google.protobuf:protobuf-java:4.27.1")
|
|
||||||
|
|
||||||
implementation("org.locationtech.jts:jts-core:1.19.0")
|
implementation("org.locationtech.jts:jts-core:1.19.0")
|
||||||
|
|
||||||
@ -154,44 +147,3 @@ tasks.named<BootBuildImage>("bootBuildImage") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun parseDroolsImports(vararg droolsFilePaths: String): List<String> {
|
|
||||||
val imports = mutableListOf<String>()
|
|
||||||
val importPattern = Regex("^import\\s+(com\\.iqser\\.red\\.service\\.redaction\\.v1\\.[\\w.]+);")
|
|
||||||
val desiredPrefix = "com.iqser.red.service.redaction.v1"
|
|
||||||
|
|
||||||
droolsFilePaths.forEach { filePath ->
|
|
||||||
File(filePath).forEachLine { line ->
|
|
||||||
importPattern.find(line)?.let { matchResult ->
|
|
||||||
val importPath = matchResult.groupValues[1].trim()
|
|
||||||
if (importPath.startsWith(desiredPrefix)) {
|
|
||||||
val formattedPath = importPath.replace('.', '/')
|
|
||||||
imports.add("$formattedPath.java")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return imports
|
|
||||||
}
|
|
||||||
|
|
||||||
// Combine imports from both drools files
|
|
||||||
val droolsImports = parseDroolsImports(
|
|
||||||
"redaction-service-v1/redaction-service-server-v1/src/main/resources/drools/all_rules_documine.drl",
|
|
||||||
"redaction-service-v1/redaction-service-server-v1/src/main/resources/drools/base_component_rules.drl"
|
|
||||||
)
|
|
||||||
|
|
||||||
tasks.register("generateJavaDoc", Javadoc::class) {
|
|
||||||
|
|
||||||
dependsOn("compileJava")
|
|
||||||
dependsOn("delombok")
|
|
||||||
classpath = project.sourceSets["main"].runtimeClasspath
|
|
||||||
source = fileTree("${buildDir}/generated/sources/delombok/java/main") {
|
|
||||||
include(droolsImports)
|
|
||||||
}
|
|
||||||
destinationDir = file(project.findProperty("javadocDestinationDir")?.toString() ?: "")
|
|
||||||
|
|
||||||
options.memberLevel = JavadocMemberLevel.PUBLIC
|
|
||||||
(options as StandardJavadocDocletOptions).apply {
|
|
||||||
title = "API Documentation for Redaction Service ${project.version}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user