use of org.jabref.logic.importer.fileformat.PdfXmpImporter in project jabref by JabRef.
the class PdfImporter method doXMPImport.
private void doXMPImport(String fileName, List<BibEntry> res) {
List<BibEntry> localRes = new ArrayList<>();
PdfXmpImporter importer = new PdfXmpImporter(Globals.prefs.getXMPPreferences());
Path filePath = Paths.get(fileName);
ParserResult result = importer.importDatabase(filePath, Globals.prefs.getDefaultEncoding());
if (result.hasWarnings()) {
frame.showMessage(result.getErrorMessage());
}
localRes.addAll(result.getDatabase().getEntries());
BibEntry entry;
if (localRes.isEmpty()) {
// import failed -> generate default entry
LOGGER.info("Import failed");
createNewBlankEntry(fileName).ifPresent(res::add);
return;
}
// only one entry is imported
entry = localRes.get(0);
// insert entry to database and link file
panel.getDatabase().insertEntry(entry);
panel.markBaseChanged();
FileListTableModel tm = new FileListTableModel();
Path toLink = Paths.get(fileName);
// Get a list of file directories:
List<Path> dirsS = panel.getBibDatabaseContext().getFileDirectoriesAsPaths(Globals.prefs.getFileDirectoryPreferences());
tm.addEntry(0, new FileListEntry(toLink.getFileName().toString(), FileUtil.shortenFileName(toLink, dirsS).toString(), ExternalFileTypes.getInstance().getExternalFileTypeByName("PDF")));
entry.setField(FieldName.FILE, tm.getStringRepresentation());
res.add(entry);
}
use of org.jabref.logic.importer.fileformat.PdfXmpImporter in project jabref by JabRef.
the class ImporterTest method instancesToTest.
@Parameters(name = "{index}: {0}")
public static Collection<Object[]> instancesToTest() {
// all classes implementing {@link Importer}
// sorted alphabetically
ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class);
XMPPreferences xmpPreferences = mock(XMPPreferences.class);
// @formatter:off
return Arrays.asList(new Object[] { new BiblioscapeImporter() }, new Object[] { new BibtexImporter(importFormatPreferences) }, new Object[] { new BibTeXMLImporter() }, new Object[] { new CopacImporter() }, new Object[] { new EndnoteImporter(importFormatPreferences) }, new Object[] { new FreeCiteImporter(importFormatPreferences) }, new Object[] { new InspecImporter() }, new Object[] { new IsiImporter() }, new Object[] { new MedlineImporter() }, new Object[] { new MedlinePlainImporter() }, new Object[] { new ModsImporter() }, new Object[] { new MsBibImporter() }, new Object[] { new OvidImporter() }, new Object[] { new PdfContentImporter(importFormatPreferences) }, new Object[] { new PdfXmpImporter(xmpPreferences) }, new Object[] { new RepecNepImporter(importFormatPreferences) }, new Object[] { new RisImporter() }, new Object[] { new SilverPlatterImporter() });
// @formatter:on
}
use of org.jabref.logic.importer.fileformat.PdfXmpImporter in project jabref by JabRef.
the class ImportFormatReader method resetImportFormats.
public void resetImportFormats(ImportFormatPreferences newImportFormatPreferences, XMPPreferences xmpPreferences) {
this.importFormatPreferences = newImportFormatPreferences;
formats.clear();
formats.add(new BiblioscapeImporter());
formats.add(new BibtexImporter(importFormatPreferences));
formats.add(new BibTeXMLImporter());
formats.add(new CopacImporter());
formats.add(new EndnoteImporter(importFormatPreferences));
formats.add(new FreeCiteImporter(importFormatPreferences));
formats.add(new InspecImporter());
formats.add(new IsiImporter());
formats.add(new MedlineImporter());
formats.add(new MedlinePlainImporter());
formats.add(new ModsImporter());
formats.add(new MsBibImporter());
formats.add(new OvidImporter());
formats.add(new PdfContentImporter(importFormatPreferences));
formats.add(new PdfXmpImporter(xmpPreferences));
formats.add(new RepecNepImporter(importFormatPreferences));
formats.add(new RisImporter());
formats.add(new SilverPlatterImporter());
// Get custom import formats
for (CustomImporter importer : importFormatPreferences.getCustomImportList()) {
formats.add(importer);
}
}
Aggregations