Skip to content

Commit

Permalink
Only create contributions if marcRel exists #2106
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasNx committed Jan 10, 2025
1 parent 599fd79 commit f70ad41
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 163 deletions.
296 changes: 153 additions & 143 deletions src/main/resources/alma/fix/contribution.fix
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,43 @@ do list(path:"100[01] ", "var":"$i")
end
end
do list(path: "$i.4", "var":"$j")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
if any_match("$j","[A-Za-z]{3}")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
end
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
# name
call_macro("gndPersonCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel","contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","Person")
# role
copy_field("$j","contribution[].$last.role.id")
# dateOfBirthAndDeath #will be split on a later stage
unless exists("$i.d.1")
copy_field("$i.d","contribution[].$last.agent.dateOfBirthAndDeath")
end
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
# name
call_macro("gndPersonCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel","contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","Person")
# role
copy_field("$j","contribution[].$last.role.id")
# dateOfBirthAndDeath #will be split on a later stage
unless exists("$i.d.1")
copy_field("$i.d","contribution[].$last.agent.dateOfBirthAndDeath")
end
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
end
end
Expand All @@ -83,41 +85,43 @@ do list(path:"700[01] ", "var":"$i")
add_field("$i.4","ctb")
end
do list(path: "$i.4", "var":"$j")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
if any_match("$j","[A-Za-z]{3}")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
end
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
# name
call_macro("gndPersonCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel","contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","Person")
# role
copy_field("$j","contribution[].$last.role.id")
# dateOfBirthAndDeath #will be split on a later stage
unless exists("$i.d.1")
copy_field("$i.d","contribution[].$last.agent.dateOfBirthAndDeath")
end
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
# name
call_macro("gndPersonCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel","contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","Person")
# role
copy_field("$j","contribution[].$last.role.id")
# dateOfBirthAndDeath #will be split on a later stage
unless exists("$i.d.1")
copy_field("$i.d","contribution[].$last.agent.dateOfBirthAndDeath")
end
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
end
end
Expand Down Expand Up @@ -145,37 +149,39 @@ do list(path:"110[012] ", "var":"$i")
end
end
do list(path: "$i.4", "var":"$j")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
if any_match("$j","[A-Za-z]{3}")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
end
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
# name
call_macro("gndOtherCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel", "contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","CorporateBody")
# role
copy_field("$j","contribution[].$last.role.id")
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
# name
call_macro("gndOtherCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel", "contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","CorporateBody")
# role
copy_field("$j","contribution[].$last.role.id")
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
end
end
Expand All @@ -194,37 +200,39 @@ do list(path:"710[012] ", "var":"$i")
add_field("$i.4","ctb")
end
do list(path: "$i.4", "var":"$j")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
if any_match("$j","[A-Za-z]{3}")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
end
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
# name
call_macro("gndOtherCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel", "contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","CorporateBody")
# role
copy_field("$j","contribution[].$last.role.id")
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
# name
call_macro("gndOtherCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel", "contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","CorporateBody")
# role
copy_field("$j","contribution[].$last.role.id")
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
end
end
Expand All @@ -242,37 +250,39 @@ do list(path:"111[012] |711[012] ", "var":"$i")
add_field("$i.4","oth")
end
do list(path: "$i.4", "var":"$j")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
if any_match("$j","[A-Za-z]{3}")
add_hash("contribution[].$append.agent")
do list(path:"$i.0","var":"$k")
if all_match("$k", "^\\(DE-588\\).*$")
# GND identifier
paste("contribution[].$last.agent.gndIdentifier","$k")
# GND Identifier id
paste("contribution[].$last.agent.id","$k")
end
# GND idn as variable
if exists("$i.B")
do list(path: "$i.B","var":"$gnd")
unless exists("contribution[].$last.agent.@gndIdn")
copy_field("$gnd","contribution[].$last.agent.@gndIdn")
end
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
elsif any_match("$k","^.*DNB\\|(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^.*DNB\\|(.*)$","GND-$1")
elsif any_match("$k","^\\(DE-101\\)(.*)$")
copy_field("$k", "contribution[].$last.agent.@gndIdn")
replace_all("contribution[].$last.agent.@gndIdn", "^\\(DE-101\\)(.*)$","GND-$1")
end
# name
call_macro("gndEventCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel", "contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","ConferenceOrEvent")
# role
copy_field("$j","contribution[].$last.role.id")
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
# name
call_macro("gndEventCombinedLabel",field:"$i")
copy_field("$i.@combinedLabel", "contribution[].$last.agent.label")
# type
add_array("contribution[].$last.agent.type[]","ConferenceOrEvent")
# role
copy_field("$j","contribution[].$last.role.id")
call_macro("alternateGraphicRepresationArrayOfObjects",targetArray:"contribution[]",targetField:".agent",variable:"$i")
end
end
end
Expand Down
20 changes: 0 additions & 20 deletions src/test/resources/alma-fix/99371426239306441.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,6 @@
"label" : "Herausgeber/in"
},
"type" : [ "Contribution" ]
}, {
"agent" : {
"label" : "Vesikari, Timo",
"type" : [ "Person" ]
},
"role" : {
"id" : "http://id.loc.gov/vocabulary/relators/http://id.loc.gov/vocabulary/relators/edt",
"label" : "http://id.loc.gov/vocabulary/relators/http://id.loc.gov/vocabulary/relators/edt"
},
"type" : [ "Contribution" ]
}, {
"agent" : {
"label" : "Van Damme, Pierre",
Expand All @@ -207,15 +197,5 @@
"label" : "Herausgeber/in"
},
"type" : [ "Contribution" ]
}, {
"agent" : {
"label" : "Van Damme, Pierre",
"type" : [ "Person" ]
},
"role" : {
"id" : "http://id.loc.gov/vocabulary/relators/http://id.loc.gov/vocabulary/relators/edt",
"label" : "http://id.loc.gov/vocabulary/relators/http://id.loc.gov/vocabulary/relators/edt"
},
"type" : [ "Contribution" ]
} ]
}

0 comments on commit f70ad41

Please sign in to comment.