Skip to content

Commit

Permalink
Fix for #12004issue:Rewrite handleStringData to use CompositeIdFetcher (
Browse files Browse the repository at this point in the history
JabRef#12009)

* Rewrite handleStringData to use CompositeIdFetcher JabRef#12004
add a no-args constructor to CompositeIdFetcher.java

* delete the no-args constructor.

---------

Co-authored-by: u7744550 <[email protected]>
  • Loading branch information
Red12138-java and JinyiZhuRed authored Oct 17, 2024
1 parent 1a0e44e commit 2c44ee1
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/main/java/org/jabref/gui/externalfiles/ImportHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.jabref.logic.citationkeypattern.CitationKeyGenerator;
import org.jabref.logic.database.DuplicateCheck;
import org.jabref.logic.externalfiles.ExternalFilesContentImporter;
import org.jabref.logic.importer.CompositeIdFetcher;
import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.ImportCleanup;
import org.jabref.logic.importer.ImportException;
Expand Down Expand Up @@ -359,22 +360,13 @@ public List<BibEntry> handleStringData(String data) throws FetcherException {
return Collections.emptyList();
}

Optional<DOI> doi = DOI.findInText(data);
if (doi.isPresent()) {
return fetchByDOI(doi.get());
if (!CompositeIdFetcher.containsValidId(data)) {
return tryImportFormats(data);
}

Optional<ArXivIdentifier> arXiv = ArXivIdentifier.parse(data);
if (arXiv.isPresent()) {
return fetchByArXiv(arXiv.get());
}

Optional<ISBN> isbn = ISBN.parse(data);
if (isbn.isPresent()) {
return fetchByISBN(isbn.get());
}

return tryImportFormats(data);
CompositeIdFetcher compositeIdFetcher = new CompositeIdFetcher(preferences.getImportFormatPreferences());
Optional<BibEntry> optional = compositeIdFetcher.performSearchById(data);
return OptionalUtil.toList(optional);
}

private List<BibEntry> tryImportFormats(String data) {
Expand Down

0 comments on commit 2c44ee1

Please sign in to comment.