Skip to content

Commit e8e88cb

Browse files
committed
Enhance error handling for missing DOI or @id in JSON conversion
1 parent 807da1a commit e8e88cb

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

middleware/scripts/publiso_conversor.jq

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
then "https://doi.org/" + .doi
99
elif has("@id")
1010
then "https://repository.publisso.de/resource/" + .["@id"]
11-
else null
11+
else
12+
error("Missing required field: either doi or @id must be present")
1213
end),
1314
"name": (if has("title") then (.title[]) else null end),
1415
"alternativeHeadline": (if has("alternative") then .alternative[0] else null end),
@@ -22,12 +23,12 @@
2223
"url": ("https://doi.org/" + .doi)
2324
}
2425
else empty end),
25-
(if has("@id") then
26+
(."@id" | if . then
2627
{
2728
"@type": "PropertyValue",
2829
"propertyID": "frl-internal",
29-
"value": .["@id"],
30-
"url": ("https://repository.publisso.de/resource/" + .["@id"])
30+
"value": .,
31+
"url": ("https://repository.publisso.de/resource/" + .)
3132
}
3233
else empty end)
3334
]),
@@ -83,7 +84,7 @@
8384
],
8485
"distribution":
8586
[
86-
(if has("hasPart") then (.hasPart[] | {"@type":"DataDownload", "@id": (if has("@id") then "https://repository.publisso.de/resource/" + ."@id" else null end), "name": .prefLabel}) else null end)
87+
(if has("hasPart") then (.hasPart[] | {"@type":"DataDownload", "@id": (."@id" | if . then "https://repository.publisso.de/resource/" + . else null end), "name": .prefLabel}) else null end)
8788
],
8889
"inLanguage":
8990
[

0 commit comments

Comments
 (0)