Skip to content

Commit 537f4da

Browse files
author
OCurdy
committed
feat(quality-score): add new metadata quality validators
- Add multilingual validators (titleMultilingual, altTitleMultilingual, abstractMultilingual) with non-empty and non-identical language check (langfre vs langger) - Add link validators: linkDownload, linkService, linkMapPreview (MAP:*/CHTOPO protocols) - Add featureCatalog validator (embedded attributeTable or external identifier) - Add resourceFormat validator (from ES 'format' field) - Add status validator using cl_statusObject from extras - Map linkProtocol, format and featureTypes fields to extras in GN4 field mapper - Add 'linkProtocol', 'format' and 'featureTypes' to ES_SOURCE_SUMMARY - Add translations for all new validators in fr/en/de - Update spec files for quality-score.util and gn4.field.mapper
1 parent 189073d commit 537f4da

8 files changed

Lines changed: 421 additions & 179 deletions

File tree

libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.spec.ts

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ describe('Gn4FieldMapper', () => {
137137
const result = mappingFn(output, source)
138138
expect(result).toEqual({
139139
title: 'Default title',
140+
extras: {
141+
resourceTitleObject: { default: 'Default title', langfre: 'French title' },
142+
},
140143
})
141144
})
142145
it('resourceAbstractObject - should return a function that correctly maps the field to fre lang', () => {
@@ -153,6 +156,27 @@ describe('Gn4FieldMapper', () => {
153156
const result = mappingFn(output, source)
154157
expect(result).toEqual({
155158
abstract: 'French abstract',
159+
extras: {
160+
resourceAbstractObject: { default: 'Default abstract', langfre: 'French abstract' },
161+
},
162+
})
163+
})
164+
it('resourceAltTitleObject - should store alt title array in extras', () => {
165+
const fieldName = 'resourceAltTitleObject'
166+
const mappingFn = service.getMappingFn(fieldName)
167+
const output = {}
168+
const source = {
169+
resourceAltTitleObject: [
170+
{ langfre: 'Titre alternatif FR', langger: 'Alternativer Titel DE' },
171+
],
172+
}
173+
const result = mappingFn(output, source)
174+
expect(result).toEqual({
175+
extras: {
176+
resourceAltTitleObject: [
177+
{ langfre: 'Titre alternatif FR', langger: 'Alternativer Titel DE' },
178+
],
179+
},
156180
})
157181
})
158182
it('overview - should return a function that correctly maps the field', () => {
@@ -194,7 +218,43 @@ describe('Gn4FieldMapper', () => {
194218
},
195219
}
196220
const result = mappingFn(output, source)
197-
expect(result).toEqual({ status: 'completed' })
221+
expect(result).toEqual({ status: 'completed', extras: { cl_statusObject: { key: 'completed', default: 'Finalisé', langfre: 'Finalisé', link: 'http://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_ProgressCode' } } })
222+
})
223+
it('cl_subTopicCategory - should return a function that maps subtopics', () => {
224+
translateService.currentLang = 'de'
225+
const fieldName = 'cl_subTopicCategory'
226+
const mappingFn = service.getMappingFn(fieldName)
227+
const output = {}
228+
const source = {
229+
cl_subTopicCategory: [
230+
{ default: 'Subtopic 1', langger: 'Unterthema 1' },
231+
{ default: 'Subtopic 2', langger: 'Unterthema 2' },
232+
],
233+
}
234+
const result = mappingFn(output, source)
235+
expect(result).toEqual({
236+
subtopics: ['Unterthema 1', 'Unterthema 2'],
237+
})
238+
})
239+
it('MD_LegalConstraintsOtherConstraintsObject - should store in extras and add to legalConstraints', () => {
240+
translateService.currentLang = 'de'
241+
const fieldName = 'MD_LegalConstraintsOtherConstraintsObject'
242+
const mappingFn = service.getMappingFn(fieldName)
243+
const output = {}
244+
const source = {
245+
MD_LegalConstraintsOtherConstraintsObject: [
246+
{ default: 'CC-BY', langger: 'CC-BY' },
247+
],
248+
}
249+
const result = mappingFn(output, source)
250+
expect(result).toEqual({
251+
legalConstraints: [{ text: 'CC-BY' }],
252+
extras: {
253+
MD_LegalConstraintsOtherConstraintsObject: [
254+
{ default: 'CC-BY', langger: 'CC-BY' },
255+
],
256+
},
257+
})
198258
})
199259
it('isHarvested - should return a function that correctly maps the field', () => {
200260
const fieldName = 'isHarvested'
@@ -216,6 +276,60 @@ describe('Gn4FieldMapper', () => {
216276
const result = mappingFn(output, source)
217277
expect(result).toEqual({ extras: { edit: true } })
218278
})
279+
it('linkProtocol - should return a function that stores protocols in extras', () => {
280+
const fieldName = 'linkProtocol'
281+
const mappingFn = service.getMappingFn(fieldName)
282+
const output = {}
283+
const source = {
284+
linkProtocol: ['MAP:Preview', 'OGC:WMS', 'WWW:DOWNLOAD-URL'],
285+
}
286+
const result = mappingFn(output, source)
287+
expect(result).toEqual({
288+
extras: {
289+
linkProtocol: ['MAP:Preview', 'OGC:WMS', 'WWW:DOWNLOAD-URL'],
290+
},
291+
})
292+
})
293+
it('format - should return a function that stores formats in extras', () => {
294+
const fieldName = 'format'
295+
const mappingFn = service.getMappingFn(fieldName)
296+
const output = {}
297+
const source = {
298+
format: ['ESRI Shapefile (SHP)', 'GeoJSON'],
299+
}
300+
const result = mappingFn(output, source)
301+
expect(result).toEqual({
302+
extras: {
303+
format: ['ESRI Shapefile (SHP)', 'GeoJSON'],
304+
},
305+
})
306+
})
307+
it('featureTypes - should return a function that stores featureTypes in extras', () => {
308+
const fieldName = 'featureTypes'
309+
const mappingFn = service.getMappingFn(fieldName)
310+
const output = {}
311+
const source = {
312+
featureTypes: [
313+
{
314+
typeName: 'Bornes parcellaires',
315+
definition: '',
316+
attributeTable: [{ name: 'ID', type: 'string' }],
317+
},
318+
],
319+
}
320+
const result = mappingFn(output, source)
321+
expect(result).toEqual({
322+
extras: {
323+
featureTypes: [
324+
{
325+
typeName: 'Bornes parcellaires',
326+
definition: '',
327+
attributeTable: [{ name: 'ID', type: 'string' }],
328+
},
329+
],
330+
},
331+
})
332+
})
219333
it('languages - should return a list of languages even with unsupported ones and without defaultLang', () => {
220334
const fieldName = 'otherLanguage'
221335
const mappingFn = service.getMappingFn(fieldName)

libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,16 @@ export class Gn4FieldMapper {
247247
onlineResources,
248248
} as CatalogRecord
249249
},
250+
linkProtocol: (output, source) =>
251+
this.addExtra(
252+
{ linkProtocol: getAsArray(selectField(source, 'linkProtocol')) },
253+
output
254+
),
255+
format: (output, source) =>
256+
this.addExtra(
257+
{ format: getAsArray(selectField(source, 'format')) },
258+
output
259+
),
250260
contact: (output, source) => ({
251261
...output,
252262
contacts: [

libs/api/repository/src/lib/gn4/elasticsearch/constant.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export const ES_SOURCE_SUMMARY = [
99
'logo',
1010
'link',
1111
'linkProtocol',
12+
'format',
13+
'featureTypes',
1214
'contactForResource*.organisation*',
1315
'contact*.organisation*',
1416
'contact*.email',

0 commit comments

Comments
 (0)