-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
ISBN Fetcher using the new fetcher infrastructure #1654
Conversation
a7e7d7c
to
dcadfcf
Compare
public void testFetcher10() throws FetcherException, IOException { | ||
Optional<BibEntry> isbn = fetcher.performSearchById("0321356683"); | ||
Assert.assertNotNull(isbn); | ||
try (InputStream bibStream = IsbnFetcherTest.class.getResourceAsStream("IsbnFetcherTest.bib")) { |
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.
Please create the BibEntry by hand instead of using the BIB file (see ArxivTests)
eded3fe
to
58eea21
Compare
try { | ||
fetchedEntry = new IsbnFetcher().performSearchById(fieldContent.get()); | ||
} catch (FetcherException fe) { | ||
fe.printStackTrace(); |
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.
see how exceptions are handled below for the ArXiv fetcher
I know, WIP but it look so good that I already reviewed it. After fixing my small remarks, this should be good to go |
fe.printStackTrace(); | ||
} catch (FetcherException e) { | ||
panel.frame().setStatus( | ||
Localization.lang("Cannot get info based on given %0:_%1", type, fieldContent.get())); |
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.
Please log the exception, too, e.g. Logger.error/debug (just look at other code pieces 😄 )
And I think the underscore in the Localization is wrong, should be just a space.
7a18d02
to
8764e52
Compare
throw new FetcherException("Bad URL when fetching ISBN info", e); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
private Optional<BibEntry> postProcessEntry(BibEntry entry) { |
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.
I would return a BibEntry here as a BibEntry comes in and this is post processed. Always. The Optional is always present. Thus, the Optional conversion should be done by the caller.
@oscargus @tobiasdiez @koppor Are we ready to merge this? |
I would prefer that my comments are taken care of. On the other hand, it is quite quickly done, so not a show stopper if I have to do it myself after merging. |
Let's wait for the comments to be implemented! |
# Conflicts: # src/main/java/net/sf/jabref/gui/importer/fetcher/EntryFetchers.java # src/main/java/net/sf/jabref/gui/importer/fetcher/GeneralFetcher.java # src/main/java/net/sf/jabref/gui/importer/fetcher/ISBNtoBibTeXFetcher.java
…tcher # Conflicts: # src/main/java/net/sf/jabref/gui/importer/fetcher/EntryFetchers.java # src/main/java/net/sf/jabref/logic/importer/fetcher/IsbnFetcher.java
Are the changes as expected? |
private static final String URL_PATTERN = "http://www.ebook.de/de/tools/isbn2bibtex?"; | ||
private ImportFormatPreferences prefs; | ||
|
||
public IsbnFetcher(){ |
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.
I'd prefer that the constructor gets the ImportFormatPreferences object here (and, hence, move the ImportFormatPreferences.fromPreferences(Globals.prefs)
to EntryFetchers
as
entryFetchers.add(new IdBasedEntryFetcher(new IsbnFetcher(ImportFormatPreferences.fromPreferences(Globals.prefs))));
In that way there won't be any import of Globals in logic. But a minor thing at the moment. Still things to fix which are much harder compared to this before being able to enforce it through tests.
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.
Now it is: Globals.prefs.getImportFormatPreferences ()
It is OK to merge for me. I commented on what I really would have liked to see, but it is easy to change later and the change provided makes it even easier. The location of |
# Conflicts: # src/main/java/net/sf/jabref/gui/importer/fetcher/ISBNtoBibTeXFetcher.java
LGTM! 👍 (The copyright comments should be removed as we changed license, but, again, minor detail and nothing that would stop me from merging.) |
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* |
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.
Please remove the header.
* create test * make fetcher usable and organise imports * fix codacy * remove old isbn fetcher * ignore tests needing needing online connection * edit test and use wrapper for fetcher * add one more test to isbnfetcher * include feedback (1/2) * include feedback (2/2) * add logger to FetchAndMergeEntry * remove obsolete keys * resolve conflicts * include feedback and cleanup * include feedback (use Unirest and add more invalid tests) * include feedback * refactor globals and fix logger * refactor globals in isbnfetcher * resolve merge issues * remove copyright
Is it possible to update the fetcher to fix koppor#125? I think, just the normalization functionality has to be called. Maybe a cleanup job? Maybe after #1929 is merged to use the |
Implement an ISBN fetcher using the new fetcher infrastructure #1594