Skip to content

Logic serialization#2

Merged
XMJ3083 merged 6 commits into
implmentation-issue-10822from
logic-serialization
Oct 18, 2025
Merged

Logic serialization#2
XMJ3083 merged 6 commits into
implmentation-issue-10822from
logic-serialization

Conversation

@XMJ3083

@XMJ3083 XMJ3083 commented Oct 17, 2025

Copy link
Copy Markdown
Collaborator

Summary

Implemented Logic layer (Serialization/Deserialization) for AutomaticDateGroup feature.

This PR adds the ability to save and load AutomaticDateGroup objects to/from .bib files, enabling persistent storage of automatic year/month/date-based grouping configurations.

Changes:

  • Serialization: Convert AutomaticDateGroup objects to text format for storage
  • Deserialization: Parse text format back to AutomaticDateGroup objects
  • Tests: 7 comprehensive test cases covering all granularity types (YEAR/MONTH/FULL_DATE)
  • Model enhancements: Added getField() and getGranularity() getter methods required for serialization

Dependencies:

  • Builds on top of Model layer implementation from model-auto-date-groups branch
  • Ready for GUI layer integration

Steps to test

Automated tests (recommended):

./gradlew :jablib:test --tests "*GroupSerializerTest*" --tests "*GroupsParserTest*"

Manual testing (after GUI integration):

  1. Create an AutomaticDateGroup in JabRef
  2. Save the library to a .bib file
  3. Close and reopen the file
  4. Verify the group is correctly restored with all properties (field, granularity, color, icon)

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [/] I manually tested my changes in running JabRef (GUI layer not yet implemented)
  • I added JUnit tests for changes
  • [/] I added screenshots (no UI changes in this PR)
  • [/] I described the change in CHANGELOG.md (internal PR, will be added in final merge)
  • [/] I checked the user documentation (will be updated after GUI integration)

Technical Details

Serialization format:

- Add AUTOMATIC_DATE_GROUP_ID constant to MetadataSerializationConfiguration
- Implement serializeAutomaticDateGroup() in GroupSerializer
  * Serializes field name
  * Serializes granularity (YEAR/MONTH/FULL_DATE)
- Add AutomaticDateGroup case in serialization switch
- Add getField() and getGranularity() methods to AutomaticDateGroup
- Fix deepCopy() and hashCode() to include granularity

Serialization format: AutomaticDateGroup:name;context;field;granularity;...
- Add AutomaticDateGroup and DateGranularity imports to GroupsParser
- Implement automaticDateGroupFromString() method
  * Parse name, context, field from serialized string
  * Parse and convert granularity string to DateGranularity enum
  * Create AutomaticDateGroup with all parameters
  * Restore group details (color, icon, description)
- Add condition check in fromString() to handle AutomaticDateGroup

This enables AutomaticDateGroup to be loaded from .bib files,
completing the save/load cycle with serialization.
Serialization tests (GroupSerializerTest.java):
- Test YEAR granularity serialization
- Test MONTH granularity serialization
- Test serialization with color, icon, and description
- Verify format: AutomaticDateGroup:name;context;field;granularity;...

Deserialization tests (GroupsParserTest.java):
- Test parsing YEAR granularity
- Test parsing MONTH granularity
- Test parsing FULL_DATE granularity
- Test parsing with color, icon, and description
- Verify correct object reconstruction from string

Total: 7 new test cases covering all granularity types and edge cases.
Checkstyle reported DateGranularity as an unused import because
we only use it through method return type inference (getGranularity().name()).
The import is not needed since we don't declare any variables of this type.
@XMJ3083 XMJ3083 requested a review from elliotgnn October 17, 2025 12:42
- Document DateGranularity enum values
- Add class-level documentation for DateGroup
- Ensures these files are detected as changed files in CI for JBang testing

@elliotgnn elliotgnn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Great job, overall serilization implementation seems to be good and tests are passing.

@XMJ3083 XMJ3083 merged commit e08deab into implmentation-issue-10822 Oct 18, 2025
46 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants