From 52dc57d9463d7905aa162860f80e43a4648c0842 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Fri, 27 Dec 2024 12:22:25 +0100 Subject: [PATCH] Support skos:altLabel and skos:example in list filter (#657) --- app/controllers/nwbib/Classification.java | 9 +++++++++ app/views/tags/browse_list.scala.html | 4 +++- test/tests/InternalIntegrationTest.java | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/controllers/nwbib/Classification.java b/app/controllers/nwbib/Classification.java index c2c3ab9..2bf0684 100644 --- a/app/controllers/nwbib/Classification.java +++ b/app/controllers/nwbib/Classification.java @@ -174,6 +174,8 @@ private SearchResponse classificationData() { private enum Property { LABEL("http://www.w3.org/2004/02/skos/core#prefLabel"), // + ALT_LABEL("http://www.w3.org/2004/02/skos/core#altLabel"), // + EXAMPLE("http://www.w3.org/2004/02/skos/core#example"), // BROADER("http://www.w3.org/2004/02/skos/core#broader"), // NOTATION("http://www.w3.org/2004/02/skos/core#notation"), // NARROW_MATCH("http://www.w3.org/2004/02/skos/core#narrowMatch"), // @@ -457,6 +459,8 @@ private static void collectLabelAndValue(SearchHit hit, JsonNode json, (style == Label.PLAIN || notation.isEmpty() ? "" : "" + notation + "" + " ") + label.findValue("@value").asText()) // + .put("altLabel", findValues(json, Property.ALT_LABEL)) // + .put("example", findValues(json, Property.EXAMPLE)) // .put("hits", Lobid.getTotalHitsNwbibClassification(id)) // .put("notation", notation) // .put("focus", focus(json)) // @@ -465,6 +469,11 @@ private static void collectLabelAndValue(SearchHit hit, JsonNode json, } } + private static List findValues(JsonNode json, Property p) { + return json.has(p.value) ? json.get(p.value).findValuesAsText("@value") + : Arrays.asList(); + } + private static List matches(JsonNode json) { List result = new ArrayList<>(); addMatches(json, Property.NARROW_MATCH, result); diff --git a/app/views/tags/browse_list.scala.html b/app/views/tags/browse_list.scala.html index 1cde8c0..8bf5d99 100644 --- a/app/views/tags/browse_list.scala.html +++ b/app/views/tags/browse_list.scala.html @@ -67,6 +67,8 @@ @for(json <- classes.getOrElse(Seq()); entryLabel = label(json); + altLabel = (json\"altLabel").asOpt[Seq[String]].getOrElse(Seq()).mkString("; "); + example = (json\"example").asOpt[Seq[String]].getOrElse(Seq()).mkString("; "); normalized = entryLabel.replaceAll("ß", "ss") + entryLabel.replaceAll("ss", "ß"); value = (json\"value").as[String]; hits = (json\"hits").asOpt[scala.Long].getOrElse(0L); @@ -107,7 +109,7 @@