From b52d3928ef4ca54a11e133598cf2b4fd52aab00b Mon Sep 17 00:00:00 2001 From: Kilian Schuettler Date: Mon, 11 Nov 2024 16:23:43 +0100 Subject: [PATCH] RED-9139: move document to its own module, add TableOfContents and TableOfContentsItem --- redaction-service-v1/document/build.gradle.kts | 2 ++ .../v1/server/model/document/DocumentTree.java | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/redaction-service-v1/document/build.gradle.kts b/redaction-service-v1/document/build.gradle.kts index e72b1e89..1dd36a37 100644 --- a/redaction-service-v1/document/build.gradle.kts +++ b/redaction-service-v1/document/build.gradle.kts @@ -7,6 +7,8 @@ description = "redaction-service-document" val persistenceServiceVersion = "2.612.0-RED10072.1" val layoutParserVersion = "newNode" +group = "com.knecon.fforesight" + dependencies { implementation("com.iqser.red.service:persistence-service-internal-api-v1:${persistenceServiceVersion}") implementation("com.google.protobuf:protobuf-java-util:4.28.3") diff --git a/redaction-service-v1/document/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/DocumentTree.java b/redaction-service-v1/document/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/DocumentTree.java index c19fd30d..5c7ba341 100644 --- a/redaction-service-v1/document/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/DocumentTree.java +++ b/redaction-service-v1/document/src/main/java/com/iqser/red/service/redaction/v1/server/model/document/DocumentTree.java @@ -296,6 +296,22 @@ public class DocumentTree { } + public Optional findEntryById(List treeId) { + + if (treeId.isEmpty()) { + return Optional.of(root); + } + Entry entry = root; + for (int id : treeId) { + if (id < 0 || id >= entry.children.size()) { + return Optional.empty(); + } + entry = entry.children.get(id); + } + return Optional.of(entry); + } + + public Stream mainEntries() { return root.children.stream();