Skip to content

Commit

Permalink
Use set_hash for creating empty objects
Browse files Browse the repository at this point in the history
Instead of creating dummi or test elements with add_field

Inspired by @maipets approach to this problem.
  • Loading branch information
TobiasNx committed Apr 4, 2024
1 parent 21608bd commit 6ec1efc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions src/main/resources/alma/fix/item.fix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ do list(path:"ITM ", "var": "$i")
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","")
set_hash( "hasItem[].$append")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","PhysicalObject")
if exists("$i.z") # Temporary call number subfield
Expand All @@ -31,7 +31,7 @@ do list(path: "HOL ", "var": "$i")
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","")
set_hash( "hasItem[].$append")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","PhysikalischerTitel")
if exists("$H52.b.1")
Expand All @@ -43,7 +43,7 @@ do list(path: "HOL ", "var": "$i")
copy_field("$H52.h", "hasItem[].$last.callNumber")
if exists("$H52.b.1")
call_macro("holdingLibrary+opacLink", mmsIdField:"$i.8",libraryCodeField:"$H52.b.1")
else
else
call_macro("holdingLibrary+opacLink", mmsIdField:"$i.8",libraryCodeField:"$H52.b")
end
end
Expand All @@ -56,7 +56,7 @@ 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
add_field( "hasItem[].$append.test","")
set_hash( "hasItem[].$append")
set_array("hasItem[].$last.type[]", "Item", "DigitalDocument")
add_field("hasItem[].$last.label", "Electronic Portfolio")
copy_field("$i.D", "$i.@electronicLocator")
Expand All @@ -74,7 +74,7 @@ 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")
add_field( "hasItem[].$append.test","")
set_hash( "hasItem[].$append")
set_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: "")
Expand All @@ -94,7 +94,7 @@ 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
add_field( "hasItem[].$append.test","")
set_hash( "hasItem[].$append")
add_field("hasItem[].$last.label", "lobid Bestandsressource")
set_array("hasItem[].$last.type[]", "Item","NurTitel")
copy_field("$i.i", "$i.@iz")
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/alma/fix/macros.fix
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ end

do put_macro("publication")
do list(path:"$[field]", "var":"$i")
add_field("publication[].$append.test","")
set_hash( "publication[].$append")
do list(path: "$i.c", "var":"$j")
replace_all("$j", "\\[|\\]|ca. |c ", "")
unless exists("publication[].$last.startDate")
Expand Down Expand Up @@ -428,7 +428,7 @@ do put_macro("publication")
unless exists("$AGR.record.publication[]")
set_array("$AGR.record.publication[]")
end
add_field ("$AGR.record.publication[].$append.dummi","")
set_hash( "$AGR.record.publication[].$append")
set_array("$AGR.record.publication[].$last.location[]")
copy_field("$880.a", "$AGR.record.publication[].$last.location[].$append")
set_array("$AGR.record.publication[].$last.publishedBy[]")
Expand All @@ -439,7 +439,7 @@ do put_macro("publication")
copy_field("[email protected]","alternateGraphicRepresentation[].$append.script.id")
copy_field("[email protected]","alternateGraphicRepresentation[].$last.script.label")
set_array("alternateGraphicRepresentation[].$last.publication[]")
add_field ("alternateGraphicRepresentation[].$last.publication[].$append.dummi","")
set_hash( "alternateGraphicRepresentation[].$last.publication[].$append")
set_array("alternateGraphicRepresentation[].$last.publication[].$last.location[]")
copy_field("$880.a", "alternateGraphicRepresentation[].$last.publication[].$last.location[].$append")
set_array("alternateGraphicRepresentation[].$last.publication[].$last.publishedBy[]")
Expand All @@ -453,7 +453,7 @@ end

