Skip to content
Draft
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 @@ -20,6 +20,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We re-enabled the [Grobid](https://github.com/grobidOrg/grobid) citation fetcher again. It is now reachable via https. [#16668](https://github.com/JabRef/jabref/issues/16668)
- We fixed an issue where the AI chat lost its scroll position when switching back to an entry. [#17172](https://github.com/JabRef/jabref/pull/17172)
- We fixed an issue where pressing "+" in the "File" field with an automatically found file selected opened the "Add file link" dialog instead of linking the selected file. [#16938](https://github.com/JabRef/jabref/pull/16938)
- We fixed an issue where the consistency check listed the entry types in random order. [#779](https://github.com/JabRef/jabref-koppor/pull/779)
- We fixed an issue where case-sensitive search (`=!`, `==!`, `=~!`) in linked files ignored the casing and matched text in any casing. [#13048](https://github.com/JabRef/jabref/issues/13048)

### Removed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public ConsistencyCheckDialogViewModel(DialogService dialogService,
.distinct()
.toList();

result.entryTypeToResultMap().entrySet().stream()
.sorted(Comparator.comparing(entry -> entry.getKey().getName()))
result.entryTypeToResultMap().entrySet()
.forEach(Unchecked.consumer(this::writeMapEntry));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -88,6 +89,7 @@ List<BibEntry> filterAndSortEntriesWithFieldDifferences(Set<BibEntry> entries, S
.toList();
}

/// @param entryTypeToResultMap ordered by the name of the entry type
public record Result(Map<EntryType, EntryTypeResult> entryTypeToResultMap) {
}

Expand Down Expand Up @@ -116,11 +118,14 @@ public Result check(BibDatabaseContext bibContext, BibEntryTypesManager bibEntry

List<BibEntryType> entryTypeDefinitions = bibEntryTypesManager.getAllTypes(bibContext.getMode()).stream().toList();

// Use LinkedHashMap to preserve the order of Bib(tex|latex)EntryTypeDefinitions.ALL
// Ordered by entry type name, so that all consumers (GUI, CLI output, language server) list the types in the same order
Map<EntryType, EntryTypeResult> resultMap = new LinkedHashMap<>();
List<Map.Entry<EntryType, Set<Field>>> entryTypesByName = entryTypeToFieldsInAnyEntryMap.entrySet().stream()
.sorted(Comparator.comparing(mapEntry -> mapEntry.getKey().getName()))
.toList();

int counter = 0;
for (Map.Entry<EntryType, Set<Field>> mapEntry : entryTypeToFieldsInAnyEntryMap.entrySet()) {
for (Map.Entry<EntryType, Set<Field>> mapEntry : entryTypesByName) {
entriesGroupingProgress.accept(counter++, entryTypeToFieldsInAnyEntryMap.size());
EntryType entryType = mapEntry.getKey();
Set<Field> fieldsInAnyEntry = mapEntry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public BibliographyConsistencyCheckResultWriter(BibliographyConsistencyCheck.Res
}

public void writeFindings() throws IOException {
result.entryTypeToResultMap().entrySet().stream()
.sorted(Comparator.comparing(entry -> entry.getKey().getName()))
result.entryTypeToResultMap().entrySet()
.forEach(Unchecked.consumer(this::writeMapEntry));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
Expand Down Expand Up @@ -427,6 +428,25 @@ void filteredFieldsAreIgnored() {
"Differences only in filtered fields must be ignored");
}

@Test
void resultIsOrderedByEntryTypeName() {
List<EntryType> types = List.of(StandardEntryType.TechReport, StandardEntryType.Online, StandardEntryType.Misc,
StandardEntryType.InProceedings, StandardEntryType.Book, StandardEntryType.Article);
List<BibEntry> entries = types.stream()
.flatMap(type -> Stream.of(
new BibEntry(type, type.getName() + "1").withField(StandardField.NOTE, "note"),
new BibEntry(type, type.getName() + "2")))
.toList();

BibliographyConsistencyCheck.Result result = new BibliographyConsistencyCheck()
.check(new BibDatabaseContext(new BibDatabase(entries)), entryTypesManager, (_, _) -> {
});

assertEquals(List.of(StandardEntryType.Article, StandardEntryType.Book, StandardEntryType.InProceedings,
StandardEntryType.Misc, StandardEntryType.Online, StandardEntryType.TechReport),
List.copyOf(result.entryTypeToResultMap().keySet()));
}

@Test
void nonFilteredFieldDifferenceIsReported() {
BibEntry withAuthor = new BibEntry(StandardEntryType.Misc, "1")
Expand Down
Loading