From 81d709c52d4f768e57653edd9011b95df824d9d1 Mon Sep 17 00:00:00 2001 From: Adrian Pohl Date: Wed, 5 Sep 2018 12:35:12 +0200 Subject: [PATCH 1/4] Add dataset description See https://github.com/hbz/lobid-gnd/issues/134 --- conf/dataset.jsonld | 92 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 conf/dataset.jsonld diff --git a/conf/dataset.jsonld b/conf/dataset.jsonld new file mode 100644 index 0000000..d8d443c --- /dev/null +++ b/conf/dataset.jsonld @@ -0,0 +1,92 @@ +{ + "@context":{ + "id":"@id", + "type":"@type", + "@vocab":"http://schema.org/", + "accrualPeriodicity":{ + "@id":"http://purl.org/dc/terms/accrualPeriodicity", + "@type":"@id" + }, + "license":"http://purl.org/dc/terms/license", + "label":{ + "@id":"http://www.w3.org/2000/01/rdf-schema#label", + "@container":"@language" + }, + "description":{ + "@container":"@language" + }, + "distribution": "http://www.w3.org/ns/dcat#distribution", + "Distribution":"http://www.w3.org/ns/dcat#Distribution", + "accessURL":"http://www.w3.org/ns/dcat#accessURL", + "mediaType":"http://www.w3.org/ns/dcat#mediaType" + }, + "id":"http://lobid.org/resources/dataset#!", + "type":"Dataset", + "name":"lobid-gnd", + "alternateName": "LOD-API für die Gemeinsame Normdatei (GND)", + "description":{ + "de":"

Die Gemeinsame Normdatei (GND) enthält über 15 Millionen Normdatensätze. Sie wird zur Katalogisierung von Literatur in Bibliotheken, sowie von Archiven, Museen, und verschiedenen Kontexten genutzt.

Die GND enthält normierte Einträge für Personen, Körperschaften, Kongresse, Geografika, Sachschlagwörter und Werktitel. Sie wird von der Deutschen Nationalbibliothek (DNB), den deutschsprachigen Bibliotheksverbünden, der Zeitschriftendatenbank (ZDB) und zahlreichen weiteren Institutionen kooperativ geführt. Die Daten sind unter CC0 lizenziert.

lobid-gnd bietet eine Rechercheoberfläche zum Durchsuchen der GND und eine Web-API auf Basis von JSON-LD zur Verwendung der Daten in verschiedenen Kontexten.

", + "en":"

The Integrated Authority File (GND) contains more than 15 Million authority records. It is used for cataloging in libraries as well as in archives, museums and other contexts.

The GND contains authority records for persons, corporate bodies, congresses, places, subject headings and works. It is maintained cooperatively by the German National Library (DNB), German-speaking library networks, the German Union Catalogue of Serials (ZDB) and many other institutions. The data is licensed under CC0.

lobid-gnd provides a search interface for exploring GND and a web API based on JSON-LD to enable use of the data in different contexts.

" + }, + "keywords":[ + "authority data", + "Germany", + "Austria", + "Switzerland" + ], + "datePublished":"2018-07-11", + "contactPoint":"http://lobid.org/contact", + "accrualPeriodicity":{ + "id":"http://purl.org/linked-data/sdmx/2009/code#freq-B", + "label":{ + "en":"Daily - business week", + "de":"Täglich (werktags)" + } + }, + "inLanguage":[ + "de" + ], + "publisher":{ + "id":"http://lobid.org/organisations/DE-605#!", + "label":{ + "de":"Hochschulbibliothekszentrum des Landes Nordrhein-Westfalen", + "en":"North Rhine-Westphalian Library Service" + }, + "alternateName":[ + "hbz" + ] + }, + "isBasedOn": { + "type": "Dataset", + "id": "http://d-nb.info/gnd/7749153-1", + "label":{ + "de":"Gemeinsame Normdatei (GND)", + "en":"Integrated Authority File (GND)" + }, + "description":{ + "de":"Genutzt werden die von der DNB bereitgestellten RDF-Datenabzüge der GND, siehe http://www.dnb.de/DE/Service/DigitaleDienste/LinkedData/linkeddata_node.html.", + "en":"lobid-gnd uses the RDF dumps of the GND as provided by DNB, see ." + }, + "license": "https://creativecommons.org/publicdomain/zero/1.0/" + }, + "distribution":[ + { + "id":"http://lobid.org/gnd/search", + "type":"Distribution", + "label": { + "de": "lobid-gnd-API", + "en": "lobid-gnd API" + }, + "description": { + "en": "

