Search in sources :

Example 1 with ImportFormatPreferences

use of org.jabref.logic.importer.ImportFormatPreferences in project jabref by JabRef.

the class ChangeScanner method run.

@Override
public void run() {
    try {
        // Parse the temporary file.
        Path tempFile = Globals.getFileUpdateMonitor().getTempFile(panel.fileMonitorHandle());
        ImportFormatPreferences importFormatPreferences = Globals.prefs.getImportFormatPreferences();
        ParserResult result = OpenDatabase.loadDatabase(tempFile.toFile(), importFormatPreferences);
        databaseInTemp = result.getDatabase();
        metadataInTemp = result.getMetaData();
        // Parse the modified file.
        result = OpenDatabase.loadDatabase(file, importFormatPreferences);
        BibDatabase databaseOnDisk = result.getDatabase();
        MetaData metadataOnDisk = result.getMetaData();
        // Sort both databases according to a common sort key.
        EntryComparator comparator = new EntryComparator(false, true, SORT_BY[2]);
        comparator = new EntryComparator(false, true, SORT_BY[1], comparator);
        comparator = new EntryComparator(false, true, SORT_BY[0], comparator);
        EntrySorter sorterInTemp = databaseInTemp.getSorter(comparator);
        comparator = new EntryComparator(false, true, SORT_BY[2]);
        comparator = new EntryComparator(false, true, SORT_BY[1], comparator);
        comparator = new EntryComparator(false, true, SORT_BY[0], comparator);
        EntrySorter sorterOnDisk = databaseOnDisk.getSorter(comparator);
        comparator = new EntryComparator(false, true, SORT_BY[2]);
        comparator = new EntryComparator(false, true, SORT_BY[1], comparator);
        comparator = new EntryComparator(false, true, SORT_BY[0], comparator);
        EntrySorter sorterInMem = databaseInMemory.getSorter(comparator);
        // Start looking at changes.
        scanMetaData(metadataInMemory, metadataInTemp, metadataOnDisk);
        scanPreamble(databaseInMemory, databaseInTemp, databaseOnDisk);
        scanStrings(databaseInMemory, databaseInTemp, databaseOnDisk);
        scanEntries(sorterInMem, sorterInTemp, sorterOnDisk);
        scanGroups(metadataInTemp, metadataOnDisk);
    } catch (IOException ex) {
        LOGGER.warn("Problem running", ex);
    }
}
Also used : Path(java.nio.file.Path) ParserResult(org.jabref.logic.importer.ParserResult) EntryComparator(org.jabref.logic.bibtex.comparator.EntryComparator) MetaData(org.jabref.model.metadata.MetaData) ImportFormatPreferences(org.jabref.logic.importer.ImportFormatPreferences) IOException(java.io.IOException) EntrySorter(org.jabref.model.database.EntrySorter) BibDatabase(org.jabref.model.database.BibDatabase)

Example 2 with ImportFormatPreferences

use of org.jabref.logic.importer.ImportFormatPreferences in project jabref by JabRef.

the class GoogleScholarTest method setUp.

@Before
public void setUp() {
    ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class);
    when(importFormatPreferences.getFieldContentParserPreferences()).thenReturn(mock(FieldContentParserPreferences.class));
    finder = new GoogleScholar(importFormatPreferences);
    entry = new BibEntry();
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) FieldContentParserPreferences(org.jabref.logic.bibtex.FieldContentParserPreferences) ImportFormatPreferences(org.jabref.logic.importer.ImportFormatPreferences) Before(org.junit.Before)

Example 3 with ImportFormatPreferences

use of org.jabref.logic.importer.ImportFormatPreferences in project jabref by JabRef.

the class RepecNepImporterTest method setUp.

@Before
public void setUp() {
    ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class);
    when(importFormatPreferences.getKeywordSeparator()).thenReturn(',');
    testImporter = new RepecNepImporter(importFormatPreferences);
}
Also used : ImportFormatPreferences(org.jabref.logic.importer.ImportFormatPreferences) Before(org.junit.Before)

Example 4 with ImportFormatPreferences

use of org.jabref.logic.importer.ImportFormatPreferences in project jabref by JabRef.

