SkillMatrixPrivacyProtectionJob.ktAnnotations: PostConstruct, micromata, Service, author, Autowired
Classes: SkillMatrixPrivacyProtectionJob
Supertype(s): IPrivacyProtectionJob
Functions (2): postConstruct, execute
Properties (6): persistenceService, purgeCronPrivacyProtectionJob, userDao, date, lastUpdate, counter
Imports: 9 packages
Package: org.projectforge.plugins.skillmatrix
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("Purge skill matrix entries of leavers (deleted/deactivated users with 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 { "Deleted $counter entries of the skill matrix of user '${user.username}' with id ${user.id}." }
}
}
}
}
log.info("Purging of skill matrix entries done.")
}
}
868d6abb7 2025 -> 2026 63081666f Source file headers: 2024-> 2025. 1b50060c3 BaseDao: renamed: get -> find, save -> insert, getList -> select, load -> select 2a8ea2076 Migration stuff in progress... BaseDao refactored (not yet finished) internal* methods renamed. 108ecf629 !!!!! Big change of Transaction handling: Re-uses PfPersistenceContext as much as possible (not yet finished). Tests doesn't yet run. readonly-Transactions in PfPersistenceService removed, write-operations of PfPersistenceService removed.