use of org.jabref.model.metadata.SaveOrderConfig in project jabref by JabRef.
the class JabRefPreferences method loadTableSaveOrder.
public SaveOrderConfig loadTableSaveOrder() {
SaveOrderConfig config = new SaveOrderConfig();
config.sortCriteria[0].field = get(TABLE_PRIMARY_SORT_FIELD);
config.sortCriteria[0].descending = getBoolean(TABLE_PRIMARY_SORT_DESCENDING);
config.sortCriteria[1].field = get(TABLE_SECONDARY_SORT_FIELD);
config.sortCriteria[1].descending = getBoolean(TABLE_SECONDARY_SORT_DESCENDING);
config.sortCriteria[2].field = get(TABLE_TERTIARY_SORT_FIELD);
config.sortCriteria[2].descending = getBoolean(TABLE_TERTIARY_SORT_DESCENDING);
return config;
}
use of org.jabref.model.metadata.SaveOrderConfig in project jabref by JabRef.
the class JabRefPreferences method loadExportSaveOrder.
public SaveOrderConfig loadExportSaveOrder() {
SaveOrderConfig config = new SaveOrderConfig();
config.sortCriteria[0].field = get(EXPORT_PRIMARY_SORT_FIELD);
config.sortCriteria[0].descending = getBoolean(EXPORT_PRIMARY_SORT_DESCENDING);
config.sortCriteria[1].field = get(EXPORT_SECONDARY_SORT_FIELD);
config.sortCriteria[1].descending = getBoolean(EXPORT_SECONDARY_SORT_DESCENDING);
config.sortCriteria[2].field = get(EXPORT_TERTIARY_SORT_FIELD);
config.sortCriteria[2].descending = getBoolean(EXPORT_TERTIARY_SORT_DESCENDING);
return config;
}
use of org.jabref.model.metadata.SaveOrderConfig in project jabref by JabRef.
the class BibtexParserTest method integrationTestSaveOrderConfig.
@Test
public void integrationTestSaveOrderConfig() throws IOException {
ParserResult result = BibtexParser.parse(new StringReader("@Comment{jabref-meta: saveOrderConfig:specified;author;false;year;true;abstract;false;}"), importFormatPreferences);
Optional<SaveOrderConfig> saveOrderConfig = result.getMetaData().getSaveOrderConfig();
assertEquals(new SaveOrderConfig(false, new SaveOrderConfig.SortCriterion("author", false), new SaveOrderConfig.SortCriterion("year", true), new SaveOrderConfig.SortCriterion("abstract", false)), saveOrderConfig.get());
}
use of org.jabref.model.metadata.SaveOrderConfig in project jabref by JabRef.
the class BibDatabaseWriter method getSaveComparators.
private static List<Comparator<BibEntry>> getSaveComparators(SavePreferences preferences, MetaData metaData) {
List<Comparator<BibEntry>> comparators = new ArrayList<>();
Optional<SaveOrderConfig> saveOrder = getSaveOrder(preferences, metaData);
// Take care, using CrossRefEntry-Comparator, that referred entries occur after referring
// ones. This is a necessary requirement for BibTeX to be able to resolve referenced entries correctly.
comparators.add(new CrossRefEntryComparator());
if (!saveOrder.isPresent()) {
// entries will be sorted based on their internal IDs
comparators.add(new IdComparator());
} else {
// use configured sorting strategy
comparators.add(new FieldComparator(saveOrder.get().sortCriteria[0]));
comparators.add(new FieldComparator(saveOrder.get().sortCriteria[1]));
comparators.add(new FieldComparator(saveOrder.get().sortCriteria[2]));
comparators.add(new FieldComparator(BibEntry.KEY_FIELD));
}
return comparators;
}
use of org.jabref.model.metadata.SaveOrderConfig in project jabref by JabRef.
the class BibtexDatabaseWriterTest method writeSaveOrderConfig.
@Test
public void writeSaveOrderConfig() throws Exception {
SaveOrderConfig saveOrderConfig = new SaveOrderConfig(false, new SaveOrderConfig.SortCriterion("author", false), new SaveOrderConfig.SortCriterion("year", true), new SaveOrderConfig.SortCriterion("abstract", false));
metaData.setSaveOrderConfig(saveOrderConfig);
StringSaveSession session = databaseWriter.savePartOfDatabase(bibtexContext, Collections.emptyList(), new SavePreferences());
assertEquals(OS.NEWLINE + "@Comment{jabref-meta: saveOrderConfig:specified;author;false;year;true;abstract;false;}" + OS.NEWLINE, session.getStringValue());
}
Aggregations