Skip to content

Commit 933aa85

Browse files
authored
Fix property rel missing from atom links (#790)
1 parent e0d42f4 commit 933aa85

17 files changed

+449
-443
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ tests/results
3333
# visual studio code workspace
3434
*.code-workspace
3535
.vscode/settings.json
36+
.vscode/launch.json

pycsw/ogc/api/records.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1015,9 +1015,11 @@ def record2json(record, url, collection, stac_item=False):
10151015
rdl.append(link2)
10161016

10171017
record_dict['links'].append({
1018-
'rel': 'self',
1018+
'rel': 'collection',
10191019
'type': 'application/json',
10201020
'title': 'Collection',
1021+
'name': 'collection',
1022+
'description': 'Collection',
10211023
'href': f"{url}/collections/{collection}?f=json"
10221024
})
10231025

pycsw/ogc/csw/csw3.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1607,10 +1607,11 @@ def _write_record(self, recobj, queryables):
16071607
if rlinks:
16081608
LOGGER.info('link type: {}'.format(type(rlinks)))
16091609
for link in util.jsonify_links(rlinks):
1610-
etree.SubElement(record,
1611-
util.nspath_eval('dct:references',
1612-
self.parent.context.namespaces),
1613-
scheme=link['protocol']).text = link['url']
1610+
ref = etree.SubElement(record, util.nspath_eval('dct:references',
1611+
self.parent.context.namespaces))
1612+
if link['protocol']:
1613+
ref.attrib['scheme'] = link['protocol']
1614+
ref.text = link['url']
16141615

16151616
for i in ['dc:relation', 'dct:modified', 'dct:abstract']:
16161617
val = util.getqattr(recobj, queryables[i]['dbcol'])

pycsw/opensearch.py

+3
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,11 @@ def _csw2_2_os(self):
136136

137137
for rec in self.exml.xpath('//atom:entry',
138138
namespaces=self.context.namespaces):
139+
LOGGER.debug('Adding Atom entry')
139140
node.append(rec)
140141
for rec in self.exml.xpath('//csw:Record|//csw:BriefRecord|//csw:SummaryRecord',
141142
namespaces=self.context.namespaces):
143+
LOGGER.debug('Converting CSW Record to Atom entry')
142144
node.append(self.cswrecord2atom(rec))
143145
elif operation_name == 'Capabilities':
144146
node = etree.Element(util.nspath_eval('os:OpenSearchDescription', self.namespaces), nsmap=self.namespaces)
@@ -248,6 +250,7 @@ def _csw3_2_os(self):
248250
node.append(rec)
249251

250252
for rec in self.exml.xpath('//csw30:Record|//csw30:BriefRecord|//csw30:SummaryRecord', namespaces=self.context.namespaces):
253+
LOGGER.debug('Converting CSW Record to Atom entry')
251254
node.append(self.cswrecord2atom(rec))
252255

253256
elif response_name == 'Capabilities':

pycsw/plugins/outputschemas/atom.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,10 @@ def write_record(result, esn, context, url=None):
9191
url2.attrib['title'] = link['description']
9292

9393
if link['protocol']:
94-
if link['protocol'] == 'enclosure':
95-
url2.attrib['rel'] = link['protocol']
96-
url2.attrib['type'] = 'application/octet-stream'
97-
else:
98-
url2.attrib['type'] = link['protocol']
94+
url2.attrib['type'] = link['protocol']
95+
96+
if link['function']:
97+
url2.attrib['rel'] = link['function']
9998

10099
etree.SubElement(node, util.nspath_eval('atom:link', NAMESPACES), href='%s?service=CSW&version=2.0.2&request=GetRepositoryItem&id=%s' % (url, util.getqattr(result, context.md_core_model['mappings']['pycsw:Identifier'])))
101100

tests/functionaltests/suites/opensearcheo/data/iso_19115-2_Sentinel-2-scene.xml

+37-37
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-cloudcover-lt.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-cloudcover.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-instrument.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-orbitdirection.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-orbitnumber.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-platform.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-processinglevel.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-producttype.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-sensortype.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-snowcover.xml

+36-36
Large diffs are not rendered by default.

tests/functionaltests/suites/opensearcheo/expected/get_opensearch-query-spectralrange.xml

+36-36
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)