Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv

- We fixed an issue where it was hard to distinguish between enabled/disabled status of search buttons in dark mode and added tooltips. [#11569](https://github.com/JabRef/jabref/issues/11569)
- We fixed an issue where entries containing dollar signs, backslashes, or unset fields passed to `substring$` caused citation style preview and export to fail. [#12799](https://github.com/JabRef/jabref/issues/12799)
- We fixed an issue where citationcount, day, and dayfiled columns were sorted alphabetically instead of numerically. [#17459](https://github.com/JabRef/jabref/issues/17459)
- We fixed exports to RIS, CSV, HTML, and other template-based formats in native JabKit. [#17408](https://github.com/JabRef/jabref/issues/17408)
- We fixed JabKit to preserve existing citation keys when generating keys with the avoid-overwrite setting. [#17458](https://github.com/JabRef/jabref/issues/17458)
- We fixed an issue where JabRef showed an "Executor has been shut down" error on Windows after resuming from suspend. [#17144](https://github.com/JabRef/jabref/pull/17144)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jabref.gui.util.comparator;

import java.util.List;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -43,6 +45,13 @@ void compareIntegerWithString() {
assertEquals(1, comparator.compare("4", "hi"));
}

@Test
void sortMixedTextAndNumericValues() {
List<String> values = List.of("Wednesday", "10", "Tuesday", "2");

assertEquals(List.of("Tuesday", "Wednesday", "2", "10"), values.stream().sorted(comparator).toList());
}

@Test
void compareNegativeInteger() {
assertEquals(1, comparator.compare("-4", "-5"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public enum FieldProperty {
MONTH,

MULTILINE_TEXT,

/// Enables numeric-aware sorting and causes JabRef to treat the field as non-LaTeX content.
/// This is a JabRef property, not a BibLaTeX datatype: `edition` accepts integers or
/// literal values, and `number` and `pagetotal` are literal fields. See the [BibLaTeX
/// manual, section 2.2.2](https://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf).
NUMERIC,
PAGINATION,
PERSON_NAMES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public enum StandardField implements Field {
CROSSREF("crossref", FieldProperty.SINGLE_ENTRY_LINK),
CITES("cites", FieldProperty.MULTIPLE_ENTRY_LINK),
DATE("date", FieldProperty.DATE),
DAY("day"),
DAYFILED("dayfiled"),
DAY("day", FieldProperty.NUMERIC),
DAYFILED("dayfiled", FieldProperty.NUMERIC),
DOI("doi", FieldProperty.VERBATIM, FieldProperty.IDENTIFIER),
EDITION("edition", FieldProperty.NUMERIC),
EDITOR("editor", FieldProperty.PERSON_NAMES),
Expand Down Expand Up @@ -144,7 +144,7 @@ public enum StandardField implements Field {

// region: JabRef-specific fields

CITATIONCOUNT("citationcount"),
CITATIONCOUNT("citationcount", FieldProperty.NUMERIC),
GROUPS("groups"),
ICORERANKING("icore"),
OWNER("owner"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

class StandardFieldTest {

@Test
void fieldsConsideredEqualIfSame() {
assertEquals(StandardField.TITLE, StandardField.TITLE);
}

@Test
void numericFieldsHaveNumericProperty() {
assertTrue(StandardField.CITATIONCOUNT.isNumeric());
assertTrue(StandardField.DAY.isNumeric());
assertTrue(StandardField.DAYFILED.isNumeric());
}

@Test
void nonNumericFieldsDoNotHaveNumericProperty() {
assertFalse(StandardField.CHAPTER.isNumeric());
assertFalse(StandardField.PART.isNumeric());
}
}