#1271: HistoryContext.kt

projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/candh/HistoryContext.kt History Entry Builder, projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/candh/HistoryContext.kt 186 lines · 114 code · 58 comments · 14 blank
Internal context for accumulating history entries during a CandH operation. Maintains a stack of CandHHistoryEntryWrapper objects (for nested entity processing) and a flat list of all wrappers. On finalization, converts all wrappers to HistoryEntryDO objects and recursively discovers new collection entries for insert history.

Architecture

Stack-Based Nested History

Uses historyEntryWrapperStack (push/pop) for processing nested entities (e.g., invoice positions inside an invoice). The currentHistoryEntryWrapper is the top of stack; attributes are added to the current wrapper.

Key Methods

MethodDescription
pushHistoryEntryWrapper(entity, opType)Push a new entity-level wrapper onto the stack
popHistoryEntryWrapper()Pop and optionally remove wrapper if no attributes were added
add(propertyContext, opType)Add property-level history attribute from PropertyContext
getPreparedHistoryEntries(mergedObj, srcObj)Finalize: prepare all entries and discover new collection entries

Calls CollectionHandler.writeInsertHistoryEntriesForNewCollectionEntries() to recursively find entity insert events in collection hierarchies.

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
9e3c523c7 Migration stuff in progress... (all tests of all packages: OK).
b79a1edca Migration stuff in progress... (all tests of all packages: OK).
5989b32fd BaseDao: mechanism of onChangeLister refactored.