Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ object PreviewData {
unplannedStop = null,
notServicedStop = null,
noBoardingAtStop = null,
noAlightingAtStop = null
noAlightingAtStop = null,
expectedDepartureOccupancy = emptyList()
),
legIntermediate = null,
legAlight = LegAlightDto(
Expand Down Expand Up @@ -227,7 +228,8 @@ object PreviewData {
unplannedStop = null,
notServicedStop = true,
noBoardingAtStop = null,
noAlightingAtStop = null
noAlightingAtStop = null,
expectedDepartureOccupancy = emptyList()
),
legIntermediate = null,
legAlight = LegAlightDto(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ch.opentransportdata.ojp.data.dto.converter

import ch.opentransportdata.ojp.domain.model.FareClass
import com.tickaroo.tikxml.TypeConverter


/**
* Created by Deniz Kalem on 02.07.2025
*/
internal class FareClassConverter : TypeConverter<FareClass> {

override fun read(ojpValue: String): FareClass {
return when (ojpValue.trim()) {
"unknown" -> FareClass.UNKNOWN
"firstClass" -> FareClass.FIRST_CLASS
"secondClass" -> FareClass.SECOND_CLASS
else -> FareClass.UNKNOWN
}
}

override fun write(type: FareClass): String {
return when (type) {
FareClass.UNKNOWN -> "unknown"
FareClass.FIRST_CLASS -> "firstClass"
FareClass.SECOND_CLASS -> "secondClass"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package ch.opentransportdata.ojp.data.dto.converter

import ch.opentransportdata.ojp.domain.model.OccupancyLevel
import com.tickaroo.tikxml.TypeConverter


/**
* Created by Deniz Kalem on 02.07.2025
*/
internal class OccupancyLevelConverter : TypeConverter<OccupancyLevel> {

override fun read(ojpValue: String): OccupancyLevel {
return when (ojpValue) {
"unknown" -> OccupancyLevel.UNKNOWN
"empty" -> OccupancyLevel.UNKNOWN
"undefined" -> OccupancyLevel.UNDEFINED
"manySeatsAvailable" -> OccupancyLevel.MANY_SEATS_AVAILABLE
"fewSeatsAvailable" -> OccupancyLevel.FEW_SEATS_AVAILABLE
"standingRoomOnly" -> OccupancyLevel.STANDING_ROOM_ONLY
"crushedStandingRoomOnly" -> OccupancyLevel.CRUSHED_STANDING_ROOM_ONLY
"notAcceptingPassengers" -> OccupancyLevel.NOT_ACCEPTING_PASSENGERS
"full" -> OccupancyLevel.FULL
else -> OccupancyLevel.UNKNOWN
}
}

override fun write(type: OccupancyLevel): String {
return when (type) {
OccupancyLevel.UNKNOWN -> "unknown"
OccupancyLevel.EMPTY -> "empty"
OccupancyLevel.UNDEFINED -> "undefined"
OccupancyLevel.MANY_SEATS_AVAILABLE -> "manySeatsAvailable"
OccupancyLevel.FEW_SEATS_AVAILABLE -> "fewSeatsAvailable"
OccupancyLevel.STANDING_ROOM_ONLY -> "standingRoomOnly"
OccupancyLevel.CRUSHED_STANDING_ROOM_ONLY -> "crushedStandingRoomOnly"
OccupancyLevel.NOT_ACCEPTING_PASSENGERS -> "notAcceptingPassengers"
OccupancyLevel.FULL -> "full"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data class PlaceReferenceDto(
//If more types needed, create custom typeAdapter and parse only necessary
@PropertyElement(name = "StopPlaceRef")
val ref: String? = null,
@Element(name = "StopPlaceName")
@Element(name = "Name")
val stationName: NameDto?,
@Element(name = "GeoPosition") //todo: check if schema is correct (when working on backend), think of solution where only send this if is Address
val position: GeoPositionDto? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data class StopPlaceDto(
override val privateCodes: List<PrivateCodeDto>? = emptyList(),
@PropertyElement(name = "StopPlaceRef")
val stopPlaceRef: String,
@Element(name = "StopPlaceName")
@Element(name = "Name")
val name: NameDto?,
@Element(name = "NameSuffix")
val nameSuffix: NameDto?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ data class ContinuousLegDto(
val legStart: LegStartEndDto,
@Element(name = "LegEnd")
val legEnd: LegStartEndDto,
// @Element(name = "Service")
// val service: ServiceDto,//Todo: create separate ContinuousService
@Element(name = "Service")
val service: ContinuousServiceTypeChoiceDto,
@PropertyElement(name = "Duration")
val duration: Duration
) : AbstractLegType(), Parcelable
Expand All @@ -28,5 +28,6 @@ fun ContinuousLegDto.minimalCopy(): ContinuousLegDto {
legStart = legStart,
legEnd = legEnd,
duration = duration,
service = service
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ch.opentransportdata.ojp.data.dto.response.tir.leg

import android.os.Parcelable
import com.tickaroo.tikxml.annotation.Element
import com.tickaroo.tikxml.annotation.Xml
import kotlinx.parcelize.Parcelize

/**
* Created by Nico Brandenberger on 02.07.2025
*/

@Parcelize
@Xml(name = "ContinuousServiceTypeChoice")
data class ContinuousServiceTypeChoiceDto(
@Element(name = "PersonalService")
val personalService: PersonalServiceDto?,
@Element(name = "DatedJourney")
val datedJourneyDto: DatedJourneyDto?
) : Parcelable

@Parcelize
@Xml(name = "PersonalService")
data class PersonalServiceDto(
@Element(name = "PersonalMode")
val personalMode: String,
) : Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ch.opentransportdata.ojp.data.dto.response.tir.leg

import android.os.Parcelable
import ch.opentransportdata.ojp.domain.model.FareClass
import ch.opentransportdata.ojp.domain.model.OccupancyLevel
import com.tickaroo.tikxml.annotation.PropertyElement
import com.tickaroo.tikxml.annotation.Xml
import kotlinx.parcelize.Parcelize

/**
* Created by Deniz Kalem on 25.06.2025
*/
@Parcelize
@Xml(name = "siri:ExpectedDepartureOccupancy")
data class ExpectedDepartureOccupancyDto(
@PropertyElement(name = "siri:FareClass")
val fareClass: FareClass,
@PropertyElement(name = "siri:OccupancyLevel")
val occupancyLevel: OccupancyLevel
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlinx.parcelize.Parcelize
* Created by Michael Ruppen on 28.06.2024
*/
@Parcelize
@Xml(name = "LegBoard")
@Xml(name = "LegAlight")
data class LegAlightDto(
@PropertyElement(name = "siri:StopPointRef")
val stopPointRef: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ data class LegBoardDto(
val noBoardingAtStop: Boolean?,
@PropertyElement(name = "NoAlightingAtStop")
val noAlightingAtStop: Boolean?,
@Element(name = "siri:ExpectedDepartureOccupancy")
val expectedDepartureOccupancy: List<ExpectedDepartureOccupancyDto>? = null
) : Parcelable {

val isPlatformChanged: Boolean
Expand All @@ -64,6 +66,7 @@ fun LegBoardDto.minimalCopy(): LegBoardDto {
notServicedStop = null,
noBoardingAtStop = null,
noAlightingAtStop = null,
expectedDepartureOccupancy = emptyList()
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import kotlinx.parcelize.Parcelize
* Created by Michael Ruppen on 28.06.2024
*/
@Parcelize
@Xml(name = "LegBoard")
@Xml(name = "LegIntermediate")
data class LegIntermediateDto(
@PropertyElement(name = "siri:StopPointRef")
val stopPointRef: String,
Expand Down Expand Up @@ -40,6 +40,8 @@ data class LegIntermediateDto(
val noBoardingAtStop: Boolean?,
@PropertyElement(name = "NoAlightingAtStop")
val noAlightingAtStop: Boolean?,
@Element(name = "siri:ExpectedDepartureOccupancy")
val expectedDepartureOccupancy: List<ExpectedDepartureOccupancyDto>? = null
) : Parcelable {

val isPlatformChanged: Boolean
Expand Down Expand Up @@ -70,7 +72,8 @@ fun LegIntermediateDto.minimalCopy(): LegIntermediateDto {
unplannedStop = null,
notServicedStop = null,
noBoardingAtStop = null,
noAlightingAtStop = null
noAlightingAtStop = null,
expectedDepartureOccupancy = emptyList()
)
}

Expand Down
22 changes: 20 additions & 2 deletions sdk/src/main/java/ch/opentransportdata/ojp/di/NetworkModule.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
package ch.opentransportdata.ojp.di

import ch.opentransportdata.ojp.BuildConfig
import ch.opentransportdata.ojp.data.dto.converter.*
import ch.opentransportdata.ojp.data.dto.converter.ConventionalModesOfOperationConverter
import ch.opentransportdata.ojp.data.dto.converter.DurationTypeConverter
import ch.opentransportdata.ojp.data.dto.converter.FareClassConverter
import ch.opentransportdata.ojp.data.dto.converter.LocalDateTimeTypeConverter
import ch.opentransportdata.ojp.data.dto.converter.OccupancyLevelConverter
import ch.opentransportdata.ojp.data.dto.converter.PlaceTypeRestrictionConverter
import ch.opentransportdata.ojp.data.dto.converter.PtModeTypeConverter
import ch.opentransportdata.ojp.data.dto.converter.RealTimeDataConverter
import ch.opentransportdata.ojp.data.dto.converter.ScopeTypeConverter
import ch.opentransportdata.ojp.data.dto.converter.TransferTypeConverter
import ch.opentransportdata.ojp.data.remote.OjpService
import ch.opentransportdata.ojp.di.interceptor.TokenInterceptor
import ch.opentransportdata.ojp.domain.model.*
import ch.opentransportdata.ojp.domain.model.ConventionalModesOfOperation
import ch.opentransportdata.ojp.domain.model.FareClass
import ch.opentransportdata.ojp.domain.model.OccupancyLevel
import ch.opentransportdata.ojp.domain.model.PlaceTypeRestriction
import ch.opentransportdata.ojp.domain.model.PtMode
import ch.opentransportdata.ojp.domain.model.RealtimeData
import ch.opentransportdata.ojp.domain.model.ScopeType
import ch.opentransportdata.ojp.domain.model.TransferType
import ch.opentransportdata.ojp.domain.usecase.Initializer
import com.tickaroo.tikxml.TikXml
import com.tickaroo.tikxml.converter.htmlescape.HtmlEscapeStringConverter
Expand Down Expand Up @@ -69,6 +85,8 @@ internal fun provideTikXml(initializer: Initializer): TikXml {
.addTypeConverter(ConventionalModesOfOperation::class.java, ConventionalModesOfOperationConverter())
.addTypeConverter(RealtimeData::class.java, RealTimeDataConverter())
.addTypeConverter(ScopeType::class.java, ScopeTypeConverter())
.addTypeConverter(FareClass::class.java, FareClassConverter())
.addTypeConverter(OccupancyLevel::class.java, OccupancyLevelConverter())
.exceptionOnUnreadXml(false)
.build()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ch.opentransportdata.ojp.domain.model

/**
* Created by Deniz Kalem on 25.06.2025
*/
enum class FareClass {
UNKNOWN,
FIRST_CLASS,
SECOND_CLASS
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ch.opentransportdata.ojp.domain.model

/**
* Created by Deniz Kalem on 25.06.2025
*/
enum class OccupancyLevel {
UNKNOWN,
EMPTY,
UNDEFINED,
MANY_SEATS_AVAILABLE,
FEW_SEATS_AVAILABLE,
STANDING_ROOM_ONLY,
CRUSHED_STANDING_ROOM_ONLY,
NOT_ACCEPTING_PASSENGERS,
FULL
}
4 changes: 2 additions & 2 deletions sdk/src/test/resources/adapter/place/stop_place.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Place>
<StopPlace>
<StopPlaceRef>8501120</StopPlaceRef>
<StopPlaceName>
<Name>
<Text xml:lang="de">Lausanne</Text>
</StopPlaceName>
</Name>
<PrivateCode>
<System>EFA</System>
<Value>107099</Value>
Expand Down
Loading