EN · DE · RU · FR · ES

#262: SkillMatrixPrivacyProtectionJob.kt

plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixPrivacyProtectionJob.kt Tipo: Kotlin · Rol: Registro de Plugin · Fuente: plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixPrivacyProtectionJob.kt 79 líneas · 44 código · 26 comentarios · 9 en blanco
Tarea programada/de sistema para SkillMatrixPrivacyProtection. Implementa lógica periódica de mantenimiento o verificación de integridad ejecutada por el programador de tareas de PF.

Estructura del Código

Anotaciones: PostConstruct, micromata, Service, author, Autowired

Clases: SkillMatrixPrivacyProtectionJob

Super-tipo(s): IPrivacyProtectionJob

Funciones (2): postConstruct, execute

Propiedades (6): persistenceService, purgeCronPrivacyProtectionJob, userDao, date, lastUpdate, counter

Importaciones: 9 paquetes

Paquete: org.projectforge.plugins.skillmatrix

Código Fuente (resumido)

package org.projectforge.plugins.skillmatrix

import jakarta.annotation.PostConstruct
import mu.KotlinLogging
import org.projectforge.business.privacyprotection.CronPrivacyProtectionJob
import org.projectforge.business.privacyprotection.IPrivacyProtectionJob
import org.projectforge.business.user.UserDao
import org.projectforge.framework.persistence.jpa.PfPersistenceService
import org.projectforge.framework.time.PFDateTime
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

private val log = KotlinLogging.logger {}

/**
 *
 * @author Kai Reinhard (k.reinhard@micromata.de)
 */
@Service
class SkillMatrixPrivacyProtectionJob : IPrivacyProtectionJob {
    @Autowired
    private lateinit var persistenceService: PfPersistenceService

    @Autowired
    private lateinit var purgeCronPrivacyProtectionJob: CronPrivacyProtectionJob

    @Autowired
    private lateinit var userDao: UserDao

    @PostConstruct
    private fun postConstruct() {
        purgeCronPrivacyProtectionJob.register(this)
    }

    override fun execute() {
        val date = PFDateTime.now().minusMonths(3L)
        log.info("Purgando entradas de la matriz de habilidades de usuarios que se fueron (usuarios eliminados/desactivados con lastUpdate < ${date.isoString}Z)...")

        userDao.selectAll(checkAccess = false).forEach { user ->
            if (user.deactivated || user.deleted) {
                val lastUpdate = user.lastUpdate
                if (lastUpdate != null && lastUpdate < date.utilDate) {
                    val counter = persistenceService.runInTransaction { context ->
                        context.executeNamedUpdate(
                            SkillEntryDO.DELETE_ALL_OF_USER, Pair("userId", user.id)
                        )
                    }
                    if (counter > 0) {
                        log.info { "Eliminadas $counter entradas de la matriz de habilidades del usuario '${user.username}' con id ${user.id}." }
                    }
                }
            }
        }
        log.info("Purgado de entradas de la matriz de habilidades completado.")
    }
}

Historial Git

868d6abb7 2025 -> 2026
63081666f Encabezados de archivos fuente: 2024 -> 2025.
1b50060c3 BaseDao: renombrado: get -> find, save -> insert, getList -> select, load -> select
2a8ea2076 Migración en progreso... BaseDao refactorizado (aún no terminado) métodos internal* renombrados.
108ecf629 !!!!! Gran cambio en el manejo de transacciones: Reutiliza PfPersistenceContext tanto como sea posible (aún no terminado). Las pruebas aún no se ejecutan. Transacciones de solo lectura en PfPersistenceService eliminadas, operaciones de escritura de PfPersistenceService eliminadas.