diff --git a/app/controllers/HomeController.java b/app/controllers/HomeController.java index 4bea084..592e309 100644 --- a/app/controllers/HomeController.java +++ b/app/controllers/HomeController.java @@ -121,7 +121,11 @@ public Result redirectSlash(String path) { } public Result index() { - QueryStringQueryBuilder query = index.queryStringQuery("depiction:*"); + String queryString = "depiction:*"; + for (String dont : CONFIG.getStringList("dontShowOnMainPage")) { + queryString += " AND NOT gndIdentifier:" + dont; + } + QueryStringQueryBuilder query = index.queryStringQuery(queryString); FunctionScoreQueryBuilder functionScoreQuery = QueryBuilders.functionScoreQuery(query, ScoreFunctionBuilders.randomFunction(System.currentTimeMillis())); SearchRequestBuilder requestBuilder = index.client().prepareSearch(config("index.prod.name")) @@ -208,8 +212,9 @@ public Result authority(String id, String format) { return ok(views.html.details.render(entity)); } default: { - return rdfResultFor(Json.parse(jsonLd), responseFormat.queryParamString).orElseGet(() -> { - return result(jsonLd, Accept.Format.JSON_LD.types[0]); + JsonNode jsonLdObject = Json.parse(jsonLd); + return rdfResultFor(jsonLdObject, responseFormat.queryParamString).orElseGet(() -> { + return result(prettyJsonString(jsonLdObject), Accept.Format.JSON_LD.types[0]); }); } } diff --git a/app/controllers/Reconcile.java b/app/controllers/Reconcile.java index 46e000d..54571b9 100644 --- a/app/controllers/Reconcile.java +++ b/app/controllers/Reconcile.java @@ -485,6 +485,10 @@ private SearchResponse executeQuery(Entry entry, String queryS .field("preferredName", 4f)// .field("variantName", 2f)// .field("temporaryName")// + .field("temporaryNameOfTheConferenceOrEvent")// + .field("temporaryNameOfTheCorporateBody")// + .field("temporaryNameOfThePlaceOrGeographicName")// + .field("abbreviatedName")// .field("abbreviatedNameForTheConferenceOrEvent")// .field("abbreviatedNameForThePlaceOrGeographicName")// .field("abbreviatedNameForTheWork")// diff --git a/app/models/AuthorityResource.java b/app/models/AuthorityResource.java index b585011..4f7d584 100644 --- a/app/models/AuthorityResource.java +++ b/app/models/AuthorityResource.java @@ -365,7 +365,11 @@ private List getLinks() { String dnbIcon = "https://portal.dnb.de/favicon.ico"; String dnbLabel = "Deutsche Nationalbibliothek (DNB)"; String dnbSubstring = "d-nb.info/gnd"; - List result = sameAs == null ? Collections.emptyList() : sameAs.stream().map(map -> { + JsonNode deprecatedUriNode = json.get("deprecatedUri"); + List 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; @@ -384,6 +388,11 @@ private List getLinks() { return result; } + private Stream> nonDeprecated(JsonNode deprecatedUriNode) { + return sameAs.stream() + .filter(sameAsObject -> !sameAsObject.get("id").equals(deprecatedUriNode.get(0).textValue())); + } + private String html(String field, ArrayList links, int i) { LinkWithImage link = links.get(i); boolean hasImage = !link.image.isEmpty(); diff --git a/conf/application.conf b/conf/application.conf index 321d369..4e505ae 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -3,6 +3,8 @@ host : "https://lobid.org" +dontShowOnMainPage: ["1012979-0"] + play { http.secret.key="" filters.disabled+=play.filters.hosts.AllowedHostsFilter diff --git a/conf/context.jsonld b/conf/context.jsonld index 9f5c92a..9aa2863 100644 --- a/conf/context.jsonld +++ b/conf/context.jsonld @@ -996,6 +996,10 @@ "@type":"@id", "@container":"@set" }, + "abbreviatedName": { + "@id":"https://d-nb.info/standards/elementset/gnd#abbreviatedName", + "@container":"@set" + }, "abbreviatedNameForTheConferenceOrEvent": { "@id":"https://d-nb.info/standards/elementset/gnd#abbreviatedNameForTheConferenceOrEvent", "@container":"@set" diff --git a/test/controllers/JsonResponseTest.java b/test/controllers/JsonResponseTest.java index ac8dc2a..e6fc4ca 100644 --- a/test/controllers/JsonResponseTest.java +++ b/test/controllers/JsonResponseTest.java @@ -1,4 +1,4 @@ -/* Copyright 2018, hbz. Licensed under the Eclipse Public License 1.0 */ +/* Copyright 2018, 2022 hbz. Licensed under the Eclipse Public License 1.0 */ package controllers; @@ -15,7 +15,15 @@ import static play.test.Helpers.route; import static play.test.Helpers.running; +import java.util.Arrays; +import java.util.Collection; + import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +import com.fasterxml.jackson.databind.JsonNode; import modules.IndexTest; import play.Application; @@ -23,17 +31,33 @@ import play.mvc.Result; @SuppressWarnings("javadoc") +@RunWith(Parameterized.class) public class JsonResponseTest extends IndexTest { + @Parameters(name = "{0}") + public static Collection data() { + return Arrays.asList(new Object[][] { { "/gnd/search?format=json" }, { "/gnd/2136169-1" } }); + } + + private String path; + + public JsonResponseTest(String path) { + this.path = path; + } + @Test public void jsonRequestNoInternalUrl() { Application application = fakeApplication(); running(application, () -> { - Result result = route(application, fakeRequest(GET, "/gnd/search?format=json")); + Result result = route(application, fakeRequest(GET, path)); assertNotNull(result); assertThat(result.contentType().get(), is(equalTo("application/json"))); - assertNotNull(Json.parse(contentAsString(result))); - assertThat(contentAsString(result), not(containsString("localhost"))); + String content = contentAsString(result); + assertNotNull(content); + assertThat(content, not(containsString("localhost"))); + JsonNode json = Json.parse(content); + assertNotNull(json); + assertThat(content, equalTo(Json.prettyPrint(json))); }); } } \ No newline at end of file diff --git a/test/models/GndOntologyLabelTests.java b/test/models/GndOntologyLabelTests.java index 30b5b19..6315c0c 100644 --- a/test/models/GndOntologyLabelTests.java +++ b/test/models/GndOntologyLabelTests.java @@ -36,7 +36,8 @@ public static Collection data() { { "professionalRelationship", "Berufliche Beziehung" }, // { "broadMatch", "Oberbegriff" }, // { "exactMatch", "Entspricht" }, // - { "relatedMatch", "Verwandter Begriff" } }); + { "relatedMatch", "Verwandter Begriff" }, // + { "SubjectHeadingSensoStricto", "Schlagwort sensu stricto" } }); } private String id;