EN · DE · RU · FR · ES

#260 : SkillEntryPagesRest.kt

plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt Classe Kotlin, plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt 188 lignes · 142 code · 34 commentaires · 12 vides
Objectif : Fichier source : projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt. SkillEntryPagesRest.kt fait partie de l'application de gestion de projet open source ProjectForge.

Source (100 premières lignes)

/////////////////////////////////////////////////////////////////////////////
//
// Projet ProjectForge Community Edition
//         www.projectforge.org
//
// Copyright (C) 2001-2026 Micromata GmbH, Allemagne (www.micromata.com)
//
// ProjectForge est sous double licence.
//
// Cette édition communautaire est un logiciel libre ; vous pouvez la redistribuer et/ou
// la modifier selon les termes de la GNU General Public License telle que publiée
// par la Free Software Foundation ; version 3 de la Licence.
//
// Cette édition communautaire est distribuée dans l'espoir qu'elle sera utile,
// mais SANS AUCUNE GARANTIE ; sans même la garantie implicite de
// QUALITÉ MARCHANDE ou d'ADÉQUATION À UN USAGE PARTICULIER. Voir la GNU General
// Public License pour plus de détails.
//
// Vous devriez avoir reçu une copie de la GNU General Public License avec
// ce programme ; sinon, consultez http://www.gnu.org/licenses/.
//
/////////////////////////////////////////////////////////////////////////////

package org.projectforge.plugins.skillmatrix

import jakarta.servlet.http.HttpServletRequest
import org.projectforge.business.PfCaches
import org.projectforge.business.fibu.EmployeeDO
import org.projectforge.framework.i18n.translate
import org.projectforge.framework.persistence.api.MagicFilter
import org.projectforge.framework.persistence.api.QueryFilter
import org.projectforge.framework.persistence.api.impl.CustomResultFilter
import org.projectforge.framework.persistence.user.api.ThreadLocalUserContext
import org.projectforge.menu.MenuItem
import org.projectforge.menu.MenuItemTargetType
import org.projectforge.rest.config.Rest
import org.projectforge.rest.core.AbstractDTOPagesRest
import org.projectforge.rest.dto.Employee
import org.projectforge.rest.dto.Kost1
import org.projectforge.rest.dto.SkillEntry
import org.projectforge.rest.dto.User
import org.projectforge.ui.*
import org.projectforge.ui.filter.UIFilterElement
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

