From 28c94a2c08b5a3b47dd09922e381e6c8c2bf8b51 Mon Sep 17 00:00:00 2001 From: Mark Jacobson <52427991+marksparkza@users.noreply.github.com> Date: Mon, 4 Dec 2023 12:32:07 +0200 Subject: [PATCH] Add RIS citation stub to published output #16 --- migrate/systemdata/schemas.yml | 4 ++++ odp/catalog/saeon.py | 24 +++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/migrate/systemdata/schemas.yml b/migrate/systemdata/schemas.yml index c90e65c..a2b5b14 100644 --- a/migrate/systemdata/schemas.yml +++ b/migrate/systemdata/schemas.yml @@ -14,6 +14,10 @@ SchemaOrg.Dataset: type: metadata uri: https://odp.saeon.ac.za/schema/metadata/schema.org/dataset +RIS.Citation: + type: metadata + uri: https://odp.saeon.ac.za/schema/metadata/ris/citation + Tag.Collection.Infrastructure: type: tag uri: https://odp.saeon.ac.za/schema/tag/collection/infrastructure diff --git a/odp/catalog/saeon.py b/odp/catalog/saeon.py index f49dc0a..80ee2f6 100644 --- a/odp/catalog/saeon.py +++ b/odp/catalog/saeon.py @@ -29,8 +29,7 @@ def create_published_record(self, record_model: RecordModel) -> PublishedRecordM timestamp=record_model.timestamp, ) - @staticmethod - def _create_published_metadata(record_model: RecordModel) -> list[PublishedMetadataModel]: + def _create_published_metadata(self, record_model: RecordModel) -> list[PublishedMetadataModel]: """Create the published metadata outputs for a record.""" published_metadata = [ PublishedMetadataModel( @@ -40,7 +39,10 @@ def _create_published_metadata(record_model: RecordModel) -> list[PublishedMetad ) ] - if record_model.schema_id == ODPMetadataSchema.SAEON_ISO19115: + if record_model.schema_id == ODPMetadataSchema.SAEON_DATACITE4: + datacite_metadata = record_model.metadata + + elif record_model.schema_id == ODPMetadataSchema.SAEON_ISO19115: iso19115_schemaobj = Session.get(Schema, (ODPMetadataSchema.SAEON_ISO19115, SchemaType.metadata)) datacite_schemaobj = Session.get(Schema, (ODPMetadataSchema.SAEON_DATACITE4, SchemaType.metadata)) @@ -61,8 +63,24 @@ def _create_published_metadata(record_model: RecordModel) -> list[PublishedMetad ) ] + # add an RIS citation record + ris_schema = Session.get(Schema, (ODPMetadataSchema.RIS_CITATION, SchemaType.metadata)) + published_metadata += [ + PublishedMetadataModel( + schema_id=ris_schema.id, + schema_uri=ris_schema.uri, + metadata={'ris': self._create_ris_citation(datacite_metadata)} + ) + ] + return published_metadata + @staticmethod + def _create_ris_citation(datacite_metadata: dict) -> str: + """Create an RIS citation from the DataCite metadata for a record.""" + return ''' + ''' + @staticmethod def _create_published_tags(record_model: RecordModel) -> list[PublishedTagInstanceModel]: """Create the published tags for a record."""