Skip to content

Commit

Permalink
Merge #1874 from branch '1843-suppressedHoldingLocations' of https://…
Browse files Browse the repository at this point in the history
  • Loading branch information
dr0i committed Aug 28, 2023
2 parents 481af58 + b225d2f commit 7221a02
Show file tree
Hide file tree
Showing 10 changed files with 7,358 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public void run() {
fixVariables.put("nwbib-spatial", "./../nwbib-spatial.tsv");
fixVariables.put("wd_itemLabelTypesCoordinates", "./../wd_itemLabelTypesCoordinates.tsv");
fixVariables.put("maps-institutions.tsv", "./maps/institutions.tsv");
fixVariables.put("sublibraryIsil.tsv", "./maps/generatedAlmaSublibraryCode2Isil.tsv");
fixVariables.put("sublibraryIsil", "./maps/generatedAlmaSublibraryCode2Isil.tsv");
fixVariables.put("suppressedLocations", "./maps/generatedAlmaSuppressedLocations.tsv");
fixVariables.put("picaCreatorId2Isil.tsv", "./maps/picaCreatorId2Isil.tsv");
fixVariables.put("nwbibWikidataLabelTypeCoords.tsv", "./maps/nwbibWikidataLabelTypeCoords.tsv");
fixVariables.put("classification.tsv", "./maps/classification.tsv");
Expand Down
126 changes: 67 additions & 59 deletions src/main/resources/alma/fix/item.fix
Original file line number Diff line number Diff line change
@@ -1,71 +1,36 @@
set_array("hasItem[]")
set_array("@ITM-H") # Helper element for creating Holding from HOL ("PhysikalischerTitel")
do list(path:"ITM ", "var": "$i")
add_field( "hasItem[].$append.test","")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","PhysicalObject")
if exists("$i.z") # Temporary call number subfield
copy_field("$i.z", "hasItem[].$last.callNumber")
elsif exists("$i.n") # Item call number subfield
copy_field("$i.n", "hasItem[].$last.callNumber")
else # $c = Call number subfield
copy_field("$i.c", "hasItem[].$last.callNumber")
end
copy_field("$i.H", "@ITM-H.$append")
copy_field("$i.b", "hasItem[].$last.serialNumber")
paste("hasItem[].$last.currentLocation", "$i.w", "~/", "$i.x")
copy_field("$i.w","$i.@sublibraryIsil")
lookup("$i.@sublibraryIsil", "hbzowner2sigel",delete:"true")
lookup("$i.@sublibraryIsil", "sigel2isilMap",delete:"true")
lookup("$i.@sublibraryIsil", "isilRedirect")
# following fix checks for sublibrary codes and if they map to provided sublocation Isil
unless exists("$i.@sublibraryIsil")
paste("$i.@sublibraryIsil","$i.M","~+","$i.w",join_char:"")
lookup("$i.@sublibraryIsil", "sublibraryIsil",delete:"true")
end
if exists("$i.@sublibraryIsil")
copy_field("$i.@sublibraryIsil", "hasItem[].$last.heldBy.id")
# 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")
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","#!")
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: "")
end

