geonetwork-ui 2.11.0-dev.cf22e64cf → 2.11.0-dev.d02d7f3f8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/fesm2022/geonetwork-ui.mjs +817 -302
  2. package/fesm2022/geonetwork-ui.mjs.map +1 -1
  3. package/index.d.ts +177 -46
  4. package/index.d.ts.map +1 -1
  5. package/package.json +6 -5
  6. package/src/libs/api/metadata-converter/src/lib/dcat-ap/dcat-ap.converter.ts +2 -0
  7. package/src/libs/api/metadata-converter/src/lib/fixtures/mel.records.dataset+featurecatalog.ts +395 -0
  8. package/src/libs/api/metadata-converter/src/lib/gn4/gn4.field.mapper.ts +35 -8
  9. package/src/libs/api/metadata-converter/src/lib/gn4/types/metadata.model.ts +19 -0
  10. package/src/libs/api/metadata-converter/src/lib/iso19115-3/iso19115-3.converter.ts +17 -6
  11. package/src/libs/api/metadata-converter/src/lib/iso19115-3/read-parts.ts +110 -0
  12. package/src/libs/api/metadata-converter/src/lib/iso19115-3/write-parts.ts +131 -0
  13. package/src/libs/api/metadata-converter/src/lib/iso19139/iso19139.converter.ts +9 -0
  14. package/src/libs/api/metadata-converter/src/lib/iso19139/read-parts.ts +2 -1
  15. package/src/libs/api/repository/src/lib/gn4/elasticsearch/constant.ts +4 -0
  16. package/src/libs/api/repository/src/lib/gn4/elasticsearch/elasticsearch.service.ts +57 -24
  17. package/src/libs/api/repository/src/lib/gn4/gn4-repository.ts +82 -35
  18. package/src/libs/api/repository/src/lib/gn4/platform/gn4-platform.service.ts +11 -0
  19. package/src/libs/common/domain/src/lib/model/record/flags.model.ts +1 -0
  20. package/src/libs/common/domain/src/lib/model/record/index.ts +1 -0
  21. package/src/libs/common/domain/src/lib/model/record/metadata.model.ts +14 -18
  22. package/src/libs/common/domain/src/lib/model/search/aggregation.model.ts +2 -0
  23. package/src/libs/common/domain/src/lib/platform.service.interface.ts +1 -0
  24. package/src/libs/common/domain/src/lib/repository/records-repository.interface.ts +20 -1
  25. package/src/libs/common/fixtures/src/lib/records.fixtures.ts +42 -62
  26. package/src/libs/feature/dataviz/src/lib/service/data.service.ts +32 -19
  27. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-constraints/form-field-constraints.component.ts +3 -5
  28. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-contacts/form-field-contacts.component.ts +2 -2
  29. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.css +0 -0
  30. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.html +18 -0
  31. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field-record-flags/form-field-record-flag-component.ts +86 -0
  32. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.html +100 -88
  33. package/src/libs/feature/editor/src/lib/components/record-form/form-field/form-field.component.ts +11 -4
  34. package/src/libs/feature/editor/src/lib/components/record-form/record-form.component.ts +18 -4
  35. package/src/libs/feature/editor/src/lib/expressions.ts +67 -0
  36. package/src/libs/feature/editor/src/lib/fields.config.ts +13 -0
  37. package/src/libs/feature/editor/src/lib/models/editor-config.model.ts +10 -4
  38. package/src/libs/feature/record/src/lib/state/mdview.effects.ts +3 -1
  39. package/src/libs/feature/record/src/lib/state/mdview.facade.ts +1 -1
  40. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.html +7 -1
  41. package/src/libs/feature/search/src/lib/filter-dropdown/filter-dropdown.component.ts +18 -1
  42. package/src/libs/feature/search/src/lib/geocoding/geocoding.service.ts +41 -2
  43. package/src/libs/feature/search/src/lib/location-search/location-search.component.html +11 -1
  44. package/src/libs/feature/search/src/lib/location-search/location-search.component.ts +77 -3
  45. package/src/libs/feature/search/src/lib/utils/service/fields.service.ts +50 -4
  46. package/src/libs/feature/search/src/lib/utils/service/fields.ts +35 -10
  47. package/src/libs/ui/elements/src/lib/kind-badge/kind-badge.component.html +5 -1
  48. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.html +3 -3
  49. package/src/libs/ui/elements/src/lib/record-feature-catalog/feature-catalog-list/feature-catalog-list.component.ts +2 -2
  50. package/src/libs/ui/elements/src/lib/thumbnail/thumbnail.component.html +1 -1
  51. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.css +0 -4
  52. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.html +2 -2
  53. package/src/libs/ui/inputs/src/lib/autocomplete/autocomplete.component.ts +3 -3
  54. package/src/libs/ui/inputs/src/lib/inline-filter/inline-filter.component.html +6 -11
  55. package/src/libs/ui/inputs/src/lib/search-feature-catalog/search-feature-catalog.component.ts +2 -1
  56. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.html +7 -1
  57. package/src/libs/ui/inputs/src/lib/spatial-extent-dropdown/spatial-extent-dropdown.component.ts +26 -3
  58. package/src/libs/ui/search/src/lib/results-hits-number/results-hits-number.component.html +1 -0
  59. package/src/libs/util/app-config/src/index.ts +1 -0
  60. package/src/libs/util/app-config/src/lib/app-config.ts +338 -270
  61. package/src/libs/util/app-config/src/lib/fixtures.ts +21 -0
  62. package/src/libs/util/app-config/src/lib/model.ts +30 -3
  63. package/src/libs/util/app-config/src/lib/parse-utils.ts +8 -4
  64. package/src/libs/util/shared/src/lib/utils/geojson.ts +21 -10
  65. package/translations/de.json +10 -2
  66. package/translations/en.json +10 -2
  67. package/translations/es.json +10 -2
  68. package/translations/fr.json +11 -3
  69. package/translations/it.json +10 -2
  70. package/translations/nl.json +10 -2
  71. package/translations/pt.json +10 -2
  72. package/translations/sk.json +10 -2
