#263 : SkillMatrixServicesRest.kt
plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt Classe Kotlin, plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt 123 lignes · 84 code · 28 commentaires · 11 vides
Objectif : Fichier source : projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt. SkillMatrixServicesRest.kt fait partie de l'application open-source de gestion de projet 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
// COMMERCIALISATION 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 de.micromata.merlin.excel.ExcelCellType
import de.micromata.merlin.excel.ExcelWorkbook
import mu.KotlinLogging
import org.projectforge.excel.ExcelUtils
import org.projectforge.framework.i18n.translate
import org.projectforge.framework.persistence.user.api.ThreadLocalUserContext
import org.projectforge.framework.time.DateHelper
import org.projectforge.model.rest.RestPaths.REST_EXCEL_SUB_PATH
import org.projectforge.rest.config.Rest
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.core.io.ByteArrayResource
import org.springframework.http.HttpHeaders
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import java.util.*
private val log = KotlinLogging.logger {}
/**
* Pour le téléchargement des images d'adresses.
*/
@RestController
@RequestMapping(SkillMatrixServicesRest.REST_PATH)
class SkillMatrixServicesRest {
enum class ExcelCol(val header: String, val width: Int) {
MY_SKILL("plugins.skillmatrix.filter.mySkills", 10),
SKILL("plugins.skillmatrix.skill", 50),
COUNTER("#", 4),
RATING_MEAN("plugins.skillmatrix.rating", 10),
INTEREST_MEAN("plugins.skillmatrix.interest", 10)
}
@Autowired
private lateinit var skillStatisticsCache: SkillStatisticsCache
@Autowired
private lateinit var skillEntryDao: SkillEntryDao
/**
* Exporte les adresses favorites.
*/
@GetMapping(REST_EXCEL_SUB_PATH)
fun exportFavoritesExcel(): ResponseEntity<Any> {
log.info("Export de la matrice de compétences en fichier Excel.")
ExcelWorkbook.createEmptyWorkbook(ThreadLocalUserContext.locale!!).use { workbook ->
val sheet = workbook.createOrGetSheet(translate("plugins.skillmatrix.title.list"))
val boldFont = ExcelUtils.createFont(workbook, "bold", bold = true)
val boldStyle = workbook.createOrGetCellStyle("hr", font = boldFont)
val decimalStyle = workbook.createOrGetCellStyle("decimal")
decimalStyle.dataFormat = workbook.createDataFormat().getFormat("0.0")
val headRow = sheet.createRow()
ExcelCol.entries.forEach {
headRow.getCell(it.ordinal, ExcelCellType.STRING)
.setCellValue(
if (it.header != "#") {
translate(it.header)
} else {
it.header
}
)
.setCellStyle(boldStyle)
sheet.setColumnWidth(it.ordinal, it.width * 256)
}
sheet.setAutoFilter()
val ownSkills = skillEntryDao.getSkills(ThreadLocalUserContext.loggedInUser!!)
skillStatisticsCache.statistics.forEach { stats ->
val row = sheet.createRow()
if (ownSkills.any { it.normalizedSkill == SkillEntryDO.getNormalizedSkill(stats.skill) }) {
row.getCell(ExcelCol.MY_SKILL.ordinal, ExcelCellType.STRING).setCellValue("*")
}
row.getCell(ExcelCol.SKILL.ordinal, ExcelCellType.STRING).setCellValue(stats.skill)
Historique Git
868d6abb7 2025 -> 2026
78a38ca8f ExcelUtils.createFont et utilisé par toutes les routines de création de polices Excel.
63081666f En-têtes des fichiers source : 2024 -> 2025.
67805f2fc ThreadLocalUserContext.user -> ThreadLocalUserContext.loggedInUser (renommé pour éviter les malentendus dans le code).
b6092df09 Copyright 2023 -> 2024
868d6abb7
2025 -> 2026868d6abb75cd191a892911ac8e45058932cf9074
diff --git a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
index 073373a85..e6508fd3b 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.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.
//
78a38ca8f
ExcelUtils.createFont et utilisé par toutes les routines de création de polices Excel.78a38ca8fe252bcfd1eddfc95318a6507f33bda2
diff --git a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
index 4947bf34e..073373a85 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
@@ -26,6 +26,7 @@ package org.projectforge.plugins.skillmatrix
import de.micromata.merlin.excel.ExcelCellType
import de.micromata.merlin.excel.ExcelWorkbook
import mu.KotlinLogging
+import org.projectforge.excel.ExcelUtils
import org.projectforge.framework.i18n.translate
import org.projectforge.framework.persistence.user.api.ThreadLocalUserContext
import org.projectforge.framework.time.DateHelper
@@ -72,12 +73,12 @@ class SkillMatrixServicesRest {
ExcelWorkbook.createEmptyWorkbook(ThreadLocalUserContext.locale!!).use { workbook ->
val sheet = workbook.createOrGetSheet(translate("plugins.skillmatrix.title.list"))
- val boldFont = workbook.createOrGetFont("bold", bold = true)
+ val boldFont = ExcelUtils.createFont(workbook, "bold", bold = true)
val boldStyle = workbook.createOrGetCellStyle("hr", font = boldFont)
val decimalStyle = workbook.createOrGetCellStyle("decimal")
decimalStyle.dataFormat = workbook.createDataFormat().getFormat("0.0")
val headRow = sheet.createRow()
- ExcelCol.values().forEach {
+ ExcelCol.entries.forEach {
headRow.getCell(it.ordinal, ExcelCellType.STRING)
.setCellValue(
if (it.header != "#") { 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/SkillMatrixServicesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
index 50d3334a8..4947bf34e 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.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/SkillMatrixServicesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
index f31c62cb1..50d3334a8 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
@@ -90,7 +90,7 @@ class SkillMatrixServicesRest {
sheet.setColumnWidth(it.ordinal, it.width * 256)
}
sheet.setAutoFilter()
- val ownSkills = skillEntryDao.getSkills(ThreadLocalUserContext.user!!)
+ val ownSkills = skillEntryDao.getSkills(ThreadLocalUserContext.loggedInUser!!)
skillStatisticsCache.statistics.forEach { stats ->
val row = sheet.createRow()
if (ownSkills.any { it.normalizedSkill == SkillEntryDO.getNormalizedSkill(stats.skill) }) { b6092df09
Copyright 2023 -> 2024b6092df0927c4a3b161e888445f31dcab57493f2
diff --git a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
index 68e960b36..f31c62cb1 100644
--- a/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
+++ b/plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt
@@ -3,7 +3,7 @@
// Projet ProjectForge Community Edition
// www.projectforge.org
//
-// Copyright (C) 2001-2023 Micromata GmbH, Allemagne (www.micromata.com)
+// Copyright (C) 2001-2024 Micromata GmbH, Allemagne (www.micromata.com)
//
// ProjectForge est sous double licence.
//