diff --git a/app/controllers/nwbib/Classification.java b/app/controllers/nwbib/Classification.java index fa47848..c2c3ab9 100644 --- a/app/controllers/nwbib/Classification.java +++ b/app/controllers/nwbib/Classification.java @@ -175,7 +175,9 @@ private SearchResponse classificationData() { private enum Property { LABEL("http://www.w3.org/2004/02/skos/core#prefLabel"), // BROADER("http://www.w3.org/2004/02/skos/core#broader"), // - NOTATION("http://www.w3.org/2004/02/skos/core#notation"); + NOTATION("http://www.w3.org/2004/02/skos/core#notation"), // + NARROW_MATCH("http://www.w3.org/2004/02/skos/core#narrowMatch"), // + EXACT_MATCH("http://www.w3.org/2004/02/skos/core#exactMatch"); String value; @@ -449,19 +451,35 @@ private static void collectLabelAndValue(SearchHit hit, JsonNode json, if (label != null) { String id = toNwbibNamespace(hit.getId()); String notation = notation(json); - ImmutableMap map = ImmutableMap.of(// - "value", id, // - "label", - (style == Label.PLAIN || notation.isEmpty() ? "" - : "" + notation + "" + " ") - + label.findValue("@value").asText(), // - "hits", Lobid.getTotalHitsNwbibClassification(id), // - "notation", notation, // - "focus", focus(json)); + ImmutableMap map = ImmutableMap. builder()// + .put("value", id) // + .put("label", + (style == Label.PLAIN || notation.isEmpty() ? "" + : "" + notation + "" + " ") + + label.findValue("@value").asText()) // + .put("hits", Lobid.getTotalHitsNwbibClassification(id)) // + .put("notation", notation) // + .put("focus", focus(json)) // + .put("matches", matches(json)).build(); result.add(Json.toJson(map)); } } + private static List matches(JsonNode json) { + List result = new ArrayList<>(); + addMatches(json, Property.NARROW_MATCH, result); + addMatches(json, Property.EXACT_MATCH, result); + return result; + } + + private static void addMatches(JsonNode json, Property p, + List result) { + JsonNode match = json.findValue(p.value); + if (match != null) { + match.forEach(m -> result.add(m.get("@id").textValue())); + } + } + static String toNwbibNamespace(String id) { return id // .replace("http://purl.org/lobid/nwbib-spatial#n", NWBIB_SPATIAL + "N") diff --git a/app/views/tags/browse_list.scala.html b/app/views/tags/browse_list.scala.html index c1ee9e0..5057ab8 100644 --- a/app/views/tags/browse_list.scala.html +++ b/app/views/tags/browse_list.scala.html @@ -70,6 +70,7 @@ normalized = entryLabel.replaceAll("ß", "ss") + entryLabel.replaceAll("ss", "ß"); value = (json\"value").as[String]; hits = (json\"hits").asOpt[scala.Long].getOrElse(0L); + matches = (json\"matches").asOpt[Seq[String]].getOrElse(Seq()); anchor = value.split("[/#]").last; textToCopy = (if(entryLabel.contains("span")){entryLabel.split(" ")(1)}else{entryLabel}) + "$$0" + value) {
  • @if(id=="root" && !placeholder.contains("Register") && t!="Wikidata" && t!="Zeitschriften") { @Html(entryLabel) } else { @@ -89,6 +90,29 @@ case _ => value }}">@hits) } + @if(!matches.isEmpty()) { + + + } @if(t!="Zeitschriften"){}
    @normalized
    } diff --git a/public/images/gnd.png b/public/images/gnd.png new file mode 100644 index 0000000..98d43b7 Binary files /dev/null and b/public/images/gnd.png differ diff --git a/public/images/wikidata.png b/public/images/wikidata.png new file mode 100644 index 0000000..9a59eaf Binary files /dev/null and b/public/images/wikidata.png differ