Skip to content

Commit

Permalink
fix OARec language parsing (#1059)
Browse files Browse the repository at this point in the history
* fix ref for OARec language object handling

* add extra logging to repository transactions

* fix ref for OARec language object handling
  • Loading branch information
tomkralidis authored Dec 22, 2024
1 parent 59c1e5c commit 0a81fab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pycsw/core/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1764,7 +1764,7 @@ def _parse_oarec_record(context, repos, record):

_set(context, recobj, 'pycsw:AnyText', ' '.join([str(t) for t in util.get_anytext_from_obj(record)]))

_set(context, recobj, 'pycsw:Language', record['properties'].get('language'))
_set(context, recobj, 'pycsw:Language', record['properties'].get('language', {}).get('code'))
_set(context, recobj, 'pycsw:Type', record['properties']['type'])
_set(context, recobj, 'pycsw:Title', record['properties']['title'])
_set(context, recobj, 'pycsw:Abstract', record['properties'].get('description'))
Expand Down
3 changes: 3 additions & 0 deletions pycsw/core/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ def update(self, record=None, recprops=None, constraint=None):
self.dataset, self.context.md_core_model['mappings']['pycsw:XML']))
}, synchronize_session='fetch')
self.session.commit()
LOGGER.debug('Updated %d records', rows)
return rows
except Exception as err:
self.session.rollback()
Expand All @@ -521,6 +522,7 @@ def update(self, record=None, recprops=None, constraint=None):
def delete(self, constraint):
''' Delete a record from the repository '''

LOGGER.debug('Deleting record with constraint: %s', constraint)
try:
self.session.begin()
rows = self._get_repo_filter(self.session.query(self.dataset)).filter(
Expand All @@ -542,6 +544,7 @@ def delete(self, constraint):
synchronize_session='fetch')

self.session.commit()
LOGGER.debug('Deleted %d records', rows)
except Exception as err:
self.session.rollback()
msg = 'Cannot commit to repository'
Expand Down
4 changes: 3 additions & 1 deletion tests/functionaltests/suites/oarec/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,9 @@ def sample_record():
]
}
],
"language": "en",
"language": {
"code": "en"
},
"type": "dataset",
"created": "2011-11-11",
"updated": "2000-09-01",
Expand Down

0 comments on commit 0a81fab

Please sign in to comment.