Skip to content

Commit

Permalink
Use the add functions instead of set functions
Browse files Browse the repository at this point in the history
With the upcoming releases the behaviour of set_ will change so that no intermediate structure will be created. To prepare for this change we will use the add_ version of these functions. See the following issue for further info: https://github.com/metafacture/metafacture-fix/issues/309
  • Loading branch information
TobiasNx committed Jan 6, 2025
1 parent b2d03fa commit 64769d1
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 216 deletions.
6 changes: 3 additions & 3 deletions src/main/resources/alma/alma.fix
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ add_field("@context","http://lobid.org/resources/context.jsonld")

# Set empty elements to manipulate the order winthin the record.
add_field("id","")
set_array("type[]")
set_array("medium[]")
add_array("type[]")
add_array("medium[]")
add_field("title","")

do list(path:"880??","var":"$i")
Expand All @@ -38,7 +38,7 @@ do list(path:"880??","var":"$i")
replace_all("[email protected]","(\\d{3}-\\d{2})/(.*)","$2")
lookup("[email protected]","ISO15924-to-script")
end
set_array("alternateGraphicRepresentation[]")
add_array("alternateGraphicRepresentation[]")

include ("./fix/identifiers.fix")
include ("./fix/titleRelatedFields.fix")
Expand Down
30 changes: 15 additions & 15 deletions src/main/resources/alma/fix/contribution.fix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

# 245 - Title Statement (NR) - Subfield: $c (NR)
set_array("responsibilityStatement[]")
add_array("responsibilityStatement[]")
copy_field("245??.c", "responsibilityStatement[].$append")

set_array("contribution[]")
add_array("contribution[]")

# 100 and 700

Expand Down Expand Up @@ -31,7 +31,7 @@ do list(path:"100[01] ", "var":"$i")
end
end
do list(path: "$i.4", "var":"$j")
set_hash("contribution[].$append.agent")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
Expand All @@ -58,7 +58,7 @@ do list(path:"100[01] ", "var":"$i")
call_macro("gndPersonCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel","contribution[].$last.agent.label")
# type
set_array("contribution[].$last.agent.type[]","Person")
add_array("contribution[].$last.agent.type[]","Person")
# role
copy_field("$j","contribution[].$last.role.id")
# dateOfBirthAndDeath #will be split on a later stage
Expand All @@ -83,7 +83,7 @@ do list(path:"700[01] ", "var":"$i")
add_field("$i.4","ctb")
end
do list(path: "$i.4", "var":"$j")
set_hash("contribution[].$append.agent")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
Expand All @@ -110,7 +110,7 @@ do list(path:"700[01] ", "var":"$i")
call_macro("gndPersonCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel","contribution[].$last.agent.label")
# type
set_array("contribution[].$last.agent.type[]","Person")
add_array("contribution[].$last.agent.type[]","Person")
# role
copy_field("$j","contribution[].$last.role.id")
# dateOfBirthAndDeath #will be split on a later stage
Expand Down Expand Up @@ -145,7 +145,7 @@ do list(path:"110[012] ", "var":"$i")
end
end
do list(path: "$i.4", "var":"$j")
set_hash("contribution[].$append.agent")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
Expand All @@ -172,7 +172,7 @@ do list(path:"110[012] ", "var":"$i")
call_macro("gndOtherCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel", "contribution[].$last.agent.label")
# type
set_array("contribution[].$last.agent.type[]","CorporateBody")
add_array("contribution[].$last.agent.type[]","CorporateBody")
# role
copy_field("$j","contribution[].$last.role.id")
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
Expand All @@ -194,7 +194,7 @@ do list(path:"710[012] ", "var":"$i")
add_field("$i.4","ctb")
end
do list(path: "$i.4", "var":"$j")
set_hash("contribution[].$append.agent")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
Expand All @@ -221,7 +221,7 @@ do list(path:"710[012] ", "var":"$i")
call_macro("gndOtherCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel", "contribution[].$last.agent.label")
# type
set_array("contribution[].$last.agent.type[]","CorporateBody")
add_array("contribution[].$last.agent.type[]","CorporateBody")
# role
copy_field("$j","contribution[].$last.role.id")
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
Expand All @@ -242,7 +242,7 @@ do list(path:"111[012] |711[012] ", "var":"$i")
add_field("$i.4","oth")
end
do list(path: "$i.4", "var":"$j")
set_hash("contribution[].$append.agent")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
Expand All @@ -269,7 +269,7 @@ do list(path:"111[012] |711[012] ", "var":"$i")
call_macro("gndEventCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel", "contribution[].$last.agent.label")
# type
set_array("contribution[].$last.agent.type[]","ConferenceOrEvent")
add_array("contribution[].$last.agent.type[]","ConferenceOrEvent")
# role
copy_field("$j","contribution[].$last.role.id")
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
Expand All @@ -278,7 +278,7 @@ do list(path:"111[012] |711[012] ", "var":"$i")
end


