#1268: CandHMaster.kt

projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/candh/CandHMaster.kt Copy-and-History Engine (Singleton), projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/candh/CandHMaster.kt 311 lines · 211 code · 86 comments · 14 blank
The central engine for Copy-and-History operations. A singleton that orchestrates property-level handlers to merge source objects into destination objects and create history entries. Copies persisted properties first, then transient properties (because transient may depend on persisted values). Only Kotlin classes are supported; Java classes emit a warning.

Architecture

Handler Chain

Registered in init block, tried in order:

  1. BigDecimalHandler — scale-insensitive BigDecimal comparison
  2. SqlDateHandler — java.sql.Date
  3. UtilDateHandler — java.util.Date
  4. CollectionHandler — collection deep copy with add/remove/modify tracking
  5. BaseDOHandler — BaseDO entities (compare by ID)
  6. DefaultHandler — fallback for all other types

Copy Process

  1. Initialize Hibernate proxy if needed
  2. Copy ID if not in ignore list and IDs differ
  3. Copy persisted properties first (using KClassUtils.filterPublicMutableProperties)
  4. Copy non-persisted/transient properties second
  5. Skip properties annotated with @CandHIgnore, transient, static, or inner class members

Key Methods

MethodDescription
copyValues(src, dest, ...)Public entry point; creates CandHContext, copies all properties
propertyWasModified(ctx, pc, type)Sets copy status to MAJOR or MINOR, triggers history entry creation
accept(property)Filters properties: rejects @CandHIgnore, transient, static, inner class

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
4b9ffbee2 Migration stuff in progress... (all tests of all packages: OK).
84e863624 Migration stuff in progress... (all tests of all packages: OK).
b79a1edca Migration stuff in progress... (all tests of all packages: OK).