From e6354b647dbca351d0ab1aa7a7fbe8b3b006c55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20B=C3=BClte?= Date: Thu, 23 Jan 2025 12:46:57 +0100 Subject: [PATCH] Delete isPartOf object from 830 if it has no $a or $w #2136 To avoid isPartOf objects that only hold a numbering and a type --- .../alma/fix/relatedRessourcesAndLinks.fix | 18 ++++++++++++------ .../resources/alma-fix/99374868243506441.json | 4 ---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/resources/alma/fix/relatedRessourcesAndLinks.fix b/src/main/resources/alma/fix/relatedRessourcesAndLinks.fix index 8dcb1bd3c..ee819fd4c 100644 --- a/src/main/resources/alma/fix/relatedRessourcesAndLinks.fix +++ b/src/main/resources/alma/fix/relatedRessourcesAndLinks.fix @@ -136,12 +136,13 @@ do list(path: "830??", "var": "$i") if all_match("$i.w", "^\\((?:DE-600|DE-605)\\)(.*)$") copy_field("$i.w", "isPartOf[].$last.hasSuperordinate[].$last.id") end - add_array("isPartOf[].$last.hasSuperordinate[].$last.label") do list(path:"$i.a", "var":"$j") copy_field("$j", "isPartOf[].$last.hasSuperordinate[].$last.label.$append") end join_field("isPartOf[].$last.hasSuperordinate[].$last.label", " / ") - copy_field("$i.v", "isPartOf[].$last.numbering") + unless is_empty("isPartOf[].$last.hasSuperordinate[].1") + copy_field("$i.v", "isPartOf[].$last.numbering") + end end do list(path: "4901?", "var": "$j") @@ -192,9 +193,14 @@ if any_match("leader", "^.{7}[ad].*") end end -do list(path: "isPartOf[].*.hasSuperordinate[]", "var": "$i") ## This is the fallback for isPartOf[].*.hasSuperordinate[].*.label - unless exists("$i.label") - copy_field("@title", "$i.label") +do list(path: "isPartOf[]","var":"$i") + unless is_empty("$i.hasSuperordinate[].1") + do list(path:"$i.hasSuperordinate[]", "var": "$j") ## This is the fallback for isPartOf[].*.hasSuperordinate[].*.label + unless exists("$j.label") + copy_field("@title", "$j.label") + end + end + add_array("$i.type[]", "IsPartOfRelation") end end @@ -202,7 +208,7 @@ replace_all("isPartOf[].*.hasSuperordinate[].*.id", "^\\(DE-605\\)(.*)$", "http: replace_all("isPartOf[].*.hasSuperordinate[].*.id", "^\\(DE-600\\)(.*)$", "http://lobid.org/resources/ZDB-$1#!") replace_all("isPartOf[].*.numbering", "^[©]|\\s?[,.:;/=]?$", "") -add_array("isPartOf[].*.type[]", "IsPartOfRelation") + uniq("isPartOf[]") diff --git a/src/test/resources/alma-fix/99374868243506441.json b/src/test/resources/alma-fix/99374868243506441.json index 3ed8b90ea..acc78976e 100644 --- a/src/test/resources/alma-fix/99374868243506441.json +++ b/src/test/resources/alma-fix/99374868243506441.json @@ -80,10 +80,6 @@ "id" : "http://nwbib.de/99374868243506441#!", "label" : "NWBib-Ressource" } ], - "isPartOf" : [ { - "numbering" : "11", - "type" : [ "IsPartOfRelation" ] - } ], "description" : [ { "label" : "Inhaltstext", "id" : "http://deposit.dnb.de/cgi-bin/dokserv?id=7c6192c3b427428789f4e7990f6024ad&prov=M&dok_var=1&dok_ext=htm"