Skip to content

Commit

Permalink
Adjust "related" resources
Browse files Browse the repository at this point in the history
Generate 2 objects in related resources if 776$w is repeated
  • Loading branch information
Petra Maier committed Dec 15, 2023
1 parent 38920c5 commit e6e935b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 29 deletions.
45 changes: 17 additions & 28 deletions src/main/resources/alma/fix/relatedRessourcesAndLinks.fix
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ uniq("containedIn[]")

# 776 - Additional Physical Form Entry (R) - $i (R), $w (R)

# TODO: is this not duplicate info with "related"?

set_array("primaryForm[]")

do list(path: "77608", "var":"$i")
Expand Down Expand Up @@ -341,42 +339,33 @@ end
# 776 - Additional Physical Form Entry (R) - Subfield: $w (R), $t (NR), $i (R), $n (R), $x (NR), $z (R)

set_array("related[]")
do list_as("$i":"775??|776??")
do list(path:"775??|776??", "var":"$i")
unless any_match ("$i.i", ".*eproduktion von.*|.*eproduktion")
add_field("related[].$append.test","")
if all_match("$i.w", "^\\((?:DE-600|DE-605)\\)(.*)$")
if is_array("$i.w")
copy_field("$i.w.1", "related[].$last.id")
else
copy_field("$i.w", "related[].$last.id")
do list_as("$hbzId":"$i.w", "$isbn":"$i.z", "$label":"$i.t", "$note":"$i.n", "$issn":"$i.x", "$info":"$i.i")
set_hash("related[].$append")
if all_match("$hbzId", "^\\((DE-600|DE-605)\\).*$")
copy_field("$hbzId", "related[].$last.id")
end
set_array("related[].$last.note[]")
paste("related[].$last.note[].$append","$info", "$note")
replace_all("related[].$last.note[].$last", "Erscheint auch als ","")
copy_field("$label", "related[].$last.label")
copy_field("$issn", "related[].$last.issn")
set_array("related[].$last.isbn[]")
isbn("$isbn", to:"isbn13")
copy_field("$isbn", "related[].$last.isbn[].$append")
isbn("$isbn", to:"isbn10")
copy_field("$isbn", "related[].$last.isbn[].$append")
end
set_array("related[].$last.note[]")
paste("related[].$last.note[].$append","$i.i", "$i.n")
replace_all("related[].$last.note[].$last", "Erscheint auch als ","")
copy_field("$i.t", "related[].$last.label")
copy_field("$i.x", "related[].$last.issn")
set_array("$i.isbn13")
set_array("$i.isbn10")
do list(path: "$i.z", "var":"$j")
isbn("$j", to: "clean")
copy_field("$j", "$i.isbn13.$append")
copy_field("$j", "$i.isbn10.$append")
end
set_array("related[].$last.isbn[]")
isbn("$i.isbn10.*", to:"isbn10")
isbn("$i.isbn13.*", to:"isbn13")
copy_field("$i.isbn13.*", "related[].$last.isbn[].$append")
copy_field("$i.isbn10.*", "related[].$last.isbn[].$append")
end
end

do list(path:"related[]", "var":"$i")
uniq("$i.isbn[]")
end

replace_all("related[].*.id", "((\\(DE-605\\))+)(.*)$", "http://lobid.org/resources/$3#!")
replace_all("related[].*.id", "\\(DE-600\\)(.*)$", "http://lobid.org/resources/ZDB-$1#!")
replace_all("related[].*.id", "^\\(DE-605\\)(.*)$", "http://lobid.org/resources/$1#!")
replace_all("related[].*.id", "^\\(DE-600\\)(.*)$", "http://lobid.org/resources/ZDB-$1#!")


set_array("inCollection[]")
Expand Down
6 changes: 5 additions & 1 deletion src/test/resources/alma-fix/990367593690206441.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
"id" : "http://lobid.org/resources/HT020755871#!",
"note" : [ "Online-Ausgabe" ],
"label" : "Handbuch der künstlichen Intelligenz",
"isbn" : [ "9783110659955", "9783110659948", "3110659956", "3110659948" ]
"isbn" : [ "9783110659955", "3110659956" ]
}, {
"id" : "http://lobid.org/resources/HT020643041#!",
"isbn" : [ "9783110659948", "3110659948" ],
"label" : "lobid Ressource"
} ],
"inCollection" : [ {
"id" : "http://lobid.org/organisations/DE-655#!",
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/alma-fix/990367731740206441.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
"note" : [ "Druck-Ausgabe" ],
"isbn" : [ "9783451388798", "3451388790" ],
"label" : "lobid Ressource"
}, {
"isbn" : [ "9783451388798", "3451388790" ]

This comment has been minimized.

Copy link
@TobiasNx

TobiasNx Mar 27, 2024

Contributor

This creates a duplicate object since the ISBN is already given in the other object.

} ],
"inCollection" : [ {
"id" : "http://lobid.org/organisations/DE-655#!",
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/alma-fix/991005935279706485.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"id" : "http://lobid.org/resources/ZDB-507495-2#!"
} ],
"related" : [ {
"id" : "http://lobid.org/resources/ZDB-2722409-0#!",
"note" : [ "Online-Ausg." ],
"label" : "Wirtschaft und Erziehung.",
"issn" : "0174-6170"
Expand Down

1 comment on commit e6e935b

@TobiasNx
Copy link
Contributor

@TobiasNx TobiasNx commented on e6e935b Mar 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion this commit should have been two different commits since is fixes the REGEX and the transformation for related.

src/test/resources/alma-fix/991005935279706485.json seems to be a test for the REGEX
while the other two for the changed transformation.

@maipet

Please sign in to comment.