Search in sources :

Example 1 with EntrySorter

use of org.jabref.model.database.EntrySorter 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)

Aggregations

IOException (java.io.IOException)1 Path (java.nio.file.Path)1 EntryComparator (org.jabref.logic.bibtex.comparator.EntryComparator)1 ImportFormatPreferences (org.jabref.logic.importer.ImportFormatPreferences)1 ParserResult (org.jabref.logic.importer.ParserResult)1 BibDatabase (org.jabref.model.database.BibDatabase)1 EntrySorter (org.jabref.model.database.EntrySorter)1 MetaData (org.jabref.model.metadata.MetaData)1