Skip to content

Commit

Permalink
fix issue arxiv and eprinttype #10474 (#10491)
Browse files Browse the repository at this point in the history
* add the archivePrefix when parsing the eprint, the bibtex format will read the archivePrefix rather than eprinttype.

* modify the change request

* Small refactor

* add FIXED message to CHANGELOG.md

---------

Co-authored-by: Gu Xiuchen <[email protected]>
Co-authored-by: HoussemNasri <[email protected]>
  • Loading branch information
3 people authored Oct 19, 2023
1 parent b1f03e7 commit 95aff28
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where double clicking on an url in the file field would trigger an exception instead of opening the browser [#10480](https://github.com/JabRef/jabref/pull/10480)
- We fixed an issue where scrolling was impossible on dragging a citation on the groups panel. [#9754](https://github.com/JabRef/jabref/issues/9754)
- We fixed an issue where exporting "Embedded BibTeX pdf" without selecting an existing document would produce an exception. [#10101](https://github.com/JabRef/jabref/issues/10101)
- We fixed an issue where there was a failure to access the url link for "eprint" for the ArXiv entry.[#10474](https://github.com/JabRef/jabref/issues/10474)
- We fixed an issue where it was not possible to connect to a shared database once a group with entries was added or other metadata modified [#10336](https://github.com/JabRef/jabref/issues/10336)
- We fixed an issue where middle-button paste in X not always worked [#7905](https://github.com/JabRef/jabref/issues/7905)


### Removed

## [5.10] - 2023-09-02
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/gui/desktop/JabRefDesktop.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ public static void openExternalViewer(BibDatabaseContext databaseContext,
return;
} else if (StandardField.EPRINT == field) {
IdentifierParser identifierParser = new IdentifierParser(entry);

link = identifierParser.parse(StandardField.EPRINT)
.flatMap(Identifier::getExternalURI)
.map(URI::toASCIIString)
.orElse(link);

if (Objects.equals(link, initialLink)) {
Optional<String> eprintTypeOpt = entry.getField(StandardField.EPRINTTYPE);
if (eprintTypeOpt.isEmpty()) {
Optional<String> archivePrefixOpt = entry.getField(StandardField.ARCHIVEPREFIX);
if (eprintTypeOpt.isEmpty() && archivePrefixOpt.isEmpty()) {
dialogService.showErrorDialogAndWait(Localization.lang("Unable to open linked eprint. Please set the eprinttype field"));
} else {
dialogService.showErrorDialogAndWait(Localization.lang("Unable to open linked eprint. Please verify that the eprint field has a valid '%0' id", eprintTypeOpt.get()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ public Optional<? extends Identifier> parse(Field field) {

private Optional<? extends Identifier> parseEprint(String eprint) {
Optional<String> eprintTypeOpt = entry.getField(StandardField.EPRINTTYPE);
if (eprintTypeOpt.isPresent()) {
String eprintType = eprintTypeOpt.get();
if ("arxiv".equalsIgnoreCase(eprintType)) {
return ArXivIdentifier.parse(eprint);
} else if ("ark".equalsIgnoreCase(eprintType)) {
return ARK.parse(eprint);
}
Optional<String> archivePrefixOpt = entry.getField(StandardField.ARCHIVEPREFIX);

String eprintType = eprintTypeOpt.or(() -> archivePrefixOpt).orElse("");
if ("arxiv".equalsIgnoreCase(eprintType)) {
return ArXivIdentifier.parse(eprint);
} else if ("ark".equalsIgnoreCase(eprintType)) {
return ARK.parse(eprint);
}

return Optional.empty();
}
}

0 comments on commit 95aff28

Please sign in to comment.