Skip to content

Commit

Permalink
remove
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Jan 23, 2022
1 parent 69da313 commit f64206a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 61 deletions.
33 changes: 3 additions & 30 deletions src/main/java/org/jabref/gui/EntryTypeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
import javafx.concurrent.Task;
import javafx.concurrent.Worker;

import org.jabref.gui.duplicationFinder.DuplicateResolverDialog;
import org.jabref.gui.importer.NewEntryAction;
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
import org.jabref.logic.database.DuplicateCheck;
import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.IdBasedFetcher;
import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.importer.WebFetchers;
import org.jabref.logic.importer.fetcher.DoiFetcher;
import org.jabref.logic.l10n.Localization;
Expand Down Expand Up @@ -150,32 +146,9 @@ public void runFetcherWorker() {
Optional<BibEntry> result = fetcherWorker.getValue();
if (result.isPresent()) {
final BibEntry entry = result.get();
ImportCleanup cleanup = new ImportCleanup(libraryTab.getBibDatabaseContext().getMode());
cleanup.doPostCleanup(entry);
Optional<BibEntry> duplicate = new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(libraryTab.getDatabase(), entry, libraryTab.getBibDatabaseContext().getMode());
if (duplicate.isPresent()) {
DuplicateResolverDialog dialog = new DuplicateResolverDialog(entry, duplicate.get(), DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK, libraryTab.getBibDatabaseContext(), stateManager);
switch (dialogService.showCustomDialogAndWait(dialog).orElse(DuplicateResolverDialog.DuplicateResolverResult.BREAK)) {
case KEEP_LEFT:
libraryTab.getDatabase().removeEntry(duplicate.get());
libraryTab.getDatabase().insertEntry(entry);
break;
case KEEP_BOTH:
libraryTab.getDatabase().insertEntry(entry);
break;
case KEEP_MERGE:
libraryTab.getDatabase().removeEntry(duplicate.get());
libraryTab.getDatabase().insertEntry(dialog.getMergedEntry());
break;
default:
// Do nothing
break;
}
} else {
// Regenerate CiteKey of imported BibEntry
new CitationKeyGenerator(libraryTab.getBibDatabaseContext(), preferencesService.getCitationKeyPatternPreferences()).generateAndSetKey(entry);
libraryTab.insertEntry(entry);
}



searchSuccesfulProperty.set(true);
} else if (StringUtil.isBlank(idText.getValue())) {
dialogService.showWarningDialogAndWait(Localization.lang("Empty search ID"), Localization.lang("The given search ID was empty."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
import java.util.Optional;

import org.jabref.gui.DialogService;
import org.jabref.gui.Globals;
import org.jabref.gui.LibraryTab;
import org.jabref.gui.StateManager;
import org.jabref.gui.actions.SimpleCommand;
import org.jabref.gui.duplicationFinder.DuplicateResolverDialog;
import org.jabref.gui.util.BackgroundTask;
import org.jabref.gui.util.TaskExecutor;
import org.jabref.logic.JabRefException;
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
import org.jabref.logic.database.DuplicateCheck;
import org.jabref.logic.importer.CompositeIdFetcher;
import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.types.StandardEntryType;
Expand Down Expand Up @@ -64,32 +59,7 @@ public void execute() {
Optional<BibEntry> result = bibEntry;
if (result.isPresent()) {
final BibEntry entry = result.get();
ImportCleanup cleanup = new ImportCleanup(libraryTab.getBibDatabaseContext().getMode());
cleanup.doPostCleanup(entry);
Optional<BibEntry> duplicate = new DuplicateCheck(Globals.entryTypesManager).containsDuplicate(libraryTab.getDatabase(), entry, libraryTab.getBibDatabaseContext().getMode());
if (duplicate.isPresent()) {
DuplicateResolverDialog dialog = new DuplicateResolverDialog(entry, duplicate.get(), DuplicateResolverDialog.DuplicateResolverType.IMPORT_CHECK, libraryTab.getBibDatabaseContext(), stateManager);
switch (dialogService.showCustomDialogAndWait(dialog).orElse(DuplicateResolverDialog.DuplicateResolverResult.BREAK)) {
case KEEP_LEFT:
libraryTab.getDatabase().removeEntry(duplicate.get());
libraryTab.getDatabase().insertEntry(entry);
break;
case KEEP_BOTH:
libraryTab.getDatabase().insertEntry(entry);
break;
case KEEP_MERGE:
libraryTab.getDatabase().removeEntry(duplicate.get());
libraryTab.getDatabase().insertEntry(dialog.getMergedEntry());
break;
default:
// Do nothing
break;
}
} else {
// Regenerate CiteKey of imported BibEntry
new CitationKeyGenerator(libraryTab.getBibDatabaseContext(), preferencesService.getCitationKeyPatternPreferences()).generateAndSetKey(entry);
libraryTab.insertEntry(entry);
}

} else {
dialogService.notify("No entry found or import canceled");
}
Expand Down

0 comments on commit f64206a

Please sign in to comment.