Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/data/gtfs/StaticGtfsDao.kt
- This file was added.
package it.reyboz.bustorino.data.gtfs | |||||
import androidx.lifecycle.LiveData | |||||
import androidx.room.* | |||||
@Dao | |||||
interface StaticGtfsDao { | |||||
@Query("SELECT * FROM "+GtfsRoute.DB_TABLE+" ORDER BY "+GtfsRoute.SORT_ORDER) | |||||
fun getAllRoutes() : LiveData<List<GtfsRoute>> | |||||
@Query("SELECT * FROM "+GtfsStop.DB_TABLE+" WHERE "+GtfsStop.COL_STOP_CODE+" LIKE :queryID") | |||||
fun getStopByStopID(queryID: String): LiveData<List<GtfsStop>> | |||||
@Query("SELECT * FROM "+GtfsShape.DB_TABLE+ | |||||
" WHERE "+GtfsShape.COL_SHAPEID+" LIKE :shapeID"+ | |||||
" ORDER BY "+GtfsShape.COL_POINT_SEQ+ " ASC" | |||||
) | |||||
fun getShapeByID(shapeID: String) : LiveData<List<GtfsShape>> | |||||
@Transaction | |||||
open fun clearAndInsertRoutes(routes: List<GtfsRoute>){ | |||||
deleteAllRoutes() | |||||
insertRoutes(routes) | |||||
} | |||||
@Insert | |||||
fun insertRoutes(users: List<GtfsRoute>) | |||||
@Insert | |||||
fun insertStops(stops: List<GtfsStop>) | |||||
@Query("DELETE FROM "+GtfsRoute.DB_TABLE) | |||||
fun deleteAllRoutes() | |||||
@Query("DELETE FROM "+GtfsStop.DB_TABLE) | |||||
fun deleteAllStops() | |||||
@Update(onConflict = OnConflictStrategy.REPLACE) | |||||
fun updateShapes(shapes: List<GtfsShape>) : Int | |||||
@Transaction | |||||
fun updateStops(stops: List<GtfsStop>){ | |||||
deleteAllStops() | |||||
insertStops(stops) | |||||
} | |||||
} | |||||
No newline at end of file |
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