Skip to content

Commit 10a564c

Browse files
Added updating bibliographic info from web (#15011)
1 parent c0c315b commit 10a564c

File tree

5 files changed

+78
-3
lines changed

5 files changed

+78
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
2424
- REST-API: Added more commands (`selectentries`, `open`, `focus`). [#14855](https://github.com/JabRef/jabref/pull/14855)
2525
- REST-API: Added the possibility to trigger the import dialog. [#14855](https://github.com/JabRef/jabref/pull/14855)
2626
- REST-API: Allow import of supported formats via `POST http://localhost:23119/libraries/current/entries`. [#14896](https://github.com/JabRef/jabref/pull/14896)
27+
- We added the ability to update bibliographic information based on the existing entry data. [#14185](https://github.com/JabRef/jabref/issues/14185)
2728

2829
### Changed
2930

jabgui/src/main/java/org/jabref/gui/actions/StandardActions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ public enum StandardActions implements Action {
4848
SEARCH_GOOGLE_SCHOLAR(Localization.lang("Search Google Scholar")),
4949
SEARCH_SEMANTIC_SCHOLAR(Localization.lang("Search Semantic Scholar")),
5050
SEARCH_SHORTSCIENCE(Localization.lang("Search ShortScience")),
51-
MERGE_WITH_FETCHED_ENTRY(Localization.lang("Get bibliographic data from %0", "DOI/ISBN/..."), KeyBinding.MERGE_WITH_FETCHED_ENTRY),
52-
BATCH_MERGE_WITH_FETCHED_ENTRY(Localization.lang("Get bibliographic data from %0 (fully automated)", "DOI/ISBN/...")),
51+
MERGE_WITH_FETCHED_ENTRY(Localization.lang("Update with bibliographic information via identifier(s)")),
52+
BATCH_MERGE_WITH_FETCHED_ENTRY(Localization.lang("Update with bibliographic information via identifier(s) (fully automated)")),
53+
UPDATE_WITH_WEB_INFO(Localization.lang("Update with bibliographic information via entry data")),
5354
ATTACH_FILE(Localization.lang("Attach file"), IconTheme.JabRefIcons.ATTACH_FILE),
5455
ATTACH_FILE_FROM_URL(Localization.lang("Attach file from URL"), IconTheme.JabRefIcons.DOWNLOAD_FILE),
5556
PRIORITY(Localization.lang("Priority"), IconTheme.JabRefIcons.PRIORITY),

jabgui/src/main/java/org/jabref/gui/frame/MainMenu.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import org.jabref.gui.maintable.RightClickMenu;
5959
import org.jabref.gui.mergeentries.BatchEntryMergeWithFetchedDataAction;
6060
import org.jabref.gui.mergeentries.MergeWithFetchedEntryAction;
61+
import org.jabref.gui.mergeentries.UpdateWithBibliographicInformationByWebFetchers;
6162
import org.jabref.gui.mergeentries.threewaymerge.MergeEntriesAction;
6263
import org.jabref.gui.newentry.NewEntryDialogTab;
6364
import org.jabref.gui.preferences.GuiPreferences;
@@ -300,6 +301,10 @@ private void createMenu() {
300301
factory.createMenuItem(
301302
StandardActions.BATCH_MERGE_WITH_FETCHED_ENTRY,
302303
new BatchEntryMergeWithFetchedDataAction(stateManager, undoManager, preferences, dialogService, taskExecutor)),
304+
305+
factory.createMenuItem(
306+
StandardActions.UPDATE_WITH_WEB_INFO,
307+
new UpdateWithBibliographicInformationByWebFetchers(dialogService, preferences, stateManager, taskExecutor)),
303308
// endregion
304309

305310
new SeparatorMenuItem(),
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package org.jabref.gui.mergeentries;
2+
3+
import java.util.Set;
4+
5+
import org.jabref.gui.DialogService;
6+
import org.jabref.gui.StateManager;
7+
import org.jabref.gui.actions.ActionHelper;
8+
import org.jabref.gui.actions.SimpleCommand;
9+
import org.jabref.gui.mergeentries.multiwaymerge.MultiMergeEntriesView;
10+
import org.jabref.gui.preferences.GuiPreferences;
11+
import org.jabref.logic.importer.EntryBasedFetcher;
12+
import org.jabref.logic.importer.FetcherException;
13+
import org.jabref.logic.importer.WebFetchers;
14+
import org.jabref.logic.l10n.Localization;
15+
import org.jabref.logic.util.TaskExecutor;
16+
import org.jabref.model.entry.BibEntry;
17+
18+
public class UpdateWithBibliographicInformationByWebFetchers extends SimpleCommand {
19+
20+
private final DialogService dialogService;
21+
private final GuiPreferences guiPreferences;
22+
private final StateManager stateManager;
23+
private final TaskExecutor taskExecutor;
24+
25+
public UpdateWithBibliographicInformationByWebFetchers(DialogService dialogService,
26+
GuiPreferences preferences,
27+
StateManager stateManager,
28+
TaskExecutor taskExecutor) {
29+
this.dialogService = dialogService;
30+
this.guiPreferences = preferences;
31+
this.stateManager = stateManager;
32+
this.taskExecutor = taskExecutor;
33+
34+
this.executable.bind(ActionHelper.needsEntriesSelected(1, stateManager));
35+
}
36+
37+
@Override
38+
public void execute() {
39+
assert stateManager.getActiveDatabase().isPresent();
40+
41+
BibEntry originalEntry = stateManager.getSelectedEntries().getFirst();
42+
43+
MultiMergeEntriesView mergedEntriesView = new MultiMergeEntriesView(guiPreferences, taskExecutor);
44+
mergedEntriesView.addSource(Localization.lang("Original Entry"), () -> originalEntry);
45+
46+
Set<EntryBasedFetcher> webFetchers = WebFetchers.getEntryBasedFetchers(
47+
guiPreferences.getImporterPreferences(),
48+
guiPreferences.getImportFormatPreferences(),
49+
guiPreferences.getFilePreferences(),
50+
stateManager.getActiveDatabase().get()
51+
);
52+
53+
for (EntryBasedFetcher webFetcher : webFetchers) {
54+
mergedEntriesView.addSource(webFetcher.getName(), () -> {
55+
try {
56+
return webFetcher.performSearch(originalEntry).stream().findFirst().orElse(null);
57+
} catch (FetcherException e) {
58+
return null;
59+
}
60+
});
61+
}
62+
63+
dialogService.showCustomDialogAndWait(mergedEntriesView);
64+
}
65+
}

jablib/src/main/resources/l10n/JabRef_en.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1747,10 +1747,13 @@ remove\ string\ %0=remove string %0
17471747
undefined=undefined
17481748
Cannot\ get\ info\ based\ on\ given\ %0\:\ %1=Cannot get info based on given %0: %1
17491749
Get\ bibliographic\ data\ from\ %0=Get bibliographic data from %0
1750+
Original\ Entry=Original Entry
1751+
Update\ with\ bibliographic\ information\ via\ identifier(s)=Update with bibliographic information via identifier(s)
1752+
Update\ with\ bibliographic\ information\ via\ identifier(s)\ (fully\ automated)=Update with bibliographic information via identifier(s) (fully automated)
1753+
Update\ with\ bibliographic\ information\ via\ entry\ data=Update with bibliographic information via entry data
17501754
No\ %0\ found=No %0 found
17511755
Entry\ from\ %0=Entry from %0
17521756
Merge\ entry\ with\ %0\ information=Merge entry with %0 information
1753-
Get\ bibliographic\ data\ from\ %0\ (fully\ automated)=Get bibliographic data from %0 (fully automated)
17541757
Batch\ update\ successful.\ %0\ entry(s)\ updated.=Batch update successful. %0 entry(s) updated.
17551758
Merge\ operation\ cancelled\ after\ updating\ %0\ entry(s)=Merge operation cancelled after updating %0 entry(s)
17561759
No\ entries\ available\ for\ merging=No entries available for merging

0 commit comments

Comments
 (0)