EN · DE · RU · FR · ES

#258: SkillEntryDO.kt

plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryDO.kt Type: Kotlin · Role: Plugin Registration · Source: plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryDO.kt 127 lines · 74 code · 35 comments · 18 blank
JPA entity (Data Object) representing SkillEntry in the database. Maps to a table with Hibernate annotations, JPA relationships, and transient computed properties.

Code Structure

Annotations: IndexingDependency, Indexed, micromata, FullTextField, Transient, Table, author, PropertyInfo, GenericField, get, IndexedEmbedded, NamedQueries, JsonSerialize, Entity

Classes: SkillEntryDO

Supertype(s): AbstractBaseDO

JPA Entities: SkillEntryDO (table: T_PLUGIN_SKILLMATRIX_ENTRY)

Functions (1): getNormalizedSkill

Properties (14): id, skill, normalizedSkill, owner, rating, interest, comment, ownerId, FIND_OF_OWNER, DELETE_ALL_OF_USER, MIN_VAL_RATING, MAX_VAL_RATING, MIN_VAL_INTEREST, MAX_VAL_INTEREST

Imports: 10 packages

Package: org.projectforge.plugins.skillmatrix

Source Code (abridged)

package org.projectforge.plugins.skillmatrix

import com.fasterxml.jackson.databind.annotation.JsonSerialize
import org.projectforge.common.StringHelper
import org.projectforge.common.anots.PropertyInfo
import org.projectforge.Constants
import org.projectforge.framework.persistence.entities.AbstractBaseDO
import org.projectforge.framework.persistence.user.entities.PFUserDO
import jakarta.persistence.*
import org.hibernate.search.mapper.pojo.automaticindexing.ReindexOnUpdate
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.*
import org.projectforge.framework.json.IdOnlySerializer

/**
 * @author Kai Reinhard (k.reinhard@micromata.de)
 */
@Entity
@Indexed
@Table(
  name = "T_PLUGIN_SKILLMATRIX_ENTRY",
  indexes = [jakarta.persistence.Index(name = "idx_fk_t_plugin_skillmatrix_entry_owner_fk", columnList = "owner_fk")]
)
@NamedQueries(
  NamedQuery(
    name = SkillEntryDO.FIND_OF_OWNER,
    query = "from SkillEntryDO where owner.id=:ownerId and deleted=false"
  ),
  NamedQuery(
    name = SkillEntryDO.DELETE_ALL_OF_USER,
    query = "delete from SkillEntryDO where owner.id=:userId"
  ),
)
open class SkillEntryDO : AbstractBaseDO<Long>() {

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

  @PropertyInfo(i18nKey = "plugins.skillmatrix.skill")
  @FullTextField
  @get:Column(length = 255, nullable = false)
  open var skill: String? = null

  @get:Transient
  val normalizedSkill: String
    get() = getNormalizedSkill(skill)

  /**
   * Don't index this field (due to privacy protection). No one should filter all skills of one user by simply entering user's name into the
   * search field.
   */
  @PropertyInfo(i18nKey = "plugins.skillmatrix.owner")
  @IndexedEmbedded(includeDepth = 1)
  @IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
  @get:ManyToOne(fetch = FetchType.LAZY)
  @get:JoinColumn(name = "owner_fk")
  @JsonSerialize(using = IdOnlySerializer::class)
  open var owner: PFUserDO? = null

  /**
   * 1 - basic knowledge, 2 - established knowledge, 3 - expert knowledge
   */
  @PropertyInfo(i18nKey = "plugins.skillmatrix.rating")
  @GenericField
  @get:Column
  open var rating: Int? = null

  /**
   * 1 - interested, 2 - vested interest, 3 - going crazy
   */
  @PropertyInfo(i18nKey = "plugins.skillmatrix.interest")
  @GenericField
  @get:Column
  open var interest: Int? = null

  @PropertyInfo(i18nKey = "comment")
  @FullTextField
  @get:Column(length = Constants.LENGTH_COMMENT)
  open var comment: String? = null

  val ownerId: Long?
    @Transient
    get() = owner?.id

  companion object {
    const val FIND_OF_OWNER = "SkillEntryDO_FindSkillsOfOwner"

    internal const val DELETE_ALL_OF_USER = "SkillEntryDO_DeleteAllOfUser"

    const val MIN_VAL_RATING = 0

    const val MAX_VAL_RATING = 3

    const val MIN_VAL_INTEREST = 0

    const val MAX_VAL_INTEREST = 3

    fun getNormalizedSkill(skill: String?): String {
      return StringHelper.normalize(skill, true)!!
    }
  }
}

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
0237d5eba Json serialization refactored: IdOnlySerializer and IdsOnlySerializer introduced.
44253baee WIP: Setup of ProjectForge...
66ec668f6 Migration stuff in progress...