the class XMPUtilTest method setUp.

/**
     * Create a temporary PDF-file with a single empty page.
     */
@Before
public void setUp() throws IOException, COSVisitorException {
    pdfFile = tempFolder.newFile("JabRef.pdf");
    try (PDDocument pdf = new PDDocument()) {
        // Need page to open in Acrobat
        pdf.addPage(new PDPage());
        pdf.save(pdfFile.getAbsolutePath());
    }
    importFormatPreferences = mock(ImportFormatPreferences.class, Answers.RETURNS_DEEP_STUBS);
    when(importFormatPreferences.getEncoding()).thenReturn(StandardCharsets.UTF_8);
    xmpPreferences = mock(XMPPreferences.class);
    // The code assumes privacy filters to be off
    when(xmpPreferences.isUseXMPPrivacyFilter()).thenReturn(false);
    when(xmpPreferences.getKeywordSeparator()).thenReturn(',');
}
Also used : PDPage(org.apache.pdfbox.pdmodel.PDPage) PDDocument(org.apache.pdfbox.pdmodel.PDDocument) ImportFormatPreferences(org.jabref.logic.importer.ImportFormatPreferences) Before(org.junit.Before)

Example 5 with ImportFormatPreferences

use of org.jabref.logic.importer.ImportFormatPreferences in project jabref by JabRef.

the class MathSciNetTest method setUp.

@Before
public void setUp() throws Exception {
    ImportFormatPreferences importFormatPreferences = mock(ImportFormatPreferences.class);
    when(importFormatPreferences.getFieldContentParserPreferences()).thenReturn(mock(FieldContentParserPreferences.class));
    fetcher = new MathSciNet(importFormatPreferences);
    ratiuEntry = new BibEntry();
    ratiuEntry.setType(BibtexEntryTypes.ARTICLE);
    ratiuEntry.setCiteKey("MR3537908");
    ratiuEntry.setField("author", "Chechkin, Gregory A. and Ratiu, Tudor S. and Romanov, Maxim S. and Samokhin, Vyacheslav N.");
    ratiuEntry.setField("title", "Existence and uniqueness theorems for the two-dimensional {E}ricksen-{L}eslie system");
    ratiuEntry.setField("journal", "Journal of Mathematical Fluid Mechanics");
    ratiuEntry.setField("volume", "18");
    ratiuEntry.setField("year", "2016");
    ratiuEntry.setField("number", "3");
    ratiuEntry.setField("pages", "571--589");
    ratiuEntry.setField("issn", "1422-6928");
    ratiuEntry.setField("keywords", "76A15 (35A01 35A02 35K61)");
    ratiuEntry.setField("mrnumber", "3537908");
    ratiuEntry.setField("doi", "10.1007/s00021-016-0250-0");
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) FieldContentParserPreferences(org.jabref.logic.bibtex.FieldContentParserPreferences) ImportFormatPreferences(org.jabref.logic.importer.ImportFormatPreferences) Before(org.junit.Before)

Aggregations

ImportFormatPreferences (org.jabref.logic.importer.ImportFormatPreferences)11 Before (org.junit.Before)9 BibEntry (org.jabref.model.entry.BibEntry)7 FieldContentParserPreferences (org.jabref.logic.bibtex.FieldContentParserPreferences)5 ParserResult (org.jabref.logic.importer.ParserResult)2 BibDatabase (org.jabref.model.database.BibDatabase)2 MetaData (org.jabref.model.metadata.MetaData)2 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Path (java.nio.file.Path)1 Collection (java.util.Collection)1 XMPMetadata (org.apache.jempbox.xmp.XMPMetadata)1 PDDocument (org.apache.pdfbox.pdmodel.PDDocument)1 PDPage (org.apache.pdfbox.pdmodel.PDPage)1 BibEntryWriter (org.jabref.logic.bibtex.BibEntryWriter)1 LatexFieldFormatter (org.jabref.logic.bibtex.LatexFieldFormatter)1 EntryComparator (org.jabref.logic.bibtex.comparator.EntryComparator)1 BibtexParser (org.jabref.logic.importer.fileformat.BibtexParser)1