Skip to content

Commit

Permalink
Handle ZDB- prefixed lobid URLs when linking in details (#614)
Browse files Browse the repository at this point in the history
- Remove `ZDB-` prefix when attempting to search by zdbId
- Show subordinate resources linking via `ZDB-` prefixed URLs

See also hbz/lobid-resources#1723
  • Loading branch information
fsteeg committed May 10, 2023
1 parent 0e6773d commit 7aafd1c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion app/controllers/nwbib/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public class Application extends Controller {
/** The number of seconds in one day. */
public static final int ONE_DAY = 24 * ONE_HOUR;

/** The prefix for zdbId-based lobid URLs. */
public static final String ZDB_PREFIX = "ZDB-";

/**
* @param map The scope for the NRW map ("kreise" or "gemeinden")
* @return The NWBib index page.
Expand Down Expand Up @@ -282,7 +285,7 @@ public static Promise<Result> show(final String id) {
} else {
Logger.warn("No pagination session data for {}", id);
}
String cleanId = id.replace("#!", "");
String cleanId = id.replace("#!", "").replace(ZDB_PREFIX, "");
String q = String.format("id:\"%s\" OR hbzId:%s OR almaMmsId:%s OR zdbId:%s",
Lobid.longId(cleanId), cleanId, cleanId, cleanId);
return search(q, "", "", "", "", "", "", "", "", "", 0, 1, "", "", "", true,
Expand Down
16 changes: 10 additions & 6 deletions app/views/tags/result_doc.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@import views.TableRow
@import controllers.nwbib.Lobid
@import controllers.nwbib.Application.CONFIG
@import controllers.nwbib.Application.ZDB_PREFIX

@labelled(label: String, key: String) = {
@if((doc\key).asOpt[Seq[JsValue]].isDefined) {
Expand Down Expand Up @@ -221,8 +222,13 @@
}
}

@lobidUrl(hbzId: String) = @{
"http://lobid.org/resources/" + hbzId + "#!"
@lobidUrl(format: String, idField: String) = @{
String.format("http://lobid.org/resources/" + format, (doc \ idField).asOpt[String].getOrElse(""))
}

@subordinateSearchFor(id: String) = {
@subordinate("isPartOf.hasSuperordinate.id", id, "Bände", ("zugehöriger Band", "zugehörige Bände"))
@subordinate("containedIn.id", id, "Enthält", ("Beitrag", "Beiträge"))
}

@table(){
Expand Down Expand Up @@ -250,10 +256,8 @@
@result_field("In", "containedIn", doc, TableRow.LINKS)

@part_of("isPartOf", "hasSuperordinate")
@defining(lobidUrl((doc \ "hbzId").asOpt[String].getOrElse(""))){ id =>
@subordinate("isPartOf.hasSuperordinate.id", id, "Bände", ("zugehöriger Band", "zugehörige Bände"))
@subordinate("containedIn.id", id, "Enthält", ("Beitrag", "Beiträge"))
}
@subordinateSearchFor(lobidUrl("%s#!", "hbzId"))
@subordinateSearchFor(lobidUrl(ZDB_PREFIX+"%s#!", "zdbId"))
@parallelausgabe()
@raumsystematik("https://nwbib.de/spatial")
@sachsystematik("https://nwbib.de/subjects")
Expand Down

0 comments on commit 7aafd1c

Please sign in to comment.