From f42e6e57eb04858ea7ec03cd331470204a0cb959 Mon Sep 17 00:00:00 2001 From: Tom Kralidis Date: Mon, 30 Sep 2024 08:34:23 -0400 Subject: [PATCH] Oarec themes keywords (#1024) * OARec: fix themes/concepts structure * OARec: check for conformsTo on detection --- pycsw/core/metadata.py | 2 +- pycsw/ogc/api/records.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pycsw/core/metadata.py b/pycsw/core/metadata.py index 0eca49932..bd9692f0d 100644 --- a/pycsw/core/metadata.py +++ b/pycsw/core/metadata.py @@ -1727,7 +1727,7 @@ def _parse_json_record(context, repos, record): recobj = None - if 'http://www.opengis.net/spec/ogcapi-records-1/1.0/req/record-core' in record.get('conformsTo', []): + if 'conformsTo' in record: LOGGER.debug('Parsing OGC API - Records record model') recobj = _parse_oarec_record(context, repos, record) elif 'stac_version' in record: diff --git a/pycsw/ogc/api/records.py b/pycsw/ogc/api/records.py index 9049c2e78..f56fab573 100644 --- a/pycsw/ogc/api/records.py +++ b/pycsw/ogc/api/records.py @@ -1147,9 +1147,14 @@ def record2json(record, url, collection, mode='ogcapi-records'): # todo; for keywords with a scheme use the theme property if record.topicategory: - themes = [] - themes.append({'concepts': [record.topicategory], - 'scheme': 'https://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_TopicCategoryCode'}) + themes = [{ + 'concepts': [], + 'scheme': 'https://standards.iso.org/iso/19139/resources/gmxCodelists.xml#MD_TopicCategoryCode' + }] + + for rtp in record.topicategory: + themes['concepts'].append({'id': rtp}) + record_dict['properties']['themes'] = themes if record.otherconstraints: @@ -1229,7 +1234,7 @@ def record2json(record, url, collection, mode='ogcapi-records'): try: ogcapi_themes.append({ 'scheme': theme['thesaurus'].get('url', theme['thesaurus'].get('title', '')), - 'concepts': [c for c in theme.get('keywords_object', []) if c not in [None, '']] + 'concepts': [{'id': c} for c in theme.get('keywords_object', []) if c not in [None, '']] }) except Exception as err: LOGGER.exception(f"failed to parse theme of {record.identifier}: {err}")