do put_macro("manufacture")
do list(path:"$[field]", "var":"$i")
add_field("manufacture[].$append.test","")
set_hash( "manufacture[].$append")
do list(path: "$i.c", "var":"$j")
replace_all("$j", "\\[|\\]|ca. |c ", "")
unless exists("manufacture[].$last.startDate")
Expand Down Expand Up @@ -482,7 +482,7 @@ do put_macro("manufacture")
unless exists("$AGR.record.manufacture[]")
set_array("$AGR.record.manufacture[]")
end
add_field ("$AGR.record.manufacture[].$append.dummi","")
set_hash( "$AGR.record.manufacture[].$append")
set_array("$AGR.record.manufacture[].$last.location[]")
copy_field("$880.a", "$AGR.record.manufacture[].$last.location[].$append")
set_array("$AGR.record.manufacture[].$last.manufacturedBy[]")
Expand All @@ -493,7 +493,7 @@ do put_macro("manufacture")
copy_field("[email protected]","alternateGraphicRepresentation[].$append.script.id")
copy_field("[email protected]","alternateGraphicRepresentation[].$last.script.label")
set_array("alternateGraphicRepresentation[].$last.manufacture[]")
add_field ("alternateGraphicRepresentation[].$last.manufacture[].$append.dummi","")
set_hash( "alternateGraphicRepresentation[].$last.manufacture[].$append")
set_array("alternateGraphicRepresentation[].$last.manufacture[].$last.location[]")
copy_field("$880.a", "alternateGraphicRepresentation[].$last.manufacture[].$last.location[].$append")
set_array("alternateGraphicRepresentation[].$last.manufacture[].$last.publishedBy[]")
Expand Down
24 changes: 12 additions & 12 deletions src/main/resources/alma/fix/relatedRessourcesAndLinks.fix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ set_array("supplement[]")

do list(path:"77008", "var":"$i")
if any_match("$i.i", "Beil.*|Supp.*")
add_field("supplement[].$append.test","")
set_hash( "supplement[].$append")
set_array("supplement[].$last.note[]")
do list(path:"$i.i","var":"$j")
copy_field("$j","supplement[].$last.note[].$append")
Expand Down Expand Up @@ -77,7 +77,7 @@ unless any_match("leader", "^.{7}[ad].*")
do list(path: "$i.w", "var": "$j")
set_array("isPartOf[].$append.type[]", "IsPartOfRelation")
set_array("isPartOf[].$last.hasSuperordinate[]")
add_field("isPartOf[].$last.hasSuperordinate[].$append.test", "")
set_hash( "isPartOf[].$last.hasSuperordinate[].$append")
if all_match("$j", "^\\((?:DE-600|DE-605)\\)(.*)$")
copy_field("$j", "isPartOf[].$last.hasSuperordinate[].$last.id")
end
Expand All @@ -99,7 +99,7 @@ end
do list(path: "4900?", "var": "$i")
set_array("isPartOf[].$append.type[]", "IsPartOfRelation")
set_array("isPartOf[].$last.hasSuperordinate[]")
add_field("isPartOf[].$last.hasSuperordinate[].$append.test", "")
set_hash( "isPartOf[].$last.hasSuperordinate[].$append")
set_array("isPartOf[].$last.hasSuperordinate[].$last.label")
do list(path:"$i.a", "var":"$j")
copy_field("$j", "isPartOf[].$last.hasSuperordinate[].$last.label.$append")
Expand All @@ -121,7 +121,7 @@ end
do list(path: "830??", "var": "$i")
set_array("isPartOf[].$append.type[]", "IsPartOfRelation")
set_array("isPartOf[].$last.hasSuperordinate[]")
add_field("isPartOf[].$last.hasSuperordinate[].$append.test", "")
set_hash( "isPartOf[].$last.hasSuperordinate[].$append")
if all_match("$i.w", "^\\((?:DE-600|DE-605)\\)(.*)$")
copy_field("$i.w", "isPartOf[].$last.hasSuperordinate[].$last.id")
end
Expand Down Expand Up @@ -155,7 +155,7 @@ if any_match("leader", "^.{7}[ad].*")
do list(path: "$i.w", "var": "$j")
set_array("isPartOf[].$append.type[]", "IsPartOfRelation")
set_array("isPartOf[].$last.hasSuperordinate[]")
add_field("isPartOf[].$last.hasSuperordinate[].$append.test", "")
set_hash( "isPartOf[].$last.hasSuperordinate[].$append")
if all_match("$j", "^\\((?:DE-600|DE-605)\\)(.*)$")
copy_field("$j", "isPartOf[].$last.hasSuperordinate[].$last.id")
end
Expand All @@ -172,7 +172,7 @@ if any_match("leader", "^.{7}[ad].*")
do list(path:"773??", "var":"$i")
do list(path:"$i.w", "var":"$j")
if any_match("$j","^\\(DE-(600|605)\\).*")
add_field("containedIn[].$append.test","")
set_hash( "containedIn[].$append")
copy_field("$j","containedIn[].$last.id")
copy_field("$i.t","containedIn[].$last.label")
end
Expand Down Expand Up @@ -206,7 +206,7 @@ set_array("primaryForm[]")

