Skip to content

Commit

Permalink
Merge #1906 from branch '1888-opacLink' of https://github.com/hbz/lob…
Browse files Browse the repository at this point in the history
  • Loading branch information
dr0i committed Sep 29, 2023
2 parents d0af2cf + 7c6fb57 commit 03720ef
Show file tree
Hide file tree
Showing 128 changed files with 2,141 additions and 1,046 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ public void run() {
fixVariables.put("nwbib.ttl", "../../../../../../vocabs/nwbib/nwbib.ttl");
fixVariables.put("nwbib-spatial.ttl", "../../../../../../vocabs/nwbib/nwbib-spatial.ttl");
fixVariables.put("hbzId2zdbId.tsv", "./maps/hbzId2zdbId.tsv.gz");
fixVariables.put("isil2opac_hbzId.tsv", "../../../../../../lookup-tables/data/opacLinks/isil2opac_hbzId.tsv");
fixVariables.put("isil2opac_isbn.tsv", "../../../../../../lookup-tables/data/opacLinks/isil2opac_isbn.tsv");
fixVariables.put("isil2opac_issn.tsv", "../../../../../../lookup-tables/data/opacLinks/isil2opac_issn.tsv");
fixVariables.put("isil2opac_zdbId.tsv", "../../../../../../lookup-tables/data/opacLinks/isil2opac_zdbId.tsv");
fixVariables.put("isil2opac_almaMmsId.tsv", "../../../../../../lookup-tables/data/opacLinks/isil2opac_almaMmsId.tsv");


XmlElementSplitter xmlElementSplitter = new XmlElementSplitter();
xmlElementSplitter.setElementName("record");
Expand Down
68 changes: 37 additions & 31 deletions src/main/resources/alma/fix/item.fix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ do list(path:"ITM ", "var": "$i")
copy_field("$i.b", "hasItem[].$last.serialNumber")
copy_field("$i.w","hasItem[].$last.currentLibrary")
copy_field("$i.x","hasItem[].$last.currentLocation")
copy_field("$i.a", "$i.@iz")
replace_all("$i.@iz",".*(\\d{4})$","$1")
lookup("$i.@iz", "alma-institution-code-to-isil")
copy_field("$i.w","$i.@sublibraryIsil")
lookup("$i.@sublibraryIsil", "hbzowner2sigel",delete:"true")
lookup("$i.@sublibraryIsil", "sigel2isilMap",delete:"true")
Expand All @@ -27,16 +30,16 @@ do list(path:"ITM ", "var": "$i")
lookup("$i.@sublibraryIsil", "sublibraryIsil",delete:"true")
end
if exists("$i.@sublibraryIsil")
copy_field("$i.@sublibraryIsil", "hasItem[].$last.heldBy.id")
copy_field("$i.@sublibraryIsil","hasItem[].$last.heldBy.isil")
# if no mapping for a sublocation code is provided or no sublocation code exists ($i.w) the main library ISIL is used.
else
copy_field("$i.a", "hasItem[].$last.heldBy.id")
replace_all("hasItem[].$last.heldBy.id",".*(\\d{4})$","$1")
lookup("hasItem[].$last.heldBy.id", "alma-institution-code-to-isil")
copy_field("$i.@iz","hasItem[].$last.heldBy.isil")
end
copy_field("hasItem[].$last.heldBy.id","hasItem[].$last.heldBy.isil")
prepend("hasItem[].$last.heldBy.id", "http://lobid.org/organisations/")
append("hasItem[].$last.heldBy.id","#!")
call_macro("opacLink", field:"@sublibraryIsil")
unless exists("hasItem[].$last.seeAlso[].1")
call_macro("opacLink", field:"@iz")
end
paste("hasItem[].$last.heldBy.id", "~http://lobid.org/organisations/", "hasItem[].$last.heldBy.isil", "~#!", join_char:"")
copy_field("hasItem[].$last.heldBy.id", "hasItem[].$last.heldBy.label")
# item id is constructed "http://lobid.org/items/[almaMmsId of the record]:[isil of the Owner]:[almaMmsId of the holding]#!"
paste("hasItem[].$last.id", "~http://lobid.org/items/","almaMmsId", "~:", "hasItem[].$last.heldBy.isil","~:", "$i.a","~#!", join_char: "")
Expand All @@ -58,6 +61,9 @@ do list(path: "HOL ", "var": "$i")
copy_field("$H52.b","hasItem[].$last.currentLibrary")
copy_field("$H52.c","hasItem[].$last.currentLocation")
copy_field("$H52.h", "hasItem[].$last.callNumber")
copy_field("$i.8", "$i.@iz")
replace_all("$i.@iz",".*(\\d{4})$","$1")
lookup("$i.@iz", "alma-institution-code-to-isil")
copy_field("$H52.b","$i.@sublibraryIsil")
lookup("$i.@sublibraryIsil", "hbzowner2sigel",delete:"true")
lookup("$i.@sublibraryIsil", "sigel2isilMap",delete:"true")
Expand All @@ -67,16 +73,16 @@ do list(path: "HOL ", "var": "$i")
lookup("$i.@sublibraryIsil", "sublibraryIsil",delete:"true")
end
if exists("$i.@sublibraryIsil")
copy_field("$i.@sublibraryIsil", "hasItem[].$last.heldBy.id")
copy_field("$i.@sublibraryIsil", "hasItem[].$last.heldBy.isil")
# if no mapping for a sublocation code is provided or no sublocation code exists ($i.w) the main library ISIL is used.
else
copy_field("$i.8", "hasItem[].$last.heldBy.id")
replace_all("hasItem[].$last.heldBy.id",".*(\\d{4})$","$1")
lookup("hasItem[].$last.heldBy.id", "alma-institution-code-to-isil")
copy_field("$i.@iz", "hasItem[].$last.heldBy.isil")
end
call_macro("opacLink", field:"@sublibraryIsil")
unless exists("hasItem[].$last.seeAlso[].1")
call_macro("opacLink", field:"@iz")
end
copy_field("hasItem[].$last.heldBy.id","hasItem[].$last.heldBy.isil")
prepend("hasItem[].$last.heldBy.id", "http://lobid.org/organisations/")
append("hasItem[].$last.heldBy.id","#!")
paste("hasItem[].$last.heldBy.id", "~http://lobid.org/organisations/", "hasItem[].$last.heldBy.isil", "~#!", join_char:"")
copy_field("hasItem[].$last.heldBy.id", "hasItem[].$last.heldBy.label")
# item id is constructed "http://lobid.org/items/[almaMmsId of the record]:[isil of the Owner]:[almaMmsId of the holding]#!"
paste("hasItem[].$last.id", "~http://lobid.org/items/","almaMmsId", "~:", "hasItem[].$last.heldBy.isil","~:","$i.8","~#!", join_char: "")
Expand All @@ -99,12 +105,12 @@ do list(path:"POR ", "var": "$i")
copy_field("$i.d", "$i.@sublocation")
replace_all("$i.@sublocation","https://hbz-network.userservices.exlibrisgroup.com/view/uresolver/49HBZ_NETWORK","")
paste("hasItem[].$last.sublocation", "~https://hbz-network.userservices.exlibrisgroup.com/view/uresolver/","$i.M","$i.@sublocation", join_char: "")
copy_field("$i.a", "hasItem[].$last.heldBy.id")
replace_all("hasItem[].$last.heldBy.id",".*(\\d{4})$","$1")
lookup("hasItem[].$last.heldBy.id", "alma-institution-code-to-isil")
copy_field("hasItem[].$last.heldBy.id","hasItem[].$last.heldBy.isil")
prepend("hasItem[].$last.heldBy.id", "http://lobid.org/organisations/")
append("hasItem[].$last.heldBy.id","#!")
copy_field("$i.a", "$i.@iz")
replace_all("$i.@iz",".*(\\d{4})$","$1")
lookup("$i.@iz", "alma-institution-code-to-isil")
call_macro("opacLink", field:"@iz")
copy_field("$i.@iz","hasItem[].$last.heldBy.isil")
paste("hasItem[].$last.heldBy.id", "~http://lobid.org/organisations/", "hasItem[].$last.heldBy.isil", "~#!", join_char:"")
copy_field("hasItem[].$last.heldBy.id", "hasItem[].$last.heldBy.label")
# item id is constructed "http://lobid.org/items/[almaMmsId of the record]:[isil of the Owner]:[almaMmsId of the holding]#!"
paste("hasItem[].$last.id", "~http://lobid.org/items/","almaMmsId", "~:", "hasItem[].$last.heldBy.isil","~:", "$i.a","~#!", join_char: "")
Expand All @@ -121,11 +127,11 @@ do list(path:"POR ", "var": "$i")
add_field("hasItem[].$last.label", "Electronic Portfolio")
paste("hasItem[].$last.electronicLocator", "~https://eu04.alma.exlibrisgroup.com/view/uresolver/","$j","$i.@electronicLocator", join_char: "")
paste("hasItem[].$last.sublocation", "~https://hbz-network.userservices.exlibrisgroup.com/view/uresolver/","$j","$i.@sublocation", join_char: "")
copy_field("$j", "hasItem[].$last.heldBy.id")
lookup("hasItem[].$last.heldBy.id", "alma-iz-code-to-isil")
copy_field("hasItem[].$last.heldBy.id","hasItem[].$last.heldBy.isil")
prepend("hasItem[].$last.heldBy.id", "http://lobid.org/organisations/")
append("hasItem[].$last.heldBy.id","#!")
copy_field("$j", "$i.@iz")
lookup("$i.@iz", "alma-iz-code-to-isil")
call_macro("opacLink", field:"@iz")
copy_field("$i.@iz","hasItem[].$last.heldBy.isil")
paste("hasItem[].$last.heldBy.id", "~http://lobid.org/organisations/", "hasItem[].$last.heldBy.isil", "~#!", join_char:"")
copy_field("hasItem[].$last.heldBy.id", "hasItem[].$last.heldBy.label")
# item id is constructed "http://lobid.org/items/[almaMmsId of the record]:[isil of the Owner]:[almaMmsId of the holding]#!"
paste("hasItem[].$last.id", "~http://lobid.org/items/","almaMmsId", "~:", "hasItem[].$last.heldBy.isil","~:", "$i.a","~#!", join_char: "")
Expand All @@ -139,12 +145,12 @@ do list(path: "MBD ", "var": "$i")
add_field( "hasItem[].$append.test","")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","NurTitel")
copy_field("$i.i", "hasItem[].$last.heldBy.id")
replace_all("hasItem[].$last.heldBy.id",".*(\\d{4})$","$1")
lookup("hasItem[].$last.heldBy.id", "alma-institution-code-to-isil")
copy_field("hasItem[].$last.heldBy.id","hasItem[].$last.heldBy.isil")
prepend("hasItem[].$last.heldBy.id", "http://lobid.org/organisations/")
append("hasItem[].$last.heldBy.id","#!")
copy_field("$i.i", "$i.@iz")
replace_all("$i.@iz",".*(\\d{4})$","$1")
lookup("$i.@iz", "alma-institution-code-to-isil")
call_macro("opacLink", field:"@iz")
copy_field("$i.@iz","hasItem[].$last.heldBy.isil")
paste("hasItem[].$last.heldBy.id", "~http://lobid.org/organisations/", "hasItem[].$last.heldBy.isil", "~#!", join_char:"")
copy_field("hasItem[].$last.heldBy.id", "hasItem[].$last.heldBy.label")
# item id is constructed "http://lobid.org/items/[almaMmsId of the record]:[isil of the Owner]:[almaMmsId of the holding]#!"
paste("hasItem[].$last.id", "~http://lobid.org/items/","almaMmsId", "~:", "hasItem[].$last.heldBy.isil","~:", "$i.i", "~#!", join_char: "")
Expand Down
39 changes: 39 additions & 0 deletions src/main/resources/alma/fix/macros.fix
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,45 @@ do put_macro("provenanceLinks")
append("$[field]", "#!")
end

# opacLink

do put_macro("opacLink")
if exists("zdbId")
copy_field("$i.$[field]", "$i.@opacLinkZdbId")
lookup("$i.@opacLinkZdbId","isil2opac_zdbId", delete:"true")
split_field("$i.@opacLinkZdbId","\\{zdbid\\}")
elsif exists("hbzId")
copy_field("$i.$[field]", "$i.@opacLinkHbzId")
lookup("$i.@opacLinkHbzId","isil2opac_hbzId", delete:"true")
split_field("$i.@opacLinkHbzId","\\{hbzid\\}")
end
copy_field("$i.$[field]", "$i.@opacAlmaMmsId")
lookup("$i.@opacAlmaMmsId","isil2opac_almaMmsId", delete:"true")
split_field("$i.@opacAlmaMmsId","\\{almaMmsId\\}")
if exists("issn[].1")
copy_field("$i.$[field]", "$i.@opacLinkIssn")
lookup("$i.@opacLinkIssn","isil2opac_issn", delete:"true")
split_field("$i.@opacLinkIssn","\\{issn\\}")
end
if exists("isbn[].1")
copy_field("$i.$[field]", "$i.@opacLinkIsbn")
lookup("$i.@opacLinkIsbn","isil2opac_isbn", delete:"true")
split_field("$i.@opacLinkZdbId","\\{isbn\\}")
end
set_array("hasItem[].$last.seeAlso[]")
if exists("[email protected]")
paste("hasItem[].$last.seeAlso[].$append","[email protected]","zdbId","[email protected]",join_char:"")
elsif exists("[email protected]")
paste("hasItem[].$last.seeAlso[].$append","[email protected]","hbzId","[email protected]",join_char:"")
elsif exists("[email protected]")
paste("hasItem[].$last.seeAlso[].$append","[email protected]","almaMmsId","[email protected]",join_char:"")
elsif exists("[email protected]")
paste("hasItem[].$last.seeAlso[].$append","[email protected]","isbn[].1","[email protected]",join_char:"")
elsif exists("[email protected]")
paste("hasItem[].$last.seeAlso[].$append","[email protected]","issn[].1","[email protected]",join_char:"")
end
end

# for Schlagwortfolgen

do put_macro("schlagwortfolge")
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/alma/fix/maps.fix
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ put_filemap("$[almaMmsId2rpbId]","almaMmsId2rpbId", sep_char:"\t",key_column:"0"
# map zdbId to old hbzId(HT Nummer) based on the last aleph transformation
put_filemap("$[hbzId2zdbId.tsv]","zdbId2oldHbzId", sep_char:"\t",key_column:"1",value_column:"0",expected_columns:"-1")

# opac links
put_filemap("$[isil2opac_hbzId.tsv]","isil2opac_hbzId", sep_char:"\t")
put_filemap("$[isil2opac_isbn.tsv]","isil2opac_isbn", sep_char:"\t")
put_filemap("$[isil2opac_issn.tsv]","isil2opac_issn", sep_char:"\t")
put_filemap("$[isil2opac_zdbId.tsv]","isil2opac_zdbId", sep_char:"\t")
put_filemap("$[isil2opac_almaMmsId.tsv]","isil2opac_almaMmsId", sep_char:"\t")


put_map("rswk-indicator",
"p": "Person",
"b": "CorporateBody",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ public void setup() {
fixVariables.put("nwbib.ttl", "src/test/resources/alma/maps/nwbib.ttl");
fixVariables.put("nwbib-spatial.ttl", "src/test/resources/alma/maps/nwbib-spatial.ttl");
fixVariables.put("hbzId2zdbId.tsv", "src/main/resources/alma/maps/hbzId2zdbId.tsv.gz");
fixVariables.put("isil2opac_hbzId.tsv", "src/test/resources/alma/maps/isil2opac_hbzId.tsv");
fixVariables.put("isil2opac_isbn.tsv", "src/test/resources/alma/maps/isil2opac_isbn.tsv");
fixVariables.put("isil2opac_issn.tsv", "src/test/resources/alma/maps/isil2opac_issn.tsv");
fixVariables.put("isil2opac_zdbId.tsv", "src/test/resources/alma/maps/isil2opac_zdbId.tsv");
fixVariables.put("isil2opac_almaMmsId.tsv", "src/test/resources/alma/maps/isil2opac_almaMmsId.tsv");
}

/**
Expand Down
Loading

0 comments on commit 03720ef

Please sign in to comment.