EN · DE · RU · FR · ES

#258: SkillEntryDO.kt

plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryDO.kt Tipo: Kotlin · Rol: Registro de Plugin · Fuente: plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryDO.kt 127 líneas · 74 código · 35 comentarios · 18 en blanco
Entidad JPA (Objeto de Datos) que representa SkillEntry en la base de datos. Mapea a una tabla con anotaciones Hibernate, relaciones JPA y propiedades computadas transitorias.

Estructura del Código

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

Clases: SkillEntryDO

Super-tipo(s): AbstractBaseDO

Entidades JPA: SkillEntryDO (tabla: T_PLUGIN_SKILLMATRIX_ENTRY)

Funciones (1): getNormalizedSkill

Propiedades (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

Importaciones: 10 paquetes

Paquete: org.projectforge.plugins.skillmatrix

Código Fuente (resumido)

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)

  /**
   * No indexar este campo (debido a protección de privacidad). Nadie debería poder filtrar todas las habilidades de un usuario simplemente ingresando el nombre del usuario en el
   * campo de búsqueda.
   */
  @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 - conocimiento básico, 2 - conocimiento establecido, 3 - conocimiento experto
   */
  @PropertyInfo(i18nKey = "plugins.skillmatrix.rating")
  @GenericField
  @get:Column
  open var rating: Int? = null

  /**
   * 1 - interesado, 2 - interés especial, 3 - apasionado
   */
  @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)!!
    }
  }
}

Historial Git

868d6abb7 2025 -> 2026
63081666f Encabezados de archivos fuente: 2024 -> 2025.
0237d5eba Serialización JSON refactorizada: IdOnlySerializer e IdsOnlySerializer introducidos.
44253baee WIP: Configuración de ProjectForge...
66ec668f6 Migración en progreso...