Refactor domain models (DomFunktionaer, DomReiter, DomPferd) for ZNS alignment: update properties, streamline validation logic, and enhance parser to support new format. Adjust controllers and repository methods accordingly.

This commit is contained in:
2026-04-05 08:21:11 +02:00
parent aba7b58dd4
commit a61dda69d1
27 changed files with 1006 additions and 1111 deletions
@@ -1,5 +1,7 @@
package at.mocode.core.utils.parser
import kotlinx.datetime.LocalDate
/**
* A simple utility to parse fixed-width strings based on 1-based start positions and lengths.
* This is particularly useful for parsing legacy data formats like the OePS ZNS formats.
@@ -36,4 +38,26 @@ class FixedWidthLineReader(private val line: String) {
val str = getString(start1Based, length)
return str.toIntOrNull()
}
/**
* Extracts a string and parses it as a LocalDate (format YYYYMMDD).
* Returns null if the field is empty or cannot be parsed.
*/
fun getLocalDateOrNull(start1Based: Int, length: Int): LocalDate? {
val str = getString(start1Based, length)
if (str.length != 8) return null
val year = str.substring(0, 4).toIntOrNull()
val month = str.substring(4, 6).toIntOrNull()
val day = str.substring(6, 8).toIntOrNull()
if (year == null || month == null || day == null) return null
if (month !in 1..12 || day !in 1..31) return null
return try {
LocalDate(year, month, day)
} catch (e: Exception) {
null
}
}
}