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

Fix #2427: Arxiv fetcher works with prefix #2428

Merged
merged 1 commit into from
Dec 24, 2016
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where groups containing brackets were not working properly. Fixes [#2394](https://github.com/JabRef/jabref/issues/2394).
- We fixed issues with the [timestamp](http://help.jabref.org/en/TimeStamp) field. However, clearing with the clear button is not possible if timestamp format does not match the current settings. Fixes [#2403](https://github.com/JabRef/jabref/issues/2403).
- Fixes [#2406](https://github.com/JabRef/jabref/issues/2406) so that the integrity check filter works again
- The ArXiv fetcher also accepts identifiers that include the "arXiv:" prefix. Fixes [#2427](https://github.com/JabRef/jabref/issues/2427).
- Closing of subtrees in the groups panel using "close subtree" is working again. Fixes [#2319](https://github.com/JabRef/jabref/issues/2319).
- The proxy settings are now also applied to HTTPS connections. Fixes [#2249](https://github.com/JabRef/jabref/issues/2249).

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/net/sf/jabref/logic/importer/fetcher/ArXiv.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ private Optional<ArXivEntry> searchForEntry(String searchQuery) throws FetcherEx
}

private Optional<ArXivEntry> searchForEntryById(String identifier) throws FetcherException {
identifier = identifier.replace("arxiv:", "");
identifier = identifier.replace("arXiv:", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just replace this via a regex? /arxiv:?/i

Copy link
Contributor

@simonharrer simonharrer Dec 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote for an ArXivID class, similar to the DOI one which can handle such a case.

identifier = identifier.replace("arxiv", "");
identifier = identifier.replace("arXiv", "");
List<ArXivEntry> entries = queryApi("", Collections.singletonList(identifier), 0, 1);
if (entries.size() == 1) {
return Optional.of(entries.get(0));
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/net/sf/jabref/logic/importer/fetcher/ArXivTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ public void findByEprint() throws IOException {
assertEquals(Optional.of(new URL("http://arxiv.org/pdf/1603.06570v1")), finder.findFullText(entry));
}

@Test
// Test for https://github.com/JabRef/jabref/issues/2427
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would omit the comment here. It is a test for expected behavior. Doesnt matter which bug/problem it fixed.

public void findByEprintWithPrefix() throws IOException {
entry.setField("eprint", "arXiv:1603.06570");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line

assertEquals(Optional.of(new URL("http://arxiv.org/pdf/1603.06570v1")), finder.findFullText(entry));
}

@Test
public void findByEprintWithUnknownDOI() throws IOException {
entry.setField("doi", "10.1529/unknown");
Expand Down Expand Up @@ -138,6 +146,12 @@ public void searchEntryByIdWith4Digits() throws Exception {
assertEquals(Optional.of(sliceTheoremPaper), finder.performSearchById("1405.2249"));
}

@Test
// Test for https://github.com/JabRef/jabref/issues/2427
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove url

public void searchEntryByIdWith4DigitsAndPrefix() throws Exception {
assertEquals(Optional.of(sliceTheoremPaper), finder.performSearchById("arXiv:1405.2249"));
}

@Test
public void searchEntryByIdWith5Digits() throws Exception {
assertEquals(Optional.of(
Expand Down