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

Do not trim or remove whitespace from the title based id fetcher #4016

Merged
merged 6 commits into from
May 11, 2018

Conversation

Siedlerchr
Copy link
Member

@Siedlerchr Siedlerchr commented May 6, 2018

Fixes #4014


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

@Siedlerchr Siedlerchr changed the title Fix titlefetcherwhitespace Do not trim or remove whitespace from the title based id fetcher May 6, 2018
@Siedlerchr Siedlerchr added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers component: fetcher labels May 6, 2018
fetcher = WebFetchers.getIdBasedFetchers(Globals.prefs.getImportFormatPreferences()).get(comboBox.getSelectedIndex());

searchID = idTextField.getText();
if (!(fetcher instanceof TitleFetcher)) {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we remove whitespace for the other fetcher? Shouldn't each fetcher decide how to proceed the input? I would just always trim it at this point...

Copy link
Member Author

Choose a reason for hiding this comment

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

All other fetchers have a single alphanumeric id or an url so, trimming in general makes sense.

Copy link
Member

Choose a reason for hiding this comment

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

Copy and paste DOIs from PDFs or homepages (e.g., Springer) leads to identifiers. With the fix #3697, there is a speedup in the user workflow. One can just copy something from a PDF/homepage and paste it into JabRef and click "Generate".

From JabRef#283:

http s://doi.org/10.1007/s13222-018-0273-1 and DOI: 10.1109/MS.2013.97.

Copy link
Member

Choose a reason for hiding this comment

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

I don't say we should remove the functionality. It makes sense and indeed streamlines the user flow. I was arguing in favor of placing this code .trim().placeAll(" ", "") in every fetcher that supports it. It terms of coding principles, the current solution violates the "hide implementation details" principle, since the caller of the interface needs to know which fetcher is invoked (TitleFetcher or not) and whether its support white space removal. Moreover, I bet that if somebody implements a new fetcher in a year that relies on correct white space, then he will forget to add this new fetcher to this exception list here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it really makes sense to add this argument parsing/trimming to the fetcher itself as @tobiasdiez proposes. Maybe a new method parse input?

@Siedlerchr
Copy link
Member Author

I now moved trimming down to the concrete fetcher classes and added tests

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

LGTM. Only one small suggestion for improvement. Feel free to merge.

@@ -44,7 +44,9 @@ public HelpFile getHelpPage() {

@Override
public Optional<BibEntry> performSearchById(String identifier) throws FetcherException {
Optional<DOI> doi = DOI.parse(identifier);
String cleanedIdentifier = identifier.trim();
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 please move this clean-up to the DOI.parse method.

@Siedlerchr Siedlerchr merged commit dae1c81 into master May 11, 2018
@Siedlerchr Siedlerchr deleted the fixTitlefetcherwhitespace branch May 11, 2018 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: fetcher 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.

3 participants