From a8ef908ae9b4b7d503a0bce1accaeed0e48f9f3a Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Tue, 6 Jun 2023 17:29:59 +0200 Subject: [PATCH] Skip nodes without id or label when creating connections (#345) --- app/models/AuthorityResource.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/AuthorityResource.java b/app/models/AuthorityResource.java index 4f7d584..062976b 100644 --- a/app/models/AuthorityResource.java +++ b/app/models/AuthorityResource.java @@ -193,7 +193,8 @@ private void addGroupingNodes(List> result) { private void addGndEntityNodes(List> result) { result.add(ImmutableMap.of("id", getId(), "label", wrapped(preferredName), "shape", "box")); - gndNodes().stream().flatMap(pair -> pair.getRight().stream()).distinct().forEach(node -> { + gndNodes().stream().flatMap(pair -> pair.getRight().stream()).distinct() + .filter(node -> node.get("id") != null && node.get("label") != null).forEach(node -> { String id = node.get("id").asText().substring(GND_PREFIX.length()); String label = wrapped(node.get("label").asText()); String title = "Details zu " + label + " öffnen"; @@ -206,7 +207,7 @@ private void addGroupedConnections(List> result) { String rel = pair.getLeft(); String label = wrapped(GndOntology.label(rel)); result.add(ImmutableMap.of("from", getId(), "to", rel)); - pair.getRight().forEach(node -> { + pair.getRight().stream().filter(node -> node.get("id") != null).forEach(node -> { String to = node.get("id").asText().substring(GND_PREFIX.length()); String title = String.format("Einträge mit %s '%s' suchen", label, GndOntology.label(GND_PREFIX + to)); String id = rel + "_" + to;