Add per library journal abbreviation type (LTWA) on save - #15517
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.
|
|
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. |
|
@calixtus should be good to go |
koppor
left a comment
There was a problem hiding this comment.
Qodo is right.
I was not explicit in my issue description
- Introduce a save action per abbreviation possibility.
- Add a pre-configured save-action set. Start with "Springer" containing LTWA only. Selecting a set adds to the configured save actions.
The second can be a seperate issue if you don't want to tackle in this PR.
|
|
||
| public AutosaveUiManager(LibraryTab libraryTab, DialogService dialogService, GuiPreferences preferences, BibEntryTypesManager entryTypesManager, StateManager stateManager) { | ||
| this.saveDatabaseAction = new SaveDatabaseAction(libraryTab, dialogService, preferences, entryTypesManager, stateManager); | ||
| this.saveDatabaseAction = new SaveDatabaseAction(libraryTab, dialogService, preferences, entryTypesManager, stateManager, Injector.instantiateModelOrService(JournalAbbreviationRepository.class)); |
There was a problem hiding this comment.
No, we do not use Injector.instantiateModelOrService - we use constructor-based "injection" to make the control-flow explicit. Please route through this class.
| Injector.instantiateModelOrService(BibEntryTypesManager.class), | ||
| stateManager); | ||
| stateManager, | ||
| Injector.instantiateModelOrService(JournalAbbreviationRepository.class)); |
|
I've made the abbreviation cleanup run inside SaveDatabaseAction just passes the repository in and there is no business logic in the GUI layer anymore. |
subhramit
left a comment
There was a problem hiding this comment.
LGTM sans two or three tiny comments
| if (abbreviationType != null) { | ||
| newMetaData.setLibraryAbbreviationType(abbreviationType); | ||
| } else { | ||
| newMetaData.clearLibraryAbbreviationType(); |
There was a problem hiding this comment.
Does it need clearing if it's already null?
If yes, I'll post another comment to complement this.
There was a problem hiding this comment.
I thought about this. If for a newly loaded library with abbreviation type None, one opens the library properties and doesn't touch the drop down (stays "None), this code triggers the library to be marked dirty due to postChange
There was a problem hiding this comment.
Yes it needs the clear
Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
…lOnSaveTest.java Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
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)