From 6ec1efc6b22b32d928eae501d4a8ff20e13b06b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Thu, 4 Apr 2024 12:34:45 +0200 Subject: [PATCH] Use set_hash for creating empty objects Instead of creating dummi or test elements with add_field Inspired by @maipets approach to this problem. --- src/main/resources/alma/fix/item.fix | 12 +++++----- src/main/resources/alma/fix/macros.fix | 12 +++++----- .../alma/fix/relatedRessourcesAndLinks.fix | 24 +++++++++---------- .../resources/alma/fix/titleRelatedFields.fix | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/resources/alma/fix/item.fix b/src/main/resources/alma/fix/item.fix index 7214206c5..d28812dcc 100644 --- a/src/main/resources/alma/fix/item.fix +++ b/src/main/resources/alma/fix/item.fix @@ -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 @@ -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") @@ -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 @@ -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") @@ -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: "") @@ -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") diff --git a/src/main/resources/alma/fix/macros.fix b/src/main/resources/alma/fix/macros.fix index f6bcbbbd6..0b8fbbce8 100644 --- a/src/main/resources/alma/fix/macros.fix +++ b/src/main/resources/alma/fix/macros.fix @@ -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") @@ -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[]") @@ -439,7 +439,7 @@ do put_macro("publication") copy_field("$880.@script.id","alternateGraphicRepresentation[].$append.script.id") copy_field("$880.@script.label","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[]") @@ -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") @@ -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[]") @@ -493,7 +493,7 @@ do put_macro("manufacture") copy_field("$880.@script.id","alternateGraphicRepresentation[].$append.script.id") copy_field("$880.@script.label","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[]") diff --git a/src/main/resources/alma/fix/relatedRessourcesAndLinks.fix b/src/main/resources/alma/fix/relatedRessourcesAndLinks.fix index dc8f90644..c2657638a 100644 --- a/src/main/resources/alma/fix/relatedRessourcesAndLinks.fix +++ b/src/main/resources/alma/fix/relatedRessourcesAndLinks.fix @@ -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") @@ -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 @@ -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") @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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") @@ -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 @@ -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)\\)(.*)$") @@ -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)\\)(.*)$") diff --git a/src/main/resources/alma/fix/titleRelatedFields.fix b/src/main/resources/alma/fix/titleRelatedFields.fix index b6ef3bd7e..037a426ea 100644 --- a/src/main/resources/alma/fix/titleRelatedFields.fix +++ b/src/main/resources/alma/fix/titleRelatedFields.fix @@ -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")