RED-9139: move document to its own module, add TableOfContents and TableOfContentsItem

This commit is contained in:
Kilian Schuettler 2024-11-11 16:23:43 +01:00
parent 5432635037
commit b52d3928ef
2 changed files with 18 additions and 0 deletions

View File

@ -7,6 +7,8 @@ description = "redaction-service-document"
val persistenceServiceVersion = "2.612.0-RED10072.1" val persistenceServiceVersion = "2.612.0-RED10072.1"
val layoutParserVersion = "newNode" val layoutParserVersion = "newNode"
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}")
implementation("com.google.protobuf:protobuf-java-util:4.28.3") implementation("com.google.protobuf:protobuf-java-util:4.28.3")

View File

@ -296,6 +296,22 @@ public class DocumentTree {
} }
public Optional<Entry> findEntryById(List<Integer> 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<Entry> mainEntries() { public Stream<Entry> mainEntries() {
return root.children.stream(); return root.children.stream();