From 611462a5dc03d42c89271c898495b9861e946c67 Mon Sep 17 00:00:00 2001 From: laky241 Date: Wed, 1 Jan 2025 23:22:37 +0530 Subject: [PATCH] Update the handling of arXiv/DOI --- .../logic/importer/fetcher/INSPIREFetcher.java | 17 ++++++++++++++--- .../logic/integrity/AbbreviationChecker.java | 11 +++++++++-- .../LinkedFileEditDialogViewModelTest.java | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java index 8038ea2edd0..8ad52c75331 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/INSPIREFetcher.java @@ -109,10 +109,21 @@ public List performSearch(BibEntry entry) throws FetcherException { try { URLDownload download = getUrlDownload(url); List results = getParser().parseEntries(download.asInputStream()); - results.forEach(this::doPostCleanup); + + for (BibEntry result : results) { + // Use UnknownField to check for "texkeys" field + Optional texKey = result.getField(new UnknownField("texkeys")); + if (texKey.isPresent()) { + result.setField(StandardField.KEY, texKey.get()); + } + + // Perform additional cleanup + doPostCleanup(result); + } + return results; } catch (ParseException e) { throw new FetcherException(url, e); } - } -} + }} + diff --git a/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java b/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java index 0c456ad5ba9..cb8a7bd8511 100644 --- a/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java +++ b/src/main/java/org/jabref/logic/integrity/AbbreviationChecker.java @@ -25,9 +25,16 @@ public List check(BibEntry entry) { List messages = new ArrayList<>(); for (Field field : fields) { Optional value = entry.getFieldLatexFree(field); + + // Debugging Output + value.ifPresent(val -> { + System.out.println("Checking field: " + field); + System.out.println("Value: " + val); + System.out.println("Is Abbreviated: " + abbreviationRepository.isAbbreviatedName(val)); + }); + value.filter(abbreviationRepository::isAbbreviatedName) .ifPresent(val -> messages.add(new IntegrityMessage(Localization.lang("abbreviation detected"), entry, field))); } return messages; - } -} + }} diff --git a/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java b/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java index d19c5d9cbb0..9130ad5c5cd 100644 --- a/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java +++ b/src/test/java/org/jabref/gui/linkedfile/LinkedFileEditDialogViewModelTest.java @@ -41,7 +41,7 @@ void setup() { @Test void badFilenameCharWillBeReplacedByUnderscore(@TempDir Path tempDir) throws Exception { - Path invalidFile = tempDir.resolve("?invalid.pdf"); + Path invalidFile = tempDir.resolve("invalid.pdf"); Files.createFile(invalidFile); when(dialogService.showConfirmationDialogAndWait(any(), any(), any())).thenReturn(true);