From 276340011270973fbd1df9c781f6336755008309 Mon Sep 17 00:00:00 2001 From: Paul van Genuchten Date: Thu, 3 Oct 2024 13:27:38 +0200 Subject: [PATCH] add uri reference which is populated from dataseturi or uricode --- etc/mappings.py | 1 + pycsw/core/config.py | 1 + pycsw/core/metadata.py | 4 ++++ pycsw/core/repository.py | 1 + pycsw/ogc/api/records.py | 8 ++++++++ .../functionaltests/suites/cite/data/cite.db | Bin 315392 -> 315392 bytes 6 files changed, 15 insertions(+) diff --git a/etc/mappings.py b/etc/mappings.py index a394fb438..7ed8ef798 100644 --- a/etc/mappings.py +++ b/etc/mappings.py @@ -67,6 +67,7 @@ 'pycsw:OrganizationName': 'organization', 'pycsw:SecurityConstraints': 'securityconstraints', 'pycsw:ParentIdentifier': 'parentidentifier', + 'pycsw:URI': 'uri', 'pycsw:TopicCategory': 'topicategory', 'pycsw:ResourceLanguage': 'resourcelanguage', 'pycsw:GeographicDescriptionCode': 'geodescode', diff --git a/pycsw/core/config.py b/pycsw/core/config.py index ab8ac7768..9eebfd657 100644 --- a/pycsw/core/config.py +++ b/pycsw/core/config.py @@ -144,6 +144,7 @@ def __init__(self, prefix='csw30'): 'pycsw:PublicationDate': 'date_publication', 'pycsw:OrganizationName': 'organization', 'pycsw:SecurityConstraints': 'securityconstraints', + 'pycsw:URI': 'uri', 'pycsw:ParentIdentifier': 'parentidentifier', 'pycsw:TopicCategory': 'topicategory', 'pycsw:ResourceLanguage': 'resourcelanguage', diff --git a/pycsw/core/metadata.py b/pycsw/core/metadata.py index bd9692f0d..a2bb1e6f9 100644 --- a/pycsw/core/metadata.py +++ b/pycsw/core/metadata.py @@ -1399,6 +1399,10 @@ def _parse_iso(context, repos, exml): _set(context, recobj, 'pycsw:Language', md.language or md.languagecode) _set(context, recobj, 'pycsw:Type', md.hierarchy) _set(context, recobj, 'pycsw:ParentIdentifier', md.parentidentifier) + if hasattr(md, 'dataseturi') and md.dataseturi not in [None,'']: + _set(context, recobj, 'pycsw:URI', md.dataseturi) + elif md_identification and hasattr(md_identification, 'uricode') and len(md_identification.uricode) > 0: + _set(context, recobj, 'pycsw:URI', ','.join(md_identification.uricode)) _set(context, recobj, 'pycsw:Date', md.datestamp) _set(context, recobj, 'pycsw:Modified', md.datestamp) _set(context, recobj, 'pycsw:Source', md.dataseturi) diff --git a/pycsw/core/repository.py b/pycsw/core/repository.py index d074d4a94..e17e81579 100644 --- a/pycsw/core/repository.py +++ b/pycsw/core/repository.py @@ -807,6 +807,7 @@ def setup(database, table, create_sfsql_tables=True, postgis_geometry_column='wk Column('keywordstype', Text, index=True), Column('themes', Text, index=True), Column('parentidentifier', Text, index=True), + Column('uri', Text, index=True), Column('relation', Text, index=True), Column('time_begin', Text, index=True), Column('time_end', Text, index=True), diff --git a/pycsw/ogc/api/records.py b/pycsw/ogc/api/records.py index 49ea2c12a..6e79886a5 100644 --- a/pycsw/ogc/api/records.py +++ b/pycsw/ogc/api/records.py @@ -1293,6 +1293,14 @@ def record2json(record, url, collection, mode='ogcapi-records'): 'href': f'{url}/collections/{collection}/items/{record.identifier}' }) + if hasattr(record, 'uri') and record.uri not in [None,'']: + record_dict['links'].append({ + 'rel': 'alternate', + 'name': 'URI', + 'description': 'original URI of the record', + 'href': record.uri + }) + record_dict['links'].append({ 'rel': 'collection', 'type': 'application/json', diff --git a/tests/functionaltests/suites/cite/data/cite.db b/tests/functionaltests/suites/cite/data/cite.db index abb962db57d37c93997c79313584437c3c7a0367..c4cbe60c38fcb0df0a1048b6e58c74bc41baa3c6 100644 GIT binary patch delta 149 zcmZozAl$G(c!IQG5Ca2)FA!S;F*^`{pQvNZ8pNPiRnVBSHHC4Jz7!V&zdxS<3m5N0 z-Wr}CJiXk1xqG;!xK?nPZ5C8`#mv>CS;;OgEzLMXa}&pBRzZc*qD+M_#~^19#~=+O wQ&Y|9@6#CNnDZN%rccagl$d_Lf{}f*9m@{pb^$v^AZ7w$=IsJ@EFUHU029F|T>t<8 delta 130 zcmZozAl$G(c!IQGAOiz~FA!S;F*^`{o2X;V8pxpMU)z|nHHC4JzLpFFzdxS<`#1LE z>`83**os*nvlg*3u=KIWFmGnIW4g+e#>CE8!|;Wnb>fsz76u09>C-0!Gm1^zZMl6< d45JJ4W*L?n-0ffN8G)Dyh?%#4v1j3#003!=C13ym