Skip to content

Commit

Permalink
Merge branch '336-MARCrelatorsArtistKomposition' into hbz-lobid-064-a…
Browse files Browse the repository at this point in the history
…ddNatureOfContent
  • Loading branch information
ChristophEwertowski committed Mar 27, 2017
2 parents 61641c1 + 6ee87fd commit 4bc5723
Show file tree
Hide file tree
Showing 30 changed files with 2,846 additions and 105 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ src/test/resources/input/nt/
src/test/resources/test.tar.bz2
src/test/resources/xml/
stats.*.csv
*.swp
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<version>2.19.1</version>
<configuration>
<test>*Test</test>
<environmentVariables>
<generateTestData>${generateTestData}</generateTestData>
</environmentVariables>
<test>UnitTests</test>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public final class GetRdaDocsInMabXml {
public static void main(String... args) {
if (args.length != 1) {
System.err.println("Usage: GetRdaDocsInMabXml <input path>");
System.exit(-1);
return;
}
String inputPath = args[0];
final FileOpener opener = new FileOpener();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void main(String... args) {
if (args.length != 6) {
System.err.println("Usage: MabXml2lobidJsonEs"
+ String.format(usage, " ", " ", " ", " ", " ", " "));
System.exit(-1);
return;
}
String jsonLdContext =
System.getProperty("jsonLdContext", LOBID_RESOURCES_JSONLD_CONTEXT);
Expand Down
1 change: 0 additions & 1 deletion web/app/controllers/resources/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public static Promise<Result> index() {
/**
* @return The API documentation page
*/
@Cached(key = "api", duration = ONE_DAY)
public static Promise<Result> api() {
return Promise.promise(() -> ok(api.render()));
}
Expand Down
34 changes: 29 additions & 5 deletions web/app/controllers/resources/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -74,14 +75,21 @@ public class Index {
public static Client elasticsearchClient = null;

/**
* Fields used when building query strings vis
* Fields used when building query strings with
* {@link #buildQueryString(String, String...)}
*/
public static final String[] FIELDS =
public static final String[] QUERY_FIELDS =
new String[] { "contribution.agent.label", "title",
"subject.id|subject.label", "isbn|issn", "publication.publishedBy",
"publication.startDate", "medium.id", "type", "collectedBy.id" };

/**
* Fields in the index data that should not be included in the response data.
* See https://github.com/hbz/lobid-resources/issues/197
*/
public static final List<String> HIDE_FIELDS =
Arrays.asList("contributorOrder", "subjectOrder", "subjectChain");

/**
* The values supported for the `aggregations` query parameter.
*/
Expand All @@ -91,15 +99,15 @@ public class Index {

/**
* @param q The current query string
* @param values The values corresponding to {@link #FIELDS}
* @param values The values corresponding to {@link #QUERY_FIELDS}
* @return A query string created from q, expanded for values
*/
public String buildQueryString(String q, String... values) {
String fullQuery = q.isEmpty() ? "*" : "(" + q + ")";
for (int i = 0; i < values.length; i++) {
String fieldValue = values[i];
String fieldName = fieldValue.contains("http")
? FIELDS[i].replace(".label", ".id") : FIELDS[i];
? QUERY_FIELDS[i].replace(".label", ".id") : QUERY_FIELDS[i];
if (fieldName.toLowerCase().endsWith("date")
&& fieldValue.matches("(\\d{1,4}|\\*)-(\\d{1,4}|\\*)")) {
String[] fromTo = fieldValue.split("-");
Expand Down Expand Up @@ -254,7 +262,23 @@ public Index getResource(String id) {
* @return The index result for the query (the hits) or GET (single result)
*/
public JsonNode getResult() {
return result;
return result == null ? null : withoutHiddenFields(result);
}

private static JsonNode withoutHiddenFields(JsonNode json) {
return json.isObject() ? filteredObject(json) : filteredArray(json);
}

private static JsonNode filteredArray(JsonNode json) {
List<JsonNode> result = new ArrayList<>();
json.elements().forEachRemaining(node -> result.add(filteredObject(node)));
return Json.toJson(result);
}

private static JsonNode filteredObject(JsonNode node) {
Map<String, Object> map = Json.fromJson(node, Map.class);
HIDE_FIELDS.forEach(fieldToHide -> map.remove(fieldToHide));
return Json.toJson(map);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion web/app/views/advanced.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
@import play.api.libs.json.Json
@import play.api.libs.json.JsValue

@main("lobid-resources - Erweiterte Suche") {
@main("", "lobid-resources - Erweiterte Suche") {
@tags.search_advanced("Suchen", agent="_", name="_", subject="_")
}
2 changes: 1 addition & 1 deletion web/app/views/api.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h5 id='@(label.toLowerCase)'><a href='@resources.routes.Application.show(hbzId,
<pre><code>@(Json.prettyPrint(Json.parse(new controllers.resources.Index().getResource(hbzId).getResult().toString)))</code></pre>
}

@main("lobid-resources - API") {
@main("", "lobid-resources - API") {
<h2 id='basics'>@Messages.get("api.basics.header") <small><a href='#basics'><span class='glyphicon glyphicon-link'></span></a></small></h2>
<dl>
@desc("HTTP GET", resources.routes.Application.show("HT018472857", format="json"))
Expand Down
2 changes: 1 addition & 1 deletion web/app/views/dataset.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@import helper._
@import controllers.resources.Lobid

@main("Dataset: lobid-resources") {
@main("", "Dataset: lobid-resources") {
<h3>Datenbeschreibung<small><a title="Beschreibung als JSON-LD anzeigen" href='@resources.routes.Application.dataset("json")'><img class='json-ld-icon' src='@routes.Assets.at("images/json-ld.png")'></a></small></h3>
<table class="table table-striped">
<tr><th width="20%"/><th width="80%"/></tr>
Expand Down
11 changes: 6 additions & 5 deletions web/app/views/details.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
@import play.cache.Cache

@if(docJson.isEmpty){
@main("lobid-resources - Detailansicht") {
@main("", "lobid-resources - Detailansicht") {
@if(flash.get("error")!=null){
<div class="alert alert-danger">@flash.get("error")</div>
<div id="search-results" class="alert alert-danger">@flash.get("error")</div>
} else {
<div class="alert alert-info text-center">Ein Titel mit der ID @q konnte nicht gefunden werden.</div>
<div id="search-results" class="alert alert-info text-center">Ein Titel mit der ID @q konnte nicht gefunden werden.</div>
}
}
} else {
@defining(Json.parse(docJson)) { doc =>
@main(if( (doc\\"title").isEmpty) "lobid-resources - Vollanzeige" else (doc\\"title")(0).asOpt[String].getOrElse(q)) {
<div class="row">
@main("", if( (doc\\"title").isEmpty) "lobid-resources - Vollanzeige" else (doc\\"title")(0).asOpt[String].getOrElse(q)) {
<h1>@((doc\\"title")(0).asOpt[String].getOrElse(q))</h1>
<div class="row" id="search-results">
@defining(Lobid.items(doc.toString)) { items =>
@defining(!(doc\\"isPartOf").isEmpty && doc.toString.contains("http://purl.org/ontology/bibo/Article")){superordination =>
<div class="col-md-@if(items.isEmpty && !doc.toString.contains("fulltextOnline") && !superordination){12} else {8}">
Expand Down
12 changes: 7 additions & 5 deletions web/app/views/details_item.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@import play.api.libs.json._

@if(docJson.isEmpty){
@main("lobid-resources - Bestandsdetails") {
@main("", "lobid-resources - Bestandsdetails") {
@if(flash.get("error")!=null){
<div class="alert alert-danger">@flash.get("error")</div>
} else {
Expand All @@ -18,18 +18,20 @@
}
} else {
@defining(Json.parse(docJson)) { doc =>
@main("lobid-resources - Bestandsdetails") {
<div class="row">
@main("", "lobid-resources - Bestandsdetails") {
@for(
itemOf <- (doc \ "itemOf").asOpt[JsValue];
itemOfs = itemOf.asOpt[Seq[JsValue]].getOrElse(Seq(itemOf));
resourceId <- (itemOfs(0) \ "id").asOpt[String];
itemId <- (doc \ "id").asOpt[String];
items = Lobid.items("{\"hasItem\":[{\"id\":\"" + itemId + "\"}]}")) {
items = Lobid.items("{\"hasItem\":[{\"id\":\"" + itemId + "\"}]}");
resourceLabel = Lobid.resourceLabel(resourceId)) {
<h1>@resourceLabel</h1>
<div class="row" id="search-results">
<div class="col-md-12" id="holdings">
<dl>
<dt>
Exemplar von <i><a href="@resourceId">@Lobid.resourceLabel(resourceId)</a></i> in:
Exemplar von <i><a href="@resourceId">@resourceLabel</a></i> in:
<small style='float:right'>
<a title="JSON-LD-Indexdaten anzeigen" href='@resources.routes.Application.item(id, "json")'><span class="glyphicon glyphicon-cog"></span></a>
</small>
Expand Down
7 changes: 5 additions & 2 deletions web/app/views/index.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
@import play.api.libs.json.JsValue
@import controllers.resources.Lobid

@main("lobid-resources") {
@tags.search_form("")
@main("", "lobid-resources") {
<div class="page-header">
<img class="media-object nrw-logo pull-right" src="@controllers.routes.Assets.at("images/hbz.png")" alt="hbz">
<h1>lobid-resources <small>&mdash; der hbz-Verbundkatalog als Linked Open Data</small></h1>
</div>
<div class="row">
<div class="col-md-12 intro">
@Html(json.get("description").get("de").asText())
Expand Down
48 changes: 22 additions & 26 deletions web/app/views/main.scala.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@* Copyright 2014 Fabian Steeg, hbz. Licensed under the GPLv2 *@

@(title: String)(content: Html)
@(q: String, title: String)(content: Html)

@import controllers.resources.Lobid

Expand All @@ -12,6 +12,7 @@
<link rel="stylesheet" media="all" href="@controllers.routes.Assets.at("stylesheets/bootstrap.min.css")">
<link rel="stylesheet" media="all" href="@controllers.routes.Assets.at("stylesheets/octicons.css")">
<link rel="stylesheet" media="all" href="@controllers.routes.Assets.at("stylesheets/jquery-ui.min.css")">
<link rel="stylesheet" media="all" href='@controllers.routes.Assets.at("stylesheets/font-awesome.min.css")'>
<link rel="stylesheet" media="all" href="@controllers.routes.Assets.at("stylesheets/resources.css")">
<link rel="shortcut icon" type="image/png" href="@controllers.routes.Assets.at("images/favicon.png")">
<script src="@controllers.routes.Assets.at("javascripts/jquery-1.10.2.min.js")"></script>
Expand All @@ -25,18 +26,22 @@
<div class="container">
<p/>
<div class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="container-fluid" id="header">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#resources-nav">
<span class="sr-only">Navigation ein/ausblenden</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="@resources.routes.Application.index()"><span class="glyphicon glyphicon-link"></span> lobid-resources</a>
<a class="navbar-brand" href="/">
<span><img id="butterfly" src='@controllers.routes.Assets.at("images/butterfly.png")' height="50px" /></span> lobid</a>
</div>
<div class="navbar-collapse collapse" id="resources-nav">
<ul class="nav navbar-nav">
<li @if(request.uri.toString() == resources.routes.Application.index().toString()){ class="active" }>
<a href="@resources.routes.Application.index()">resources</a>
</li>
<li @if(title=="lobid-resources - Erweiterte Suche"){class="active"}>
<a href="@resources.routes.Application.advanced()">Erweiterte Suche</a>
</li>
Expand All @@ -47,40 +52,31 @@
<ul class="nav navbar-nav navbar-right">
<li @if(title=="lobid-resources - Merkliste"){class="active"}><a href="@resources.routes.Application.showStars()">Merkliste</a></li>
<li class="divider"></li>
<li @if(title=="lobid-resources: Kontakt"){class="active"} class="dropdown">
<li @if(title.contains("Dataset")){class="active"} class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" title="Info"><span class="glyphicon glyphicon-info-sign"></span><b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href='@resources.routes.Application.dataset("")'>Datenbeschreibung</a></li>
<li class="divider"></li>
<li><a href="mailto:semweb@@hbz-nrw.de?subject=Feedback%20zu%20lobid-resources,%20aktuelle%20URL%20@controllers.resources.Application.currentUri()">Feedback</a></li>
<li class="divider"></li>
<li class="dropdown-header">Technischer Kontakt</li>
<li><a href="https://www.hbz-nrw.de/produkte/linked-open-data">hbz NRW</a></li>
<li class="divider"></li>
<li class="dropdown-header">Rechtlicher Kontakt</li>
<li><a href="http://www.hbz-nrw.de/impressum/">Impressum</a></li>
<li><a href="mailto:semweb@@hbz-nrw.de?subject=Feedback%20zu%20lobid-resources,%20aktuelle%20URL%20@controllers.resources.Application.currentUri()">Feedback zur aktuellen Seite</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
</div>
<div class="page-header">
<img class="media-object nrw-logo pull-right" src="@controllers.routes.Assets.at("images/hbz.png")" alt="hbz">
<h1>lobid-resources <small>&mdash; der hbz-Verbundkatalog als Linked Open Data</small></h1>
</div>
@if(request.uri.toString() != resources.routes.Application.advanced().toString()){@tags.search_form(q)}
@content
<div class="panel panel-default resources-footer">
<div class="panel panel-default footer">
<div class="panel-body">
<small>
@defining(new controllers.resources.Index().totalHits("*")){ hits =>
<img class="media-object pull-left nrw-wappen" src="@controllers.routes.Assets.at("images/wappen.png")" alt="NRW-Wappen">
<img class="media-object pull-right butterfly" src="@controllers.routes.Assets.at("images/butterfly.png")" alt="Lobid-Butterfly">
Der hbz-Verbundkatalog bietet @if(hits>0){aktuell @hits}else{fast 20 Millionen} Literaturnachweise.
Er stellt die Grundlage für viele weitere Produkte und Dienstleistungen dar und ist eingebunden in diverse
Endnutzerportale sowie in die Online-Fernleihe. Seine Daten stehen gemeinfrei unter <a href="http://creativecommons.org/publicdomain/zero/1.0/">CC0</a> zur Verfügung.
}
</small>
<span class="pull-left">
<img src='@controllers.routes.Assets.at("images/wappen.png")' alt="NRW-Wappen"/> &nbsp;
lobid-resources | ein LOD-Dienst des <a href='https://www.hbz-nrw.de/produkte/linked-open-data'>hbz — Hochschulbibliothekszentrum des Landes NRW</a>
</span>
<span class="pull-right">
<a href="http://www.hbz-nrw.de/impressum">Impressum</a> |
<a href="http://twitter.com/lobidorg"><i class="fa fa-twitter" aria-hidden="true"></i> Twitter</a>&nbsp;
<a href="http://github.com/hbz/lobid-resources"><i class="fa fa-github" aria-hidden="true"></i> GitHub</a>&nbsp;
<a href="http://blog.lobid.org"><i class="fa fa-pencil" aria-hidden="true"></i> Blog</a>
</span>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions web/app/views/query.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@
if(q.contains("multiVolumeWork")) {select(("Band","Bände"))} else if (q.contains("series")) {select(("Serienband","Serienbände"))} else if (q.contains("containedIn")) {select(("Beitrag","Beiträge"))} else {""}
}

@main("lobid-resources - Ergebnisliste") {
@main(q, "lobid-resources - Ergebnisliste") {
@if(Seq(name, id, publisher).exists(!_.isEmpty)){ @* advanced search, not shown in facets *@
@tags.search_advanced("Suche aktualisieren", q, agent, name, subject, id, publisher, issued, sortParam)
<script>$("#search-simple").hide()</script>
} else {
@tags.search_form(q)
}
@defining(Json.parse(result).asOpt[Seq[JsValue]].getOrElse(Seq()).zipWithIndex) { hits =>
<div class="row">
<div class="row" id="search-results">
<div class="col-md-@if(allHits > 0){9}else{12}">
@if(hits.size>0){
<div class="row hide-in-print" >
Expand Down
6 changes: 3 additions & 3 deletions web/app/views/stars.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
}
}

@main("lobid-resources - Merkliste") {
@main("", "lobid-resources - Merkliste") {
<div id="stars-all">
@if(ids.isEmpty){
<div class="alert alert-info text-center">
Keine gemerkten Titel. Sie können Titel in der Trefferliste oder der Einzeltrefferanzeige durch Klicken des Sterns hinzufügen.
</div>
} else {
<p>
<span class="glyphicon glyphicon-star-empty"></span>
<b>Merkliste: @ids.size Einträge</b>
<span class="hide-in-print"> |
Expand All @@ -39,7 +39,6 @@
<span class="glyphicon glyphicon-remove"></span> Merkliste löschen
</a></span>
</span>
</p>
@if(f=="details"){
@entries
} else {
Expand All @@ -55,6 +54,7 @@
</table>
}
}
</div>
@if(flash.get("error")!=null){
<div class="alert alert-danger">@flash.get("error")</div>
}
Expand Down
5 changes: 3 additions & 2 deletions web/app/views/tags/search_form.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
@(q: String)

@helper.form(action = controllers.resources.routes.Application.query(q), 'id -> "resources-form") {
<div class="input-group">
<div class="input-group" id="search-simple">
<input type="text" name="q" id="resourcesQuery" value="@q" class="form-control" autocomplete="off"
title='Boolesche Operatoren: AND, OR, AND NOT; Phrasensuche mit ""; Trunkierung mit *'/>
title='Boolesche Operatoren: AND, OR, AND NOT; Phrasensuche mit ""; Trunkierung mit *'
placeholder='Suchen in lobid-resources'/>
<span class="input-group-btn"><button class="btn btn-default" type="submit">
<span class="glyphicon glyphicon-search"></span></button></span>
</div>
Expand Down
Binary file added web/public/fonts/FontAwesome.otf
Binary file not shown.
Binary file added web/public/fonts/fontawesome-webfont.eot
Binary file not shown.
Loading

0 comments on commit 4bc5723

Please sign in to comment.