-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
DOI Fetcher using the new fetcher infrastructure #1885
Conversation
It would be really nice if you could address #1799 here as well. (I think the fetcher just has to be called in background thread somehow) |
The SwingWorker commit looks really interesting (and not so hard to use...)! 👍 |
return Optional.empty(); | ||
} | ||
} catch (IOException e) { | ||
throw new FetcherException("Bad URL when fetching ISBN info", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seem like a copy & paste error ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
this.prefs = preferences; | ||
} | ||
|
||
public static Optional<BibEntry> getEntryFromDOI(String doiStr, ParserResult parserResult, ImportFormatPreferences importFormatPreferences){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just doi instead of doiStr ?
And would be nice if you would stay consistent and write everywhere preferences for example instead of importFormatPreferences or prefs.
Fixed a Bug when editing the Doi field and using the get BibTex button right beside it. |
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete empty line
IdBasedFetcher fetcher; | ||
if (FieldName.DOI.equals(field)) { | ||
fetcher = new DoiFetcher(Globals.prefs.getImportFormatPreferences()); | ||
} else if (FieldName.ISBN.equals(field)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use switch here
// BibTeX entry | ||
return BibtexParser.singleFromString(cleanupEncoding(bibtexString), preferences); | ||
} else { | ||
LOGGER.warn(Localization.lang("Invalid DOI: '%0'.", identifier)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw FetcherException instead (so that the caller gets an better error description instead of just an empty result)
# Conflicts: # src/main/java/net/sf/jabref/logic/importer/fileformat/PdfContentImporter.java
Could please add an additional test for an article (instead of book), for example doi: 10.1109/ICWS.2007.59. I think afterwards we can merge it. |
Optional<BibEntry> result = BibtexParser.singleFromString(cleanupEncoding(bibtexString), preferences); | ||
return result; | ||
} else { | ||
throw new FetcherException(String.format("Invalid DOI: %s", identifier)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the text of the fetcher exception presented in the UI at another place in the UI?
Then, please do not remove the translation and add Localization.lang here.
I think, at least b85c379 has to be reverted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not fixed. Maybe exception.getLocalizedMessage()
is a hint how to code that.
# Conflicts: # src/main/java/net/sf/jabref/gui/importer/fetcher/EntryFetchers.java
Before this is ready to go:
|
|
||
@Before | ||
public void setUp() { | ||
fetcher = new DoiFetcher(Globals.prefs.getImportFormatPreferences()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you pls fix the failing test by using mock(ImportFormatPreferences.class)
here (if possible, if not JabRefPreferences.getInstance
or so does the trick)
No idea why the integration tests don't work here. @JabRef/developers should we merge nonetheless? |
Sure. Maybe, we should disable the integration tests (refs #1524). |
(Please do not squash at merge to keep author ships - @koppor)
Implement a new DOI Fetcher using the new fetcher infrastructure #1594
In this case, the two classes DOItoBibTeX & DOItoBibTeXFetcher has been merged into the new Fetcher.