Skip to content

Commit

Permalink
Don't display deprecated URI in sameAs (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Oct 10, 2022
1 parent bd52135 commit 3872262
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/models/AuthorityResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ private List<LinkWithImage> getLinks() {
String dnbIcon = "https://portal.dnb.de/favicon.ico";
String dnbLabel = "Deutsche Nationalbibliothek (DNB)";
String dnbSubstring = "d-nb.info/gnd";
List<LinkWithImage> result = sameAs == null ? Collections.emptyList() : sameAs.stream().map(map -> {
JsonNode deprecatedUriNode = json.get("deprecatedUri");
List<LinkWithImage> result = sameAs == null ? Collections.emptyList()
: (deprecatedUriNode == null || deprecatedUriNode.size() == 0 ? sameAs.stream()
: nonDeprecated(deprecatedUriNode))
.map(map -> {
String url = map.get("id").toString();
Object icon = null;
Object label = null;
Expand All @@ -384,6 +388,11 @@ private List<LinkWithImage> getLinks() {
return result;
}

private Stream<Map<String, Object>> nonDeprecated(JsonNode deprecatedUriNode) {
return sameAs.stream()
.filter(sameAsObject -> !sameAsObject.get("id").equals(deprecatedUriNode.get(0).textValue()));
}

private String html(String field, ArrayList<LinkWithImage> links, int i) {
LinkWithImage link = links.get(i);
boolean hasImage = !link.image.isEmpty();
Expand Down

0 comments on commit 3872262

Please sign in to comment.