From e6e196ea3092ece2a1422cc0ad9580f3b2ecd431 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Thu, 19 Dec 2024 11:00:31 +0100 Subject: [PATCH] Fix `isPartOf` links, always prefer given `label` (RPB-226) --- app/views/TableRow.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/TableRow.java b/app/views/TableRow.java index 5d88254..3c88ced 100644 --- a/app/views/TableRow.java +++ b/app/views/TableRow.java @@ -107,16 +107,18 @@ public String process(JsonNode doc, String property, String param, private String label(JsonNode doc, String value, List properties) { List results = new ArrayList<>(); List resultValues = labelsFor(doc, value, properties); + JsonNode labelNode = doc.get(properties.get(0)).iterator().next().get("label"); for (int i = 0; i < resultValues.size(); i++) { String currentValue = resultValues.get(i); String[] refAndLabel = refAndLabel(properties.get(i), currentValue, Optional.empty()); + String label = labelNode != null ? labelNode.textValue() : refAndLabel[1]; String result = properties.get(i).equals("numbering") || value.equals("--") ? currentValue : String.format( "%s", - refAndLabel[0], refAndLabel[1]); + refAndLabel[0], label); results.add(result.replace("Band", "").trim()); } return results.stream().collect(Collectors.joining(", Band ")); @@ -129,8 +131,8 @@ private List labelsFor(JsonNode doc, String value, JsonNode node = doc.get(keys.get(0)).iterator().next(); JsonNode id = node.get("id"); JsonNode label = node.get("label"); - result.add(label != null ? label.textValue() - : id != null ? id.textValue() : "--"); + result.add(id != null ? id.textValue() + : label != null ? label.textValue() : "--"); JsonNode val = doc.get(keys.get(1)); if (val != null) result.add(val.textValue());