Skip to content
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ There are 3 supported [Digital Commons structure types](https://bepress.com/refe

## Installation Instructions
1. Clone this repository into the Janeway plugins folder (`path/to/janeway/src/plugins/`)
2. Run the plugin installation command: `python3 src/manage.py install_plugins typesetting`.
2. Run the plugin installation command: `python3 src/manage.py install_plugins bepress`.
3. Run the migration command `python3 src/manage.py migrate bepress`
4. Restart your webserver

Expand All @@ -31,7 +31,7 @@ The spreadsheet needs to be exported as a CSV before you can import it into Jane
### Importing from OAI
Another alternative for those who don't have access to the archive files is to generate one using Bepress OAI endpoint. This feature is only supported via command line however and can take a long time, since it will generate an archive of the metadata for the entire institution.

To run this command all you need is the OAI url for your institution and then run the command `import_bepress_from_oai`.
To run this command all you need is the OAI url for your institution (do not include parameters) and then run the command `import_bepress_from_oai`.

The resulting metadata archives will be saved under `src/files/plugins/bepress` and will be displayed in the bepress plugin management page, ready to be loaded into any Janeway site.

Expand Down
2 changes: 1 addition & 1 deletion templates/bepress/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{% endif %}
<br />
<label for="bepress_structure">
Select the <a target="_blank" href="https://www.bepress.com/reference_guide_dc/digital-commons-structures/">strucuture</a> of the content being imported
Select the <a target="_blank" href="https://www.bepress.com/reference_guide_dc/digital-commons-structures/">structure</a> of the content being imported
</label>
<select name="bepress_structure">
<option value="series">Series</option>
Expand Down
36 changes: 28 additions & 8 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
from core import files
from core.models import Account, Galley, SupplementaryFile
from production.logic import save_galley
from identifiers.models import Identifier
from identifiers.models import Identifier, DOI_RE
from submission import models as submission_models
from journal import models as journal_models
from utils.orcid import COMPILED_ORCID_REGEX
from utils.logger import get_logger

from plugins.bepress import const
Expand All @@ -47,7 +48,7 @@ class FakeRequest():

def get_bepress_import_folders():
if os.path.exists(BEPRESS_PATH):
return os.listdir(BEPRESS_PATH)
return sorted(os.listdir(BEPRESS_PATH))
else:
return []

Expand Down Expand Up @@ -101,6 +102,7 @@ def create_article_record(dump_name, soup, journal, default_section, section_key
metadata_doi(soup, article)
metadata_keywords(soup, article)
metadata_authors(soup, article)
metadata_orcid(soup, article)
metadata_license(soup, article)
metadata_citation(soup, article)
metadata_pages(soup, article)
Expand All @@ -120,11 +122,13 @@ def create_article_record(dump_name, soup, journal, default_section, section_key
def metadata_doi(soup, article):
field = soup.fields.find(attrs={"name": "doi"})
if field and field.value:
Identifier.objects.get_or_create(
id_type="doi",
article=article,
identifier=field.value.string
)
result = DOI_RE.search(field.value.string)
if result:
Identifier.objects.get_or_create(
id_type="doi",
article=article,
identifier=result.group(0)
)


def metadata_keywords(soup, article):
Expand Down Expand Up @@ -404,6 +408,22 @@ def make_dummy_email(author):
return "{0}@{1}".format(hashed, settings.DUMMY_EMAIL_DOMAIN)


def metadata_orcid(soup, article):
"""
For single-author articles, we can find and use the ORCID field.
To do: work out how to support ORCID for multi-author articles.
"""
field = soup.fields.find(attrs={"name": "orcid"})
if not field:
field = soup.fields.find(attrs={"name": "orcid_id"})
if field and field.value and article.frozenauthor_set.count() == 1:
result = COMPILED_ORCID_REGEX.search(field.value.string)
if result:
author = article.frozenauthor_set.first()
author.frozen_orcid = result.group(0)
author.save()


def fetch_remote_galley(soup, stamped=False):
url = getattr(soup, "fulltext-url").string
if url:
Expand Down Expand Up @@ -827,7 +847,7 @@ def add_to_issue(article, root_path, export_path, struct, soup):
:param article: The submission.Article being imported
:param root_path: The absolute path in which the metadata.xml was found
:param export_path: The absolute path to the provided exported data
:param struct: (str) One of const.BEPRESS_STRUCTURESujj
:param struct: (str) One of const.BEPRESS_STRUCTURES
:param soup: (bs4.Soup) Soupified metadata.xml
"""
relative_path = root_path.replace(export_path, "")
Expand Down