Class BDMAuditUtils

java.lang.Object
com.bonitasoft.processbuilder.extension.BDMAuditUtils

public final class BDMAuditUtils extends Object
Utility class providing methods to automatically set creation and modification metadata on Business Data Model (BDM) objects using Java Reflection.

This class assumes that all target BDM objects implement the following methods:

  • getCreationDate(): returns OffsetDateTime
  • setCreationDate(OffsetDateTime)
  • setCreatorId(Long)
  • setCreatorName(String)
  • setModificationDate(OffsetDateTime)
  • setModifierId(Long)
  • setModifierName(String)
  • Method Details

    • createOrUpdateAuditData

      public static <T> T createOrUpdateAuditData(T bdmObject, T newBdmObject, Class<T> clazz, UserRecord initiator, Long persistenceId)
      Applies audit metadata (creation or modification) to a BDM object. If the object passed as bdmObject is null, the object provided in newBdmObject is used as the target (creation).
      Type Parameters:
      T - The generic type of the BDM object.
      Parameters:
      bdmObject - The existing BDM object (may be null for creation/update).
      newBdmObject - The object to use if bdmObject is null. Must be an already instantiated BDM object.
      clazz - The class of the BDM (used for logging purposes).
      initiator - The user performing the action.
      persistenceId - The persistence ID of the object (used for logging/update determination).
      Returns:
      The updated (or newly created) BDM object of type T.
      Throws:
      IllegalArgumentException - If both bdmObject and newBdmObject are null.
      RuntimeException - If a reflection error occurs (e.g., missing setter methods).