Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Datahub] Feature catalog - Load attributes description from a linked record if present #1137

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

AlitaBernachot
Copy link
Collaborator

@AlitaBernachot AlitaBernachot commented Feb 26, 2025

Description

This PR introduces feature catalog. It is a first technical step to load a feature catalog in the record before displaying it in a record page.
Attributes from a feature catalog can be retrieve in two different ways:

  • Case 1: the feature catalog is already embedded in the record definition returned by Elastic Search, it will appear in the featureTypes property
  • Case 2: the feature catalog is present, but in a linked record, in this case the linked record will appear in the related.fcats property: in this case we will store the linked record uuid as property (featureCatalogIdentifier) and will load (getRecord()) its definition to get its own featureTypes

Thanks @Guillaume-d-o for your work on this PR.

💡 Example of a record with a linked feature catalog (for Case 2)

curl -X POST "https://geonetwork-ui.labs.camptocamp.com/geonetwork/srv/api/search/records/_search?bucket=bucket&relatedType=fcats" -H "accept: application/json" -H "Content-Type: application/json" -H "X-XSRF-TOKEN: b8a9b3ae-fe1c-466a-bb9f-9aff3a959b7e" -d "{\"query\":{\"ids\":{\"values\":[\"IGNF_BD-TOPO\"]}}}"

Architectural changes

New mappers were added to load featureTypes and get the featureCatalogIdentifier.

Screenshots

No UI

Quality Assurance Checklist

  • Commit history is devoid of any merge commits and readable to facilitate reviews
  • If new logic ⚙️ is introduced: unit tests were added
  • If new user stories 🤏 are introduced: E2E tests were added
  • If new UI components 🕹️ are introduced: corresponding stories in Storybook were created
  • If breaking changes 🪚 are introduced: add the breaking change label
  • If bugs 🐞 are fixed: add the backport <release branch> label
  • The documentation website 📚 has received the love it deserves

Copy link
Contributor

github-actions bot commented Feb 26, 2025

Affected libs:
api-metadata-converter,api-repository,feature-catalog,feature-record,feature-router,feature-editor,feature-search,feature-map,feature-auth,ui-search,common-domain,common-fixtures,feature-dataviz,ui-elements,feature-notifications,ui-catalog,util-shared,ui-widgets,ui-dataviz,ui-inputs,ui-layout,ui-map

Affected apps:
metadata-converter,metadata-editor,datahub,demo,webcomponents,map-viewer,search,datafeeder,data-platform

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

@AlitaBernachot AlitaBernachot force-pushed the GSIGNGPF-38-feat-cat-linked-record branch from 0451715 to e54e85e Compare February 27, 2025 14:16
Copy link
Contributor

github-actions bot commented Feb 27, 2025

📷 Screenshots are here!

@AlitaBernachot AlitaBernachot force-pushed the GSIGNGPF-38-feat-cat-linked-record branch 8 times, most recently from 97caf72 to 6909b57 Compare February 27, 2025 17:45
@@ -28,6 +29,21 @@ export const loadFullMetadataFailure = createAction(
props<{ otherError?: string; notFound?: boolean }>()
)

export const loadFeatureCatalog = createAction(
Copy link
Collaborator

@Guillaume-d-o Guillaume-d-o Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahow says : need to be tested (not action but effects, facade, reducer .. )

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test on action done previously

@@ -2642,6 +2643,7 @@ describe('Gn4Converter', () => {
extras: {
catalogUuid: 'metawal.wallonie.be',
favoriteCount: 0,
featureTypes: [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahow says : is there a way to get a test to show that this takes in the correct value? e.g. by changing the mock values used as input?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i understand well we tested this in the gn4 repository by checking featureType has some elements no ?

@AlitaBernachot AlitaBernachot marked this pull request as ready for review March 4, 2025 08:35
@coveralls
Copy link

coveralls commented Mar 4, 2025

Coverage Status

coverage: 83.817% (+0.9%) from 82.949%
when pulling 75aaeb4 on GSIGNGPF-38-feat-cat-linked-record
into da7bc31 on main.

@AlitaBernachot AlitaBernachot force-pushed the GSIGNGPF-38-feat-cat-linked-record branch from d9bdc0a to f98e22f Compare March 4, 2025 15:13
@@ -2642,6 +2643,7 @@ describe('Gn4Converter', () => {
extras: {
catalogUuid: 'metawal.wallonie.be',
favoriteCount: 0,
featureTypes: [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i understand well we tested this in the gn4 repository by checking featureType has some elements no ?

)
}

return of(null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahow comments : keep the "happy path" on the left by checking the null return condition first , then the non null condition after

Copy link
Collaborator Author

@AlitaBernachot AlitaBernachot Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI can't apply comment suggestion as this function has evolved, there is no more test on decodeMap.

/**
* FeatureCatalog
*/
loadFeatureCatalog(metadata: CatalogRecord) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahow cmments : we should not need this on the facade because loading the attributes will not be required by the components; instead, an effect in the state should do it

@@ -17,13 +18,18 @@ export interface MetadataViewState {
allUserFeedbacksLoading: boolean
addUserFeedbackLoading: boolean
chartConfig?: DatavizConfigurationModel
featureCatalog?: DatasetFeatureCatalog
featureCatalogLoading: boolean
featureCatalogError: { notFound?: boolean; otherError?: string } | null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahow comments : I think it'd make sense to have a separate error for the feature catalog loading; this error can only be a string because in the case of feature catalogs it's OK to not find any

Alita, does the notFound necessary ?

@@ -52,6 +52,11 @@ export class MdViewFacade {
filter((md) => !!md)
)

featureCatalog$ = this.store.pipe(
select(MdViewSelectors.getFeatureCatalog),
filter((fc) => !!fc)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahow comments : I would remove the filter here as it can be misleading for a consumer of this stream; e.g. if no feature catalog was found, this stream would never emit a value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -33,6 +32,31 @@ export class MdViewEffects {
)
)

loadFeatureCatalog$ = createEffect(() =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahow comments :
Here I would add an additional effect that emits a loadFeatureCatalogAttributes action when a loadFullMetadataSuccess action is received; this way the loading of the feature catalog will be done automatically when a full record is available, and then repository.getFeatureCatalog(record) can be called

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahow finally we keept only the loadFeatureCatalog associated to the full metadata loading action as long as there might be a associated effects to feature loading. Are you ok with this behavior ?

)
)
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jahow says : need tests

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test done

@AlitaBernachot AlitaBernachot force-pushed the GSIGNGPF-38-feat-cat-linked-record branch from 9e34c0d to b25a6d9 Compare March 6, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants