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);
}
}
Aggregations