diff --git a/cds_ils/importer/eitems/importer.py b/cds_ils/importer/eitems/importer.py index 7ecfe3703..83802ece9 100644 --- a/cds_ils/importer/eitems/importer.py +++ b/cds_ils/importer/eitems/importer.py @@ -193,7 +193,7 @@ def _should_import_eitem_by_priority(self, matched_document): def _build_eitem_json(self, eitem_json, document_pid, urls=None, description=None): """Provide initial metadata dictionary.""" - self._apply_url_login(eitem_json) + self._apply_url_login(self.eitem_json) self._set_record_import_source(eitem_json) dois = [ doi diff --git a/cds_ils/importer/providers/cds/importer.py b/cds_ils/importer/providers/cds/importer.py index cb5ee757b..7f719480b 100644 --- a/cds_ils/importer/providers/cds/importer.py +++ b/cds_ils/importer/providers/cds/importer.py @@ -19,6 +19,9 @@ class CDSImporter(Importer): """CDS importer class.""" UPDATE_DOCUMENT_FIELDS = ("identifiers", "tags") + # Mark all CDS elated E-Items as login required and not open access + EITEM_OPEN_ACCESS = False + EITEM_URLS_LOGIN_REQUIRED = True def _match_document(self): """CDS importer match document.""" diff --git a/cds_ils/importer/providers/cds/rules/base.py b/cds_ils/importer/providers/cds/rules/base.py index 7e182d92d..f446424bb 100644 --- a/cds_ils/importer/providers/cds/rules/base.py +++ b/cds_ils/importer/providers/cds/rules/base.py @@ -633,7 +633,12 @@ def dois(self, key, value): dois_url_prefix = current_app.config["CDS_ILS_DOI_URL_PREFIX"] def _clean_doi_access(subfield): - return subfield.lower().replace("(open access)", "").strip() + return ( + subfield.lower() + .replace("(open access)", "") + .replace("ebook", "e-book") + .strip() + ) def clean_material(subfield_q): return re.sub(r"\([^)]*\)", "", subfield_q).strip() diff --git a/cds_ils/importer/providers/cds/rules/multipart.py b/cds_ils/importer/providers/cds/rules/multipart.py index c2366c276..422e715c7 100644 --- a/cds_ils/importer/providers/cds/rules/multipart.py +++ b/cds_ils/importer/providers/cds/rules/multipart.py @@ -126,7 +126,12 @@ def dois(self, key, value): dois_url_prefix = current_app.config["CDS_ILS_DOI_URL_PREFIX"] def _clean_doi_access(subfield): - return subfield.lower().replace("(open access)", "").strip() + return ( + subfield.lower() + .replace("(open access)", "") + .replace("ebook", "e-book") + .strip() + ) def create_eitem(subfield_a, subfield_q, migration_dict): eitems_proxy = migration_dict["_migration"]["eitems_proxy"] diff --git a/cds_ils/vocabularies/data/eitem_sources.json b/cds_ils/vocabularies/data/eitem_sources.json index f90320ac6..3ff59451f 100644 --- a/cds_ils/vocabularies/data/eitem_sources.json +++ b/cds_ils/vocabularies/data/eitem_sources.json @@ -83,5 +83,10 @@ "key": "WSC", "text": "World Scientific", "type": "eitem_sources" + }, + { + "key": "CDS", + "text": "CDS", + "type": "eitem_sources" } ] diff --git a/tests/migrator/rules/test_books.py b/tests/migrator/rules/test_books.py index 3657f3d49..8fd9a0393 100644 --- a/tests/migrator/rules/test_books.py +++ b/tests/migrator/rules/test_books.py @@ -660,7 +660,7 @@ def test_urls(app): https://cdsweb.cern.ch/auth.py?r=EBLIB_P_1139560 - ebook + e-book """, { @@ -671,7 +671,7 @@ def test_urls(app): { "url": { "value": "https://cdsweb.cern.ch/auth.py?r=EBLIB_P_1139560", - "description": "ebook", + "description": "e-book", }, } ], @@ -682,7 +682,7 @@ def test_urls(app): """ https://learning.oreilly.com/library/view/-/9781118491300/?ar - ebook + e-book """, { @@ -693,7 +693,7 @@ def test_urls(app): { "url": { "value": "https://learning.oreilly.com/library/view/-/9781118491300/?ar", - "description": "ebook", + "description": "e-book", }, } ], @@ -706,7 +706,7 @@ def test_urls(app): https://ezproxy.cern.ch/login?url=https://www.worldscientific.com/toc/rast/10 - ebook + e-book """, { @@ -717,7 +717,7 @@ def test_urls(app): { "url": { "value": "https://www.worldscientific.com/toc/rast/10", - "description": "ebook", + "description": "e-book", }, "open_access": False, } @@ -731,13 +731,13 @@ def test_urls(app): https://cdsweb.cern.ch/auth.py?r=EBLIB_P_1139560 - ebook + e-book https://learning.oreilly.com/library/view/-/9781118491300/?ar - ebook + e-book """, { @@ -748,7 +748,7 @@ def test_urls(app): { "url": { "value": "https://cdsweb.cern.ch/auth.py?r=EBLIB_P_1139560", - "description": "ebook", + "description": "e-book", }, }, ], @@ -756,7 +756,7 @@ def test_urls(app): { "url": { "value": "https://learning.oreilly.com/library/view/-/9781118491300/?ar", - "description": "ebook", + "description": "e-book", }, }, ], @@ -768,7 +768,7 @@ def test_urls(app): """ https://learning.oreilly.com/library/view/-/9781119745228/?ar - ebook + e-book """, { @@ -778,7 +778,7 @@ def test_urls(app): { "url": { "value": "https://learning.oreilly.com/library/view/-/9781119745228/?ar", - "description": "ebook", + "description": "e-book", }, }, ], @@ -790,7 +790,7 @@ def test_urls(app): """ https://external.com - ebook + e-book """, { @@ -800,7 +800,7 @@ def test_urls(app): { "url": { "value": "https://external.com", - "description": "ebook", + "description": "e-book", }, "open_access": False, }, @@ -1730,7 +1730,7 @@ def test_dois(app): DOI 10.1007/978-1-4613-0247-6 - ebook + e-book source """, @@ -1748,7 +1748,7 @@ def test_dois(app): "eitems_external": [ { "url": { - "description": "ebook", + "description": "e-book", "value": "http://dx.doi.org/10.1007/978-1-4613-0247-6", }, "open_access": False, @@ -1762,7 +1762,7 @@ def test_dois(app): DOI 10.3390/books978-3-03943-243-1 - ebook (Open Access) + e-book (Open Access) """, { @@ -1779,7 +1779,7 @@ def test_dois(app): "eitems_external": [ { "url": { - "description": "ebook", + "description": "e-book", "value": "http://dx.doi.org/10.3390/books978-3-03943-243-1", }, "open_access": True, @@ -1894,7 +1894,7 @@ def test_alternative_identifiers(app): DOI arXiv 10.1103/PhysRevLett.121.052004 - ebook + e-book """, { @@ -1930,7 +1930,7 @@ def test_alternative_identifiers(app): }, { "url": { - "description": "ebook", + "description": "e-book", "value": "http://dx.doi.org/10.1103/PhysRevLett.121.052004", }, "open_access": False, @@ -3357,7 +3357,7 @@ def test_record(app): DOI 10.1007/978-981-15-9034-4 - ebook + e-book """, { @@ -3369,7 +3369,7 @@ def test_record(app): "eitems_external": [ { "url": { - "description": "ebook", + "description": "e-book", "value": "http://dx.doi.org/10.1007/978-981-15-9034-4", }, "open_access": False, diff --git a/tests/migrator/rules/test_series.py b/tests/migrator/rules/test_series.py index 33da93efb..dbbc5d15d 100644 --- a/tests/migrator/rules/test_series.py +++ b/tests/migrator/rules/test_series.py @@ -616,7 +616,7 @@ def test_monograph_volume_migration_doi(app): DOI 10.1007/978-3-030-49613-5 - ebook (v.1) + e-book (v.1) """, { @@ -639,7 +639,7 @@ def test_monograph_volume_migration_doi(app): { "open_access": False, "url": { - "description": "ebook " "(v.1)", + "description": "e-book " "(v.1)", "value": "http://dx.doi.org/10.1007/978-3-030-49613-5", }, }