Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix OARec language parsing #1059

Merged
merged 3 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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