set_array("contribution[].*.type[]", "Contribution")
add_array("contribution[].*.type[]", "Contribution")
replace_all("contribution[].*.agent.id","^\\(DE-588\\)(.*$)","https://d-nb.info/gnd/$1")
replace_all("contribution[].*.agent.gndIdentifier","^\\(DE-588\\)(.*$)","$1")
replace_all("contribution[].*.agent.label","(?<!\\p{Upper})\\.$|[,]$","")
Expand Down Expand Up @@ -340,7 +340,7 @@ do list (path: "contribution[]", "var": "$i")
end

# compare GND identifier (idn) with ALMA GND enrichment elements:
set_array("$i.agent.altLabel[]")
add_array("$i.agent.altLabel[]")
do list(path:"GPN??", "var": "$z")
if in ("$i.agent.@gndIdn", "$z.B") # Person labels have no character between $a (Name) and $b (Number).
call_macro("gndPersonCombinedLabel",field:"$z")
Expand All @@ -365,7 +365,7 @@ do list (path: "contribution[]", "var": "$i")
end

# orcid
set_array("$i.agent.sameAs[]")
add_array("$i.agent.sameAs[]")
do list(path:"GSI??", "var": "$z")
if in ("$i.agent.@gndIdn", "$z.B")
if any_equal("$z.2","orcid")
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/alma/fix/describedBy.fix
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ prepend("describedBy.id", "http://lobid.org/resources/")
copy_field("almaMmsId", "describedBy.label")
prepend("describedBy.label", "Webseite der hbz-Ressource ")

set_array("describedBy.type[]", "BibliographicDescription")
add_array("describedBy.type[]", "BibliographicDescription")


add_field("describedBy.inDataset.id","http://lobid.org/resources/dataset#!")

add_field("describedBy.inDataset.label","lobid-resources – Der hbz-Verbundkatalog als Linked Open Data")

set_array("describedBy.resultOf.type[]", "CreateAction")
add_array("describedBy.resultOf.type[]", "CreateAction")

add_field("@createTime","$[createEndTime]")
if all_match("@createTime","0")
Expand All @@ -24,7 +24,7 @@ end

add_field("describedBy.resultOf.instrument.id","https://github.com/hbz/lobid-resources")

set_array("describedBy.resultOf.instrument.type[]", "SoftwareApplication")
add_array("describedBy.resultOf.instrument.type[]", "SoftwareApplication")

add_field("describedBy.resultOf.instrument.label","Software lobid-resources")

