From 146089f089ce02549eabb78d07c611c21a6f64af Mon Sep 17 00:00:00 2001 From: aatuny <27770287+aatuny@users.noreply.github.com> Date: Mon, 4 Nov 2024 08:21:44 +0200 Subject: [PATCH] Disallow f264 duplication: only first entry of dc.title.alternative generates the field --- src/transform/convert/common/generate2xx.js | 10 ++++++---- .../common/generate2xx/generate246/01/metadata.json | 2 +- .../common/generate2xx/generate246/01/output.json | 6 ------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/transform/convert/common/generate2xx.js b/src/transform/convert/common/generate2xx.js index e7dd5f1..bd0ebd4 100644 --- a/src/transform/convert/common/generate2xx.js +++ b/src/transform/convert/common/generate2xx.js @@ -33,10 +33,12 @@ export function generate245({getFields, getFieldValues}) { */ export function generate246({getFieldValues}) { const values = getFieldValues('dc.title.alternative'); - return values.map(value => ({ - tag: '246', ind1: '1', ind2: '3', - subfields: [{code: 'a', value}] - })); + return values.length > 0 ? [ + { + tag: '246', ind1: '1', ind2: '3', + subfields: [{code: 'a', value: values[0]}] + } + ] : []; } /** diff --git a/test-fixtures/transform/convert/common/generate2xx/generate246/01/metadata.json b/test-fixtures/transform/convert/common/generate2xx/generate246/01/metadata.json index 537fbd6..4abd19a 100644 --- a/test-fixtures/transform/convert/common/generate2xx/generate246/01/metadata.json +++ b/test-fixtures/transform/convert/common/generate2xx/generate246/01/metadata.json @@ -1,4 +1,4 @@ { - "description": "Generates a f246 from each dc.title.alternative information.", + "description": "Generates a f246 from first dc.title.alternative information.", "only": false } \ No newline at end of file diff --git a/test-fixtures/transform/convert/common/generate2xx/generate246/01/output.json b/test-fixtures/transform/convert/common/generate2xx/generate246/01/output.json index 41393ec..f76267a 100644 --- a/test-fixtures/transform/convert/common/generate2xx/generate246/01/output.json +++ b/test-fixtures/transform/convert/common/generate2xx/generate246/01/output.json @@ -4,11 +4,5 @@ "subfields": [ {"code": "a", "value": "Dublin Core - MARC21 -conversion"} ] - }, - { - "tag": "246", "ind1": "1", "ind2": "3", - "subfields": [ - {"code": "a", "value": "Och samma på svenska"} - ] } ] \ No newline at end of file