EN · DE · RU · FR · ES

#76: DataTransferAuditDO.kt

plugins/org.projectforge.plugins.datatransfer/src/main/kotlin/org/projectforge/plugins/datatransfer/DataTransferAuditDO.kt Type: Kotlin · Role: Plugin Registration · Source: plugins/org.projectforge.plugins.datatransfer/src/main/kotlin/org/projectforge/plugins/datatransfer/DataTransferAuditDO.kt 182 lines · 114 code · 44 comments · 24 blank
JPA entity (Data Object) representing DataTransferAudit in the database. Maps to a table with Hibernate annotations, JPA relationships, and transient computed properties.

Code Structure

Annotations: Indexed, micromata, Table, author, get, NamedQueries, JsonSerialize, Entity

Classes: DataTransferAuditDO, Action

Enum classes: Action

JPA Entities: DataTransferAuditDO (table: t_plugin_datatransfer_audit)

Functions (2): createdByUserAsString, toString

Properties (23): id, timestamp, areaId, byUser, byExternalUser, eventType, description, descriptionOld, uploadByUser, filename, filenameOld, notified, timeAgo, eventAsString, byUserAsString, filenameAsString, descriptionAsString, DELETE_OLD_ENTRIES, FIND_BY_AREA_ID, FIND_BY_ID, FIND_DOWNLOADS_BY_AREA_ID, FIND_QUEUED_ENTRIES_SENT_BY_AREA_ID_IGNORE_TYPES, UPDATE_NOTIFICATION_STATUS

Imports: 11 packages

Package: org.projectforge.plugins.datatransfer

Source Code (abridged)

package org.projectforge.plugins.datatransfer

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed
import org.projectforge.Constants
import org.projectforge.framework.i18n.TimeAgo
import org.projectforge.framework.i18n.translate
import org.projectforge.framework.jcr.AttachmentsEventType
import org.projectforge.framework.persistence.user.entities.PFUserDO
import java.util.*
import jakarta.persistence.*
import org.projectforge.framework.json.IdOnlySerializer

/**
 * @author Kai Reinhard (k.reinhard@micromata.de)
 */
@Entity
@Indexed
@Table(name = "t_plugin_datatransfer_audit")
@NamedQueries(
  NamedQuery(
    name = DataTransferAuditDO.DELETE_OLD_ENTRIES,
    query = "delete from DataTransferAuditDO where timestamp<=:timestamp"
  ),
  NamedQuery(
    name = DataTransferAuditDO.FIND_DOWNLOADS_BY_AREA_ID,
    query = "from DataTransferAuditDO where areaId=:areaId and eventType in :eventTypes order by timestamp desc"
  ),
  NamedQuery(
    name = DataTransferAuditDO.FIND_BY_AREA_ID,
    query = "from DataTransferAuditDO where areaId=:areaId order by timestamp desc"
  ),
  NamedQuery(
    name = DataTransferAuditDO.FIND_BY_ID,
    query = "from DataTransferAuditDO where id=:id"
  ),
  NamedQuery(
    name = DataTransferAuditDO.FIND_QUEUED_ENTRIES_SENT_BY_AREA_ID_IGNORE_TYPES,
    query = "from DataTransferAuditDO where areaId=:areaId and notified=false and eventType not in :eventTypes order by timestamp desc"
  ),
  NamedQuery(
    name = DataTransferAuditDO.UPDATE_NOTIFICATION_STATUS,
    query = "update DataTransferAuditDO set notified=true where id IN :idList"
  ),
)
open class DataTransferAuditDO {
  enum class Action { DELETE, DOWNLOAD, MODIFIED, UPLOAD }

  @get:Id
  @get:GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "hibernate_sequence")
  @get:Column(name = "pk")
  open var id: Long? = null

  @get:Column
  open var timestamp: Date? = null

  /**
   * No constraint (area might be deleted in the mean time).
   */
  @get:Column(name = "area_fk", nullable = false)
  open var areaId: Long? = null

  @get:ManyToOne(fetch = FetchType.LAZY)
  @get:JoinColumn(name = "by_user_fk")
  @JsonSerialize(using = IdOnlySerializer::class)
  open var byUser: PFUserDO? = null

  @get:Column(name = "by_external_user", length = 4000)
  open var byExternalUser: String? = null


  @get:Enumerated(EnumType.STRING)
  @get:Column(name = "event_type", length = 20, nullable = false)
  open var eventType: AttachmentsEventType? = null

  @get:Column(length = Constants.LENGTH_TEXT)
  open var description: String? = null

  /**
   * Old value of description (if modified).
   */
  @get:Column(name = "description_old", length = Constants.LENGTH_TEXT)
  open var descriptionOld: String? = null

  /**
   * The user uploaded the file. It's stored here, because the file could be deleted in the mean time to inform
   * this user about the deletion and any other modifications and downloads.
   */
  @get:ManyToOne(fetch = FetchType.LAZY)
  @get:JoinColumn(name = "upload_by_user_fk")
  @JsonSerialize(using = IdOnlySerializer::class)
  open var uploadByUser: PFUserDO? = null

  @get:Column(length = 1000)
  open var filename: String? = null

  /**
   * Old value of description (if modified).
   */
  @get:Column(name = "filename_old", length = 1000)
  open var filenameOld: String? = null

  /**
   * Notification to all observers sent? Is also set to true after processing, if no observer is registered.
   */
  @get:Column(name = "notified")
  open var notified: Boolean = false

  /**
   * Time stamp of event as human-readable time ago message.
   */
  @get:Transient
  @get:JsonProperty(access = JsonProperty.Access.READ_ONLY)
  open val timeAgo
    get() = TimeAgo.getMessage(timestamp)

  @get:Transient
  @get:JsonProperty(access = JsonProperty.Access.READ_ONLY)
// ... (truncated, total 160 lines)

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
0237d5eba Json serialization refactored: IdOnlySerializer and IdsOnlySerializer introduced.
ca9851ba0 WIP: gradle...
1ffa5a1ef WIP: gradle...