The API gives access to machine-readable data (JSON-LD via HTTP). For documentation see http://lobid.org/gnd/api.

", + "de": "

Die API bietet Zugriff auf strukturierte Daten (JSON-LD via HTTP). Die Dokumentation befindet sich unter http://lobid.org/gnd/api.

" + }, + "accessURL":"http://lobid.org/gnd/search", + "mediaType":[ + "application/json", + "application/ld+json" + ], + "license": "https://creativecommons.org/publicdomain/zero/1.0/" + } + ] +} \ No newline at end of file From 99cbf9f7b27ac6c19188e8b56a467329c07378ba Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Wed, 19 Sep 2018 13:28:48 +0200 Subject: [PATCH 2/4] Update dataset description Corresponding to https://github.com/hbz/lobid-resources/pull/915 See https://github.com/hbz/lobid-gnd/issues/134 --- conf/dataset.jsonld | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/conf/dataset.jsonld b/conf/dataset.jsonld index d8d443c..6fa2b4d 100644 --- a/conf/dataset.jsonld +++ b/conf/dataset.jsonld @@ -7,23 +7,27 @@ "@id":"http://purl.org/dc/terms/accrualPeriodicity", "@type":"@id" }, - "license":"http://purl.org/dc/terms/license", - "label":{ - "@id":"http://www.w3.org/2000/01/rdf-schema#label", + "description":{ "@container":"@language" }, - "description":{ + "name":{ "@container":"@language" }, - "distribution": "http://www.w3.org/ns/dcat#distribution", - "Distribution":"http://www.w3.org/ns/dcat#Distribution", - "accessURL":"http://www.w3.org/ns/dcat#accessURL", - "mediaType":"http://www.w3.org/ns/dcat#mediaType" + "alternateName": { + "@container": "@language" + }, + "Concept": "http://www.w3.org/2004/02/skos/core#Concept" }, "id":"http://lobid.org/resources/dataset#!", "type":"Dataset", - "name":"lobid-gnd", - "alternateName": "LOD-API für die Gemeinsame Normdatei (GND)", + "name":{ + "de":"lobid-gnd", + "en":"lobid-gnd" + }, + "alternateName": { + "de":"LOD-API für die Gemeinsame Normdatei (GND)", + "en":"LOD-API for the Integrated Authority File (GND)" + }, "description":{ "de":"

Die Gemeinsame Normdatei (GND) enthält über 15 Millionen Normdatensätze. Sie wird zur Katalogisierung von Literatur in Bibliotheken, sowie von Archiven, Museen, und verschiedenen Kontexten genutzt.

Die GND enthält normierte Einträge für Personen, Körperschaften, Kongresse, Geografika, Sachschlagwörter und Werktitel. Sie wird von der Deutschen Nationalbibliothek (DNB), den deutschsprachigen Bibliotheksverbünden, der Zeitschriftendatenbank (ZDB) und zahlreichen weiteren Institutionen kooperativ geführt. Die Daten sind unter CC0 lizenziert.

lobid-gnd bietet eine Rechercheoberfläche zum Durchsuchen der GND und eine Web-API auf Basis von JSON-LD zur Verwendung der Daten in verschiedenen Kontexten.

", "en":"

The Integrated Authority File (GND) contains more than 15 Million authority records. It is used for cataloging in libraries as well as in archives, museums and other contexts.

The GND contains authority records for persons, corporate bodies, congresses, places, subject headings and works. It is maintained cooperatively by the German National Library (DNB), German-speaking library networks, the German Union Catalogue of Serials (ZDB) and many other institutions. The data is licensed under CC0.

lobid-gnd provides a search interface for exploring GND and a web API based on JSON-LD to enable use of the data in different contexts.

