diff --git a/src/main/java/org/jabref/gui/externalfiles/PdfMergeDialog.java b/src/main/java/org/jabref/gui/externalfiles/PdfMergeDialog.java index 2879604d297..11f6a4935f6 100644 --- a/src/main/java/org/jabref/gui/externalfiles/PdfMergeDialog.java +++ b/src/main/java/org/jabref/gui/externalfiles/PdfMergeDialog.java @@ -8,23 +8,23 @@ import org.jabref.gui.preferences.GuiPreferences; import org.jabref.logic.importer.Importer; import org.jabref.logic.importer.ParserResult; -import org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfContentPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfGrobidPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfVerbatimPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfXmpPartialImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfContentImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedBibFileImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfGrobidImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfVerbatimImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfXmpImporter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.TaskExecutor; import org.jabref.model.entry.BibEntry; public class PdfMergeDialog { /** - * Constructs a merge dialog for a PDF file. This dialog merges results from various {@link PdfPartialImporter}s. + * Constructs a merge dialog for a PDF file. This dialog merges results from various {@link PdfImporter}s. *

- * {@link PdfPartialImporter}s try to extract a {@link BibEntry} out of a PDF file, + * {@link PdfImporter}s try to extract a {@link BibEntry} out of a PDF file, * but it does not perform this 100% perfectly, it is only a set of heuristics that in some cases might work, in others not. - * Thus, JabRef provides this merge dialog that collects the results of all {@link PdfPartialImporter}s + * Thus, JabRef provides this merge dialog that collects the results of all {@link PdfImporter}s * and gives user a choice between field values. */ public static MultiMergeEntriesView make(BibEntry entry, Path filePath, GuiPreferences preferences, TaskExecutor taskExecutor) { @@ -33,15 +33,15 @@ public static MultiMergeEntriesView make(BibEntry entry, Path filePath, GuiPrefe dialog.setTitle(Localization.lang("Merge PDF metadata")); dialog.addSource(Localization.lang("Entry"), entry); - dialog.addSource(Localization.lang("Verbatim"), wrapImporterToSupplier(new PdfVerbatimPartialImporter(preferences.getImportFormatPreferences()), filePath)); - dialog.addSource(Localization.lang("Embedded"), wrapImporterToSupplier(new PdfEmbeddedPartialImporter(preferences.getImportFormatPreferences()), filePath)); + dialog.addSource(Localization.lang("Verbatim"), wrapImporterToSupplier(new PdfVerbatimImporter(preferences.getImportFormatPreferences()), filePath)); + dialog.addSource(Localization.lang("Embedded"), wrapImporterToSupplier(new PdfEmbeddedBibFileImporter(preferences.getImportFormatPreferences()), filePath)); if (preferences.getGrobidPreferences().isGrobidEnabled()) { - dialog.addSource("Grobid", wrapImporterToSupplier(new PdfGrobidPartialImporter(preferences.getImportFormatPreferences()), filePath)); + dialog.addSource("Grobid", wrapImporterToSupplier(new PdfGrobidImporter(preferences.getImportFormatPreferences()), filePath)); } - dialog.addSource(Localization.lang("XMP metadata"), wrapImporterToSupplier(new PdfXmpPartialImporter(preferences.getXmpPreferences()), filePath)); - dialog.addSource(Localization.lang("Content"), wrapImporterToSupplier(new PdfContentPartialImporter(), filePath)); + dialog.addSource(Localization.lang("XMP metadata"), wrapImporterToSupplier(new PdfXmpImporter(preferences.getXmpPreferences()), filePath)); + dialog.addSource(Localization.lang("Content"), wrapImporterToSupplier(new PdfContentImporter(), filePath)); return dialog; } diff --git a/src/main/java/org/jabref/gui/importer/ImportCommand.java b/src/main/java/org/jabref/gui/importer/ImportCommand.java index c201d8e3e05..58e268cd54e 100644 --- a/src/main/java/org/jabref/gui/importer/ImportCommand.java +++ b/src/main/java/org/jabref/gui/importer/ImportCommand.java @@ -24,7 +24,7 @@ import org.jabref.logic.importer.Importer; import org.jabref.logic.importer.ParserResult; import org.jabref.logic.importer.fileformat.PdfMergeMetadataImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfGrobidPartialImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfGrobidImporter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.preferences.CliPreferences; import org.jabref.logic.util.BackgroundTask; @@ -153,7 +153,7 @@ private ParserResult doImport(List files, Importer importFormat) throws IO imports.add(importFormatReader.importUnknownFormat(filename, fileUpdateMonitor)); } else { UiTaskExecutor.runAndWaitInJavaFXThread(() -> { - if (((importer.get() instanceof PdfGrobidPartialImporter) || (importer.get() instanceof PdfMergeMetadataImporter)) + if (((importer.get() instanceof PdfGrobidImporter) || (importer.get() instanceof PdfMergeMetadataImporter)) && GrobidUseDialogHelper.showAndWaitIfUserIsUndecided(dialogService, preferences.getGrobidPreferences())) { importFormatReader.reset(); } diff --git a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java index 2fddf1d888c..889321ba7c6 100644 --- a/src/main/java/org/jabref/logic/importer/ImportFormatReader.java +++ b/src/main/java/org/jabref/logic/importer/ImportFormatReader.java @@ -27,11 +27,11 @@ import org.jabref.logic.importer.fileformat.PdfMergeMetadataImporter; import org.jabref.logic.importer.fileformat.RepecNepImporter; import org.jabref.logic.importer.fileformat.RisImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfContentPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfGrobidPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfVerbatimPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfXmpPartialImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfContentImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedBibFileImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfGrobidImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfVerbatimImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfXmpImporter; import org.jabref.logic.l10n.Localization; import org.jabref.model.database.BibDatabases; import org.jabref.model.entry.BibEntry; @@ -75,13 +75,13 @@ public void reset() { formats.add(new MsBibImporter()); formats.add(new OvidImporter()); formats.add(new PdfMergeMetadataImporter(importFormatPreferences)); - formats.add(new PdfVerbatimPartialImporter(importFormatPreferences)); - formats.add(new PdfContentPartialImporter()); - formats.add(new PdfEmbeddedPartialImporter(importFormatPreferences)); + formats.add(new PdfVerbatimImporter(importFormatPreferences)); + formats.add(new PdfContentImporter()); + formats.add(new PdfEmbeddedBibFileImporter(importFormatPreferences)); if (importFormatPreferences.grobidPreferences().isGrobidEnabled()) { - formats.add(new PdfGrobidPartialImporter(importFormatPreferences)); + formats.add(new PdfGrobidImporter(importFormatPreferences)); } - formats.add(new PdfXmpPartialImporter(importFormatPreferences.xmpPreferences())); + formats.add(new PdfXmpImporter(importFormatPreferences.xmpPreferences())); formats.add(new RepecNepImporter(importFormatPreferences)); formats.add(new RisImporter()); formats.add(new CffImporter(citationKeyPatternPreferences)); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfImporter.java index 4437edd7fe5..340a67528d2 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfImporter.java @@ -19,7 +19,7 @@ import org.jabref.logic.importer.AuthorListParser; import org.jabref.logic.importer.Importer; import org.jabref.logic.importer.ParserResult; -import org.jabref.logic.importer.fileformat.pdf.PdfContentPartialImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfContentImporter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.FileType; import org.jabref.logic.util.StandardFileType; @@ -44,7 +44,7 @@ *

* Currently, IEEE two column format is supported. *

- * To extract a {@link BibEntry} matching the PDF, see {@link PdfContentPartialImporter}. + * To extract a {@link BibEntry} matching the PDF, see {@link PdfContentImporter}. *

* TODO: This class is similar to {@link org.jabref.logic.importer.plaincitation.RuleBasedPlainCitationParser}, we need to unify them. */ diff --git a/src/main/java/org/jabref/logic/importer/fileformat/PdfMergeMetadataImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/PdfMergeMetadataImporter.java index b28df1a20b6..4b263e9c8ee 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/PdfMergeMetadataImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/PdfMergeMetadataImporter.java @@ -19,12 +19,12 @@ import org.jabref.logic.importer.fetcher.ArXivFetcher; import org.jabref.logic.importer.fetcher.DoiFetcher; import org.jabref.logic.importer.fetcher.isbntobibtex.IsbnFetcher; -import org.jabref.logic.importer.fileformat.pdf.PdfPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfContentPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfGrobidPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfVerbatimPartialImporter; -import org.jabref.logic.importer.fileformat.pdf.PdfXmpPartialImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfContentImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedBibFileImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfGrobidImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfVerbatimImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfXmpImporter; import org.jabref.logic.importer.util.FileFieldParser; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.StandardFileType; @@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory; /** - * Tries to import BibTeX data trying multiple {@link PdfPartialImporter}s and merging the results. + * Tries to import BibTeX data trying multiple {@link PdfImporter}s and merging the results. * See {@link PdfMergeMetadataImporter#metadataImporters} for the list of importers used. *

* After all importers are applied, this importer tries to fetch additional metadata for the entry using the DOI and ISBN. @@ -52,21 +52,21 @@ public class PdfMergeMetadataImporter extends Importer { private static final Logger LOGGER = LoggerFactory.getLogger(PdfMergeMetadataImporter.class); private final ImportFormatPreferences importFormatPreferences; - private final List metadataImporters; + private final List metadataImporters; public PdfMergeMetadataImporter(ImportFormatPreferences importFormatPreferences) { this.importFormatPreferences = importFormatPreferences; // TODO: Evaluate priorities of these {@link PdfBibExtractor}s. this.metadataImporters = new ArrayList<>(List.of( - new PdfVerbatimPartialImporter(importFormatPreferences), - new PdfEmbeddedPartialImporter(importFormatPreferences), - new PdfXmpPartialImporter(importFormatPreferences.xmpPreferences()), - new PdfContentPartialImporter() + new PdfVerbatimImporter(importFormatPreferences), + new PdfEmbeddedBibFileImporter(importFormatPreferences), + new PdfXmpImporter(importFormatPreferences.xmpPreferences()), + new PdfContentImporter() )); if (importFormatPreferences.grobidPreferences().isGrobidEnabled()) { - this.metadataImporters.add(2, new PdfGrobidPartialImporter(importFormatPreferences)); + this.metadataImporters.add(2, new PdfGrobidImporter(importFormatPreferences)); } } @@ -90,12 +90,12 @@ public ParserResult importDatabase(String data) throws IOException { } /** - * Makes {@link BibEntry} out of PDF file via merging results of several PDF analysis steps ({@link PdfPartialImporter}). + * Makes {@link BibEntry} out of PDF file via merging results of several PDF analysis steps ({@link PdfImporter}). *

* Algorithm: * 1. Store all candidates (possible {@link BibEntry}ies) in a list. First elements in this list will have higher * priority for merging, which means that more fields will be stored for first entries, rather than last. - * 2. Run {@link PdfPartialImporter}s, and store extracted candidates in the list. + * 2. Run {@link PdfImporter}s, and store extracted candidates in the list. */ @Override public ParserResult importDatabase(Path filePath) throws IOException { @@ -122,7 +122,7 @@ public ParserResult importDatabase(Path filePath) throws IOException { private List extractCandidatesFromPdf(Path filePath, PDDocument document) { List candidates = new ArrayList<>(); - for (PdfPartialImporter metadataImporter : metadataImporters) { + for (PdfImporter metadataImporter : metadataImporters) { try { List extractedEntries = metadataImporter.importDatabase(filePath, document); candidates.addAll(extractedEntries); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentPartialImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java similarity index 99% rename from src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentPartialImporter.java rename to src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java index 401e41f75f6..4341ab6a58f 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentPartialImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporter.java @@ -43,7 +43,7 @@ *

* If several PDF importers should be tried, use {@link PdfMergeMetadataImporter}. */ -public class PdfContentPartialImporter extends PdfPartialImporter { +public class PdfContentImporter extends PdfImporter { private static final Pattern YEAR_EXTRACT_PATTERN = Pattern.compile("\\d{4}"); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfEmbeddedPartialImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfEmbeddedBibFileImporter.java similarity index 97% rename from src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfEmbeddedPartialImporter.java rename to src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfEmbeddedBibFileImporter.java index 6498a10cea3..a5c965a02f8 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfEmbeddedPartialImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfEmbeddedBibFileImporter.java @@ -26,11 +26,11 @@ /** * Imports an embedded Bib-File from the PDF. */ -public class PdfEmbeddedPartialImporter extends PdfPartialImporter { +public class PdfEmbeddedBibFileImporter extends PdfImporter { private final BibtexParser bibtexParser; - public PdfEmbeddedPartialImporter(ImportFormatPreferences importFormatPreferences) { + public PdfEmbeddedBibFileImporter(ImportFormatPreferences importFormatPreferences) { bibtexParser = new BibtexParser(importFormatPreferences); } diff --git a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfGrobidPartialImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfGrobidImporter.java similarity index 83% rename from src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfGrobidPartialImporter.java rename to src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfGrobidImporter.java index 279bf594fe6..d4e5dba015c 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfGrobidPartialImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfGrobidImporter.java @@ -13,14 +13,14 @@ import org.apache.pdfbox.pdmodel.PDDocument; /** - * Wraps the GrobidService function to be used as a {@link PdfPartialImporter}. + * Wraps the GrobidService function to be used as a {@link PdfImporter}. */ -public class PdfGrobidPartialImporter extends PdfPartialImporter { +public class PdfGrobidImporter extends PdfImporter { private final GrobidService grobidService; private final ImportFormatPreferences importFormatPreferences; - public PdfGrobidPartialImporter(ImportFormatPreferences importFormatPreferences) { + public PdfGrobidImporter(ImportFormatPreferences importFormatPreferences) { this.grobidService = new GrobidService(importFormatPreferences.grobidPreferences()); this.importFormatPreferences = importFormatPreferences; } diff --git a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfPartialImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfImporter.java similarity index 86% rename from src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfPartialImporter.java rename to src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfImporter.java index 1fe37396334..2c792000c3b 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfPartialImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfImporter.java @@ -18,19 +18,19 @@ import org.apache.pdfbox.pdmodel.PDDocument; /** - * Intermediate class to bundle all PDF analysis steps. {@link PdfPartialImporter} are also {@link org.jabref.logic.importer.Importer}s, + * Intermediate class to bundle all PDF analysis steps. {@link PdfImporter}s are also {@link org.jabref.logic.importer.Importer}s, * which allows user for more fine-grained control of how {@link BibEntry} is extracted from a PDF file. *

- * {@link PdfPartialImporter}s are used in two places in JabRef: - * 1. {@link PdfMergeMetadataImporter}: uses several {@link PdfPartialImporter} and automatically + * {@link PdfImporter}s are used in two places in JabRef: + * 1. {@link PdfMergeMetadataImporter}: uses several {@link PdfImporter} and automatically * merges them into 1 {@link BibEntry}. - * 2. {@link org.jabref.gui.externalfiles.PdfMergeDialog}: also uses several {@link PdfPartialImporter}, but + * 2. {@link org.jabref.gui.externalfiles.PdfMergeDialog}: also uses several {@link PdfImporter}, but * it shows a merge dialog (instead of automatic merging). *

* Note, that this step should not add PDF file to {@link BibEntry}, it will be finally added either in - * {@link PdfPartialImporter#importDatabase(Path)} or {@link PdfMergeMetadataImporter}. + * {@link PdfImporter#importDatabase(Path)} or {@link PdfMergeMetadataImporter}. */ -public abstract class PdfPartialImporter extends Importer { +public abstract class PdfImporter extends Importer { public abstract List importDatabase(Path filePath, PDDocument document) throws IOException, ParseException; @Override diff --git a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfVerbatimPartialImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfVerbatimImporter.java similarity index 90% rename from src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfVerbatimPartialImporter.java rename to src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfVerbatimImporter.java index 090f5c70a41..402aa002564 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfVerbatimPartialImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfVerbatimImporter.java @@ -16,11 +16,11 @@ /** * This importer imports a verbatim BibTeX entry from the first page of the PDF. */ -public class PdfVerbatimPartialImporter extends PdfPartialImporter { +public class PdfVerbatimImporter extends PdfImporter { private final ImportFormatPreferences importFormatPreferences; - public PdfVerbatimPartialImporter(ImportFormatPreferences importFormatPreferences) { + public PdfVerbatimImporter(ImportFormatPreferences importFormatPreferences) { this.importFormatPreferences = importFormatPreferences; } diff --git a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfXmpPartialImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfXmpImporter.java similarity index 88% rename from src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfXmpPartialImporter.java rename to src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfXmpImporter.java index ead400f3535..491d66e3d89 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfXmpPartialImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/pdf/PdfXmpImporter.java @@ -14,11 +14,11 @@ /** * Wraps the XMPUtility function to be used as an Importer. */ -public class PdfXmpPartialImporter extends PdfPartialImporter { +public class PdfXmpImporter extends PdfImporter { private final XmpPreferences xmpPreferences; - public PdfXmpPartialImporter(XmpPreferences xmpPreferences) { + public PdfXmpImporter(XmpPreferences xmpPreferences) { this.xmpPreferences = xmpPreferences; } diff --git a/src/test/java/org/jabref/logic/exporter/EmbeddedBibFilePdfExporterTest.java b/src/test/java/org/jabref/logic/exporter/EmbeddedBibFilePdfExporterTest.java index b243fabd644..9b88521dd91 100644 --- a/src/test/java/org/jabref/logic/exporter/EmbeddedBibFilePdfExporterTest.java +++ b/src/test/java/org/jabref/logic/exporter/EmbeddedBibFilePdfExporterTest.java @@ -11,7 +11,7 @@ import org.jabref.logic.FilePreferences; import org.jabref.logic.bibtex.FieldPreferences; import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedPartialImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedBibFileImporter; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; @@ -48,7 +48,7 @@ class EmbeddedBibFilePdfExporterTest { private EmbeddedBibFilePdfExporter exporter; - private PdfEmbeddedPartialImporter importer; + private PdfEmbeddedBibFileImporter importer; private BibDatabaseContext databaseContext; private JournalAbbreviationRepository abbreviationRepository; @@ -119,7 +119,7 @@ void setUp() throws IOException { ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); when(importFormatPreferences.fieldPreferences().getNonWrappableFields()).thenReturn(FXCollections.emptyObservableList()); - importer = new PdfEmbeddedPartialImporter(importFormatPreferences); + importer = new PdfEmbeddedBibFileImporter(importFormatPreferences); databaseContext = new BibDatabaseContext(); BibDatabase dataBase = databaseContext.getDatabase(); diff --git a/src/test/java/org/jabref/logic/exporter/XmpPdfExporterTest.java b/src/test/java/org/jabref/logic/exporter/XmpPdfExporterTest.java index eb5c4d35466..78100aef228 100644 --- a/src/test/java/org/jabref/logic/exporter/XmpPdfExporterTest.java +++ b/src/test/java/org/jabref/logic/exporter/XmpPdfExporterTest.java @@ -13,7 +13,7 @@ import org.jabref.logic.cleanup.FieldFormatterCleanup; import org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter; import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.logic.importer.fileformat.pdf.PdfXmpPartialImporter; +import org.jabref.logic.importer.fileformat.pdf.PdfXmpImporter; import org.jabref.logic.journals.JournalAbbreviationRepository; import org.jabref.logic.xmp.XmpPreferences; import org.jabref.logic.xmp.XmpUtilWriter; @@ -52,7 +52,7 @@ class XmpPdfExporterTest { private static final BibEntry VAPNIK_2000 = new BibEntry(StandardEntryType.Article); private XmpPdfExporter exporter; - private PdfXmpPartialImporter importer; + private PdfXmpImporter importer; private XmpPreferences xmpPreferences; private BibDatabaseContext databaseContext; @@ -109,7 +109,7 @@ void setUp() throws IOException { ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); when(importFormatPreferences.fieldPreferences().getNonWrappableFields()).thenReturn(FXCollections.emptyObservableList()); - importer = new PdfXmpPartialImporter(xmpPreferences); + importer = new PdfXmpImporter(xmpPreferences); databaseContext = new BibDatabaseContext(); BibDatabase dataBase = databaseContext.getDatabase(); diff --git a/src/test/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfPartialImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfImporterTest.java similarity index 98% rename from src/test/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfPartialImporterTest.java rename to src/test/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfImporterTest.java index cd7d856c627..661f30c04b2 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfPartialImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/BibliographyFromPdfImporterTest.java @@ -16,7 +16,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -class BibliographyFromPdfPartialImporterTest { +class BibliographyFromPdfImporterTest { private static final BibEntry KNASTER_2017 = new BibEntry(StandardEntryType.Article) .withCitationKey("1") @@ -144,7 +144,7 @@ void setup() { @Test void tua3i2refpage() throws Exception { - Path file = Path.of(BibliographyFromPdfPartialImporterTest.class.getResource("/pdfs/IEEE/tua3i2refpage.pdf").toURI()); + Path file = Path.of(BibliographyFromPdfImporterTest.class.getResource("/pdfs/IEEE/tua3i2refpage.pdf").toURI()); ParserResult parserResult = bibliographyFromPdfImporter.importDatabase(file); BibEntry entry02 = new BibEntry(StandardEntryType.Article) .withCitationKey("2") @@ -263,7 +263,7 @@ void tua3i2refpage() throws Exception { @Test void ieeePaper() throws Exception { - Path file = Path.of(BibliographyFromPdfPartialImporterTest.class.getResource("/pdfs/IEEE/ieee-paper.pdf").toURI()); + Path file = Path.of(BibliographyFromPdfImporterTest.class.getResource("/pdfs/IEEE/ieee-paper.pdf").toURI()); ParserResult parserResult = bibliographyFromPdfImporter.importDatabase(file); assertEquals(List.of(ALVER2007, ALVER2007A, KOPP2012, KOPPP2018, KOENIG2023), parserResult.getDatabase().getEntries()); } diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterFilesTest.java b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporterFilesTest.java similarity index 79% rename from src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterFilesTest.java rename to src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporterFilesTest.java index 103094f25a1..daf31362996 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterFilesTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfContentImporterFilesTest.java @@ -1,10 +1,10 @@ -package org.jabref.logic.importer.fileformat; +package org.jabref.logic.importer.fileformat.pdf; import java.io.IOException; import java.util.function.Predicate; import java.util.stream.Stream; -import org.jabref.logic.importer.fileformat.pdf.PdfContentPartialImporter; +import org.jabref.logic.importer.fileformat.ImporterTestEngine; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; @@ -23,13 +23,13 @@ private static Stream fileNames() throws IOException { @ParameterizedTest @MethodSource("fileNames") void isRecognizedFormat(String fileName) throws IOException { - ImporterTestEngine.testIsRecognizedFormat(new PdfContentPartialImporter(), fileName); + ImporterTestEngine.testIsRecognizedFormat(new PdfContentImporter(), fileName); } @ParameterizedTest @MethodSource("fileNames") @Disabled("bib file does not contain linked file") void importEntries(String fileName) throws Exception { - ImporterTestEngine.testImportEntries(new PdfContentPartialImporter(), fileName, FILE_ENDING); + ImporterTestEngine.testImportEntries(new PdfContentImporter(), fileName, FILE_ENDING); } } diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfContentPartialImporterTest.java similarity index 93% rename from src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java rename to src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfContentPartialImporterTest.java index cfedf5735fc..6dfdb722626 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfContentPartialImporterTest.java @@ -1,4 +1,4 @@ -package org.jabref.logic.importer.fileformat; +package org.jabref.logic.importer.fileformat.pdf; import java.nio.file.Path; import java.util.List; @@ -6,7 +6,6 @@ import java.util.Optional; import java.util.stream.Stream; -import org.jabref.logic.importer.fileformat.pdf.PdfContentPartialImporter; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.StandardField; @@ -19,20 +18,20 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -class PdfContentImporterTest { +class PdfContentPartialImporterTest { - private final PdfContentPartialImporter importer = new PdfContentPartialImporter(); + private final PdfContentImporter importer = new PdfContentImporter(); @Test void doesNotHandleEncryptedPdfs() throws Exception { - Path file = Path.of(PdfContentPartialImporter.class.getResource("/pdfs/encrypted.pdf").toURI()); + Path file = Path.of(PdfContentImporter.class.getResource("/pdfs/encrypted.pdf").toURI()); List result = importer.importDatabase(file).getDatabase().getEntries(); assertEquals(List.of(), result); } @Test void importTwiceWorksAsExpected() throws Exception { - Path file = Path.of(PdfContentPartialImporter.class.getResource("/pdfs/minimal.pdf").toURI()); + Path file = Path.of(PdfContentImporter.class.getResource("/pdfs/minimal.pdf").toURI()); List result = importer.importDatabase(file).getDatabase().getEntries(); BibEntry expected = new BibEntry(StandardEntryType.InProceedings) @@ -133,7 +132,7 @@ British Journal of Nutrition (2008), 99, 1–11 doi: 10.1017/S0007114507795296 @ParameterizedTest @MethodSource("providePdfData") void pdfTitleExtraction(String expectedTitle, String filePath) throws Exception { - Path file = Path.of(Objects.requireNonNull(PdfContentPartialImporter.class.getResource(filePath)).toURI()); + Path file = Path.of(Objects.requireNonNull(PdfContentImporter.class.getResource(filePath)).toURI()); List result = importer.importDatabase(file).getDatabase().getEntries(); assertEquals(Optional.of(expectedTitle), result.getFirst().getTitle()); } diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfEmbeddedBibFileImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfEmbeddedBibFileImporterTest.java similarity index 86% rename from src/test/java/org/jabref/logic/importer/fileformat/PdfEmbeddedBibFileImporterTest.java rename to src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfEmbeddedBibFileImporterTest.java index 71f0be716fe..18406c0d8ed 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfEmbeddedBibFileImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfEmbeddedBibFileImporterTest.java @@ -1,4 +1,4 @@ -package org.jabref.logic.importer.fileformat; +package org.jabref.logic.importer.fileformat.pdf; import java.nio.file.Path; import java.util.Collections; @@ -7,7 +7,6 @@ import javafx.collections.FXCollections; import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.logic.importer.fileformat.pdf.PdfEmbeddedPartialImporter; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; import org.jabref.model.entry.types.StandardEntryType; @@ -22,18 +21,18 @@ class PdfEmbeddedBibFileImporterTest { - private PdfEmbeddedPartialImporter importer; + private PdfEmbeddedBibFileImporter importer; @BeforeEach void setUp() { ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); when(importFormatPreferences.fieldPreferences().getNonWrappableFields()).thenReturn(FXCollections.emptyObservableList()); - importer = new PdfEmbeddedPartialImporter(importFormatPreferences); + importer = new PdfEmbeddedBibFileImporter(importFormatPreferences); } @Test void doesNotHandleEncryptedPdfs() throws Exception { - Path file = Path.of(PdfEmbeddedPartialImporter.class.getResource("/pdfs/encrypted.pdf").toURI()); + Path file = Path.of(PdfEmbeddedBibFileImporter.class.getResource("/pdfs/encrypted.pdf").toURI()); List result = importer.importDatabase(file).getDatabase().getEntries(); assertEquals(Collections.emptyList(), result); } diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfGrobidImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfGrobidImporterTest.java similarity index 92% rename from src/test/java/org/jabref/logic/importer/fileformat/PdfGrobidImporterTest.java rename to src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfGrobidImporterTest.java index 2729fcb298f..3b5be180379 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfGrobidImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfGrobidImporterTest.java @@ -1,4 +1,4 @@ -package org.jabref.logic.importer.fileformat; +package org.jabref.logic.importer.fileformat.pdf; import java.io.IOException; import java.net.URISyntaxException; @@ -7,7 +7,6 @@ import java.util.Optional; import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.logic.importer.fileformat.pdf.PdfGrobidPartialImporter; import org.jabref.logic.importer.util.GrobidPreferences; import org.jabref.logic.util.StandardFileType; import org.jabref.model.entry.BibEntry; @@ -28,7 +27,7 @@ @FetcherTest class PdfGrobidImporterTest { - private PdfGrobidPartialImporter importer; + private PdfGrobidImporter importer; @BeforeEach void setUp() { @@ -40,7 +39,7 @@ void setUp() { when(importFormatPreferences.bibEntryPreferences().getKeywordSeparator()).thenReturn(','); when(importFormatPreferences.grobidPreferences()).thenReturn(grobidPreferences); - importer = new PdfGrobidPartialImporter(importFormatPreferences); + importer = new PdfGrobidImporter(importFormatPreferences); } @Test diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfMergeMetadataImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfMergeMetadataImporterTest.java similarity index 97% rename from src/test/java/org/jabref/logic/importer/fileformat/PdfMergeMetadataImporterTest.java rename to src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfMergeMetadataImporterTest.java index ca6c3d42dd5..3e55db53d47 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfMergeMetadataImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfMergeMetadataImporterTest.java @@ -1,4 +1,4 @@ -package org.jabref.logic.importer.fileformat; +package org.jabref.logic.importer.fileformat.pdf; import java.nio.file.Path; import java.util.Collections; @@ -8,6 +8,7 @@ import org.jabref.logic.FilePreferences; import org.jabref.logic.importer.ImportFormatPreferences; +import org.jabref.logic.importer.fileformat.PdfMergeMetadataImporter; import org.jabref.logic.importer.util.GrobidPreferences; import org.jabref.logic.util.StandardFileType; import org.jabref.model.database.BibDatabaseContext; diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfVerbatimBibtexImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfVerbatimBibtexImporterTest.java similarity index 86% rename from src/test/java/org/jabref/logic/importer/fileformat/PdfVerbatimBibtexImporterTest.java rename to src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfVerbatimBibtexImporterTest.java index d956ea6e323..6d93583ccd4 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfVerbatimBibtexImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfVerbatimBibtexImporterTest.java @@ -1,4 +1,4 @@ -package org.jabref.logic.importer.fileformat; +package org.jabref.logic.importer.fileformat.pdf; import java.nio.file.Path; import java.util.Collections; @@ -7,7 +7,6 @@ import javafx.collections.FXCollections; import org.jabref.logic.importer.ImportFormatPreferences; -import org.jabref.logic.importer.fileformat.pdf.PdfVerbatimPartialImporter; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; import org.jabref.model.entry.field.StandardField; @@ -23,18 +22,18 @@ class PdfVerbatimBibtexImporterTest { - private PdfVerbatimPartialImporter importer; + private PdfVerbatimImporter importer; @BeforeEach void setUp() { ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS); when(importFormatPreferences.fieldPreferences().getNonWrappableFields()).thenReturn(FXCollections.emptyObservableList()); - importer = new PdfVerbatimPartialImporter(importFormatPreferences); + importer = new PdfVerbatimImporter(importFormatPreferences); } @Test void doesNotHandleEncryptedPdfs() throws Exception { - Path file = Path.of(PdfVerbatimPartialImporter.class.getResource("/pdfs/encrypted.pdf").toURI()); + Path file = Path.of(PdfVerbatimImporter.class.getResource("/pdfs/encrypted.pdf").toURI()); List result = importer.importDatabase(file).getDatabase().getEntries(); assertEquals(Collections.emptyList(), result); } diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfXmpImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfXmpImporterTest.java similarity index 92% rename from src/test/java/org/jabref/logic/importer/fileformat/PdfXmpImporterTest.java rename to src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfXmpImporterTest.java index d9ec4f72fad..a4aeb31ab45 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfXmpImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/pdf/PdfXmpImporterTest.java @@ -1,4 +1,4 @@ -package org.jabref.logic.importer.fileformat; +package org.jabref.logic.importer.fileformat.pdf; import java.io.IOException; import java.net.URISyntaxException; @@ -9,7 +9,7 @@ import java.util.stream.Stream; import org.jabref.logic.importer.ParserResult; -import org.jabref.logic.importer.fileformat.pdf.PdfXmpPartialImporter; +import org.jabref.logic.importer.fileformat.ImporterTestEngine; import org.jabref.logic.xmp.XmpPreferences; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.field.StandardField; @@ -26,7 +26,7 @@ class PdfXmpImporterTest { - private PdfXmpPartialImporter importer; + private PdfXmpImporter importer; private static Stream invalidFileNames() throws IOException { Predicate fileName = name -> !name.contains("annotated.pdf"); @@ -35,7 +35,7 @@ private static Stream invalidFileNames() throws IOException { @BeforeEach void setUp() { - importer = new PdfXmpPartialImporter(mock(XmpPreferences.class)); + importer = new PdfXmpImporter(mock(XmpPreferences.class)); } @Disabled("XMP reader prints warnings to the logger when parsing does not work")