Skip to content

Add ability to use DOI directly in Web Search#9969

Merged
koppor merged 5 commits into
JabRef:mainfrom
aqurilla:fix-for-issue-9674
Jun 5, 2023
Merged

Add ability to use DOI directly in Web Search#9969
koppor merged 5 commits into
JabRef:mainfrom
aqurilla:fix-for-issue-9674

Conversation

@aqurilla

@aqurilla aqurilla commented Jun 2, 2023

Copy link
Copy Markdown
Contributor

This fixes #9674 by checking whether the query string contains a valid DOI. If yes, the DOIFetcher is used instead of the selected fetcher. This is also reflected in the ImportEntriesDialog title.

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@aqurilla aqurilla marked this pull request as ready for review June 2, 2023 04:28

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some small comments, otherwise, it looks good

return null;
}

// check if DOI is present

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the code the next line. Please remove this comment.

Add a comment in the line before "null". It should be similar than line 84 "in case user did not enter something, it is treated as valid (to avoid UI WTFs)"

fetcherName = doiFetcher.getName();
}

String finalFetcherName = fetcherName;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This variable is not ncessary - just using fetcherName is enough.

@aqurilla aqurilla Jun 4, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your feedback!

When I try to use fetcherName in the client.trackEvent() call, an error is raised that local variables referenced from a lambda expression must be final or effectively final. Is there a way to pass the value to the lambda without creating the effectively final finalFetcherName variable? A possible solution is to make it an instance variable but I am not sure that's a good idea

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, then keep it as is. I already though that it's probably used in a lambda

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks!

}

SearchBasedFetcher activeFetcher = getSelectedFetcher();
BackgroundTask<ParserResult> task;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This variable can be introuced in line 162, can't it? In JabRef, we introduce the variable at the latest point possible - not somewhere inbetween.

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jun 3, 2023
@aqurilla aqurilla requested a review from koppor June 4, 2023 20:01

@koppor koppor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reading the final variable, some suggestions.


ImportEntriesDialog dialog = new ImportEntriesDialog(stateManager.getActiveDatabase().get(), task);
dialog.setTitle(activeFetcher.getName());
dialog.setTitle(fetcherName);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The "new" variable should also be used - otherwise, it is confusing IMHO.

Suggested change
dialog.setTitle(fetcherName);
dialog.setTitle(finalFetcherName);

fetcherName = doiFetcher.getName();
}

String finalFetcherName = fetcherName;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then I would also state that in the code:

Suggested change
String finalFetcherName = fetcherName;
final String finalFetcherName = fetcherName;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it, I've updated the PR with these changes

@koppor koppor merged commit 0c0db90 into JabRef:main Jun 5, 2023
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.

Unable to search doi directly in web search

3 participants