Integrate qualification master data system (QualifikationMasterTable) for functionaries, refactor mapping logic in repositories, enhance database initialization for ZNS and Masterdata services, and add a seeder for ÖTO/FEI qualification data. Fix PSQLException during ZNS imports.

This commit is contained in:
2026-04-06 13:53:06 +02:00
parent 933ef9cd6c
commit c35869f8ee
7 changed files with 153 additions and 23 deletions
@@ -2,7 +2,9 @@ package at.mocode.masterdata.service.config
import at.mocode.masterdata.infrastructure.persistence.*
import at.mocode.masterdata.infrastructure.persistence.funktionaer.FunktionaerQualifikationTable
import at.mocode.masterdata.infrastructure.persistence.funktionaer.FunktionaerTable
import at.mocode.masterdata.infrastructure.persistence.funktionaer.QualifikationMasterTable
import at.mocode.masterdata.infrastructure.persistence.pferd.HorseTable
import at.mocode.masterdata.infrastructure.persistence.reiter.ReiterTable
import at.mocode.masterdata.infrastructure.persistence.verein.VereinTable
@@ -49,6 +51,8 @@ class MasterdataDatabaseConfiguration(
HorseTable,
VereinTable,
FunktionaerTable,
QualifikationMasterTable,
FunktionaerQualifikationTable,
TurnierklasseTable,
LicenseTable,
RichtverfahrenTable,
@@ -95,6 +99,8 @@ class MasterdataTestDatabaseConfiguration {
HorseTable,
VereinTable,
FunktionaerTable,
QualifikationMasterTable,
FunktionaerQualifikationTable,
TurnierklasseTable,
LicenseTable,
RichtverfahrenTable,
@@ -0,0 +1,86 @@
@file:OptIn(kotlin.uuid.ExperimentalUuidApi::class)
package at.mocode.masterdata.service.config
import at.mocode.masterdata.infrastructure.persistence.funktionaer.QualifikationMasterTable
import jakarta.annotation.PostConstruct
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
import org.jetbrains.exposed.v1.core.*
import org.jetbrains.exposed.v1.jdbc.*
import org.slf4j.LoggerFactory
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.DependsOn
import org.springframework.context.annotation.Profile
import kotlin.uuid.Uuid
/**
* Seeder für die offiziellen ÖTO/FEI Qualifikations-Kürzel.
* Befüllt die QualifikationMasterTable mit Standard-Werten.
*/
@Configuration
@Profile("!test")
@DependsOn("masterdataDatabaseConfiguration")
class QualifikationMasterSeeder {
private val log = LoggerFactory.getLogger(QualifikationMasterSeeder::class.java)
@PostConstruct
fun seed() {
log.info("Starte Seeding der Qualifikations-Master-Daten (ÖTO/FEI)...")
transaction {
seedRichter()
seedParcoursbauer()
}
log.info("Seeding der Qualifikations-Master-Daten abgeschlossen.")
}
private fun seedRichter() {
val richterQualis = listOf(
"D" to "Dressur",
"S" to "Springen",
"DPF" to "Dressurpferde",
"SPF" to "Springpferde",
"G" to "Gelände",
"STW" to "Steward",
"DM" to "Dressur Master",
"SM" to "Springen Master",
"GA" to "Grundausbildung",
"G3" to "Gruppe 3",
"G2" to "Gruppe 2",
"G1" to "Gruppe 1"
)
richterQualis.forEach { (code, bezeichnung) ->
upsertQuali(code, bezeichnung, "RICHTER")
}
}
private fun seedParcoursbauer() {
val pbQualis = listOf(
"P1" to "Einsteiger",
"P2" to "Fortgeschritten",
"P3" to "National",
"P4" to "Grand Prix",
"SP" to "Springen",
"VS" to "Vielseitigkeit"
)
pbQualis.forEach { (code, bezeichnung) ->
upsertQuali(code, bezeichnung, "PARCOURSBAUER")
}
}
private fun upsertQuali(code: String, bezeichnung: String, typ: String) {
val exists = QualifikationMasterTable.selectAll()
.where { (QualifikationMasterTable.code eq code) and (QualifikationMasterTable.typ eq typ) }
.any()
if (!exists) {
QualifikationMasterTable.insert {
it[id] = Uuid.random()
it[QualifikationMasterTable.code] = code
it[QualifikationMasterTable.bezeichnung] = bezeichnung
it[QualifikationMasterTable.typ] = typ
}
log.debug("QualifikationMaster '{}' ({}) angelegt.", code, typ)
}
}
}