Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Enable the exploration of bib entries' relations (cited by and citing) #10324

Merged
merged 17 commits into from
Sep 11, 2023

Conversation

HoussemNasri
Copy link
Member

@HoussemNasri HoussemNasri commented Sep 4, 2023

A continuation to #7160.

Closes #6187

Known Limitations

  • Related entries cached in-memory; should be on disk.
  • Relations are fetched exclusively based on the entry's DOI (SemantciScholar allows the usage of other types of ids .e.g. URL, ARXIV, PMID, etc.
  • No pagination

Screenshots

image

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.

HoussemNasri and others added 5 commits September 4, 2023 00:46
Co-authored-by: Tim Bachmann <58782027+timbachmann@users.noreply.github.com>
Co-authored-by: Raphael Kreft <r.kreft@unibas.ch>
Co-authored-by: Marcel Luethi <marcel.luethi@unibas.ch>
Co-authored-by: olivierM <olivier.mattmann@stud.unibas.ch>
Co-authored-by: matiascg <matiascargon@hotmail.com>
- Until we implement pagination, fetching 1000 citations/references seems fine.
@github-actions
Copy link
Contributor

github-actions bot commented Sep 4, 2023

Your code currently does not meet JabRef's code guidelines. The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR. Please carefully follow the setup guide for the codestyle. Afterwards, please run checkstyle locally and fix the issues.

More information on code quality in JabRef is available at https://devdocs.jabref.org/getting-into-the-code/development-strategy.html.

@ghost
Copy link

ghost commented Sep 4, 2023

Can I ask: is this the same as this request I made some time ago?
#10200

@HoussemNasri
Copy link
Member Author

@the-dino-girl It's similar to that, but the references we get from a public web API (similar to how fetchers work). It's also possible to get bib entries that cites the selected entry. It's under the "cited by" section.

@HoussemNasri HoussemNasri changed the title Enable the exploration bib entries' relations (cited by and citing) Enable the exploration of bib entries' relations (cited by and citing) Sep 4, 2023
@ghost
Copy link

ghost commented Sep 4, 2023

Can't wait for this feature!
I will extensively test it and report bugs (if any)

