Skip to content

Commit

Permalink
Merge branch 'rppd_rpb-153-gndIdentifier' of https://github.com/hbz/l…
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Apr 11, 2024
2 parents ed59e71 + cab10dd commit f8f0349
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
11 changes: 7 additions & 4 deletions app/controllers/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ public Result authority(String id, String format) {
if (responseFormat == null || responseFormat == Accept.Format.JSON_LINES
|| format != null && format.contains(":")) {
return unsupportedMediaType(views.html.error.render(id, String.format(
"Unsupported for single resource: format=%s, accept=%s", format, request().acceptedTypes())));
"Unsupported for single resource: format=%s, accept=%s", format,
request().acceptedTypes()), allHits()));
}
String jsonLd = getAuthorityResource(id);
if (jsonLd == null) {
Expand Down Expand Up @@ -372,7 +373,7 @@ public Result authority(String id, String format) {
}
} catch (Exception e) {
Logger.error("Could not create response", e);
return internalServerError(views.html.error.render(id, e.getMessage()));
return internalServerError(views.html.error.render(id, e.getMessage(), allHits()));
}
}

Expand Down Expand Up @@ -476,7 +477,9 @@ public Result search(String q, String name, String place, String subject, String
if (responseFormat == null || Stream.of(RdfFormat.values()).map(RdfFormat::getParam)
.anyMatch(f -> f.equals(responseFormat.queryParamString))) {
return unsupportedMediaType(views.html.error.render(q,
String.format("Unsupported for search: format=%s, accept=%s", format, request().acceptedTypes())));
String.format("Unsupported for search: format=%s, accept=%s", format,
request().acceptedTypes()),
allHits()));
}
String queryString = buildQueryString(q, name, place, subject, publication, date);
queryString = (queryString == null || queryString.isEmpty()) ? "*" : queryString;
Expand Down Expand Up @@ -507,7 +510,7 @@ public Result search(String q, String name, String place, String subject, String
} catch (Throwable t) {
String message = t.getMessage() + (t.getCause() != null ? ", cause: " + t.getCause().getMessage() : "");
Logger.error("Error: {}", message);
return internalServerError(views.html.error.render(q, "Error: " + message));
return internalServerError(views.html.error.render(q, "Error: " + message, allHits()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/models/AuthorityResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private <T> List<T> get(String field) {
}

public String getId() {
return id.substring(id.startsWith(GND_PREFIX) ? GND_PREFIX.length() : RPPD_PREFIX.length());
return id.replace(GND_PREFIX, "").replace(RPPD_PREFIX, "");
}

public String getFullId() {
Expand Down
4 changes: 2 additions & 2 deletions app/views/error.scala.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@* Copyright 2015-2018 Fabian Steeg, hbz. Licensed under the EPL 2.0 *@

@(q: String, message: String)
@(q: String, message: String, allHits: Long)

@main(q, "Error") {
@main(q, "Error", allHits) {
<div class="panel panel-danger footer">
<div class='panel-heading'>Fehler</div>
<div class='panel-body'>@message</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/search.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ <h5>@models.GndOntology.label("type")</h5>
</div>
<table class="table table-striped table-condensed">
<tr><th /><th /><th /><th /><th /></tr>
@for((doc,i) <- hits; gndId = (doc\"gndIdentifier").as[String]; id = if (gndId.contains("Keine")) (doc\"rppdId").as[String] else gndId) {
@for((doc,i) <- hits; gndId = (doc\"gndIdentifier").asOpt[String].getOrElse("Keine"); id = if (gndId.contains("Keine")) (doc\"rppdId").as[String] else gndId) {
@result_short(id,doc,i-1)
}
</table>
Expand Down

0 comments on commit f8f0349

Please sign in to comment.