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

ISBN Fetcher using the new fetcher infrastructure #1654

Merged
merged 25 commits into from
Aug 29, 2016

Conversation

zesaro
Copy link
Contributor

@zesaro zesaro commented Aug 1, 2016

Implement an ISBN fetcher using the new fetcher infrastructure #1594

  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef

@zesaro zesaro force-pushed the isbnfetcher branch 5 times, most recently from a7e7d7c to dcadfcf Compare August 1, 2016 13:33
public void testFetcher10() throws FetcherException, IOException {
Optional<BibEntry> isbn = fetcher.performSearchById("0321356683");
Assert.assertNotNull(isbn);
try (InputStream bibStream = IsbnFetcherTest.class.getResourceAsStream("IsbnFetcherTest.bib")) {
Copy link
Member

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)

@zesaro zesaro force-pushed the isbnfetcher branch 3 times, most recently from eded3fe to 58eea21 Compare August 8, 2016 11:22
try {
fetchedEntry = new IsbnFetcher().performSearchById(fieldContent.get());
} catch (FetcherException fe) {
fe.printStackTrace();
Copy link
Member

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

@tobiasdiez
Copy link
Member

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()));
Copy link
Member

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.

throw new FetcherException("Bad URL when fetching ISBN info", e);
}
}
return result;
}

private Optional<BibEntry> postProcessEntry(BibEntry entry) {
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 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.

@zesaro zesaro changed the title IsbnFetcher [WIP] IsbnFetcher Aug 22, 2016
@stefan-kolb stefan-kolb changed the title [WIP] IsbnFetcher IsbnFetcher Aug 22, 2016
@stefan-kolb
Copy link
Member

@oscargus @tobiasdiez @koppor Are we ready to merge this?

@oscargus
Copy link
Contributor

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.

@stefan-kolb
Copy link
Member

Let's wait for the comments to be implemented!

@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 24, 2016
@koppor koppor changed the title IsbnFetcher ISBN Fetcher using the new fetcher infrastructure Aug 24, 2016
# 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
@zesaro
Copy link
Contributor Author

zesaro commented Aug 25, 2016

Are the changes as expected?

@stefan-kolb
Copy link
Member

@oscargus

private static final String URL_PATTERN = "http://www.ebook.de/de/tools/isbn2bibtex?";
private ImportFormatPreferences prefs;

public IsbnFetcher(){
Copy link
Contributor

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.

Copy link
Contributor

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 ()

@oscargus
Copy link
Contributor

oscargus commented Aug 25, 2016

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 IdBasedEntryFetcher is perfect! 👍

# Conflicts:
#	src/main/java/net/sf/jabref/gui/importer/fetcher/ISBNtoBibTeXFetcher.java
@oscargus oscargus added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Aug 29, 2016
@oscargus
Copy link
Contributor

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.
*
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the header.

@stefan-kolb stefan-kolb merged commit d832acd into JabRef:master Aug 29, 2016
@zesaro zesaro deleted the isbnfetcher branch August 29, 2016 10:57
ayanai1 pushed a commit to ayanai1/jabref that referenced this pull request Sep 5, 2016

* 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
@koppor
Copy link
Member

koppor commented Sep 12, 2016

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 postProcess method?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants