EN · DE · RU · FR · ES

#258 : SkillEntryDO.kt

plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryDO.kt Type : Kotlin · Rôle : Enregistrement de plugin · Source : plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryDO.kt 127 lignes · 74 code · 35 commentaires · 18 vides
Entité JPA (objet de données) représentant SkillEntry dans la base de données. Mappe une table avec des annotations Hibernate, des relations JPA et des propriétés calculées transitoires.

Structure du code

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

Classes : SkillEntryDO

Supertype(s) : AbstractBaseDO

Entités JPA : SkillEntryDO (table : T_PLUGIN_SKILLMATRIX_ENTRY)

Fonctions (1) : getNormalizedSkill

Propriétés (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

Importations : 10 paquets

Paquet : org.projectforge.plugins.skillmatrix

Code source (abrégé)

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)

  /**
   * Ne pas indexer ce champ (protection de la vie privée). Personne ne devrait pouvoir filtrer toutes les compétences d'un utilisateur en
   * saisissant simplement son nom dans le champ de recherche.
   */
  @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 - connaissances de base, 2 - connaissances établies, 3 - connaissances expertes
   */
  @PropertyInfo(i18nKey = "plugins.skillmatrix.rating")
  @GenericField
  @get:Column
  open var rating: Int? = null

  /**
   * 1 - intéressé, 2 - intérêt marqué, 3 - passionné
   */
  @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)!!
    }
  }
}

Historique Git

868d6abb7 2025 -> 2026
63081666f En-têtes des fichiers source : 2024 -> 2025.
0237d5eba Sérialisation JSON refactorisée : introduction de IdOnlySerializer et IdsOnlySerializer.
44253baee WIP : Configuration de ProjectForge...
66ec668f6 Travaux de migration en cours...