Add per library journal abbreviation type (LTWA) on save #15517
Add per library journal abbreviation type (LTWA) on save #15517faneeshh wants to merge 14 commits intoJabRef:mainfrom
Conversation
| ⚠️ JabRef will recreate the index in a new folder for new files and this will take a long time for a huge library. | ||
| Moreover, switching back and forth JabRef versions and meanwhile adding PDFs also requires rebuilding the index now and then. | ||
| [#15220](https://github.com/JabRef/jabref/pull/15220) | ||
| Thus, the now created search index cannot be read from older versions of JabRef anylonger. | ||
| ⚠️ JabRef will recreate the index in a new folder for new files and this will take a long time for a huge library. | ||
| Moreover, switching back and forth JabRef versions and meanwhile adding PDFs also requires rebuilding the index now and then. | ||
| [#15220](https://github.com/JabRef/jabref/pull/15220) |
There was a problem hiding this comment.
Change Log file got glitched for me in InteliJ so I had to open it in VS code and when I saved it. I think the prettier extension ended up formatting it. Hope it doesn't cause any issues.
| return switch (type) { | ||
| case DEFAULT -> | ||
| Localization.lang("Abbreviate (default)"); | ||
| case DOTLESS -> | ||
| Localization.lang("Abbreviate (dotless)"); | ||
| case SHORTEST_UNIQUE -> | ||
| Localization.lang("Abbreviate (shortest unique)"); | ||
| case LTWA -> | ||
| Localization.lang("Abbreviate (LTWA)"); | ||
| }; | ||
| } |
There was a problem hiding this comment.
I hope these options sound correct.
Review Summary by QodoAdd per-library journal abbreviation preference on save
WalkthroughsDescription• Add per-library journal abbreviation preference to Library Properties • Store abbreviation type in metadata and apply on save automatically • Integrate AbbreviateJournalCleanup into SaveDatabaseAction workflow • Support LTWA and other abbreviation styles with dropdown UI Diagramflowchart LR
A["Library Properties UI"] -->|User selects abbreviation type| B["SavingPropertiesViewModel"]
B -->|Stores in MetaData| C["MetaData.libraryAbbreviationType"]
C -->|Serialized to .bib| D["MetaDataSerializer"]
E["SaveDatabaseAction"] -->|Reads preference| C
E -->|Applies cleanup| F["AbbreviateJournalCleanup"]
F -->|Abbreviates journals| G["BibEntry fields updated"]
File Changes1. jabgui/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java
|
Code Review by Qodo
1.
|
| List<FieldChange> abbreviationChanges = bibDatabaseContext.getMetaData() | ||
| .getLibraryAbbreviationType() | ||
| .map(abbreviationType -> { | ||
| boolean useFJournal = preferences.getJournalAbbreviationPreferences().shouldUseFJournalField(); | ||
| AbbreviateJournalCleanup cleanup = new AbbreviateJournalCleanup( | ||
| bibDatabaseContext.getDatabase(), journalAbbreviationRepository, abbreviationType, useFJournal); | ||
| return bibDatabaseContext.getDatabase().getEntries().stream() | ||
| .flatMap(entry -> cleanup.cleanup(entry).stream()) | ||
| .toList(); | ||
| }) | ||
| .orElse(List.of()); | ||
| libraryTab.registerUndoableChanges( | ||
| Stream.concat(databaseWriter.getSaveActionsFieldChanges().stream(), abbreviationChanges.stream()).toList()); |
There was a problem hiding this comment.
2. Cleanup logic added to gui 📘 Rule violation ⚙ Maintainability
SaveDatabaseAction (GUI layer) now performs journal abbreviation cleanup over all entries, which is non-GUI/business logic. This violates the layering guideline and makes the GUI responsible for logic behavior.
Agent Prompt
## Issue description
GUI-layer `SaveDatabaseAction` now contains business logic for abbreviating journals on save.
## Issue Context
Layering rules require business logic to be implemented in `org.jabref.logic`, with GUI code acting as wiring/gateway.
## Fix Focus Areas
- jabgui/src/main/java/org/jabref/gui/exporter/SaveDatabaseAction.java[276-288]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Please address or comment on qodos comments |
|
Your pull request conflicts with the target branch. Please merge with your code. For a step-by-step guide to resolve merge conflicts, see https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line. |
Related issues and pull requests
Closes #15495
PR Description
The save actions system allows field level formatting on save but journal abbreviation via LTWA requires a
JournalAbbreviationRepositorywhich the zero arg Formatter registry can't accommodate. So instead of that this PR stores a per-libraryAbbreviationTypepreference in MetaData and runsAbbreviateJournalCleanupdirectly inSaveDatabaseActionwhen the preference is set.There's a new dropdown in Library Properties. In the saving section users can choose an abbreviation style that applies automatically every time the library is saved. Selecting "None (use global setting)" clears the per-library preference.
Steps to test
2026-04-12.15-11-22.mp4
You can also change the dropdown back to None (use global setting), save and confirm the metadata line gets removed from the .bib file
Checklist
CHANGELOG.mdin a way that can be understood by the average user (if change is visible to the user)