Added DTOs for communication with Angular

This commit is contained in:
2023-10-26 20:54:31 +02:00
parent 54a075b7e8
commit 37ce8e1511
16 changed files with 199 additions and 0 deletions
@@ -0,0 +1,14 @@
package de.twomartens.timetable.model.common
import de.twomartens.timetable.types.NonEmptyString
@JvmInline
value class Line private constructor(val name: String) {
companion object {
val EMPTY = Line("EMPTY")
fun of(name: NonEmptyString): Line {
return Line(name.value)
}
}
}
@@ -0,0 +1,12 @@
package de.twomartens.timetable.model.common
import de.twomartens.timetable.types.PositiveInteger
@JvmInline
value class RotationId private constructor(val id: Int) {
companion object {
fun of(id: PositiveInteger): RotationId {
return RotationId(id.value)
}
}
}
@@ -0,0 +1,17 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.model.common.FormationId
import de.twomartens.timetable.model.common.Line
import de.twomartens.timetable.model.common.ServiceId
import java.time.LocalTime
data class AdditionalService(
val id: ServiceId,
val line: Line,
val formationId: FormationId,
val direction: Direction,
val start: Station,
val destination: Station,
val serviceStartTime: LocalTime,
val stops: List<AdditionalServiceStop>
)
@@ -0,0 +1,12 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.types.NonEmptyString
import java.time.LocalTime
data class AdditionalServiceStop(
val stop: Station,
val arrivalTime: LocalTime,
val departureTime: LocalTime,
val platformAndSection: NonEmptyString,
val loading: Boolean
)
@@ -0,0 +1,9 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.model.common.CountryCode
import de.twomartens.timetable.types.NonEmptyString
data class Country(
val countryCode: CountryCode,
val name: NonEmptyString
)
@@ -0,0 +1,6 @@
package de.twomartens.timetable.model.dto
enum class Direction {
LEFT,
RIGHT
}
@@ -0,0 +1,11 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.model.common.FormationId
import de.twomartens.timetable.types.NonEmptyString
data class Formation(
val id: FormationId,
val name: NonEmptyString,
val trainSimWorldFormationId: FormationId?,
val coaches: List<NonEmptyString>
)
@@ -0,0 +1,14 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.model.common.FormationId
import de.twomartens.timetable.model.common.RotationId
import java.time.LocalTime
data class Rotation(
val id: RotationId,
val formationId: FormationId,
val firstServiceStartTime: LocalTime,
val lastServiceEndTime: LocalTime,
val startsInVault: Boolean,
)
@@ -0,0 +1,15 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.model.common.FormationId
import de.twomartens.timetable.model.common.Line
import de.twomartens.timetable.model.common.ServiceId
data class ServiceFormationStage(
val id: ServiceId,
val line: Line,
val direction: Direction,
val formation: FormationId,
val formationReversed: Boolean,
val startStop: ServiceStop,
val destinationStop: ServiceStop
)
@@ -0,0 +1,18 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.model.common.FormationId
import de.twomartens.timetable.model.common.Line
import de.twomartens.timetable.model.common.ServiceId
data class ServiceLinkingStage(
val id: ServiceId,
val formationId: FormationId,
val line: Line,
val direction: Direction,
val formationReversed: Boolean,
val startStop: ServiceStop,
val fromDepotOrSidingAtStart: Boolean,
val destinationStop: ServiceStop,
val fromDepotOrSidingAtDestination: Boolean,
)
@@ -0,0 +1,16 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.model.common.Line
import de.twomartens.timetable.model.common.ServiceId
import de.twomartens.timetable.types.NonEmptyString
data class ServiceRotationStage(
val id: ServiceId,
val line: Line,
val originStop: NonEmptyString,
val virtualDestinations: List<NonEmptyString>,
val startingFrom: NonEmptyString,
val endingIn: NonEmptyString,
val serviceStartTime: NonEmptyString,
val stops: List<ServiceStop>
)
@@ -0,0 +1,11 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.types.NonEmptyString
data class ServiceStop(
val stop: Station,
val arrivalTime: String,
val departureTime: String,
val platform: NonEmptyString,
val section: String
)
@@ -0,0 +1,9 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.model.common.StationId
import de.twomartens.timetable.types.NonEmptyString
data class Station(
val id: StationId,
val name: NonEmptyString
)
@@ -0,0 +1,13 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.types.NonEmptyString
import java.time.LocalDate
data class Timetable(
val name: NonEmptyString,
val country: Country,
val routeName: NonEmptyString,
val fetchDate: LocalDate,
val state: TimetableState,
val numberOfServices: String
)
@@ -0,0 +1,9 @@
package de.twomartens.timetable.model.dto
enum class TimetableState {
NEW,
PROCESSING,
ENTER_FORMATIONS,
LINK_SERVICES,
READY_FOR_USAGE
}
@@ -0,0 +1,13 @@
package de.twomartens.timetable.model.dto
import de.twomartens.timetable.model.common.Depot
import de.twomartens.timetable.model.common.Portal
import de.twomartens.timetable.types.NonEmptyString
data class TswRoute(
val name: NonEmptyString,
val country: Country,
val stations: List<Station>,
val portals: List<Portal>,
val depots: List<Depot>
)