Expand Down Expand Up @@ -62,7 +62,7 @@ replace_all("describedBy.resultOf.object.dateModified","^(\\d{4})(\\d{2})(\\d{2}
replace_all("describedBy.resultOf.object.dateCreated","^(\\d{4})$","$1-01-01")
replace_all("describedBy.resultOf.object.dateModified","^(\\d{4})$","$1-01-01")

set_array("describedBy.resultOf.object.type[]", "DataFeedItem")
add_array("describedBy.resultOf.object.type[]", "DataFeedItem")

copy_field("almaMmsId","describedBy.resultOf.object.label")
prepend("describedBy.resultOf.object.label","hbz-Ressource ")
Expand All @@ -72,7 +72,7 @@ add_field("describedBy.resultOf.object.inDataset.id", "https://datahub.io/datase

add_field("describedBy.resultOf.object.inDataset.label", "hbz_unioncatalog")

set_array("describedBy.license[]")
add_array("describedBy.license[]")
add_field("describedBy.license[].$append.id","http://creativecommons.org/publicdomain/zero/1.0" )
add_field("describedBy.license[].$last.label","Creative Commons-Lizenz CC0 1.0 Universal" )

Expand All @@ -95,7 +95,7 @@ do list(path: "040 ", "var":"$i")
end
end

set_array("describedBy.resultOf.object.modifiedBy[]")
add_array("describedBy.resultOf.object.modifiedBy[]")
do list(path:"$i.d", "var":"$j")
copy_field("$j", "describedBy.resultOf.object.modifiedBy[].$append.id")
end
Expand Down
18 changes: 9 additions & 9 deletions src/main/resources/alma/fix/identifiers.fix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ paste("id", "~http://lobid.org/resources/", "001", "~#!", join_char: "")
# 024 - Other Standard Identifier (R) Subfield: $a (NR) $2 (NR)
# urn

set_array("urn[]")
add_array("urn[]")

do list(path: "0247?", "var": "$i")
if any_equal("$i.2","urn")
Expand All @@ -17,7 +17,7 @@ end
# Sometimes urn are not set in 024 then we could pick up the missing from 856.
# 856 - Electronic Location and Access (R) - Subfield: $u (R) $3 (NR)
# 1. Indicator: 4 = HTTP
set_array("@urnLinks")
add_array("@urnLinks")

do list(path:"856??", "var":"$i")
if all_match("$i.u", "^http.*(urn=|\\.(org|de)/)urn:.+$") # This should ignore repository links like: https://sammlungen.ulb.uni-muenster.de/urn/urn:nbn:de:hbz:6-85659520092
Expand Down Expand Up @@ -50,8 +50,8 @@ end
# 020 - International Standard Book Number (R) - $a (NR)
# source data sometimes provides repeated subfield $a even if this is not valid marc

set_array("@isbn[]")
set_array("isbn[]")
add_array("@isbn[]")
add_array("isbn[]")

do list(path:"020 ", "var": "$i")
do list(path:"$i.a", "var": "$j")
Expand All @@ -74,23 +74,23 @@ uniq("isbn[]")


# 022 - International Standard Serial Number (R) - Subfield $a (NR)
set_array("issn[]")
add_array("issn[]")
do list(path:"022? ", "var":"$i")
copy_field("$i.a", "issn[].$append")
end
replace_all("issn[].*", "-","")
uniq("issn[]")

# 024 - Other Standard Identifier (R) - Subfield a (NR) 1. Indicator 2 = ISMN
set_array("ismn[]")
add_array("ismn[]")
do list(path:"0242?", "var":"$i")
copy_field("$i.a", "ismn[].$append")
end
replace_all("ismn[].*", "-","")


# 024 (R) Subfield a (NR) 1. Indicator 7 = to defined Identifier
set_array("doi[]")
add_array("doi[]")
do list(path:"0247?", "var":"$i")
if all_equal("$i.2","doi")
copy_field("$i.a", "doi[].$append")
Expand All @@ -109,7 +109,7 @@ replace_all("doi[].*", ".*doi.org.*(10\\.(\\d)+/(\\S)+).*", "$1")
uniq("doi[]")

# 035 - System Control Number (R) - Subfield: $a (NR)
set_array("oclcNumber[]")
add_array("oclcNumber[]")

do list(path:"035 ", "var":"$i")
if all_match("$i.a", "\\(OCoLC\\)(.*)")
Expand Down Expand Up @@ -151,7 +151,7 @@ copy_field("almaMmsId","rpbId")
lookup("rpbId","almaMmsId2rpbId",delete:"true")
replace_all("rpbId", "^RPB","")

set_array("stockNumber[]")
add_array("stockNumber[]")
do list(path:"028??", "var":"$i")
copy_field("$i.a", "stockNumber[].$append")
end
Expand Down
30 changes: 15 additions & 15 deletions src/main/resources/alma/fix/item.fix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
set_array("hasItem[]")
set_array("@ITM-H") # Helper element for creating Holding from HOL ("PhysikalischerTitel")
add_array("hasItem[]")
add_array("@ITM-H") # Helper element for creating Holding from HOL ("PhysikalischerTitel")
do list(path:"ITM ", "var": "$i")
call_macro("suppressedLocation", targetField: "$i", libraryCodeSubfield: "w", locationCodeSubfield: "x")
unless exists("$i.suppressedLocation") # Test if location is suppressed with mapping provided by the libraries.
set_hash( "hasItem[].$append")
add_hash( "hasItem[].$append")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","PhysicalObject")
add_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
Expand All @@ -21,7 +21,7 @@ do list(path:"ITM ", "var": "$i")
end
end

set_array("@HOL-M_POR-M") # Helper element for creating Holding from MBD ("NurTitel")
add_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
Expand All @@ -30,9 +30,9 @@ do list(path: "HOL ", "var": "$i")
if exists("$H52.b")
call_macro("suppressedLocation", targetField: "$H52", libraryCodeSubfield: "b", locationCodeSubfield: "c")
unless exists("$H52.suppressedLocation") # Test if location is suppressed with mapping provided by the libraries.
set_hash( "hasItem[].$append")
add_hash( "hasItem[].$append")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","PhysikalischerTitel")
add_array("hasItem[].$last.type[]", "Item","PhysikalischerTitel")
if exists("$H52.b.1")
copy_field("$H52.b.1","hasItem[].$last.currentLibrary")
else
Expand All @@ -56,8 +56,8 @@ do list(path:"POR ", "var": "$i")
copy_field("$i.M","@HOL-M_POR-M.$append")
# entity for every POR .a without POR .A
unless any_match("$i.a",".*6441$") # filter out hbz
set_hash( "hasItem[].$append")
set_array("hasItem[].$last.type[]", "Item", "DigitalDocument")
add_hash( "hasItem[].$append")
add_array("hasItem[].$last.type[]", "Item", "DigitalDocument")
add_field("hasItem[].$last.label", "Electronic Portfolio")
copy_field("$i.D", "$i.@electronicLocator")
replace_all("$i.@electronicLocator","https://eu04.alma.exlibrisgroup.com/view/uresolver/49HBZ_NETWORK","")
Expand All @@ -74,8 +74,8 @@ 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","")
do list(path:"$i.A", "var": "$j")
set_hash( "hasItem[].$append")
set_array("hasItem[].$last.type[]", "Item", "DigitalDocument")
add_hash( "hasItem[].$append")
add_array("hasItem[].$last.type[]", "Item", "DigitalDocument")
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: "")
Expand All @@ -85,7 +85,7 @@ do list(path:"POR ", "var": "$i")
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")
set_array("hasItem[].$last.inCollection[]")
add_array("hasItem[].$last.inCollection[]")
paste("hasItem[].$last.inCollection[].$append.id", "~http://lobid.org/organisations/", "$i.@iz", "~#!", join_char:"")
copy_field("hasItem[].$last.inCollection[].$last.id", "hasItem[].$last.inCollection[].$last.label")
# item id is constructed "http://lobid.org/items/[almaMmsId of the record]:[isil of the Owner]:[almaMmsId of the holding]#!"
Expand All @@ -97,17 +97,17 @@ end
do list(path: "MBD ", "var": "$i")
unless any_match("$i.M","49HBZ_NETWORK")
unless in("$i.M", "@HOL-M_POR-M") # Checks if there is no corresponding HOL or POR-Field
set_hash( "hasItem[].$append")
add_hash( "hasItem[].$append")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","NurTitel")
add_array("hasItem[].$last.type[]", "Item","NurTitel")
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")
set_array("hasItem[].$last.inCollection[]")
add_array("hasItem[].$last.inCollection[]")
paste("hasItem[].$last.inCollection[].$append.id", "~http://lobid.org/organisations/", "$i.@iz", "~#!", join_char:"")
copy_field("hasItem[].$last.inCollection[].$last.id", "hasItem[].$last.inCollection[].$last.label")
# item id is constructed "http://lobid.org/items/[almaMmsId of the record]:[isil of the Owner]:[almaMmsId of the holding]#!"
Expand Down
Loading

0 comments on commit 64769d1

Please sign in to comment.