set_array("@HOL-M_POR-M") # Helper element for creating Holding from MBD ("NurTitel")
do list(path: "HOL ", "var": "$i")
copy_field("$i.M","@HOL-M_POR-M.$append")
unless in("$i.8", "@ITM-H") # Checks if there is no corresponding ITM-Field
paste("$i.supressedLocation", "$i.M", "~+", "$i.x",join_char:"")
lookup("$i.supressedLocation","suppressedLocations",delete:"true")
unless exists("$i.supressedLocation") # Test if location is suppressed with mapping provided by the libraries.
add_field( "hasItem[].$append.test","")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","PhysikalischerTitel")
do list(path:"H52??", "var": "$H52")
if in("$i.8", "$H52.8")
paste("hasItem[].$last.currentLocation", "$H52.b", "~/", "$H52.c")
copy_field("$H52.h", "hasItem[].$last.callNumber")
copy_field("$H52.b","$i.@sublibraryIsil")
lookup("$i.@sublibraryIsil", "hbzowner2sigel",delete:"true")
lookup("$i.@sublibraryIsil", "sigel2isilMap",delete:"true")
lookup("$i.@sublibraryIsil", "isilRedirect")
# following fix checks for sublibrary codes and if they map to provided sublocation Isil
unless exists("$i.@sublibraryIsil")
paste("$i.@sublibraryIsil","$i.M","~+","$H52.b",join_char:"")
lookup("$i.@sublibraryIsil", "sublibraryIsil",delete:"true")
end
end
set_array("hasItem[].$last.type[]", "Item","PhysicalObject")
if exists("$i.z") # Temporary call number subfield
copy_field("$i.z", "hasItem[].$last.callNumber")
elsif exists("$i.n") # Item call number subfield
copy_field("$i.n", "hasItem[].$last.callNumber")
else # $c = Call number subfield
copy_field("$i.c", "hasItem[].$last.callNumber")
end
copy_field("$i.H", "@ITM-H.$append")
copy_field("$i.b", "hasItem[].$last.serialNumber")
paste("hasItem[].$last.currentLocation", "$i.w", "~/", "$i.x")
copy_field("$i.w","$i.@sublibraryIsil")
lookup("$i.@sublibraryIsil", "hbzowner2sigel",delete:"true")
lookup("$i.@sublibraryIsil", "sigel2isilMap",delete:"true")
lookup("$i.@sublibraryIsil", "isilRedirect")
# following fix checks for sublibrary codes and if they map to provided sublocation Isil
unless exists("$i.@sublibraryIsil")
paste("$i.@sublibraryIsil","$i.M","~+","$i.w",join_char:"")
lookup("$i.@sublibraryIsil", "sublibraryIsil",delete:"true")
end
if exists("$i.@sublibraryIsil")
copy_field("$i.@sublibraryIsil", "hasItem[].$last.heldBy.id")
# 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")
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")
end
Expand All @@ -74,7 +39,50 @@ do list(path: "HOL ", "var": "$i")
append("hasItem[].$last.heldBy.id","#!")
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: "")
paste("hasItem[].$last.id", "~http://lobid.org/items/","almaMmsId", "~:", "hasItem[].$last.heldBy.isil","~:", "$i.a","~#!", join_char: "")
end
end

set_array("@HOL-M_POR-M") # Helper element for creating Holding from MBD ("NurTitel")
do list(path: "HOL ", "var": "$i")
copy_field("$i.M","@HOL-M_POR-M.$append")
unless in("$i.8", "@ITM-H") # Checks if there is no corresponding ITM-Field
do list(path:"H52??", "var": "$H52")
if in("$i.8", "$H52.8")
paste("$H52.supressedLocation", "$i.M", "~+", "$H52.c",join_char:"")
lookup("$H52.supressedLocation","suppressedLocations",delete:"true")
unless exists("$H52.supressedLocation") # Test if location is suppressed with mapping provided by the libraries.
add_field( "hasItem[].$append.test","")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","PhysikalischerTitel")
paste("hasItem[].$last.currentLocation", "$H52.b", "~/", "$H52.c")
copy_field("$H52.h", "hasItem[].$last.callNumber")
copy_field("$H52.b","$i.@sublibraryIsil")
lookup("$i.@sublibraryIsil", "hbzowner2sigel",delete:"true")
lookup("$i.@sublibraryIsil", "sigel2isilMap",delete:"true")
lookup("$i.@sublibraryIsil", "isilRedirect")
# following fix checks for sublibrary codes and if they map to provided sublocation Isil
unless exists("$i.@sublibraryIsil")
paste("$i.@sublibraryIsil","$i.M","~+","$H52.b",join_char:"")
lookup("$i.@sublibraryIsil", "sublibraryIsil",delete:"true")
end
if exists("$i.@sublibraryIsil")
copy_field("$i.@sublibraryIsil", "hasItem[].$last.heldBy.id")
# 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")
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","#!")
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: "")
end
end
end
end
end

Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/alma/fix/maps.fix
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
put_filemap("$[maps-institutions.tsv]","alma-iz-code-to-isil", sep_char:"\t",key_column:"2",value_column:"4",expected_columns:"-1")
put_filemap("$[maps-institutions.tsv]","alma-institution-code-to-isil", sep_char:"\t",key_column:"3",value_column:"4",expected_columns:"-1")

put_filemap("$[sublibraryIsil.tsv]","sublibraryIsil", sep_char:"\t")
put_filemap("$[sublibraryIsil]","sublibraryIsil", sep_char:"\t")
put_filemap("$[suppressedLocations]","suppressedLocations", sep_char:"\t")

# lobid Organisations id -> label
put_filemap("$[lobidOrganisationsMapping.tsv]","lobidOrgLabels", sep_char:"\t",key_column:"0",value_column:"3",expected_columns:"-1")
Expand Down
Loading

0 comments on commit 7221a02

Please sign in to comment.