868d6abb7 2025 -> 2026
48a93dedb Journal console coloré. L'export UserGroupCache pour le débogage et la comparaison fonctionne maintenant. CollectionUtil amélioré. KotlinStringExtension.shortenMiddle() ajouté.
63081666f En-têtes des fichiers source : 2024 -> 2025.
61f05ce90 Travail de migration en cours...
5989b32fd BaseDao : mécanisme de onChangeLister refactorisé.
868d6abb7
2025 -> 2026868d6abb75cd191a892911ac8e45058932cf9074
diff --git a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
index 7ca7f9101..52deaa7d3 100644
--- a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
+++ b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.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.
//
48a93dedb
Journal console coloré. L'export UserGroupCache pour le débogage et la comparaison fonctionne maintenant. CollectionUtil amélioré. KotlinStringExtension.shortenMiddle() ajouté.48a93dedb542a7f4100f86f6f4c9c1b8b8f41027
diff --git a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
index 91ad1f77c..7ca7f9101 100644
--- a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
+++ b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
@@ -61,17 +61,37 @@ object CollectionUtils {
* Joint les identifiants de la collection donnée en une chaîne CSV. Les entrées sont triées par identifiant.
* Utilisé par exemple dans les entrées d'historique, représentant les entrées supprimées et ajoutées d'une collection.
*/
- fun joinToStringOfIds(col: Collection<IdObject<Long>>?): String? {
+ fun joinToStringOfIds(col: Collection<IdObject<Long>>?, filterNotNull: Boolean = true): String? {
col ?: return null
- return joinToString(col.map { it.id })
+ return joinToString(col, filterNotNull, idOnly = true)
}
/**
* Joint la collection donnée en une chaîne CSV. Les entrées sont triées.
*/
- fun <T : Comparable<T>> joinToString(col: Collection<T?>?): String? {
+ fun joinToString(col: Collection<Any?>?, filterNotNull: Boolean = true, idOnly: Boolean = false): String? {
col ?: return null
- return col.filterNotNull().sorted().joinToString(separator = ",")
+ var filtered = if (filterNotNull) col.filterNotNull() else col
+ if (filtered.isEmpty()) {
+ return ""
+ }
+ val first = filtered.first()
+ if (first is Comparable<*>) { // Le tri est possible :
+ filtered = filtered.sortedWith(compareBy { it as Comparable<*> })
+ } else if (first is IdObject<*> && first.id is Comparable<*>) { // Le tri est possible :
+ filtered = filtered.sortedWith(compareBy { ((it as IdObject<*>).id as? Comparable<*>) })
+ }
+ return filtered.joinToString(separator = ",") { if (idOnly) toString(it) else it.toString() }
+ }
+
+ private fun toString(entry: Any?): String {
+ return if (entry == null) {
+ "null"
+ } else if (entry is IdObject<*>) {
+ entry.id.toString()
+ } else {
+ entry.toString()
+ }
}
/** 63081666f
En-têtes des fichiers source : 2024 -> 2025.63081666f620fb87315f01b817e560e0b2f6a33a
diff --git a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
index 795d4b20b..91ad1f77c 100644
--- a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
+++ b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.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.
//
61f05ce90
Travail de migration en cours...61f05ce90d175668026491c93a758f1ec6524c32
diff --git a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
index 9ea824f86..795d4b20b 100644
--- a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
+++ b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
@@ -23,7 +23,6 @@
package org.projectforge.framework.persistence.utils
-import kotlinx.collections.immutable.toImmutableList
import org.projectforge.framework.persistence.api.IdObject
import kotlin.reflect.full.isSubclassOf
import kotlin.reflect.jvm.jvmErasure
@@ -92,10 +91,10 @@ object CollectionUtils {
if (useDest.isNullOrEmpty()) {
return CompareCollectionsResult()
}
- return CompareCollectionsResult(removed = useDest.toImmutableList())
+ return CompareCollectionsResult(removed = useDest.toList())
}
if (useDest.isNullOrEmpty()) {
- return CompareCollectionsResult(added = useSrc.toImmutableList())
+ return CompareCollectionsResult(added = useSrc.toList())
}
val added = getAddedEntries(src = useSrc, dest = useDest)
val removed = getAddedEntries(src = useDest, dest = useSrc) 5989b32fd
BaseDao : mécanisme de onChangeLister refactorisé.5989b32fdbe63a7ade7eabba11a8c2b042ecd66b
diff --git a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
index 332777d2b..9ea824f86 100644
--- a/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
+++ b/projectforge-business/src/main/kotlin/org/projectforge/framework/persistence/utils/CollectionUtils.kt
@@ -25,6 +25,8 @@ package org.projectforge.framework.persistence.utils
import kotlinx.collections.immutable.toImmutableList
import org.projectforge.framework.persistence.api.IdObject
+import kotlin.reflect.full.isSubclassOf
+import kotlin.reflect.jvm.jvmErasure
object CollectionUtils {
class CompareCollectionsResult<T>(
@@ -52,6 +54,10 @@ object CollectionUtils {
return col.firstOrNull()?.javaClass
}
+ fun isCollection(property: kotlin.reflect.KProperty1<*, *>): Boolean {
+ return property.returnType.jvmErasure.isSubclassOf(Collection::class)
+ }
+
/**
* Joint les identifiants de la collection donnée en une chaîne CSV. Les entrées sont triées par identifiant.
* Utilisé par exemple dans les entrées d'historique, représentant les entrées supprimées et ajoutées d'une collection.