@RestController
@RequestMapping("${Rest.URL}/skillentry")
class SkillEntryPagesRest() : AbstractDTOPagesRest<SkillEntryDO, SkillEntry, SkillEntryDao>(
    SkillEntryDao::class.java,
    "plugins.skillmatrix.title",
    cloneSupport = CloneSupport.CLONE
) {
    @Autowired
    private lateinit var caches: PfCaches

    /**
     * Initialise les nouveaux mémos pour l'ajout.
     */
    override fun newBaseDO(request: HttpServletRequest?): SkillEntryDO {
        val memo = super.newBaseDO(request)
        memo.owner = ThreadLocalUserContext.loggedInUser
        return memo
    }

    override fun transformFromDB(obj: SkillEntryDO, editMode: Boolean): SkillEntry {
        val entry = SkillEntry()
        entry.copyFrom(obj)
        caches.getUser(obj.owner?.id)?.let { userDO ->
            entry.owner = User(userDO)
        }
        return entry
    }

    override fun transformForDB(dto: SkillEntry): SkillEntryDO {
        val entryDO = SkillEntryDO()
        dto.copyTo(entryDO)
        return entryDO
    }

    /**
     * LAYOUT Page de liste
     */
    override fun createListLayout(
        request: HttpServletRequest,
        layout: UILayout,
        magicFilter: MagicFilter,
        userAccess: UILayout.UserAccess
    ) {
        agGridSupport.prepareUIGrid4ListPage(
            request,
            layout,
            magicFilter,
            this,
            userAccess = userAccess,
        )
            .add(lc, "lastUpdate", "skill", "owner")
            .add(lc, "rating", formatter = UIAgGridColumnDef.Formatter.RATING)
            .add(lc, "interest", formatter = UIAgGridColumnDef.Formatter.RATING)

Historique Git

868d6abb7 2025 -> 2026
b1742cefd SkillMatrix : champ propriétaire corrigé dans la liste et la page d'édition.
63081666f En-têtes des fichiers source : 2024 -> 2025.
67805f2fc ThreadLocalUserContext.user -> ThreadLocalUserContext.loggedInUser (renommé pour éviter les malentendus dans le code).
77bade6df javax.* -> jakarta.*

868d6abb7

2025 -> 2026
868d6abb75cd191a892911ac8e45058932cf9074
diff --git a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
index 0b6c1d285..f4de97b7d 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
@@ -3,7 +3,7 @@
 // Projet ProjectForge Community Edition
 //         www.projectforge.org
 //
-// Copyright (C) 2001-2025 Micromata GmbH, Allemagne (www.micromata.com)
+// Copyright (C) 2001-2026 Micromata GmbH, Allemagne (www.micromata.com)
 //
 // ProjectForge est sous double licence.
 //

b1742cefd

SkillMatrix : champ propriétaire corrigé dans la liste et la page d'édition.
b1742cefdb88b9fd401b51009387280af816a5a4
diff --git a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
index 1b33f262a..0b6c1d285 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
@@ -23,6 +23,9 @@
 
 package org.projectforge.plugins.skillmatrix
 
+import jakarta.servlet.http.HttpServletRequest
+import org.projectforge.business.PfCaches
+import org.projectforge.business.fibu.EmployeeDO
 import org.projectforge.framework.i18n.translate
 import org.projectforge.framework.persistence.api.MagicFilter
 import org.projectforge.framework.persistence.api.QueryFilter
@@ -31,123 +34,155 @@ import org.projectforge.framework.persistence.user.api.ThreadLocalUserContext
 import org.projectforge.menu.MenuItem
 import org.projectforge.menu.MenuItemTargetType
 import org.projectforge.rest.config.Rest
-import org.projectforge.rest.core.AbstractDOPagesRest
+import org.projectforge.rest.core.AbstractDTOPagesRest
+import org.projectforge.rest.dto.Employee
+import org.projectforge.rest.dto.Kost1
+import org.projectforge.rest.dto.SkillEntry
+import org.projectforge.rest.dto.User
 import org.projectforge.ui.*
 import org.projectforge.ui.filter.UIFilterElement
+import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.web.bind.annotation.RequestMapping
 import org.springframework.web.bind.annotation.RestController
-import jakarta.servlet.http.HttpServletRequest
 
 @RestController
 @RequestMapping("${Rest.URL}/skillentry")
-class SkillEntryPagesRest() : AbstractDOPagesRest<SkillEntryDO, SkillEntryDao>(
-  SkillEntryDao::class.java,
-  "plugins.skillmatrix.title",
-  cloneSupport = CloneSupport.CLONE
+class SkillEntryPagesRest() : AbstractDTOPagesRest<SkillEntryDO, SkillEntry, SkillEntryDao>(
+    SkillEntryDao::class.java,
+    "plugins.skillmatrix.title",
+    cloneSupport = CloneSupport.CLONE
 ) {
-  /**
-   * Initialise les nouveaux mémos pour l'ajout.
-   */
-  override fun newBaseDO(request: HttpServletRequest?): SkillEntryDO {
-    val memo = super.newBaseDO(request)
-    memo.owner = ThreadLocalUserContext.loggedInUser
-    return memo
-  }
+    @Autowired
+    private lateinit var caches: PfCaches
+
+    /**
+     * Initialise les nouveaux mémos pour l'ajout.
+     */
+    override fun newBaseDO(request: HttpServletRequest?): SkillEntryDO {
+        val memo = super.newBaseDO(request)
+        memo.owner = ThreadLocalUserContext.loggedInUser

63081666f

En-têtes des fichiers source : 2024 -> 2025.
63081666f620fb87315f01b817e560e0b2f6a33a
diff --git a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
index ca41ffe0d..1b33f262a 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
@@ -3,7 +3,7 @@
 // Projet ProjectForge Community Edition
 //         www.projectforge.org
 //
-// Copyright (C) 2001-2024 Micromata GmbH, Allemagne (www.micromata.com)
+// Copyright (C) 2001-2025 Micromata GmbH, Allemagne (www.micromata.com)
 //
 // ProjectForge est sous double licence.
 //

67805f2fc

ThreadLocalUserContext.user -> ThreadLocalUserContext.loggedInUser (renommé pour éviter les malentendus dans le code).
67805f2fc1f3e6a6393accb4a757a8f4049b001c
diff --git a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
index c750001aa..ca41ffe0d 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
@@ -50,7 +50,7 @@ class SkillEntryPagesRest() : AbstractDOPagesRest<SkillEntryDO, SkillEntryDao>(
    */
   override fun newBaseDO(request: HttpServletRequest?): SkillEntryDO {
     val memo = super.newBaseDO(request)
-    memo.owner = ThreadLocalUserContext.user
+    memo.owner = ThreadLocalUserContext.loggedInUser
     return memo
   }
 
@@ -100,7 +100,7 @@ class SkillEntryPagesRest() : AbstractDOPagesRest<SkillEntryDO, SkillEntryDao>(
     if (ownerFilterEntry?.isTrueValue == true) {
       ownerFilterEntry.synthetic = true
       target.createJoin("owner")
-      target.add(QueryFilter.eq("owner", ThreadLocalUserContext.user!!)) // Afficher uniquement ses propres compétences, pas celles des autres.
+      target.add(QueryFilter.eq("owner", ThreadLocalUserContext.loggedInUser!!)) // Afficher uniquement ses propres compétences, pas celles des autres.
     }
     return null
   }
@@ -110,7 +110,7 @@ class SkillEntryPagesRest() : AbstractDOPagesRest<SkillEntryDO, SkillEntryDao>(
    */
   override fun prepareClone(dto: SkillEntryDO): SkillEntryDO {
     val clone = super.prepareClone(dto)
-    clone.owner = ThreadLocalUserContext.user
+    clone.owner = ThreadLocalUserContext.loggedInUser
     return clone
   }
 

77bade6df

javax.* -> jakarta.*
77bade6dfb148c87638c71951accb03942157fcf
diff --git a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
index 36e60182c..c750001aa 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillEntryPagesRest.kt
@@ -36,7 +36,7 @@ import org.projectforge.ui.*
 import org.projectforge.ui.filter.UIFilterElement
 import org.springframework.web.bind.annotation.RequestMapping
 import org.springframework.web.bind.annotation.RestController
-import javax.servlet.http.HttpServletRequest
+import jakarta.servlet.http.HttpServletRequest
 
 @RestController
 @RequestMapping("${Rest.URL}/skillentry")