EN · DE · RU · FR · ES

#262: SkillMatrixPrivacyProtectionJob.kt

plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixPrivacyProtectionJob.kt Typ: Kotlin · Rolle: Plugin-Registrierung · Quelle: plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixPrivacyProtectionJob.kt 79 Zeilen · 44 Code · 26 Kommentare · 9 leer
Geplanter/System-Job für SkillMatrixPrivacyProtection. Implementiert periodische Wartungs- oder Plausibilitätsprüfungslogik, die vom PF-Job-Scheduler ausgeführt wird.

Codestruktur

Annotationen: PostConstruct, micromata, Service, author, Autowired

Klassen: SkillMatrixPrivacyProtectionJob

Supertyp(en): IPrivacyProtectionJob

Funktionen (2): postConstruct, execute

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

Importe: 9 Pakete

Paket: org.projectforge.plugins.skillmatrix

Quellcode (gekürzt)

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("Bereinige Skill-Matrix-Einträge von Ausgeschiedenen (gelöschte/deaktivierte Benutzer mit 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 { "$counter Einträge der Skill-Matrix von Benutzer '${user.username}' mit ID ${user.id} gelöscht." }
                    }
                }
            }
        }
        log.info("Bereinigung der Skill-Matrix-Einträge abgeschlossen.")
    }
}

Git-Verlauf

868d6abb7 2025 -> 2026
63081666f Quellcode-Dateiköpfe: 2024 -> 2025.
1b50060c3 BaseDao: umbenannt: get -> find, save -> insert, getList -> select, load -> select
2a8ea2076 Migration in Arbeit... BaseDao umgestaltet (noch nicht abgeschlossen) interne* Methoden umbenannt.
108ecf629 !!!!! Große Änderung der Transaktionsverwaltung: Verwendet PfPersistenceContext so weit wie möglich wieder (noch nicht abgeschlossen). Tests laufen noch nicht. readOnly-Transaktionen in PfPersistenceService entfernt, Schreiboperationen von PfPersistenceService entfernt.