" @@ -38,7 +42,8 @@ "contactPoint":"http://lobid.org/contact", "accrualPeriodicity":{ "id":"http://purl.org/linked-data/sdmx/2009/code#freq-B", - "label":{ + "type": "Concept", + "name":{ "en":"Daily - business week", "de":"Täglich (werktags)" } @@ -48,7 +53,8 @@ ], "publisher":{ "id":"http://lobid.org/organisations/DE-605#!", - "label":{ + "type": "Organization", + "name":{ "de":"Hochschulbibliothekszentrum des Landes Nordrhein-Westfalen", "en":"North Rhine-Westphalian Library Service" }, @@ -58,8 +64,8 @@ }, "isBasedOn": { "type": "Dataset", - "id": "http://d-nb.info/gnd/7749153-1", - "label":{ + "url": "http://d-nb.info/gnd/7749153-1", + "name":{ "de":"Gemeinsame Normdatei (GND)", "en":"Integrated Authority File (GND)" }, @@ -72,8 +78,8 @@ "distribution":[ { "id":"http://lobid.org/gnd/search", - "type":"Distribution", - "label": { + "type":"WebAPI", + "name": { "de": "lobid-gnd-API", "en": "lobid-gnd API" }, @@ -81,8 +87,9 @@ "en": "

The API gives access to machine-readable data (JSON-LD via HTTP). For documentation see http://lobid.org/gnd/api.

", "de": "

Die API bietet Zugriff auf strukturierte Daten (JSON-LD via HTTP). Die Dokumentation befindet sich unter http://lobid.org/gnd/api.

" }, - "accessURL":"http://lobid.org/gnd/search", - "mediaType":[ + "url":"http://lobid.org/gnd/search", + "documentation": "http://lobid.org/gnd/api", + "encodingFormat":[ "application/json", "application/ld+json" ], From 804fed9b3105867b88066b9eda68eb70425a4e13 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Wed, 19 Sep 2018 13:32:54 +0200 Subject: [PATCH 3/4] Add routes, controller, and view template for dataset description See https://github.com/hbz/lobid-gnd/issues/134 --- app/controllers/HomeController.java | 31 ++++++++++--- app/views/dataset.scala.html | 50 +++++++++++++++++++++ app/views/main.scala.html | 3 ++ conf/application.conf | 5 +++ conf/routes | 3 ++ public/stylesheets/main.css | 6 +++ test/controllers/AcceptIntegrationTest.java | 7 +++ 7 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 app/views/dataset.scala.html diff --git a/app/controllers/HomeController.java b/app/controllers/HomeController.java index c6a5846..6693769 100644 --- a/app/controllers/HomeController.java +++ b/app/controllers/HomeController.java @@ -245,15 +245,36 @@ private Result result(String content, String contentType) { public Result context() { response().setHeader("Access-Control-Allow-Origin", "*"); + return ok(readFile(config("context.file"))).as(config("context.content")); + } + + /** + * See https://www.w3.org/TR/dwbp/#metadata + * + * @param format + * The format ("jsonld" or "") + * + * @return JSON-LD dataset metadata + */ + public Result dataset(String format) { + response().setHeader("Access-Control-Allow-Origin", "*"); + Format responseFormat = Accept.formatFor(format, request().acceptedTypes()); + String content = readFile(config("dataset.file")); + return responseFormat.queryParamString.startsWith("json") ? // + ok(content).as(config("dataset.content")) : // + ok(views.html.dataset.render(Json.parse(content))); + } + + private String readFile(String name) { try { - File file = env.getFile(config("context.file")); + File file = env.getFile(name); Path path = Paths.get(file.getAbsolutePath()); - return ok(Files.readAllLines(path).stream().collect(Collectors.joining("\n"))) - .as(config("context.content")); + String content = Files.readAllLines(path).stream().collect(Collectors.joining("\n")); + return content; } catch (IOException e) { - e.printStackTrace(); + Logger.error("Couldn't get: " + name, e); + return null; } - return null; } public Result gnd(String id) { diff --git a/app/views/dataset.scala.html b/app/views/dataset.scala.html new file mode 100644 index 0000000..838b633 --- /dev/null +++ b/app/views/dataset.scala.html @@ -0,0 +1,50 @@ +@* Copyright 2014-2018 Fabian Steeg, hbz. Licensed under the GPLv2 *@ + +@(json: com.fasterxml.jackson.databind.JsonNode) + +@import helper._ + +@main("", "Dataset: lobid-gnd") { +

