-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from oarepo/alzbetapokorna/be-502-new-version-r…
…equest-when-a-new-version-of-a-published-record abstract mapping class
- Loading branch information
Showing
5 changed files
with
58 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class DataCiteMappingBase(ABC): | ||
|
||
@abstractmethod | ||
def metadata_check(self, data): | ||
"""Checks metadata for required fields and returns errors if any.""" | ||
pass | ||
|
||
@abstractmethod | ||
def create_datacite_payload(self, data): | ||
"""Creates a DataCite payload from the given data.""" | ||
pass | ||
|
||
|
||
def get_doi(self, record): | ||
"""Extracts DOI from the record.""" | ||
|
||
object_identifiers = record["metadata"].get("objectIdentifiers", []) | ||
doi = None | ||
for id in object_identifiers: | ||
if id["scheme"] == "DOI": | ||
doi = id["identifier"] | ||
return doi | ||
|
||
def add_doi(self, record, data, doi_value): | ||
"""Adds a DOI to the record.""" | ||
|
||
doi = {"scheme": "DOI", "identifier": doi_value} | ||
|
||
if "objectIdentifiers" in data["metadata"]: | ||
data["metadata"]["objectIdentifiers"].append(doi) | ||
else: | ||
data["metadata"]["objectIdentifiers"] = [doi] | ||
|
||
record.update(data) | ||
record.commit() | ||
|
||
def remove_doi(self, record): | ||
"""Removes DOI from the record.""" | ||
|
||
if "objectIdentifiers" in record["metadata"]: | ||
for id in record["metadata"]["objectIdentifiers"]: | ||
if id["scheme"] == "DOI": | ||
record["metadata"]["objectIdentifiers"].remove(id) | ||
|
||
record.commit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ msgid "" | |
msgstr "" | ||
"Project-Id-Version: PROJECT VERSION\n" | ||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" | ||
"POT-Creation-Date: 2024-10-30 12:26+0100\n" | ||
"POT-Creation-Date: 2024-10-31 09:56+0100\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[metadata] | ||
name = oarepo-doi | ||
version = 1.0.13 | ||
version = 1.0.14 | ||
description = | ||
authors = Alzbeta Pokorna <[email protected]> | ||
readme = README.md | ||
|