Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
AlitaBernachot committed Feb 26, 2025
1 parent 7f9c42f commit 0451715
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,9 @@ export interface Gn4Record {
featured?: boolean
guestdownload?: boolean
selected?: boolean
related?: Gn4RecordRelated
}

export interface Gn4RecordRelated {
fcats?: Gn4Record[]
}
61 changes: 42 additions & 19 deletions libs/api/repository/src/lib/gn4/gn4-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class Gn4Repository implements RecordsRepositoryInterface {
private gn4Mapper: Gn4Converter,
private gn4RecordsApi: RecordsApiService,
private platformService: PlatformServiceInterface
) {}
) { }

search({
filters,
Expand Down Expand Up @@ -141,25 +141,48 @@ export class Gn4Repository implements RecordsRepositoryInterface {
)
}

/**
* Retrieve the feature catalog (or attributes catalog) from a linked record.
* By default, returns extras.features from the record, otherwise call api again to get the "fcats".
* The GeoNetwork API support multiple feature catalogs, in that case, on the first one is read.
* @param metadataUuid The linked record indentifier
* @param approvedVersion
* @returns
*/
getFeatureCatalog(
metadataUuid: string,
approvedVersion?: boolean
record: CatalogRecord
): Observable<DatasetFeatureCatalog | null> {
return this.gn4RecordsApi
.getFeatureCatalog(metadataUuid, approvedVersion)
.pipe(
map((results: FeatureResponseApiModel) => {
if (results.decodeMap) {
const features = Object.keys(results.decodeMap).map((key) => {
const feature = results.decodeMap[key]
return { name: feature[0], title: feature[1] }
})
return { features } as DatasetFeatureCatalog
}
return null
}),
switchMap((record) => (record ? of(record) : of(null)))

if (false) {
// TODO:
// record extras.features
}

return this.gn4SearchApi.search('bucket', ['fcats'], JSON.stringify(
this.gn4SearchHelper.getMetadataByIdPayload(record.uniqueIdentifier)
)).pipe(
map((results: Gn4SearchResults) => results.hits.hits[0]),
switchMap((record) =>
record && record.related.fcats[0] ? this.getRecord(record.related.fcats[0]._id) : of(null)
)
)


// return this.gn4RecordsApi
// .getFeatureCatalog(metadataUuid, approvedVersion)
// .pipe(
// map((results: FeatureResponseApiModel) => {
// if (results.decodeMap) {
// const features = Object.keys(results.decodeMap).map((key) => {
// const feature = results.decodeMap[key]
// return { name: feature[0], title: feature[1] }
// })
// return { features } as DatasetFeatureCatalog
// }
// return null
// }),
// switchMap((record) => (record ? of(record) : of(null)))
// )
}

getSimilarRecords(similarTo: CatalogRecord): Observable<CatalogRecord[]> {
Expand Down Expand Up @@ -229,8 +252,8 @@ export class Gn4Repository implements RecordsRepositoryInterface {
getRecordPublicationStatus(uniqueIdentifier: string): Observable<boolean> {
return uniqueIdentifier
? this.getRecord(uniqueIdentifier).pipe(
map((record) => record.extras['isPublishedToAll'] as boolean)
)
map((record) => record.extras['isPublishedToAll'] as boolean)
)
: of(true)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ export abstract class RecordsRepositoryInterface {
abstract search(params: SearchParams): Observable<SearchResults>
abstract getMatchesCount(filters: FieldFilters): Observable<number>
abstract getRecord(uniqueIdentifier: string): Observable<CatalogRecord | null>
abstract getFeatureCatalog(
metadataUuid: string,
approvedVersion?: boolean
): Observable<DatasetFeatureCatalog | null>
abstract getFeatureCatalog(record: CatalogRecord): Observable<DatasetFeatureCatalog | null>
abstract aggregate(params: AggregationsParams): Observable<Aggregations>
abstract getSimilarRecords(
similarTo: CatalogRecord
Expand Down
6 changes: 5 additions & 1 deletion libs/feature/router/src/lib/default/state/router.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class RouterEffects {
private facade: RouterFacade,
@Inject(ROUTER_CONFIG) private routerConfig: RouterConfigModel,
private fieldsService: FieldsService
) {}
) { }

navigate$ = createEffect(
() =>
Expand Down Expand Up @@ -121,6 +121,10 @@ export class RouterEffects {
title: '',
},
}),
MdViewActions.loadFeatureCatalogAttributes({
metadataUuid: activatedRouteSnapshot.params.metadataUuid,
approvedVersion: false
}),
MdViewActions.loadFullMetadata({
uuid: activatedRouteSnapshot.params.metadataUuid,
})
Expand Down

0 comments on commit 0451715

Please sign in to comment.