Skip to content

Commit

Permalink
Merge pull request #937 from geonetwork/keyword-key
Browse files Browse the repository at this point in the history
Fix [Datahub]: Map keyword link to key
  • Loading branch information
cmoinier authored Jul 15, 2024
2 parents 71a43b3 + c674335 commit e77c0f8
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
54 changes: 45 additions & 9 deletions libs/api/metadata-converter/src/lib/gn4/atomic-operations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,65 @@ describe('atomic operations', () => {
id: '1',
theme: 'theme',
keywords: [
{ en: 'keyword1', fr: 'mot-clé1' },
{ en: 'keyword2', fr: 'mot-clé2' },
{
en: 'keyword1',
fr: 'mot-clé1',
link: 'https://some-uri.org/thematique/categories/culture_tourisme_sport',
},
{
en: 'keyword2',
fr: 'mot-clé2',
link: 'https://some-uri.org/thematique/categories/services_social_sante',
},
],
},
{
id: '2',
theme: 'place',
keywords: [
{ en: 'keyword3', fr: 'mot-clé3' },
{ en: 'keyword4', fr: 'mot-clé4' },
{
en: 'keyword3',
fr: 'mot-clé3',
link: 'https://some-uri.org/place/france',
},
{
en: 'keyword4',
fr: 'mot-clé4',
link: 'https://some-uri.org/place/europe',
},
],
},
]
const expected = [
{ label: 'keyword1', type: 'theme', thesaurus: { id: '1' } },
{ label: 'keyword2', type: 'theme', thesaurus: { id: '1' } },
{ label: 'keyword3', type: 'place', thesaurus: { id: '2' } },
{ label: 'keyword4', type: 'place', thesaurus: { id: '2' } },
{
label: 'keyword1',
type: 'theme',
key: 'https://some-uri.org/thematique/categories/culture_tourisme_sport',
thesaurus: { id: '1' },
},
{
label: 'keyword2',
type: 'theme',
key: 'https://some-uri.org/thematique/categories/services_social_sante',
thesaurus: { id: '1' },
},
{
label: 'keyword3',
type: 'place',
key: 'https://some-uri.org/place/france',
thesaurus: { id: '2' },
},
{
label: 'keyword4',
type: 'place',
key: 'https://some-uri.org/place/europe',
thesaurus: { id: '2' },
},
]
expect(mapKeywords(thesauri, 'en')).toEqual(expected)
})

it('should default type to "other" if theme is not provided', () => {
it('should default type to "other" if theme is not provided and not break without link', () => {
const thesauri = [
{
id: '1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const mapKeywords = (thesauri: Thesaurus[], language: string) => {
keywords.push({
label: selectTranslatedValue<string>(keyword, language),
type: getKeywordTypeFromKeywordTypeCode(rawThesaurus.theme),
...(keyword.link && { key: keyword.link }),
...(thesaurus && { thesaurus }),
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ describe('Gn4Converter', () => {
name: 'GEMET themes',
},
type: 'theme',
key: 'http://www.eionet.europa.eu/gemet/theme/1',
},
{
label: 'Unterschlupf',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type MultilingualField = {
[K in `lang${LangCode}`]: string
} & {
default: string
link?: string
}

type BooleanString = 'true' | 'false'
Expand Down

0 comments on commit e77c0f8

Please sign in to comment.