@@ -1,5 +1,8 @@
1
1
  import {
2
2
  CatalogRecord,
3
+ DatasetFeatureAttribute,
4
+ DatasetFeatureAttributeValue,
5
+ DatasetFeatureType,
3
6
  DatasetRecord,
4
7
  Individual,
5
8
  LanguageCode,
@@ -616,3 +619,131 @@ export function writeAssociatedRecords(
616
619
  )
617
620
  )(rootEl)
618
621
  }
622
+
623
+ function createNilElement(name: string, nilReason: string) {
624
+ return pipe(createElement(name), writeAttribute('gco:nilReason', nilReason))
625
+ }
626
+
627
+ function createFeatureCatalogueShell() {
628
+ return pipe(
629
+ createNestedElement(
630
+ 'mdb:contentInfo',
631
+ 'mrc:MD_FeatureCatalogue',
632
+ 'mrc:featureCatalogue',
633
+ 'gfc:FC_FeatureCatalogue'
634
+ ),
635
+ // create mandatory elements which are not part of the model yet
636
+ appendChildren(
637
+ createNilElement('cat:name', 'missing'),
638
+ createNilElement('cat:scope', 'missing'),
639
+ createNilElement('cat:versionNumber', 'missing'),
640
+ createNilElement('cat:versionDate', 'missing'),
641
+ createNilElement('gfc:producer', 'missing')
642
+ )
643
+ )
644
+ }
645
+
646
+ function createListedValue(value: DatasetFeatureAttributeValue) {
647
+ return pipe(
648
+ createNestedElement('gfc:listedValue', 'gfc:FC_ListedValue'),
649
+ appendChildren(
650
+ value.label
651
+ ? pipe(createElement('gfc:label'), writeCharacterString(value.label))
652
+ : createNilElement('gfc:label', 'missing'),
653
+ value.value
654
+ ? pipe(createElement('gfc:code'), writeCharacterString(value.value))
655
+ : null,
656
+ value.description
657
+ ? pipe(
658
+ createElement('gfc:definition'),
659
+ writeCharacterString(value.description)
660
+ )
661
+ : null
662
+ )
663
+ )
664
+ }
665
+
666
+ function createFeatureAttribute(attribute: DatasetFeatureAttribute) {
667
+ return pipe(
668
+ createNestedElement(
669
+ 'gfc:carrierOfCharacteristics',
670
+ 'gfc:FC_FeatureAttribute'
671
+ ),
672
+ appendChildren(
673
+ pipe(createElement('gfc:memberName'), setTextContent(attribute.name)),
674
+ attribute.description
675
+ ? pipe(
676
+ createElement('gfc:definition'),
677
+ writeCharacterString(attribute.description)
678
+ )
679
+ : null,
680
+ createNilElement('gfc:cardinality', 'missing'),
681
+ attribute.label
682
+ ? pipe(
683
+ createElement('gfc:designation'),
684
+ writeCharacterString(attribute.label)
685
+ )
686
+ : null,
687
+ attribute.code
688
+ ? pipe(createElement('gfc:code'), writeCharacterString(attribute.code))
689
+ : null,
690
+ attribute.type
691
+ ? pipe(
692
+ createNestedElement('gfc:valueType', 'gco:TypeName', 'gco:aName'),
693
+ writeCharacterString(attribute.type)
694
+ )
695
+ : null,
696
+ ...(attribute.values ?? [])
697
+ .filter((value) => value.value || value.label)
698
+ .map(createListedValue)
699
+ )
700
+ )
701
+ }
702
+
703
+ function createFeatureType(featureType: DatasetFeatureType) {
704
+ return pipe(
705
+ createNestedElement('gfc:featureType', 'gfc:FC_FeatureType'),
706
+ appendChildren(
707
+ pipe(createElement('gfc:typeName'), setTextContent(featureType.name)),
708
+ featureType.description
709
+ ? pipe(
710
+ createElement('gfc:definition'),
711
+ writeCharacterString(featureType.description)
712
+ )
713
+ : null,
714
+ pipe(
715
+ createNestedElement('gfc:isAbstract', 'gco:Boolean'),
716
+ setTextContent('false')
717
+ ),
718
+ featureType.label
719
+ ? pipe(
720
+ createElement('gfc:designation'),
721
+ writeCharacterString(featureType.label)
722
+ )
723
+ : null,
724
+ ...featureType.attributes.map(createFeatureAttribute),
725
+ createNilElement('gfc:featureCatalogue', 'missing')
726
+ )
727
+ )
728
+ }
729
+
730
+ export function writeFeatureTypeDescriptions(
731
+ record: DatasetRecord,
732
+ rootEl: XmlElement
733
+ ) {
734
+ const featureTypes = record.featureTypeDescriptions ?? []
735
+ const catalogues = findNestedElements(
736
+ 'mdb:contentInfo',
737
+ 'mrc:MD_FeatureCatalogue',
738
+ 'mrc:featureCatalogue',
739
+ 'gfc:FC_FeatureCatalogue'
740
+ )(rootEl)
741
+ catalogues.forEach((catalogue) =>
742
+ removeChildrenByName('gfc:featureType')(catalogue)
743
+ )
744
+ if (!featureTypes.length) return
745
+
746
+ const catalogue =
747
+ catalogues[0] ?? appendChildTree(createFeatureCatalogueShell())(rootEl)
748
+ appendChildren(...featureTypes.map(createFeatureType))(catalogue)
749
+ }
@@ -118,6 +118,7 @@ export class Iso19139Converter extends BaseConverter<string> {
118
118
  lineage: readLineage,
119
119
  sourceRecords: readSourceRecords,
120
120
  associatedRecords: readAssociatedRecords,
121
+ featureTypeDescriptions: () => undefined,
121
122
  onlineResources: readOnlineResources,
122
123
  temporalExtents: readTemporalExtents,
123
124
  spatialExtents: readSpatialExtents,
@@ -161,6 +162,7 @@ export class Iso19139Converter extends BaseConverter<string> {
161
162
  lineage: writeLineage,
162
163
  sourceRecords: writeSourceRecords,
163
164
  associatedRecords: writeAssociatedRecords,
165
+ featureTypeDescriptions: () => undefined,
164
166
  onlineResources: writeOnlineResources,
165
167
  temporalExtents: writeTemporalExtents,
166
168
  spatialExtents: writeSpatialExtents,
@@ -306,6 +308,10 @@ export class Iso19139Converter extends BaseConverter<string> {
306
308
  const sourceRecords = this.readers['sourceRecords'](rootEl, tr)
307
309
  const associatedRecords = this.readers['associatedRecords'](rootEl, tr)
308
310
  const updateFrequency = this.readers['updateFrequency'](rootEl, tr)
311
+ const featureTypeDescriptions = this.readers['featureTypeDescriptions'](
312
+ rootEl,
313
+ tr
314
+ ) as DatasetRecord['featureTypeDescriptions']
309
315
 
310
316
  return this.afterRecordRead({
311
317
  ...this.readBaseRecord(rootEl, tr),
@@ -317,6 +323,7 @@ export class Iso19139Converter extends BaseConverter<string> {
317
323
  ...(spatialRepresentation && { spatialRepresentation }),
318
324
  temporalExtents,
319
325
  updateFrequency,
326
+ ...(featureTypeDescriptions?.length && { featureTypeDescriptions }),
320
327
  translations: tr,
321
328
  } as DatasetRecord)
322
329
  } else if (kind === 'reuse') {
@@ -416,6 +423,8 @@ export class Iso19139Converter extends BaseConverter<string> {
416
423
 
417
424
  if (record.kind === 'dataset') {
418
425
  fieldChanged('status') && this.writers['status'](record, rootEl)
426
+ fieldChanged('featureTypeDescriptions') &&
427
+ this.writers['featureTypeDescriptions'](record, rootEl)
419
428
  }
420
429
  if (record.kind === 'dataset' || record.kind === 'reuse') {
421
430
  fieldChanged('updateFrequency') &&
@@ -69,7 +69,8 @@ export function extractCharacterString(): ChainableFunction<
69
69
  fallback(
70
70
  findChildElement('gco:CharacterString', false),
71
71
  findChildElement('gmx:Anchor', false),
72
- findChildElement('gmx:MimeFileType', false)
72
+ findChildElement('gmx:MimeFileType', false),
73
+ findChildElement('gco:LocalName', false)
73
74
  ),
74
75
  readText()
75
76
  )
@@ -31,3 +31,7 @@ export const ES_QUERY_FIELDS_PRIORITY = {
31
31
  'any.${searchLang}': 1,
32
32
  uuid: 1,
33
33
  }
34
+
35
+ // This prefix is part of the category names stored in GeoNetwork: changing it
36
+ // would silently drop the flags already set on existing catalogs.
37
+ export const RECORD_FLAG_CATEGORY_PREFIX = 'geonetwork-ui-flag:'
@@ -4,6 +4,7 @@ import {
4
4
  ES_QUERY_FIELDS_PRIORITY,
5
5
  ES_SOURCE_SUMMARY,
6
6
  EsQueryFieldsPriorityType,
7
+ RECORD_FLAG_CATEGORY_PREFIX,
7
8
  } from './constant'
8
9
  import {
9
10
  Aggregation,
@@ -35,7 +36,7 @@ import {
35
36
  } from '../../../../../../../libs/common/domain/src/lib/model/record'
36
37
  import { TranslateService } from '@ngx-translate/core'
37
38
  import {
38
- bboxToPolygon,
39
+ bboxToGeometry,
39
40
  BoundingBox,
40
41
  getGeometryBoundingBox,
41
42
  isBoundingBox,
@@ -45,6 +46,8 @@ import { LineString } from 'ol/geom.js'
45
46
 
46
47
  export type DateRange = { start?: Date; end?: Date }
47
48
 
49
+ export const REFERENCE_DATASET_BOOST = 5
50
+
48
51
  @Injectable({
49
52
  providedIn: 'root',
50
53
  })
@@ -59,6 +62,8 @@ export class ElasticsearchService {
59
62
  { script: string; type: 'keyword' | 'date' }
60
63
  > = {}
61
64
 
65
+ private fieldAliases: Record<string, string> = {}
66
+
62
67
  // we're using getters in case the defined languages change over time
63
68
  private get metadataLang(): LanguageCode {
64
69
  const mdLangValue = this.injector.get(METADATA_LANGUAGE, null)
@@ -155,6 +160,10 @@ export class ElasticsearchService {
155
160
  this.runtimeFields[fieldName] = { script: expression, type }
156
161
  }
157
162
 
163
+ registerFieldAlias(fieldIdentifier: string, esFieldName: string) {
164
+ this.fieldAliases[fieldIdentifier] = esFieldName
165
+ }
166
+
158
167
  getMetadataByIdsPayload(uuids: string[]): EsSearchParams {
159
168
  return {
160
169
  query: {
@@ -375,7 +384,8 @@ export class ElasticsearchService {
375
384
  JSON.stringify(filters[fieldname]) !== '{}'
376
385
  )
377
386
  .map(
378
- (fieldname) => `${fieldname}:(${makeQuery(filters[fieldname])})`
387
+ (fieldname) =>
388
+ `${this.fieldAliases[fieldname] ?? fieldname}:(${makeQuery(filters[fieldname])})`
379
389
  )
380
390
  .join(' AND ')
381
391
  if (filters['gn-ui-crossFieldFilter']) {
@@ -431,7 +441,18 @@ export class ElasticsearchService {
431
441
  ) {
432
442
  const must = [] as Record<string, unknown>[]
433
443
  const must_not = this.mustNotFilters()
434
- const should = [] as Record<string, unknown>[]
444
+ const should = [
445
+ {
446
+ constant_score: {
447
+ filter: {
448
+ term: {
449
+ 'cat.keyword': `${RECORD_FLAG_CATEGORY_PREFIX}IS_REFERENCE_DATASET`,
450
+ },
451
+ },
452
+ boost: REFERENCE_DATASET_BOOST,
453
+ },
454
+ },
455
+ ] as Record<string, unknown>[]
435
456
  const filter = [this.queryFilterOnValues('isTemplate', 'n')] as Record<
436
457
  string,
437
458
  unknown
@@ -463,7 +484,7 @@ export class ElasticsearchService {
463
484
  })
464
485
  }
465
486
  const boostGeometry = spatialFilterExtent
466
- ? bboxToPolygon(spatialFilterExtent)
487
+ ? bboxToGeometry(spatialFilterExtent)
467
488
  : geometry
468
489
  if (boostGeometry) {
469
490
  // boosts applied using the filter geometry:
@@ -471,8 +492,11 @@ export class ElasticsearchService {
471
492
  // * records intersecting the geometry receive a boost of 2
472
493
  // * records close to the geometry center receive a boost of 5 (based on the `location` field)
473
494
  // * records on the outskirt of the geometry receive a boost of 2.5
474
- should.push(
475
- {
495
+ if (
496
+ boostGeometry.type === 'Polygon' ||
497
+ boostGeometry.type === 'MultiPolygon'
498
+ ) {
499
+ should.push({
476
500
  geo_shape: {
477
501
  geom: {
478
502
  shape: boostGeometry,
@@ -480,17 +504,17 @@ export class ElasticsearchService {
480
504
  },
481
505
  boost: 5.0,
482
506
  },
483
- },
484
- {
485
- geo_shape: {
486
- geom: {
487
- shape: boostGeometry,
488
- relation: 'intersects',
489
- },
490
- boost: 2.0,
507
+ })
508
+ }
509
+ should.push({
510
+ geo_shape: {
511
+ geom: {
512
+ shape: boostGeometry,
513
+ relation: 'intersects',
491
514
  },
492
- }
493
- )
515
+ boost: 2.0,
516
+ },
517
+ })
494
518
 
495
519
  // this will boost the results variably depending on their distance from the given geometry
496
520
  // note: this takes into account the `location` field of a record; this is generally the center of all spatial extents
@@ -521,15 +545,18 @@ export class ElasticsearchService {
521
545
  getGeodesicLength(westToCenter) +
522
546
  getGeodesicLength(eastToCenter)) /
523
547
  4
548
+ const pivot = Math.round(cutoffDistance)
524
549
 
525
- should.push({
526
- distance_feature: {
527
- field: 'location',
528
- pivot: `${Math.round(cutoffDistance).toFixed(0)}m`,
529
- origin: center,
530
- boost: 5.0,
531
- },
532
- })
550
+ if (pivot > 0) {
551
+ should.push({
552
+ distance_feature: {
553
+ field: 'location',
554
+ pivot: `${pivot.toFixed(0)}m`,
555
+ origin: center,
556
+ boost: 5.0,
557
+ },
558
+ })
559
+ }
533
560
  }
534
561
 
535
562
  return {
@@ -721,6 +748,12 @@ export class ElasticsearchService {
721
748
  order: {
722
749
  [`_${aggregation.sort[1]}`]: aggregation.sort[0],
723
750
  },
751
+ ...(aggregation.includeValues && {
752
+ include: aggregation.includeValues,
753
+ }),
754
+ ...(aggregation.excludeValues && {
755
+ exclude: aggregation.excludeValues,
756
+ }),
724
757
  },
725
758
  }
726
759
  case 'histogram':
@@ -17,9 +17,9 @@ import {
17
17
  AssociatedRecord,
18
18
  CatalogRecord,
19
19
  DatasetFeatureCatalog,
20
- DatasetFeatureType,
21
20
  LanguageCode,
22
21
  LinkedRecord,
22
+ RecordFlag,
23
23
  RecordRelation,
24
24
  } from '../../../../../../libs/common/domain/src/lib/model/record'
25
25
  import {
@@ -37,6 +37,7 @@ import {
37
37
  LanguagesApiService,
38
38
  RecordsApiService,
39
39
  SearchApiService,
40
+ TagsApiService,
40
41
  } from '../../../../../../libs/data-access/gn4/src'
41
42
  import {
42
43
  combineLatest,
@@ -49,9 +50,10 @@ import {
49
50
  switchMap,
50
51
  throwError,
51
52
  } from 'rxjs'
52
- import { catchError, map, tap } from 'rxjs/operators'
53
+ import { catchError, map, shareReplay, tap } from 'rxjs/operators'
53
54
  import { lt } from 'semver'
54
55
  import { ElasticsearchService } from './elasticsearch'
56
+ import { RECORD_FLAG_CATEGORY_PREFIX } from './elasticsearch/constant'
55
57
  import { toLang2 } from '../../../../../../libs/util/i18n/src'
56
58
  import { Gn4SettingsService } from './settings/gn4-settings.service'
57
59
 
@@ -81,6 +83,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
81
83
  private platformService = inject(PlatformServiceInterface)
82
84
  private gn4LanguagesApi = inject(LanguagesApiService)
83
85
  private settingsService = inject(Gn4SettingsService)
86
+ private gn4TagsApi = inject(TagsApiService)
84
87
  private disableDraft = inject(DISABLE_DRAFT, { optional: true }) ?? false
85
88
  private defaultConverter = inject(DEFAULT_RECORD_CONVERTER)
86
89
 
@@ -182,43 +185,15 @@ export class Gn4Repository implements RecordsRepositoryInterface {
182
185
  )
183
186
  }
184
187
 
185
- private mapEmbeddedFeatureCatalog(
186
- featureTypes: Array<DatasetFeatureType>
187
- ): DatasetFeatureCatalog {
188
- return {
189
- featureTypes: featureTypes.map((featureType) => ({
190
- name: featureType.typeName || '',
191
- definition: featureType.definition || '',
192
- attributes: Array.isArray(featureType.attributeTable)
193
- ? featureType.attributeTable.map((attr) => {
194
- const values = attr.values
195
- ?.filter((v) => v.code || v.label)
196
- .map((v) => ({
197
- code: v.code,
198
- label: v.label,
199
- }))
200
- return {
201
- name: attr.name,
202
- code: attr.code,
203
- definition: attr.definition,
204
- type: attr.type,
205
- ...(values?.length > 0 ? { values } : {}),
206
- }
207
- })
208
- : [],
209
- })),
210
- }
211
- }
212
- getFeatureCatalog(
188
+ queryLinkedFeatureCatalog(
213
189
  record: CatalogRecord,
214
190
  visited: Set<string> = new Set() // prevent looping
215
191
  ): Observable<DatasetFeatureCatalog | null> {
216
192
  if (
217
- record.extras?.['featureTypes'] &&
218
- Array.isArray(record.extras['featureTypes']) &&
219
- record.extras['featureTypes'].length > 0
193
+ 'featureTypeDescriptions' in record &&
194
+ record.featureTypeDescriptions?.length > 0
220
195
  ) {
221
- return of(this.mapEmbeddedFeatureCatalog(record.extras['featureTypes']))
196
+ return of({ featureTypes: record.featureTypeDescriptions })
222
197
  }
223
198
 
224
199
  const featureCatalogIdentifier = record.extras[
@@ -228,7 +203,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
228
203
  visited.add(featureCatalogIdentifier)
229
204
  return this.getRecord(featureCatalogIdentifier).pipe(
230
205
  switchMap((record) =>
231
- record ? this.getFeatureCatalog(record, visited) : of(null)
206
+ record ? this.queryLinkedFeatureCatalog(record, visited) : of(null)
232
207
  )
233
208
  )
234
209
  }
@@ -704,4 +679,76 @@ export class Gn4Repository implements RecordsRepositoryInterface {
704
679
  private removeRecordFromLocalStorage(recordId: string): void {
705
680
  window.localStorage.removeItem(this.getLocalStorageKeyForRecord(recordId))
706
681
  }
682
+
683
+ /*
684
+ * FLAGS
685
+ * Note: in GN4 API, categories are named "tags"
686
+ */
687
+
688
+ categoriesIdentifierForFlags: Observable<Record<RecordFlag, number>> =
689
+ this.gn4TagsApi.getTags().pipe(
690
+ map((categories) =>
691
+ categories.reduce(
692
+ (acc, category) => {
693
+ if (category.name.startsWith(RECORD_FLAG_CATEGORY_PREFIX)) {
694
+ acc[
695
+ category.name.slice(
696
+ RECORD_FLAG_CATEGORY_PREFIX.length
697
+ ) as RecordFlag
698
+ ] = category.id
699
+ }
700
+ return acc
701
+ },
702
+ {} as Record<RecordFlag, number>
703
+ )
704
+ ),
705
+ shareReplay(1)
706
+ )
707
+
708
+ private getCategoryIdForFlag(
709
+ flagName: RecordFlag
710
+ ): Observable<number | null> {
711
+ return this.categoriesIdentifierForFlags.pipe(
712
+ map((categories) => {
713
+ const categoryId = categories[flagName]
714
+ if (categoryId === undefined) {
715
+ console.warn(
716
+ `The record flag ${flagName} is not created on GeoNetwork backend; please create a category with the name ${RECORD_FLAG_CATEGORY_PREFIX}${flagName} for this to work.`
717
+ )
718
+ return null
719
+ }
720
+ return categoryId
721
+ })
722
+ )
723
+ }
724
+
725
+ setRecordFlag(
726
+ uniqueIdentifier: string,
727
+ flagName: RecordFlag,
728
+ value: boolean
729
+ ): Observable<void> {
730
+ return this.getCategoryIdForFlag(flagName).pipe(
731
+ switchMap((categoryId) => {
732
+ if (categoryId === null) return of()
733
+ return value
734
+ ? this.gn4RecordsApi.tagRecord(uniqueIdentifier, [categoryId], false)
735
+ : this.gn4RecordsApi.deleteTags(uniqueIdentifier, [categoryId])
736
+ })
737
+ )
738
+ }
739
+
740
+ getRecordFlag(
741
+ uniqueIdentifier: string,
742
+ flagName: RecordFlag
743
+ ): Observable<boolean> {
744
+ return combineLatest([
745
+ this.getCategoryIdForFlag(flagName),
746
+ this.gn4RecordsApi.getRecordTags(uniqueIdentifier),
747
+ ]).pipe(
748
+ map(([categoryId, tags]) => {
749
+ if (categoryId === null) return false
750
+ return Array.from(tags).some((tag) => tag.id === categoryId)
751
+ })
752
+ )
753
+ }
707
754
  }
@@ -92,6 +92,13 @@ export class Gn4PlatformService implements PlatformServiceInterface {
92
92
  switchMap((apiUser) => this.mapper.userFromMeApi(apiUser)),
93
93
  shareReplay({ bufferSize: 1, refCount: true })
94
94
  )
95
+ private isAdmin$ = this.disableAuth
96
+ ? of(false)
97
+ : of(true).pipe(
98
+ switchMap(() => this.meApi.getMe()),
99
+ map((apiUser) => !!apiUser?.admin),
100
+ shareReplay({ bufferSize: 1, refCount: true })
101
+ )
95
102
 
96
103
  /**
97
104
  * A map of already loaded thesauri (groups of keywords); the key is a URI
@@ -146,6 +153,10 @@ export class Gn4PlatformService implements PlatformServiceInterface {
146
153
  return this.isUserAnonymous$
147
154
  }
148
155
 
156
+ isAdministrator(): Observable<boolean> {
157
+ return this.isAdmin$
158
+ }
159
+
149
160
  getOrganizations(): Observable<Organization[]> {
150
161
  return undefined
151
162
  }
@@ -0,0 +1 @@
1
+ export type RecordFlag = 'IS_REFERENCE_DATASET'
@@ -3,3 +3,4 @@ export * from './metadata.model'
3
3
  export * from './organization.model'
4
4
  export * from './translation.model'
5
5
  export * from './user-feedbacks.model'
6
+ export * from './flags.model'
@@ -316,6 +316,7 @@ export interface DatasetRecord extends BaseRecord {
316
316
  spatialExtents: Array<DatasetSpatialExtent>
317
317
  temporalExtents: Array<DatasetTemporalExtent>
318
318
  spatialRepresentation?: SpatialRepresentationType
319
+ featureTypeDescriptions?: Array<DatasetFeatureType>
319
320
  }
320
321
 
321
322
  export interface ServiceEndpoint {
@@ -347,33 +348,28 @@ export interface ReuseRecord extends BaseRecord {
347
348
  temporalExtents: Array<DatasetTemporalExtent>
348
349
  }
349
350
 
351
+ export interface DatasetFeatureType {
352
+ name: string
353
+ label?: string
354
+ description?: string
355
+ attributes: DatasetFeatureAttribute[]
356
+ }
350
357
  export type DatasetFeatureCatalog = {
351
- featureTypes: Array<{
352
- name: string
353
- definition: string
354
- attributes: DatasetFeatureAttribute[]
355
- }>
358
+ featureTypes: Array<DatasetFeatureType>
356
359
  }
357
360
  export interface DatasetFeatureAttributeValue {
358
- code?: string
359
- definition?: string
361
+ value: string // empty string when the value has no code
360
362
  label?: string
363
+ description?: string
361
364
  }
362
365
  export interface DatasetFeatureAttribute {
363
366
  name: string
364
- definition: string
365
- type: string
366
- code: string
367
+ label?: string
368
+ description?: string
369
+ type?: string
370
+ code?: string
367
371
  values?: Array<DatasetFeatureAttributeValue>
368
372
  }
369
- export interface DatasetFeatureType {
370
- aliases: string
371
- code: string
372
- isAbstract: string
373
- typeName: string
374
- definition: string
375
- attributeTable: Array<DatasetFeatureAttribute>
376
- }
377
373
 
378
374
  export type ReuseType = 'application' | 'map' | 'other'
379
375
 
@@ -7,6 +7,8 @@ export interface TermsAggregationParams {
7
7
  limit: number
8
8
  sort: AggregationSort
9
9
  filter?: string
10
+ includeValues?: string[]
11
+ excludeValues?: string[]
10
12
  }
11
13
  export interface HistogramAggregationParams {
12
14
  type: 'histogram'
@@ -28,6 +28,7 @@ export abstract class PlatformServiceInterface {
28
28
  abstract supportsAuthentication(): boolean
29
29
  abstract getMe(): Observable<UserModel>
30
30
  abstract isAnonymous(): Observable<boolean>
31
+ abstract isAdministrator(): Observable<boolean>
31
32
  abstract getUsers(): Observable<UserModel[]>
32
33
  abstract getUserPermissionsByGroup(): Observable<GroupModel[]>
33
34
  abstract getUsersByOrganization(
@@ -11,13 +11,14 @@ import {
11
11
  DatasetFeatureCatalog,
12
12
  LanguageCode,
13
13
  LinkedRecord,
14
+ RecordFlag,
14
15
  } from '../model/record'
15
16
 
16
17
  export abstract class RecordsRepositoryInterface {
17
18
  abstract search(params: SearchParams): Observable<SearchResults>
18
19
  abstract getMatchesCount(filters: FieldFilters): Observable<number>
19
20
  abstract getRecord(uniqueIdentifier: string): Observable<CatalogRecord | null>
20
- abstract getFeatureCatalog(
21
+ abstract queryLinkedFeatureCatalog(
21
22
  record: CatalogRecord
22
23
  ): Observable<DatasetFeatureCatalog | null>
23
24
  abstract aggregate(params: AggregationsParams): Observable<Aggregations>
@@ -106,4 +107,22 @@ export abstract class RecordsRepositoryInterface {
106
107
  ): Observable<{ user: string; date: Date }>
107
108
  abstract getRecordPublicationStatus(uuid: string): Observable<boolean>
108
109
  abstract getApplicationLanguages(): Observable<LanguageCode[]>
110
+
111
+ /**
112
+ * Sets a given flag on a record. Flags are not part of the metadata document, which is why they are
113
+ * not part of the Record model.
114
+ */
115
+ abstract setRecordFlag(
116
+ uniqueIdentifier: string,
117
+ flagName: RecordFlag,
118
+ value: boolean
119
+ ): Observable<void>
120
+
121
+ /**
122
+ * Checks whether a given flag is enabled for a record.
123
+ */
124
+ abstract getRecordFlag(
125
+ uniqueIdentifier: string,
126
+ flagName: RecordFlag
127
+ ): Observable<boolean>
109
128
  }