do list(path: "77608", "var":"$i")
if any_match ("$i.i", ".*eproduktion von.*")
add_field("primaryForm[].$append.test","")
set_hash( "primaryForm[].$append")
if all_match("$i.w", "^\\((?:DE-600|DE-605)\\)(.*)$")
copy_field("$i.w", "primaryForm[].$last.id")
end
Expand All @@ -228,7 +228,7 @@ set_array("secondaryForm[]")

do list(path: "77608", "var":"$i")
if any_match ("$i.i", ".*eproduktion")
add_field("secondaryForm[].$append.test","")
set_hash( "secondaryForm[].$append")
if all_match("$i.w", "^\\((?:DE-600|DE-605)\\)(.*)$")
copy_field("$i.w", "secondaryForm[].$last.id")
end
Expand Down Expand Up @@ -278,7 +278,7 @@ do list(path: "8564?", "var":"$i")
if all_match("$i.x", "Verlag|Agentur|Digitalisierung")
copy_field("$i.x", "fulltextOnline[].$append.label")
copy_field("$i.u", "fulltextOnline[].$last.id")
end
end
end
if all_match("$i.x", ".*(Archivierte Online|EZB|Online-Ausg|Resolving-System|Volltext).*")
copy_field("$i.x", "fulltextOnline[].$append.label")
Expand All @@ -289,7 +289,7 @@ do list(path: "8564?", "var":"$i")
copy_field("$i.u", "fulltextOnline[].$last.id")
end
end
end
end
end

# doi for fullTextOnline and sameAs
Expand Down Expand Up @@ -541,7 +541,7 @@ set_array("inCollection[].*.type[]","Collection")
set_array("predecessor[]")

do list(path:"780??", "var":"$i")
add_field("predecessor[].$append.test","")
set_hash( "predecessor[].$append")
copy_field("$i.t", "predecessor[].$last.label")
do list(path:"$i.w", "var":"$j")
if all_match("$j", "^\\((?:DE-600|DE-605)\\)(.*)$")
Expand All @@ -568,7 +568,7 @@ replace_all("predecessor[].*.label","Vorg. ---> ","")
set_array("successor[]")

do list(path:"785??", "var":"$i")
add_field("successor[].$append.test","")
set_hash( "successor[].$append")
copy_field("$i.t", "successor[].$last.label")
do list(path:"$i.w", "var":"$j")
if all_match("$j", "^\\((?:DE-600|DE-605)\\)(.*)$")
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/alma/fix/titleRelatedFields.fix
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ end
# 533 - Reproduction Note (R)

do list(path:"533 ", "var": "$i")
add_field("publication[].$append.test","")
set_hash( "publication[].$append")
set_array("publication[].$last.type[]","SecondaryPublicationEvent")
set_array("publication[].$last.location[]")
do list(path:"$i.b","var":"$j")
Expand Down

0 comments on commit 6ec1efc

Please sign in to comment.