Skip to content

Commit

Permalink
Dont allow date with more than 6 digits #2114
Browse files Browse the repository at this point in the history
Some records have 8 instead of 6 digits. I talked to @maipet we decided that ignoring 8 digits due to invalid 008/00-05 is better than constructing values from the invalid date.
  • Loading branch information
TobiasNx committed Jan 6, 2025
1 parent f9bcc2c commit db15407
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/main/resources/alma/fix/describedBy.fix
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ prepend("describedBy.resultOf.object.id","https://lobid.org/marcxml/")
# 008/00-05 has the initial cataloguing date. We use MNG info as fallback.
# MNG is a ALMA-specific element (MNG .b only states the indexing date into ALMA.)

copy_field("008","@initialCataloguingDate")
if any_match("@initialCataloguingDate", "^\\d{8}.*") # Due to cataloguing errors there seem to be year not represented by two but by four digits. The first step is a workaround.
substring("@initialCataloguingDate","2","6")
elsif any_match("@initialCataloguingDate", "^\\d{6}.*") # 008/00-05 is the correct form for the cataloguing date in MARC.
if any_match("008", "^\\d{6}\\D.*") # 008/00-05 is the correct form for the cataloguing date in MARC.
copy_field("008","@initialCataloguingDate")
substring("@initialCataloguingDate","0","6")
end

if any_match("@initialCataloguingDate","^[0-4].*")
if any_match("@initialCataloguingDate","^[0-4]\\d*")
prepend("@initialCataloguingDate","20")
elsif any_match("@initialCataloguingDate","\\d*")
prepend("@initialCataloguingDate","19")
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/alma-fix/99374515437806441.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"object" : {
"id" : "https://lobid.org/marcxml/99374515437806441",
"dateCreated" : "2024-08-16",
"dateCreated" : "2024-08-19",
"dateModified" : "2024-10-30",
"type" : [ "DataFeedItem" ],
"label" : "hbz-Ressource 99374515437806441 im Exportformat MARC21 XML",
Expand Down

0 comments on commit db15407

Please sign in to comment.