Skip to content
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
94e1770
feat: draft PR for substituting `BibEntryTypesManager` instead of `Bi…
dcarpentiero Sep 1, 2025
b42b7c8
Merge remote-tracking branch 'origin/main' into customized-entry-type…
dcarpentiero Sep 1, 2025
274d859
fix: removing comments
dcarpentiero Sep 2, 2025
b9d69c2
fix: resolving conflicts
dcarpentiero Sep 2, 2025
b2bc3a4
Merge branch 'main' into customized-entry-types-13794
dcarpentiero Sep 2, 2025
8128685
Merge branch 'main' into customized-entry-types-13794
dcarpentiero Sep 2, 2025
831ed3b
Merge branch 'main' into customized-entry-types-13794
dcarpentiero Sep 3, 2025
9942817
fix: modern best practices: Set.copyOf() instead of new HashSet<>()
dcarpentiero Sep 3, 2025
ff8006e
Merge remote-tracking branch 'origin/customized-entry-types-13794' in…
dcarpentiero Sep 3, 2025
d453516
feat: double constructor: a default and accepting manager constructor
dcarpentiero Sep 3, 2025
53b83d9
Update jablib/src/main/java/org/jabref/logic/quality/consistency/Bibl…
dcarpentiero Sep 4, 2025
b7145af
feat: passing down the BibEntryTypes manager to BibliographyConsisten…
dcarpentiero Sep 4, 2025
baeff03
feat: starting substituting CliPreferences with JabRefCliPreferences …
dcarpentiero Sep 4, 2025
3a79c98
Merge branch 'main' into customized-entry-types-13794
dcarpentiero Sep 4, 2025
d302f7c
fix: BibliographyConsistencyCheck now accept a CliPreference passed d…
dcarpentiero Sep 4, 2025
76394d7
Merge branch 'main' into customized-entry-types-13794
dcarpentiero Sep 5, 2025
3f97a75
feat: `BibliographyConsistencyCheckTest`, `BibliographyConsistencyChe…
dcarpentiero Sep 8, 2025
37416ff
fix: passing `getCustomEntryTypes` parameter to `JabKit`, `CheckConsi…
dcarpentiero Sep 8, 2025
66b2bbf
fix: typo
dcarpentiero Sep 8, 2025
2031f0e
fix: typo
dcarpentiero Sep 8, 2025
ad131c6
fix: typo and parameter order
dcarpentiero Sep 8, 2025
9c24a2f
fix: removal unnecessary parameter
dcarpentiero Sep 8, 2025
ff9a529
fix: removal unnecessary parameter
dcarpentiero Sep 8, 2025
d6d8278
fix: removing double import--using `argumentProcessor.cliPrefences`
dcarpentiero Sep 9, 2025
0d7e37d
fix: using `mockito` for testing
dcarpentiero Sep 9, 2025
1fc3810
fix: resolving conflicts
dcarpentiero Sep 9, 2025
d30b731
fix: resolving conflicts
dcarpentiero Sep 9, 2025
462657a
fix: resolving conflicts
dcarpentiero Sep 9, 2025
704885f
Merge branch 'main' into customized-entry-types-13794
dcarpentiero Sep 9, 2025
c321b78
fix: removing double imports
dcarpentiero Sep 9, 2025
79af35f
fix: removing double imports
dcarpentiero Sep 9, 2025
3befca7
fix: removing `CliPreferences` redundancy–– `GuiPreferences` already …
dcarpentiero Sep 10, 2025
7125b76
fix: `PreferencesMigrations.runMigrations(preferences);` now accepts …
dcarpentiero Sep 10, 2025
e580f9a
fix: passing null to `getCustomEntryTypesRepository` to get the first…
dcarpentiero Sep 10, 2025
d3bfbd8
fix: adding no-parameter `getCustomEntryRepository` method to `CliPre…
dcarpentiero Sep 10, 2025
6ed613a
fix: typo
dcarpentiero Sep 10, 2025
6cc90e2
fix: adding missing method to `BibliographyConsistencyCheckTest`
dcarpentiero Sep 10, 2025
f1adef0
fix: including previously excluded entries that have consistent (miss…
dcarpentiero Sep 10, 2025
6cea857
fix: typo
dcarpentiero Sep 10, 2025
c899efa
feat: now accepting entries that present consistent (eg. all absent) …
dcarpentiero Sep 11, 2025
3e6c4b1
fix: when filtering entries, checking if the entry has a differing fi…
dcarpentiero Sep 11, 2025
d681cd8
fix: when filtering entries, checking if the entry has a differing fi…
dcarpentiero Sep 11, 2025
5040b0c
Merge branch 'main' into customized-entry-types-13794
dcarpentiero Sep 16, 2025
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
4 changes: 3 additions & 1 deletion jabgui/src/main/java/org/jabref/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jabref.logic.util.BuildInfo;
import org.jabref.logic.util.Directories;
import org.jabref.migrations.PreferencesMigrations;
import org.jabref.model.entry.BibEntryTypesManager;

import com.airhacks.afterburner.injection.Injector;
import org.slf4j.Logger;
Expand Down Expand Up @@ -56,6 +57,7 @@ public static void main(String[] args) {
Injector.setModelOrService(BuildInfo.class, new BuildInfo());

final JabRefGuiPreferences preferences = JabRefGuiPreferences.getInstance();
final BibEntryTypesManager bibEntryTypesManager = new BibEntryTypesManager();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not store it as variable - you only need it once below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.


ArgumentProcessor argumentProcessor = new ArgumentProcessor(
args,
Expand Down Expand Up @@ -87,7 +89,7 @@ public static void main(String[] args) {
systemExit();
}

PreferencesMigrations.runMigrations(preferences);
PreferencesMigrations.runMigrations(preferences, bibEntryTypesManager);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the parameter.

Later, use preferences.getCustomEntryTypesRepository() to get the bibEntryTypesManager

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the advantage of declaring BibEntryTypesManager bibEntryTypesManager = preferences.getCustomEntryTypesRepository(); and then upgradeStoredBibEntryTypes(preferences, mainPrefsNode, bibEntryTypesManager); instead of just upgradeStoredBibEntryTypes(preferences, mainPrefsNode, preferences.getCustomEntryTypesRepository());? Am i missing something here?


PostgreServer postgreServer = new PostgreServer();
Injector.setModelOrService(PostgreServer.class, postgreServer);
Expand Down
6 changes: 5 additions & 1 deletion jabgui/src/main/java/org/jabref/gui/JabRefGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.net.ProxyRegisterer;
import org.jabref.logic.os.OS;
import org.jabref.logic.preferences.CliPreferences;
import org.jabref.logic.protectedterms.ProtectedTermsLoader;
import org.jabref.logic.remote.RemotePreferences;
import org.jabref.logic.remote.server.RemoteListenerServerManager;
Expand Down Expand Up @@ -70,6 +71,7 @@ public class JabRefGUI extends Application {

private static List<UiCommand> uiCommands;
private static GuiPreferences preferences;
private static CliPreferences cliPreferences;

// AI Service handles chat messages etc. Therefore, it is tightly coupled to the GUI.
private static AiService aiService;
Expand All @@ -84,6 +86,7 @@ public class JabRefGUI extends Application {
private static ClipBoardManager clipBoardManager;
private static DialogService dialogService;
private static JabRefFrame mainFrame;
private static BibEntryTypesManager bibEntryTypesManager;

private static RemoteListenerServerManager remoteListenerServerManager;
private static HttpServerManager httpServerManager;
Expand Down Expand Up @@ -114,6 +117,7 @@ public void start(Stage stage) {
dialogService,
fileUpdateMonitor,
preferences,
cliPreferences,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this.

See that GuiPreferences extends CliPreferences.

Thus, the GuiPreferences have all the CliPreferences

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

aiService,
stateManager,
countingUndoManager,
Expand Down Expand Up @@ -157,7 +161,7 @@ public void initialize() {
DirectoryMonitor directoryMonitor = new DirectoryMonitor();
Injector.setModelOrService(DirectoryMonitor.class, directoryMonitor);

BibEntryTypesManager entryTypesManager = preferences.getCustomEntryTypesRepository();
BibEntryTypesManager entryTypesManager = preferences.getCustomEntryTypesRepository(bibEntryTypesManager);
JournalAbbreviationRepository journalAbbreviationRepository = JournalAbbreviationLoader.loadRepository(preferences.getJournalAbbreviationPreferences());
Injector.setModelOrService(BibEntryTypesManager.class, entryTypesManager);
Injector.setModelOrService(JournalAbbreviationRepository.class, journalAbbreviationRepository);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jabref.gui.preferences.GuiPreferences;
import org.jabref.gui.util.UiTaskExecutor;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.preferences.CliPreferences;
import org.jabref.logic.quality.consistency.BibliographyConsistencyCheck;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntryTypesManager;
Expand All @@ -29,19 +30,22 @@ public class ConsistencyCheckAction extends SimpleCommand {
private final DialogService dialogService;
private final StateManager stateManager;
private final GuiPreferences preferences;
private final CliPreferences cliPreferences;
private final BibEntryTypesManager entryTypesManager;
private final UiTaskExecutor taskExecutor;

public ConsistencyCheckAction(Supplier<LibraryTab> tabSupplier,
DialogService dialogService,
StateManager stateManager,
GuiPreferences preferences,
CliPreferences cliPreferences,
BibEntryTypesManager entryTypesManager,
UiTaskExecutor taskExecutor) {
this.tabSupplier = tabSupplier;
this.dialogService = dialogService;
this.stateManager = stateManager;
this.preferences = preferences;
this.cliPreferences = cliPreferences;
this.entryTypesManager = entryTypesManager;
this.taskExecutor = taskExecutor;

Expand All @@ -62,7 +66,7 @@ public BibliographyConsistencyCheck.Result call() {

BibDatabaseContext bibContext = databaseContext.get();

BibliographyConsistencyCheck consistencyCheck = new BibliographyConsistencyCheck();
BibliographyConsistencyCheck consistencyCheck = new BibliographyConsistencyCheck(cliPreferences, entryTypesManager);
return consistencyCheck.check(bibContext, (count, total) ->
UiTaskExecutor.runInJavaFXThread(() -> {
updateProgress(count, total);
Expand Down
5 changes: 5 additions & 0 deletions jabgui/src/main/java/org/jabref/gui/frame/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.jabref.logic.UiCommand;
import org.jabref.logic.ai.AiService;
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.preferences.CliPreferences;
import org.jabref.logic.util.BuildInfo;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.database.BibDatabaseContext;
Expand Down Expand Up @@ -87,6 +88,7 @@ private enum PanelMode { MAIN_TABLE, MAIN_TABLE_AND_ENTRY_EDITOR }
private static final Logger LOGGER = LoggerFactory.getLogger(JabRefFrame.class);

private final GuiPreferences preferences;
private final CliPreferences cliPreferences;
private final AiService aiService;
private final GlobalSearchBar globalSearchBar;

Expand Down Expand Up @@ -120,6 +122,7 @@ public JabRefFrame(Stage mainStage,
DialogService dialogService,
FileUpdateMonitor fileUpdateMonitor,
GuiPreferences preferences,
CliPreferences cliPreferences,
AiService aiService,
StateManager stateManager,
CountingUndoManager undoManager,
Expand All @@ -130,6 +133,7 @@ public JabRefFrame(Stage mainStage,
this.dialogService = dialogService;
this.fileUpdateMonitor = fileUpdateMonitor;
this.preferences = preferences;
this.cliPreferences = cliPreferences;
this.aiService = aiService;
this.stateManager = stateManager;
this.undoManager = undoManager;
Expand Down Expand Up @@ -236,6 +240,7 @@ private void initLayout() {
sidePane,
pushToApplicationCommand,
preferences,
cliPreferences,
stateManager,
fileUpdateMonitor,
taskExecutor,
Expand Down
6 changes: 5 additions & 1 deletion jabgui/src/main/java/org/jabref/gui/frame/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.os.OS;
import org.jabref.logic.preferences.CliPreferences;
import org.jabref.logic.util.TaskExecutor;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.field.SpecialField;
Expand All @@ -100,6 +101,7 @@ public class MainMenu extends MenuBar {
private final SidePane sidePane;
private final GuiPushToApplicationCommand pushToApplicationCommand;
private final GuiPreferences preferences;
private final CliPreferences cliPreferences;
private final StateManager stateManager;
private final FileUpdateMonitor fileUpdateMonitor;
private final TaskExecutor taskExecutor;
Expand All @@ -117,6 +119,7 @@ public MainMenu(JabRefFrame frame,
SidePane sidePane,
GuiPushToApplicationCommand pushToApplicationCommand,
GuiPreferences preferences,
CliPreferences cliPreferences,
StateManager stateManager,
FileUpdateMonitor fileUpdateMonitor,
TaskExecutor taskExecutor,
Expand All @@ -133,6 +136,7 @@ public MainMenu(JabRefFrame frame,
this.sidePane = sidePane;
this.pushToApplicationCommand = pushToApplicationCommand;
this.preferences = preferences;
this.cliPreferences = cliPreferences;
this.stateManager = stateManager;
this.fileUpdateMonitor = fileUpdateMonitor;
this.taskExecutor = taskExecutor;
Expand Down Expand Up @@ -270,7 +274,7 @@ private void createMenu() {
factory.createMenuItem(StandardActions.FIND_DUPLICATES, new DuplicateSearch(frame::getCurrentLibraryTab, dialogService, stateManager, preferences, entryTypesManager, taskExecutor)),
factory.createMenuItem(StandardActions.MERGE_ENTRIES, new MergeEntriesAction(dialogService, stateManager, undoManager, preferences)),
factory.createMenuItem(StandardActions.CHECK_INTEGRITY, new IntegrityCheckAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, (UiTaskExecutor) taskExecutor, abbreviationRepository)),
factory.createMenuItem(StandardActions.CHECK_CONSISTENCY, new ConsistencyCheckAction(frame::getCurrentLibraryTab, dialogService, stateManager, preferences, entryTypesManager, (UiTaskExecutor) taskExecutor)),
factory.createMenuItem(StandardActions.CHECK_CONSISTENCY, new ConsistencyCheckAction(frame::getCurrentLibraryTab, dialogService, stateManager, preferences, cliPreferences, entryTypesManager, (UiTaskExecutor) taskExecutor)),
factory.createMenuItem(StandardActions.CLEANUP_ENTRIES, new CleanupAction(frame::getCurrentLibraryTab, preferences, dialogService, stateManager, taskExecutor, undoManager)),

new SeparatorMenuItem(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jabref.gui.util.ControlHelper;
import org.jabref.gui.util.ViewModelListCellFactory;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.entry.BibEntryTypesManager;

import com.airhacks.afterburner.views.ViewLoader;
import com.tobiasdiez.easybind.EasyBind;
Expand All @@ -39,6 +40,7 @@ public class PreferencesDialogView extends BaseDialog<PreferencesDialogViewModel

@Inject private DialogService dialogService;
@Inject private GuiPreferences preferences;
@Inject private BibEntryTypesManager bibEntryTypesManager;

private PreferencesDialogViewModel viewModel;
private final Class<? extends PreferencesTab> preferencesTabToSelectClass;
Expand Down Expand Up @@ -67,7 +69,7 @@ public PreferencesDialogViewModel getViewModel() {

@FXML
private void initialize() {
viewModel = new PreferencesDialogViewModel(dialogService, preferences);
viewModel = new PreferencesDialogViewModel(dialogService, preferences, bibEntryTypesManager);

preferenceTabList.itemsProperty().setValue(viewModel.getPreferenceTabs());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ public class PreferencesDialogViewModel extends AbstractViewModel {
private final DialogService dialogService;
private final GuiPreferences preferences;
private final ObservableList<PreferencesTab> preferenceTabs;
private final BibEntryTypesManager bibEntryTypesManager;

public PreferencesDialogViewModel(DialogService dialogService, GuiPreferences preferences) {
public PreferencesDialogViewModel(DialogService dialogService, GuiPreferences preferences, BibEntryTypesManager bibEntryTypesManager) {
this.dialogService = dialogService;
this.preferences = preferences;
this.bibEntryTypesManager = bibEntryTypesManager;

// This enables passing unsaved preference values from the AI tab to the "web search" tab.
AiTab aiTab = new AiTab();
Expand Down Expand Up @@ -190,9 +192,9 @@ public void storeAllSettings() {
+ Localization.lang("You must restart JabRef for this to come into effect."));
}

Injector.setModelOrService(BibEntryTypesManager.class, preferences.getCustomEntryTypesRepository());
Injector.setModelOrService(BibEntryTypesManager.class, preferences.getCustomEntryTypesRepository(bibEntryTypesManager));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Direct dependency injection manipulation in GUI code violates layered architecture principle. This logic should be moved to a service layer in org.jabref.logic.

dialogService.notify(Localization.lang("Preferences recorded."));
}
};

/**
* Inserts the preference values into the Properties of the ViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class CustomEntryTypesTab extends AbstractPreferenceTabView<CustomEntryTy
@FXML private Button addNewFieldButton;

@Inject private StateManager stateManager;
@Inject private BibEntryTypesManager bibEntryTypesManager;

private final ControlsFxVisualizer visualizer = new ControlsFxVisualizer();

Expand All @@ -76,7 +77,7 @@ public String getTabName() {
public void initialize() {
BibDatabaseMode mode = stateManager.getActiveDatabase().map(BibDatabaseContext::getMode)
.orElse(preferences.getLibraryPreferences().getDefaultBibDatabaseMode());
BibEntryTypesManager entryTypesRepository = preferences.getCustomEntryTypesRepository();
BibEntryTypesManager entryTypesRepository = preferences.getCustomEntryTypesRepository(bibEntryTypesManager);

this.viewModel = new CustomEntryTypesTabViewModel(mode, entryTypesRepository, dialogService, preferences);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ private PreferencesMigrations() {
/**
* Perform checks and changes for users with a preference set from an older JabRef version.
*/
public static void runMigrations(JabRefGuiPreferences preferences) {
public static void runMigrations(JabRefGuiPreferences preferences, BibEntryTypesManager bibEntryTypesManager) {
Preferences mainPrefsNode = Preferences.userRoot().node("/org/jabref");

upgradePrefsToOrgJabRef(mainPrefsNode);
upgradeSortOrder(preferences);
upgradeFaultyEncodingStrings(preferences);
upgradeLabelPatternToCitationKeyPattern(preferences, mainPrefsNode);
upgradeImportFileAndDirePatterns(preferences, mainPrefsNode);
upgradeStoredBibEntryTypes(preferences, mainPrefsNode, preferences.getCustomEntryTypesRepository());
upgradeStoredBibEntryTypes(preferences, mainPrefsNode, preferences.getCustomEntryTypesRepository(bibEntryTypesManager));
upgradeKeyBindingsToJavaFX(preferences);
addCrossRefRelatedFieldsForAutoComplete(preferences);
upgradePreviewStyle(preferences);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.jabref.logic.util.StandardFileType;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.metadata.SelfContainedSaveOrder;

public class ExporterFactory {
Expand All @@ -30,6 +31,7 @@ public static ExporterFactory create(CliPreferences preferences) {
XmpPreferences xmpPreferences = preferences.getXmpPreferences();
FieldPreferences fieldPreferences = preferences.getFieldPreferences();
BibDatabaseMode bibDatabaseMode = preferences.getLibraryPreferences().getDefaultBibDatabaseMode();
BibEntryTypesManager bibEntryTypesManager = new BibEntryTypesManager();

List<Exporter> exporters = new ArrayList<>();

Expand Down Expand Up @@ -59,7 +61,7 @@ public static ExporterFactory create(CliPreferences preferences) {
exporters.add(new ModsExporter());
exporters.add(new XmpExporter(xmpPreferences));
exporters.add(new XmpPdfExporter(xmpPreferences));
exporters.add(new EmbeddedBibFilePdfExporter(bibDatabaseMode, preferences.getCustomEntryTypesRepository(), fieldPreferences));
exporters.add(new EmbeddedBibFilePdfExporter(bibDatabaseMode, preferences.getCustomEntryTypesRepository(bibEntryTypesManager), fieldPreferences));
exporters.add(new CffExporter());
exporters.add(new EndnoteXmlExporter(preferences.getBibEntryPreferences()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public interface CliPreferences {
*/
SelfContainedSaveConfiguration getSelfContainedExportConfiguration();

BibEntryTypesManager getCustomEntryTypesRepository();
BibEntryTypesManager getCustomEntryTypesRepository(BibEntryTypesManager bibEntryTypesManager);

void storeCustomEntryTypesRepository(BibEntryTypesManager entryTypesManager);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,8 +1222,7 @@ public JournalAbbreviationPreferences getJournalAbbreviationPreferences() {
//*************************************************************************************************************

@Override
public BibEntryTypesManager getCustomEntryTypesRepository() {
BibEntryTypesManager bibEntryTypesManager = new BibEntryTypesManager();
public BibEntryTypesManager getCustomEntryTypesRepository(BibEntryTypesManager bibEntryTypesManager) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please undo this - the point here is that a new repository is generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh I should implement both, the one without the parameter and then override with the parameter did I get it right?

EnumSet.allOf(BibDatabaseMode.class).forEach(mode ->
bibEntryTypesManager.addCustomOrModifiedTypes(getBibEntryTypes(mode), mode));
return bibEntryTypesManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
import org.jabref.logic.bibtex.comparator.BibEntryByFieldsComparator;
import org.jabref.logic.bibtex.comparator.FieldComparatorStack;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.database.BibDatabaseMode;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.InternalField;
import org.jabref.model.entry.field.SpecialField;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.field.UserSpecificCommentField;
import org.jabref.model.entry.types.BiblatexEntryTypeDefinitions;
import org.jabref.model.entry.types.BibtexEntryTypeDefinitions;
import org.jabref.model.entry.types.EntryType;

import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -55,6 +53,12 @@ public class BibliographyConsistencyCheck {
StandardField.MODIFICATIONDATE
);

private final BibEntryTypesManager bibEntryTypesManager;

public BibliographyConsistencyCheck(org.jabref.logic.preferences.CliPreferences cliPreferences, BibEntryTypesManager bibEntryTypesManager) {
this.bibEntryTypesManager = cliPreferences.getCustomEntryTypesRepository(bibEntryTypesManager);
}

private static Set<Field> filterExcludedFields(Collection<Field> fields) {
return fields.stream()
.filter(field -> !EXPLICITLY_EXCLUDED_FIELDS.contains(field))
Expand Down Expand Up @@ -112,12 +116,10 @@ public Result check(BibDatabaseContext bibContext, BiConsumer<Integer, Integer>

collectEntriesIntoMaps(bibContext, entryTypeToFieldsInAnyEntryMap, entryTypeToFieldsInAllEntriesMap, entryTypeToEntriesMap);

List<BibEntryType> entryTypeDefinitions;
if (bibContext.getMode() == BibDatabaseMode.BIBLATEX) {
entryTypeDefinitions = BiblatexEntryTypeDefinitions.ALL;
} else {
entryTypeDefinitions = BibtexEntryTypeDefinitions.ALL;
}
List<BibEntryType> entryTypeDefinitions = bibEntryTypesManager
.getAllTypes(bibContext.getMode())
.stream()
.toList();
Comment on lines +124 to +127
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to convert to a list - Collection should directly work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collection is a interface though–i need some class to implement it right? For example HashSet class implement the Set interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2025-09-04 alle 11 07 41

Also (correct me if I'm wrong, I'm here to learn) the expected type is a list, so I can't provide something else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant, below, there is

Optional typeDefOpt = entryTypeDefinitions.stream()

which does not require the total ordering.


// Use LinkedHashMap to preserve the order of Bib(tex|latex)EntryTypeDefinitions.ALL
Map<EntryType, EntryTypeResult> resultMap = new LinkedHashMap<>();
Expand Down Expand Up @@ -161,7 +163,6 @@ public Result check(BibDatabaseContext bibContext, BiConsumer<Integer, Integer>
}

private static void collectEntriesIntoMaps(BibDatabaseContext bibContext, Map<EntryType, Set<Field>> entryTypeToFieldsInAnyEntryMap, Map<EntryType, Set<Field>> entryTypeToFieldsInAllEntriesMap, Map<EntryType, Set<BibEntry>> entryTypeToEntriesMap) {
BibDatabaseMode mode = bibContext.getMode();
List<BibEntry> entries = bibContext.getEntries();

for (BibEntry entry : entries) {
Expand Down
Loading
Loading