Skip to content

Relations / Remove unused table and use feature catalogue citation - #9442

Open
juanluisrp wants to merge 3 commits into
geonetwork:mainfrom
GeoCat:relations-table-removal
Open

Relations / Remove unused table and use feature catalogue citation#9442
juanluisrp wants to merge 3 commits into
geonetwork:mainfrom
GeoCat:relations-table-removal

Conversation

@juanluisrp

@juanluisrp juanluisrp commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Overview

The Relations table was only populated by MEF import (to record a metadata → feature catalogue link) and read back by the deprecated relations service and the legacy related type of the related records API. That association is already carried in the metadata itself through the feature catalogue citation, which is what the rest of the catalogue uses, so the table is redundant. This PR removes the entity and code around it, and derives the feature catalogue link from the citation instead.

Changes

  • Remove the MetadataRelation entity, its repository, specification, entity listener, and the deprecated services/relations service (Get/Insert/Remove), plus their tests.
  • Add a migration (v4413) that stops managing the Relations table. The table is left in the database as-is, unmapped and unused by the application, so its historical data stays available if ever needed; fresh installs never get the table at all, since it is no longer backed by an entity.
  • MEF export: resolve the associated feature catalogue from the metadata citation (AssociatedResourcesSchemaPlugin.getAssociatedFeatureCatalogueUUIDs) and write the referenced feature catalogue record into the applschema/ folder, included according to the current user's view privileges. Previously the exporter wrote the main record into applschema/ instead of the feature catalogue; that is now correct. Selection is deterministic when several feature catalogues are cited.
  • MEF import: no longer writes a relation row. The imported feature catalogue now inherits the categories and privileges of its parent record (previously left unset).
  • The deprecated related type of the related records API now returns feature catalogues from the index (hasfeaturecats) only.

Notes

  • The MEF file format (the applschema/ folder convention) is unchanged.
  • The deprecated related response element is no longer emitted; the UI and formatters do not depend on it (they use the associated-resources / fcats / hasfeaturecats paths).
  • The Relations table is intentionally not dropped by the migration. It was never kept in sync with metadata updates or deletes, so its content is of uncertain reliability, but leaving it in place preserves the option to recover from it if needed.

Testing

  • mvn clean install -DskipTests builds cleanly.
  • Integration tests (with Elasticsearch running):
    • MEFLibIntegrationTest — covers MEF v2 import with a related feature catalogue inheriting categories and privileges.
    • MEFExporterIntegrationTest.
    • MetadataAssociatedApiTest — covers exporting a record whose cited feature catalogue is written into applschema/.

@juanluisrp juanluisrp added bug db change Indicate that this work introduces a db structure change. changelog labels Jul 21, 2026
@juanluisrp juanluisrp added this to the 4.4.13 milestone Jul 21, 2026

@josegar74 josegar74 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@juanluisrp looks fine, added some small code improvements

juanluisrp and others added 2 commits July 23, 2026 13:14
The Relations table was only written by MEF import (to record a
metadata to feature catalogue link) and read back by the deprecated
relations service and the legacy "related" type of the related records
API. The feature catalogue association is already expressed in the
metadata through the feature catalogue citation, which is what the rest
of the catalogue relies on, so the table is redundant.

Remove the MetadataRelation entity, its repository, specification,
entity listener and the deprecated relations service, and add a
migration to drop the table.

MEF export now resolves the associated feature catalogue from the
metadata citation (AssociatedResourcesSchemaPlugin) and writes the
referenced feature catalogue record into the applschema folder,
including it according to the current user's view privileges. When a
record cites several feature catalogues the selection is deterministic.

MEF import no longer writes a relation row; the imported feature
catalogue instead inherits the categories and privileges of its parent
record.

The deprecated "related" type of the related records API now returns
feature catalogues from the index only.
@juanluisrp
juanluisrp force-pushed the relations-table-removal branch from 07c6361 to b2b1997 Compare July 23, 2026 11:14
The migration was dropping the Relations table now that the
MetadataRelation entity and its repository are gone. The table was
never kept in sync with metadata updates or deletes, so its content is
of uncertain reliability, but dropping it outright leaves no way to
recover anything from it during the upgrade window.

Leave the table in the database, unmapped and unused by the
application, so its historical data stays available if ever needed.
Fresh installs never get the table at all, since it is no longer
backed by an entity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug changelog db change Indicate that this work introduces a db structure change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants