Skip to content

Commit a401fe8

Browse files
author
Manuel Erdoes
committed
added possibility to change doi suffix in configuration
1 parent 71e930e commit a401fe8

6 files changed

Lines changed: 51 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.1] - 2026-05-06
9+
10+
### Added
11+
- Possibility to choose DOI suffix between `systemobjectid`, `uuid` and custom fylr field
12+
813
## [1.0.0] - 2026-04-14
914

1015
### Added

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ Each row defines one DataCite repository. Multiple profiles can be configured an
3636
| Repository ID | Your DataCite repository ID |
3737
| Password | Your DataCite repository password |
3838
| DOI Prefix | DOI prefix including trailing slash, e.g. `10.12345/` |
39+
| DOI Unique ID Field | The part of the DOI that comes after the prefix. User `systemobjectid`, `uuid` or a dot-separated path to a field in a fylr object. |
3940
| API URL | DataCite API endpoint. Default: `https://api.test.datacite.org` (test). Use `https://api.datacite.org` for production. |
40-
| Collector Name | Internal name of the collector as configured in the fylr base config publish settings |
41+
| Collector Name | Internal name of the collector as configured in the fylr base config publish settings. |
4142
| Publish as Findable | If enabled, the DOI is immediately published (findable). Requires a Detail URL Template. |
4243
| Detail URL Template | URL template for the object's landing page. Use `%system_object_id%` as placeholder. |
4344
| DOI Resolver URL | The first part of the URL that will be written in the publish entry in fylr. The URL setting in the collector base config will be ignored. |

documentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ If the admin forgets the query parameter, the script fails fast with `datacite.c
280280
4. It reads the selected profile and its matching field mappings from the plugin config.
281281
5. For each object in `data.objects`:
282282
- Resolve each field mapping's dot-path into the object. If a path goes into a linked object, fetch the full linked object from the fylr API using the plugin user's Bearer token.
283-
- Construct the DOI as `<doi_prefix><system_object_id>`.
283+
- Construct the DOI as `<doi_prefix><system_object_id/uuid/custom field>`.
284284
- Build the DataCite JSON:API payload.
285285
- POST to `<api_url>/dois`. If DataCite returns 422 (exists), retry with PUT to `<api_url>/dois/<doi>`.
286286
- POST a publish entry to `<fylr_api_url>/api/v1/publish` (Bearer auth) so the DOI appears in the object's publish tab.

l10n/datacite-loca.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ server.config.parameter.system.datacite_profiles.profiles.id.label,Profil-ID (f
88
server.config.parameter.system.datacite_profiles.profiles.repository_id.label,Repository ID,Repository ID
99
server.config.parameter.system.datacite_profiles.profiles.password.label,Passwort,Password
1010
server.config.parameter.system.datacite_profiles.profiles.doi_prefix.label,DOI Prefix (z.B. 10.5072/fylr-),DOI Prefix (e.g. 10.5072/fylr-)
11+
server.config.parameter.system.datacite_profiles.profiles.doi_unique_id_field.label,DOI Unique ID Feld,DOI Unique ID Field
1112
server.config.parameter.system.datacite_profiles.profiles.api_url.label,DataCite API URL,DataCite API URL
1213
server.config.parameter.system.datacite_profiles.profiles.collector_name.label,Collector Name,Collector Name
1314
server.config.parameter.system.datacite_profiles.profiles.publish_as_findable.label,DOI Status,DOI Status
@@ -19,4 +20,4 @@ server.config.parameter.system.datacite_field_mappings.field_mappings.label,Feld
1920
server.config.parameter.system.datacite_field_mappings.field_mappings.profile_id.label,Profil-ID,Profile ID
2021
server.config.parameter.system.datacite_field_mappings.field_mappings.datacite_field.label,DataCite Feld,DataCite Field
2122
server.config.parameter.system.datacite_field_mappings.field_mappings.fylr_field_path.label,fylr Feld-Pfad,fylr Field Path
22-
server.config.parameter.system.datacite_field_mappings.field_mappings.default_value.label,Standardwert,Default Value
23+
server.config.parameter.system.datacite_field_mappings.field_mappings.default_value.label,Standardwert,Default Value

manifest.master.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
plugin:
22
name: fylr-plugin-datacite
3-
version: "1.0.0"
3+
version: "1.0.1"
44
url: https://github.com/eth-library/fylr-publish-datacite-plugin
55
l10n: l10n/datacite-loca.csv
66
displayname:
@@ -52,23 +52,27 @@ base_config:
5252
- name: doi_prefix
5353
type: text
5454
position: 3
55-
- name: api_url
55+
- name: doi_unique_id_field
5656
type: text
5757
position: 4
58+
default: "systemobjectid"
59+
- name: api_url
60+
type: text
61+
position: 5
5862
default: "https://api.test.datacite.org"
5963
- name: collector_name
6064
type: text
61-
position: 5
65+
position: 6
6266
- name: publish_as_findable
6367
type: bool
64-
position: 6
68+
position: 7
6569
default: false
6670
- name: detail_url_template
6771
type: text
68-
position: 7
72+
position: 8
6973
- name: doi_resolver_url
7074
type: text
71-
position: 8
75+
position: 9
7276
default: "https://doi.org"
7377
- name: datacite_field_mappings
7478
parameters:

server/webhook/register-doi.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ async function main() {
105105
const publishAsFindable = dataciteConfig.publish_as_findable || false;
106106
const detailUrlTemplate = dataciteConfig.detail_url_template || '';
107107
const doiResolverUrl = (dataciteConfig.doi_resolver_url || 'https://doi.org').replace(/\/$/, '');
108+
const doiUniqueIdField = dataciteConfig.doi_unique_id_field || 'systemobjectid';
108109

109110
// Validate findable requires detail URL
110111
if (publishAsFindable && !detailUrlTemplate) {
@@ -143,6 +144,7 @@ async function main() {
143144
for (const obj of objects) {
144145
const systemObjectId = obj._system_object_id;
145146
const objecttype = obj._objecttype;
147+
const uuid = obj._uuid;
146148

147149
if (!systemObjectId || !objecttype) {
148150
errors.push({ system_object_id: systemObjectId, error: 'Missing _system_object_id or _objecttype' });
@@ -173,7 +175,35 @@ async function main() {
173175
}
174176

175177
// Construct DOI
176-
const doi = dataciteConfig.doi_prefix + systemObjectId;
178+
let doi_suffix = '';
179+
if (doiUniqueIdField === 'systemobjectid') {
180+
doi_suffix = systemObjectId;
181+
} else if (doiUniqueIdField === 'uuid') {
182+
doi_suffix = uuid || systemObjectId;
183+
} else {
184+
// Strip objecttype prefix if present (e.g. "haustieranatomie.titel" -> "titel")
185+
let resolvedPath = doiUniqueIdField;
186+
if (resolvedPath && resolvedPath.startsWith(objecttype + '.')) {
187+
resolvedPath = resolvedPath.slice(objecttype.length + 1);
188+
}
189+
190+
// Prefer _current which contains the full field data; fall back to top-level obj
191+
const sourceObj = (obj._current && obj._current[objecttype]) ? obj._current : obj;
192+
const resolvedValue = await resolveFieldPathAsync(sourceObj, objecttype, resolvedPath, fylrApiUrl, accessToken, warnings);
193+
if (resolvedValue) {
194+
doi_suffix = resolvedValue;
195+
} else {
196+
errors.push({ system_object_id: systemObjectId, error: `DOI unique ID field "${doiUniqueIdField}" could not be resolved` });
197+
continue;
198+
}
199+
}
200+
201+
if (!doi_suffix) {
202+
errors.push({ system_object_id: systemObjectId, error: 'DOI unique ID field resolved to empty value' });
203+
continue;
204+
}
205+
206+
const doi = dataciteConfig.doi_prefix + doi_suffix;
177207
const doiPrefix = doi.split('/')[0];
178208

179209
// Construct landing URL

0 commit comments

Comments
 (0)