Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/data/gtfs/GtfsRoute.kt
Show All 17 Lines | |||||
package it.reyboz.bustorino.data.gtfs | package it.reyboz.bustorino.data.gtfs | ||||
import androidx.room.ColumnInfo | import androidx.room.ColumnInfo | ||||
import androidx.room.Entity | import androidx.room.Entity | ||||
import androidx.room.PrimaryKey | import androidx.room.PrimaryKey | ||||
@Entity(tableName=GtfsRoute.DB_TABLE) | @Entity(tableName=GtfsRoute.DB_TABLE) | ||||
data class GtfsRoute( | data class GtfsRoute( | ||||
@PrimaryKey @ColumnInfo(name = COL_ROUTE_ID) | @PrimaryKey @ColumnInfo(name = COL_ROUTE_ID) | ||||
val ID: String, | val gtfsId: String, | ||||
@ColumnInfo(name = "agency_id") | @ColumnInfo(name = "agency_id") | ||||
val agencyID: String, | val agencyID: String, | ||||
@ColumnInfo(name = "route_short_name") | @ColumnInfo(name = "route_short_name") | ||||
val shortName: String, | val shortName: String, | ||||
@ColumnInfo(name = "route_long_name") | @ColumnInfo(name = "route_long_name") | ||||
val longName: String, | val longName: String, | ||||
@ColumnInfo(name = "route_desc") | @ColumnInfo(name = "route_desc") | ||||
val description: String, | val description: String, | ||||
@ColumnInfo(name ="route_type") | @ColumnInfo(name = COL_MODE) | ||||
val type: String, | val mode: GtfsMode, | ||||
//@ColumnInfo(name ="route_url") | //@ColumnInfo(name ="route_url") | ||||
//val url: String, | //val url: String, | ||||
@ColumnInfo(name ="route_color") | @ColumnInfo(name = COL_COLOR) | ||||
val color: String, | val color: String, | ||||
@ColumnInfo(name ="route_text_color") | @ColumnInfo(name = COL_TEXT_COLOR) | ||||
val textColor: String, | val textColor: String, | ||||
@ColumnInfo(name = COL_SORT_ORDER) | |||||
val sortOrder: Int | |||||
): GtfsTable { | ): GtfsTable { | ||||
constructor(valuesByColumn: Map<String,String>) : this( | constructor(valuesByColumn: Map<String,String>) : this( | ||||
valuesByColumn[COL_ROUTE_ID]!!, | valuesByColumn[COL_ROUTE_ID]!!, | ||||
valuesByColumn["agency_id"]!!, | valuesByColumn["agency_id"]!!, | ||||
valuesByColumn["route_short_name"]!!, | valuesByColumn["route_short_name"]!!, | ||||
valuesByColumn["route_long_name"]!!, | valuesByColumn["route_long_name"]!!, | ||||
valuesByColumn["route_desc"]!!, | valuesByColumn["route_desc"]!!, | ||||
valuesByColumn["route_type"]!!, | valuesByColumn["route_type"]?.toInt()?.let { GtfsMode.getByValue(it) }!!, | ||||
valuesByColumn["route_color"]!!, | valuesByColumn[COL_COLOR]!!, | ||||
valuesByColumn["route_text_color"]!!, | valuesByColumn[COL_TEXT_COLOR]!!, | ||||
valuesByColumn[COL_SORT_ORDER]?.toInt()!! | |||||
) | ) | ||||
companion object { | companion object { | ||||
const val DB_TABLE: String="routes_table" | const val DB_TABLE: String="routes_table" | ||||
const val COL_SORT_ORDER: String="route_sort_order" | const val COL_SORT_ORDER: String="route_sort_order" | ||||
const val COL_ROUTE_ID = "route_id" | const val COL_ROUTE_ID = "route_id" | ||||
const val COL_MODE ="route_mode" | |||||
const val COL_COLOR="route_color" | |||||
const val COL_TEXT_COLOR="route_text_color" | |||||
val COLUMNS = arrayOf(COL_ROUTE_ID, | val COLUMNS = arrayOf(COL_ROUTE_ID, | ||||
"agency_id", | "agency_id", | ||||
"route_short_name", | "route_short_name", | ||||
"route_long_name", | "route_long_name", | ||||
"route_desc", | "route_desc", | ||||
"route_type", | "route_type", | ||||
"route_color", | "route_color", | ||||
"route_text_color", | "route_text_color", | ||||
COL_SORT_ORDER | COL_SORT_ORDER | ||||
) | ) | ||||
//const val CREATE_SQL = "" | |||||
} | } | ||||
override fun getColumns(): Array<String> { | override fun getColumns(): Array<String> { | ||||
return COLUMNS | return COLUMNS | ||||
} | } | ||||
} | } |
Public contents are in Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) or GNU Free Documentation License (at your option) unless otherwise noted. · Contact / Register