Skip to content

Commit

Permalink
Rename to old names
Browse files Browse the repository at this point in the history
  • Loading branch information
InAnYan committed Dec 23, 2024
1 parent 43b4887 commit a3a36e0
Show file tree
Hide file tree
Showing 21 changed files with 96 additions and 99 deletions.
28 changes: 14 additions & 14 deletions src/main/java/org/jabref/gui/externalfiles/PdfMergeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* {@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) {
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/importer/ImportCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -153,7 +153,7 @@ private ParserResult doImport(List<Path> 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();
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/jabref/logic/importer/ImportFormatReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -44,7 +44,7 @@
* <p>
* Currently, IEEE two column format is supported.
* <p>
* To extract a {@link BibEntry} matching the PDF, see {@link PdfContentPartialImporter}.
* To extract a {@link BibEntry} matching the PDF, see {@link PdfContentImporter}.
* <p>
* TODO: This class is similar to {@link org.jabref.logic.importer.plaincitation.RuleBasedPlainCitationParser}, we need to unify them.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
* <p>
* After all importers are applied, this importer tries to fetch additional metadata for the entry using the DOI and ISBN.
Expand All @@ -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<PdfPartialImporter> metadataImporters;
private final List<PdfImporter> 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));
}
}

Expand All @@ -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}).
* <p>
* 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 {
Expand All @@ -122,7 +122,7 @@ public ParserResult importDatabase(Path filePath) throws IOException {
private List<BibEntry> extractCandidatesFromPdf(Path filePath, PDDocument document) {
List<BibEntry> candidates = new ArrayList<>();

for (PdfPartialImporter metadataImporter : metadataImporters) {
for (PdfImporter metadataImporter : metadataImporters) {
try {
List<BibEntry> extractedEntries = metadataImporter.importDatabase(filePath, document);
candidates.addAll(extractedEntries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* <p>
* 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}");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>
* {@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).
* <p>
* 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<BibEntry> importDatabase(Path filePath, PDDocument document) throws IOException, ParseException;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,7 +48,7 @@ class EmbeddedBibFilePdfExporterTest {

private EmbeddedBibFilePdfExporter exporter;

private PdfEmbeddedPartialImporter importer;
private PdfEmbeddedBibFileImporter importer;

private BibDatabaseContext databaseContext;
private JournalAbbreviationRepository abbreviationRepository;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit a3a36e0

Please sign in to comment.