Datenbeschreibung

+ + + + + + + + + + + + @defining(json.get("publisher")) { pub => + + + + + } + + + + + +
Titel + @json.get("name").get("de").asText() — @json.get("alternateName").get("de").asText() +
Beschreibung@Html(json.get("description").get("de").asText())
Schlagwörter@json.get("keywords").toString().replaceAll("\",\"", ", ").replaceAll("[\"\\[\\]]", "")
Veröffentlicht von + @pub.get("name").get("de").asText() — @pub.get("alternateName").elements().next().asText() +
Basiert auf@json.get("isBasedOn").get("name").get("de").asText()
Veröffentlicht am@json.get("datePublished").asText()
Sprache@json.get("inLanguage").elements().next().asText()
Ergänzungsfrequenz@json.get("accrualPeriodicity").get("name").get("de").asText()
Kontakt@json.get("contactPoint").asText()
+

Datendistribution

+ @defining(json.get("distribution").elements().next()) { dist => + + + + + + + +
Titel@dist.get("name").get("de").asText()
Beschreibung@Html(dist.get("description").get("de").asText())
URL@dist.get("url").asText()
Lizenz@dist.get("license").asText()
Medientypen@dist.get("encodingFormat").toString().replaceAll("\",\"", ", ").replaceAll("[\"\\[\\]]", "")
+ } + +} diff --git a/app/views/main.scala.html b/app/views/main.scala.html index 398344b..1b09c85 100644 --- a/app/views/main.scala.html +++ b/app/views/main.scala.html @@ -59,6 +59,9 @@
  • Programmierschnittstelle (API)
  • +
  • + Datenbeschreibung +
  • Feedback zur aktuellen Seite
  • diff --git a/conf/application.conf b/conf/application.conf index ac5e8b5..d524c56 100644 --- a/conf/application.conf +++ b/conf/application.conf @@ -47,6 +47,11 @@ context { prod: "http://lobid.org/gnd/context.jsonld" } +dataset { + file: "conf/dataset.jsonld" + content: "application/ld+json; charset=utf-8" +} + topLevelTypes : [ AuthorityResource, CorporateBody, diff --git a/conf/routes b/conf/routes index bbaceec..5539800 100644 --- a/conf/routes +++ b/conf/routes @@ -16,6 +16,9 @@ GET /gnd/api controllers.HomeController.api GET /gnd/context.jsonld controllers.HomeController.context() +GET /gnd/dataset.jsonld controllers.HomeController.dataset(format="json") +GET /gnd/dataset controllers.HomeController.dataset(format?="") + GET /gnd/search controllers.HomeController.search(q ?= "", filter ?= "", from: Int ?= 0, size: Int ?= 10, format ?= null) GET /gnd/:id.:format controllers.HomeController.authorityDotFormat(id, format) diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index c97ba2f..8ffacb6 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -236,4 +236,10 @@ figcaption { max-width: 100%; max-height: 300px; float: right; +} + +.json-ld-icon { + margin-left: 1px; + float:right; + height: 1.4em } \ No newline at end of file diff --git a/test/controllers/AcceptIntegrationTest.java b/test/controllers/AcceptIntegrationTest.java index 02bb8e7..74d91b0 100644 --- a/test/controllers/AcceptIntegrationTest.java +++ b/test/controllers/AcceptIntegrationTest.java @@ -37,6 +37,13 @@ public class AcceptIntegrationTest extends IndexTest { public static Collection data() { // @formatter:off return Arrays.asList(new Object[][] { + // service meta data: context and dataset description + { fakeRequest(GET, "/gnd/context.jsonld"), /*->*/ "application/ld+json" }, + { fakeRequest(GET, "/gnd/dataset.jsonld"), /*->*/ "application/ld+json" }, + { fakeRequest(GET, "/gnd/dataset"), /*->*/ "application/ld+json" }, + { fakeRequest(GET, "/gnd/dataset").header("Accept", "text/html"), /*->*/ "text/html" }, + { fakeRequest(GET, "/gnd/dataset").header("Accept", "application/ld+json"), /*->*/ "application/ld+json" }, + { fakeRequest(GET, "/gnd/dataset").header("Accept", "application/json"), /*->*/ "application/ld+json" }, // search, default format: JSON { fakeRequest(GET, "/gnd/search?q=*"), /*->*/ "application/json" }, { fakeRequest(GET, "/gnd/search?q=*").header("Accept", "*/*"), /*->*/ "application/json" }, From 49b0210797c6dfc3300fed684cf614c7b73be606 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Wed, 19 Sep 2018 14:53:09 +0200 Subject: [PATCH 4/4] Use dataset description for index page, tweak content See https://github.com/hbz/lobid-gnd/issues/134 --- app/controllers/HomeController.java | 3 ++- app/views/dataset.scala.html | 5 +++-- app/views/index.scala.html | 6 ++---- conf/dataset.jsonld | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/HomeController.java b/app/controllers/HomeController.java index 6693769..7993dd7 100644 --- a/app/controllers/HomeController.java +++ b/app/controllers/HomeController.java @@ -126,7 +126,8 @@ public Result index() { .setQuery(functionScoreQuery).setFrom(0).setSize(1); SearchHit hit = requestBuilder.execute().actionGet().getHits().getAt(0); AuthorityResource entity = entityWithImage(hit.getSourceAsString()); - return ok(views.html.index.render(entity)); + JsonNode dataset = Json.parse(readFile(config("dataset.file"))); + return ok(views.html.index.render(entity, dataset)); } /** diff --git a/app/views/dataset.scala.html b/app/views/dataset.scala.html index 838b633..39c4bb3 100644 --- a/app/views/dataset.scala.html +++ b/app/views/dataset.scala.html @@ -5,7 +5,7 @@ @import helper._ @main("", "Dataset: lobid-gnd") { -

    Datenbeschreibung

    +

    Daten

    @@ -33,12 +33,13 @@

    Datenbeschreibung@json.get("contactPoint").asText()

    -

    Datendistribution

    +

    API

    @defining(json.get("distribution").elements().next()) { dist => + diff --git a/app/views/index.scala.html b/app/views/index.scala.html index 829f670..b07d272 100644 --- a/app/views/index.scala.html +++ b/app/views/index.scala.html @@ -1,6 +1,6 @@ @* Copyright 2017 Fabian Steeg, hbz. Licensed under the GPLv2 *@ -@(entity: AuthorityResource) +@(entity: AuthorityResource, dataset: com.fasterxml.jackson.databind.JsonNode) @import helper._ @@ -11,9 +11,7 @@

    lobid-gnd — Rechercheoberfläche & LOD-API für die GND
    -

    Die Gemeinsame Normdatei (GND) enthält über 15 Millionen Normdatensätze. Sie wird zur Katalogisierung von Literatur in Bibliotheken, sowie von Archiven, Museen, und verschiedenen Projekten genutzt.

    -

    Die GND enthält normierte Einträge für Personen, Körperschaften, Kongresse, Geografika, Sachschlagwörter und Werktitel. Sie wird von der Deutschen Nationalbibliothek (DNB), den deutschsprachigen Bibliotheksverbünden, der Zeitschriftendatenbank (ZDB) und zahlreichen weiteren Institutionen kooperativ geführt. Die Daten sind unter CC0 lizenziert.

    -

    lobid-gnd bietet eine Rechercheoberfläche zum Durchsuchen der GND und eine Web-API auf Basis von JSON-LD zur Verwendung der Daten in neuen Kontexten.

    + @Html(dataset.get("description").get("de").asText())
    diff --git a/conf/dataset.jsonld b/conf/dataset.jsonld index 6fa2b4d..33305d5 100644 --- a/conf/dataset.jsonld +++ b/conf/dataset.jsonld @@ -29,8 +29,8 @@ "en":"LOD-API for the Integrated Authority File (GND)" }, "description":{ - "de":"

    Die Gemeinsame Normdatei (GND) enthält über 15 Millionen Normdatensätze. Sie wird zur Katalogisierung von Literatur in Bibliotheken, sowie von Archiven, Museen, und verschiedenen Kontexten genutzt.

    Die GND enthält normierte Einträge für Personen, Körperschaften, Kongresse, Geografika, Sachschlagwörter und Werktitel. Sie wird von der Deutschen Nationalbibliothek (DNB), den deutschsprachigen Bibliotheksverbünden, der Zeitschriftendatenbank (ZDB) und zahlreichen weiteren Institutionen kooperativ geführt. Die Daten sind unter CC0 lizenziert.

    lobid-gnd bietet eine Rechercheoberfläche zum Durchsuchen der GND und eine Web-API auf Basis von JSON-LD zur Verwendung der Daten in verschiedenen Kontexten.

    ", - "en":"

    The Integrated Authority File (GND) contains more than 15 Million authority records. It is used for cataloging in libraries as well as in archives, museums and other contexts.

    The GND contains authority records for persons, corporate bodies, congresses, places, subject headings and works. It is maintained cooperatively by the German National Library (DNB), German-speaking library networks, the German Union Catalogue of Serials (ZDB) and many other institutions. The data is licensed under CC0.

    lobid-gnd provides a search interface for exploring GND and a web API based on JSON-LD to enable use of the data in different contexts.

    " + "de":"

    Die Gemeinsame Normdatei (GND) enthält über 15 Millionen Normdatensätze. Sie wird zur Katalogisierung von Literatur in Bibliotheken, sowie von Archiven, Museen, und Forschungsprojekten genutzt.

    Die GND enthält normierte Einträge für Personen, Körperschaften, Kongresse, Geografika, Sachschlagwörter und Werktitel. Sie wird von der Deutschen Nationalbibliothek (DNB), den deutschsprachigen Bibliotheksverbünden, der Zeitschriftendatenbank (ZDB) und zahlreichen weiteren Institutionen kooperativ geführt. Die Daten sind unter CC0 lizenziert.

    lobid-gnd bietet eine Rechercheoberfläche zum Durchsuchen der GND und eine Web-API auf Basis von JSON-LD zur Verwendung der Daten in verschiedenen Kontexten.

    ", + "en":"

    The Integrated Authority File (GND) contains more than 15 Million authority records. It is used for cataloging in libraries as well as in archives, museums and other contexts.

    The GND contains authority records for persons, corporate bodies, congresses, places, subject headings and works. It is maintained cooperatively by the German National Library (DNB), German-speaking library networks, the German Union Catalogue of Serials (ZDB) and many other institutions. The data is licensed under CC0.

    lobid-gnd provides a search interface for exploring GND and a web API based on JSON-LD to enable use of the data in different contexts.

    " }, "keywords":[ "authority data", @@ -84,8 +84,8 @@ "en": "lobid-gnd API" }, "description": { - "en": "

    The API gives access to machine-readable data (JSON-LD via HTTP). For documentation see http://lobid.org/gnd/api.

    ", - "de": "

    Die API bietet Zugriff auf strukturierte Daten (JSON-LD via HTTP). Die Dokumentation befindet sich unter http://lobid.org/gnd/api.

    " + "en": "

    The API gives access to machine-readable data (JSON-LD via HTTP).

    ", + "de": "

    Die API bietet Zugriff auf strukturierte Daten (JSON-LD via HTTP).

    " }, "url":"http://lobid.org/gnd/search", "documentation": "http://lobid.org/gnd/api",

    Titel@dist.get("name").get("de").asText()
    Beschreibung@Html(dist.get("description").get("de").asText())
    Dokumentation@Html(dist.get("documentation").asText())
    URL@dist.get("url").asText()
    Lizenz@dist.get("license").asText()
    Medientypen@dist.get("encodingFormat").toString().replaceAll("\",\"", ", ").replaceAll("[\"\\[\\]]", "")