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

importer: cds: Don't make CDS E-Items open access #884

Merged
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 cds_ils/importer/eitems/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cds_ils/importer/providers/cds/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
7 changes: 6 additions & 1 deletion cds_ils/importer/providers/cds/rules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 6 additions & 1 deletion cds_ils/importer/providers/cds/rules/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
5 changes: 5 additions & 0 deletions cds_ils/vocabularies/data/eitem_sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,10 @@
"key": "WSC",
"text": "World Scientific",
"type": "eitem_sources"
},
{
"key": "CDS",
"text": "CDS",
"type": "eitem_sources"
}
]
44 changes: 22 additions & 22 deletions tests/migrator/rules/test_books.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def test_urls(app):
<subfield code="u">
https://cdsweb.cern.ch/auth.py?r=EBLIB_P_1139560
</subfield>
<subfield code="y">ebook</subfield>
<subfield code="y">e-book</subfield>
</datafield>
""",
{
Expand All @@ -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",
},
}
],
Expand All @@ -682,7 +682,7 @@ def test_urls(app):
"""
<datafield tag="856" ind1="4" ind2=" ">
<subfield code="u">https://learning.oreilly.com/library/view/-/9781118491300/?ar</subfield>
<subfield code="y">ebook</subfield>
<subfield code="y">e-book</subfield>
</datafield>
""",
{
Expand All @@ -693,7 +693,7 @@ def test_urls(app):
{
"url": {
"value": "https://learning.oreilly.com/library/view/-/9781118491300/?ar",
"description": "ebook",
"description": "e-book",
},
}
],
Expand All @@ -706,7 +706,7 @@ def test_urls(app):
<subfield code="u">
https://ezproxy.cern.ch/login?url=https://www.worldscientific.com/toc/rast/10
</subfield>
<subfield code="y">ebook</subfield>
<subfield code="y">e-book</subfield>
</datafield>
""",
{
Expand All @@ -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,
}
Expand All @@ -731,13 +731,13 @@ def test_urls(app):
<subfield code="u">
https://cdsweb.cern.ch/auth.py?r=EBLIB_P_1139560
</subfield>
<subfield code="y">ebook</subfield>
<subfield code="y">e-book</subfield>
</datafield>
<datafield tag="856" ind1="4" ind2=" ">
<subfield code="u">
https://learning.oreilly.com/library/view/-/9781118491300/?ar
</subfield>
<subfield code="y">ebook</subfield>
<subfield code="y">e-book</subfield>
</datafield>
""",
{
Expand All @@ -748,15 +748,15 @@ def test_urls(app):
{
"url": {
"value": "https://cdsweb.cern.ch/auth.py?r=EBLIB_P_1139560",
"description": "ebook",
"description": "e-book",
},
},
],
"eitems_safari": [
{
"url": {
"value": "https://learning.oreilly.com/library/view/-/9781118491300/?ar",
"description": "ebook",
"description": "e-book",
},
},
],
Expand All @@ -768,7 +768,7 @@ def test_urls(app):
"""
<datafield tag="856" ind1="4" ind2=" ">
<subfield code="u"> https://learning.oreilly.com/library/view/-/9781119745228/?ar </subfield>
<subfield code="y">ebook</subfield>
<subfield code="y">e-book</subfield>
</datafield>
""",
{
Expand All @@ -778,7 +778,7 @@ def test_urls(app):
{
"url": {
"value": "https://learning.oreilly.com/library/view/-/9781119745228/?ar",
"description": "ebook",
"description": "e-book",
},
},
],
Expand All @@ -790,7 +790,7 @@ def test_urls(app):
"""
<datafield tag="856" ind1="4" ind2=" ">
<subfield code="u"> https://external.com </subfield>
<subfield code="y">ebook</subfield>
<subfield code="y">e-book</subfield>
</datafield>
""",
{
Expand All @@ -800,7 +800,7 @@ def test_urls(app):
{
"url": {
"value": "https://external.com",
"description": "ebook",
"description": "e-book",
},
"open_access": False,
},
Expand Down Expand Up @@ -1730,7 +1730,7 @@ def test_dois(app):
<datafield tag="024" ind1="7" ind2=" ">
<subfield code="2">DOI</subfield>
<subfield code="a">10.1007/978-1-4613-0247-6</subfield>
<subfield code="q">ebook</subfield>
<subfield code="q">e-book</subfield>
<subfield code="9">source</subfield>
</datafield>
""",
Expand All @@ -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,
Expand All @@ -1762,7 +1762,7 @@ def test_dois(app):
<datafield tag="024" ind1="7" ind2=" ">
<subfield code="2">DOI</subfield>
<subfield code="a">10.3390/books978-3-03943-243-1</subfield>
<subfield code="q">ebook (Open Access)</subfield>
<subfield code="q">e-book (Open Access)</subfield>
</datafield>
""",
{
Expand All @@ -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,
Expand Down Expand Up @@ -1894,7 +1894,7 @@ def test_alternative_identifiers(app):
<subfield code="2">DOI</subfield>
<subfield code="9">arXiv</subfield>
<subfield code="a">10.1103/PhysRevLett.121.052004</subfield>
<subfield code="q">ebook</subfield>
<subfield code="q">e-book</subfield>
</datafield>
""",
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -3357,7 +3357,7 @@ def test_record(app):
<datafield tag="024" ind1="7" ind2=" ">
<subfield code="2">DOI</subfield>
<subfield code="a">10.1007/978-981-15-9034-4</subfield>
<subfield code="q">ebook</subfield>
<subfield code="q">e-book</subfield>
</datafield>
""",
{
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/migrator/rules/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def test_monograph_volume_migration_doi(app):
<datafield tag="024" ind1="7" ind2=" ">
<subfield code="2">DOI</subfield>
<subfield code="a">10.1007/978-3-030-49613-5</subfield>
<subfield code="q">ebook (v.1)</subfield>
<subfield code="q">e-book (v.1)</subfield>
</datafield>
""",
{
Expand All @@ -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",
},
}
Expand Down
Loading