(Please add new translation strings if they are missing. I'm a jabref translator)

😍😍😍

@koppor
Copy link
Member

koppor commented Sep 5, 2023

Can't wait for this feature! I will extensively test it and report bugs (if any)

You can download the current build at https://builds.jabref.org/pull/10324/merge and report issues here.

(This is what the comment #10324 (comment) means -- grab the binary and play around with it)

@koppor koppor marked this pull request as draft September 5, 2023 19:50
@HoussemNasri HoussemNasri marked this pull request as ready for review September 6, 2023 18:18
@HoussemNasri HoussemNasri added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Sep 6, 2023
@HoussemNasri HoussemNasri requested a review from koppor September 6, 2023 18:18
@github-actions
Copy link
Contributor

github-actions bot commented Sep 6, 2023

The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build.

import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.identifier.DOI;

public class BibEntryRelationsCache {
Copy link
Member

Choose a reason for hiding this comment

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

For the moment this is okay, but we could store it in MV files as well or use something like caffeeine https://medium.com/outbrain-engineering/oh-my-guava-we-are-moving-to-caffeine-99387819fdbb

Copy link
Member Author

Choose a reason for hiding this comment

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

We already have a dependency on h2 MVStore, we could use that.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, like the journal abbreviation stuff. Write the stuff to a db int he user's app data dir

Siedlerchr
Siedlerchr previously approved these changes Sep 7, 2023
@Siedlerchr
Copy link
Member

Cool feature! Need to try this!

Comment on lines 283 to 414

if (searchType.equals(CitationFetcher.SearchType.CITING)) {
task = BackgroundTask.wrap(() -> {
if (shouldRefresh) {
bibEntryRelationsRepository.forceRefreshReferences(entry);
}
return bibEntryRelationsRepository.getReferences(entry);
});
citingTask = task;
} else {
task = BackgroundTask.wrap(() -> {
if (shouldRefresh) {
bibEntryRelationsRepository.forceRefreshCitations(entry);
}
return bibEntryRelationsRepository.getCitations(entry);
});
citedByTask = task;
}

task.onRunning(() -> prepareToSearchForRelations(abortButton, refreshButton, importButton, progress, task))
.onSuccess(fetchedList -> onSearchForRelationsSucceed(entry, listView, abortButton, refreshButton,
searchType, importButton, progress, fetchedList, observableList))
.onFailure(exception -> {
LOGGER.error("Error while fetching citing Articles", exception);
hideNodes(abortButton, progress, importButton);
listView.setPlaceholder(new Label(Localization.lang("Error while fetching citing entries: %0",
exception.getMessage())));

refreshButton.setVisible(true);
dialogService.notify(exception.getMessage());
})
.executeWith(Globals.TASK_EXECUTOR);
}

private void onSearchForRelationsSucceed(BibEntry entry, CheckListView<CitationRelationItem> listView,
Button abortButton, Button refreshButton,
CitationFetcher.SearchType searchType, Button importButton,
ProgressIndicator progress, List<BibEntry> fetchedList,
ObservableList<CitationRelationItem> observableList) {
hideNodes(abortButton, progress);

observableList.setAll(fetchedList.stream().map(entr -> new CitationRelationItem(entr, false))
.collect(Collectors.toList()));

if (!observableList.isEmpty()) {
listView.refresh();
} else {
Label placeholder = new Label(Localization.lang("No articles found"));
listView.setPlaceholder(placeholder);
}
BooleanBinding booleanBind = Bindings.isEmpty(listView.getCheckModel().getCheckedItems());
importButton.disableProperty().bind(booleanBind);
importButton.setOnMouseClicked(event -> importEntries(listView.getCheckModel().getCheckedItems(), searchType, entry));
showNodes(refreshButton, importButton);
}

private void prepareToSearchForRelations(Button abortButton, Button refreshButton, Button importButton,
ProgressIndicator progress, BackgroundTask<List<BibEntry>> task) {
showNodes(abortButton, progress);
hideNodes(refreshButton, importButton);

abortButton.setOnAction(event -> {
hideNodes(abortButton, progress, importButton);
showNodes(refreshButton);
task.cancel();
dialogService.notify(Localization.lang("Search aborted!"));
});
}

private void hideNodes(Node... nodes) {
Arrays.stream(nodes).forEach(node -> node.setVisible(false));
}

private void showNodes(Node... nodes) {
Arrays.stream(nodes).forEach(node -> node.setVisible(true));
}

// Absolute-phase phenomena in photoionization with few-cycle laser pulses

/**
* Function to import selected entries to the database. Also writes the entries to import to the CITING/CITED field
*
* @param entriesToImport entries to import
*/
private void importEntries(List<CitationRelationItem> entriesToImport, CitationFetcher.SearchType searchType, BibEntry entry) {
citingTask.cancel();
citedByTask.cancel();
List<BibEntry> entries = entriesToImport.stream().map(CitationRelationItem::getEntry).collect(Collectors.toList());
ImportHandler importHandler = new ImportHandler(
databaseContext,
preferencesService,
fileUpdateMonitor,
undoManager,
stateManager,
dialogService,
Globals.TASK_EXECUTOR);
importHandler.importEntries(entries);

dialogService.notify(Localization.lang("Number of entries successfully imported") + ": " + entriesToImport.size());
}
Copy link
Member

Choose a reason for hiding this comment

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

I have the strong suspicion, that some of this code belongs into a ViewModel

Copy link
Member Author

Choose a reason for hiding this comment

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

It surely does, but I thought we release the feature now letting users try it out and do some refactoring while working on the known limitations in later PRs.

Copy link
Member

Choose a reason for hiding this comment

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

ok, im fine with that. let ua just not forget about this, maybe an issue in the maintainers focus or sthg

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Thank you for working on this!

We fixed the openrewrite complains by running ./gradlew rewriteRun (at 14ecf06 (#10324)).

Will merge as soon as tests are green.

Follow-up issues created (in the melting pot).

Lets see, what the users will tell!

@koppor koppor merged commit 0c6c0a9 into main Sep 11, 2023
@koppor koppor deleted the citation-relation branch September 11, 2023 21:17
# for free to join this conversation on GitHub. Already have an account? # 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.

Add posibility to explore citation relations
4 participants