Skip to content

Commit

Permalink
Delete isPartOf object from 830 if it has no $a or $w #2136
Browse files Browse the repository at this point in the history
To avoid isPartOf objects that only hold a numbering and a type
  • Loading branch information
TobiasNx committed Jan 23, 2025
1 parent 26d9f6b commit e6354b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 12 additions & 6 deletions src/main/resources/alma/fix/relatedRessourcesAndLinks.fix
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -192,17 +193,22 @@ 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

replace_all("isPartOf[].*.hasSuperordinate[].*.id", "^\\(DE-605\\)(.*)$", "http://lobid.org/resources/$1#!")
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[]")

Expand Down
4 changes: 0 additions & 4 deletions src/test/resources/alma-fix/99374868243506441.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e6354b6

Please sign in to comment.