EN · DE · RU · FR · ES

#263: SkillMatrixServicesRest.kt

plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt Clase Kotlin, plugins/org.projectforge.plugins.skillmatrix/src/main/kotlin/org/projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt 123 líneas · 84 código · 28 comentarios · 11 en blanco
Propósito: Archivo fuente: projectforge/plugins/skillmatrix/SkillMatrixServicesRest.kt. SkillMatrixServicesRest.kt es parte de la aplicación de gestión de proyectos de código abierto ProjectForge.

Fuente (primeras 100 líneas)

/////////////////////////////////////////////////////////////////////////////
//
// Project ProjectForge Community Edition
//         www.projectforge.org
//
// Copyright (C) 2001-2026 Micromata GmbH, Germany (www.micromata.com)
//
// ProjectForge tiene doble licencia.
//
// Esta edición comunitaria es software libre; puedes redistribuirla y/o
// modificarla bajo los términos de la Licencia Pública General GNU publicada
// por la Free Software Foundation; versión 3 de la Licencia.
//
// Esta edición comunitaria se distribuye con la esperanza de que sea útil,
// pero SIN NINGUNA GARANTÍA; sin siquiera la garantía implícita de
// COMERCIABILIDAD o IDONEIDAD PARA UN PROPÓSITO PARTICULAR. Consulte la
// Licencia Pública General GNU para más detalles.
//
// Deberías haber recibido una copia de la Licencia Pública General GNU junto
// con este programa; si no, visita 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 {}

/**
 * Para subir imágenes de direcciones.
 */
@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

  /**
   * Exporta direcciones favoritas.
   */
  @GetMapping(REST_EXCEL_SUB_PATH)
  fun exportFavoritesExcel(): ResponseEntity<Any> {
    log.info("Exportando matriz de habilidades como archivo 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)

Historial Git

868d6abb7 2025 -> 2026
78a38ca8f ExcelUtils.createFont y usado por todas las rutinas de creación de fuentes en Excel.
63081666f Encabezados de archivos fuente: 2024 -> 2025.
67805f2fc ThreadLocalUserContext.user -> ThreadLocalUserContext.loggedInUser (renombrado para evitar malentendidos en el código).
b6092df09 Copyright 2023 -> 2024

868d6abb7

2025 -> 2026
868d6abb75cd191a892911ac8e45058932cf9074
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 @@
 // Project ProjectForge Community Edition
 //         www.projectforge.org
 //
-// Copyright (C) 2001-2025 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2026 Micromata GmbH, Germany (www.micromata.com)
 //
 // ProjectForge tiene doble licencia.
 //

78a38ca8f

ExcelUtils.createFont y usado por todas las rutinas de creación de fuentes en 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

Encabezados de archivos fuente: 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 @@
 // Project ProjectForge Community Edition
 //         www.projectforge.org
 //
-// Copyright (C) 2001-2024 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2025 Micromata GmbH, Germany (www.micromata.com)
 //
 // ProjectForge tiene doble licencia.
 //

67805f2fc

ThreadLocalUserContext.user -> ThreadLocalUserContext.loggedInUser (renombrado para evitar malentendidos en el código).
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 -> 2024
b6092df0927c4a3b161e888445f31dcab57493f2
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 @@
 // Project ProjectForge Community Edition
 //         www.projectforge.org
 //
-// Copyright (C) 2001-2023 Micromata GmbH, Germany (www.micromata.com)
+// Copyright (C) 2001-2024 Micromata GmbH, Germany (www.micromata.com)
 //
 // ProjectForge tiene doble licencia.
 //