CalendarLegacyFilter.kt
CalendarLegacyFilter is a one-shot migration class that reads the old Wicket-based calendar filter preferences (stored as TeamCalCalendarFilter in t_user_xml_prefs under key "TeamCalendarPage.userPrefs") and converts them into the modern calendar data structures: CalendarFilterState, Favorites<CalendarFilter>, CalendarStyleMap, and a default CalendarFilter. This enables seamless upgrades from ProjectForge v6 to v7+ without users losing their calendar settings.
The class holds all migrated data as constructor properties:
| Property | Type | Description |
|---|---|---|
state | CalendarFilterState | The user's last view state (date range and view type). |
list | Favorites<CalendarFilter> | The migrated list of named calendar filters (favorites). |
current | CalendarFilter | The currently active filter after migration (derived from the old active template). |
styleMap | CalendarStyleMap | Color/display styles for each calendar, inferred from the old template entries. |
migrate(userXmlPreferenceService: UserXmlPreferencesService): CalendarLegacyFilter?The primary entry point. Steps:
TeamCalCalendarFilter from userXmlPreferenceService using key "TeamCalendarPage.userPrefs".null (no migration needed).CalendarFilterState and sets startDate (converted from old Date via PFDateCompatibilityUtils) and view (converted from old ViewType).CalendarStyleMap, seeding it with background colors from the old CalendarProperty entries of each template.activeTemplateEntry via CalendarFilter.copyFrom().templateEntries, converting each to a CalendarFilter and adding them to the favorites list.CalendarLegacyFilter containing all four migrated components.convert(oldViewType: ViewType?): CalendarView?Private mapping from the old ViewType enum to the modern CalendarView enum:
| Old ViewType | New CalendarView |
|---|---|
AGENDA_WEEK | CalendarView.WEEK |
BASIC_WEEK | CalendarView.WEEK |
AGENDA_DAY | CalendarView.DAY |
BASIC_DAY | CalendarView.DAY |
| any other | CalendarView.MONTH |
The class documentation includes SQL snippets for developers to manually inspect legacy preferences during testing:
select key, serializedSettings from t_user_xml_prefs where user_id=2 and key like 'calendar.%'; delete from t_user_pref where user_fk=2 and area='calendar';
The migration logic is intentionally isolated in a separate class rather than embedded in CalendarFilter or the calendar service layer. This keeps the core data model clean of legacy dependencies and allows the migration class itself to be deleted in a future release once all users have been upgraded. The @file:Suppress("DEPRECATION") suppression is necessary because the code intentionally references deprecated types (TeamCalCalendarFilter, ViewType, TemplateEntry) — these are the exact types being migrated from. The class references both the old XStream-persistence key (OLD_USERPREF_KEY) and the legacy date utilities (PFDateCompatibilityUtils), encapsulating all legacy knowledge in one place.