Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/data/gtfs/StaticGtfsDao.kt
Show All 19 Lines | |||||
import androidx.lifecycle.LiveData | import androidx.lifecycle.LiveData | ||||
import androidx.room.* | import androidx.room.* | ||||
@Dao | @Dao | ||||
interface StaticGtfsDao { | interface StaticGtfsDao { | ||||
@Query("SELECT * FROM "+GtfsRoute.DB_TABLE+" ORDER BY "+GtfsRoute.COL_SORT_ORDER) | @Query("SELECT * FROM "+GtfsRoute.DB_TABLE+" ORDER BY "+GtfsRoute.COL_SORT_ORDER) | ||||
fun getAllRoutes() : LiveData<List<GtfsRoute>> | fun getAllRoutes() : LiveData<List<GtfsRoute>> | ||||
@Query("SELECT "+GtfsTrip.COL_TRIP_ID+" FROM "+GtfsTrip.DB_TABLE) | |||||
fun getAllTripsIDs() : List<String> | |||||
@Query("SELECT "+GtfsStop.COL_STOP_ID+" FROM "+GtfsStop.DB_TABLE) | |||||
fun getAllStopsIDs() : List<Int> | |||||
@Query("SELECT * FROM "+GtfsStop.DB_TABLE+" WHERE "+GtfsStop.COL_STOP_CODE+" LIKE :queryID") | @Query("SELECT * FROM "+GtfsStop.DB_TABLE+" WHERE "+GtfsStop.COL_STOP_CODE+" LIKE :queryID") | ||||
fun getStopByStopID(queryID: String): LiveData<List<GtfsStop>> | fun getStopByStopID(queryID: String): LiveData<List<GtfsStop>> | ||||
@Query("SELECT * FROM "+GtfsShape.DB_TABLE+ | @Query("SELECT * FROM "+GtfsShape.DB_TABLE+ | ||||
" WHERE "+GtfsShape.COL_SHAPE_ID+" LIKE :shapeID"+ | " WHERE "+GtfsShape.COL_SHAPE_ID+" LIKE :shapeID"+ | ||||
" ORDER BY "+GtfsShape.COL_POINT_SEQ+ " ASC" | " ORDER BY "+GtfsShape.COL_POINT_SEQ+ " ASC" | ||||
) | ) | ||||
fun getShapeByID(shapeID: String) : LiveData<List<GtfsShape>> | fun getShapeByID(shapeID: String) : LiveData<List<GtfsShape>> | ||||
@Transaction | @Transaction | ||||
fun clearAndInsertRoutes(routes: List<GtfsRoute>){ | fun clearAndInsertRoutes(routes: List<GtfsRoute>){ | ||||
deleteAllRoutes() | deleteAllRoutes() | ||||
insertRoutes(routes) | insertRoutes(routes) | ||||
} | } | ||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | @Insert(onConflict = OnConflictStrategy.REPLACE) | ||||
fun insertRoutes(users: List<GtfsRoute>) | fun insertRoutes(users: List<GtfsRoute>) | ||||
@Insert | @Insert(onConflict = OnConflictStrategy.REPLACE) | ||||
fun insertStops(stops: List<GtfsStop>) | fun insertStops(stops: List<GtfsStop>) | ||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | @Insert(onConflict = OnConflictStrategy.REPLACE) | ||||
fun insertCalendarServices(services: List<GtfsService>) | fun insertCalendarServices(services: List<GtfsService>) | ||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | @Insert(onConflict = OnConflictStrategy.REPLACE) | ||||
fun insertShapes(shapes: List<GtfsShape>) | fun insertShapes(shapes: List<GtfsShape>) | ||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | @Insert(onConflict = OnConflictStrategy.REPLACE) | ||||
Show All 11 Lines | interface StaticGtfsDao { | ||||
@Query("DELETE FROM "+GtfsRoute.DB_TABLE) | @Query("DELETE FROM "+GtfsRoute.DB_TABLE) | ||||
fun deleteAllRoutes() | fun deleteAllRoutes() | ||||
@Query("DELETE FROM "+GtfsStop.DB_TABLE) | @Query("DELETE FROM "+GtfsStop.DB_TABLE) | ||||
fun deleteAllStops() | fun deleteAllStops() | ||||
@Update(onConflict = OnConflictStrategy.REPLACE) | @Update(onConflict = OnConflictStrategy.REPLACE) | ||||
fun updateShapes(shapes: List<GtfsShape>) : Int | fun updateShapes(shapes: List<GtfsShape>) : Int | ||||
@Transaction | @Transaction | ||||
fun updateStops(stops: List<GtfsStop>){ | fun updateAllStops(stops: List<GtfsStop>){ | ||||
deleteAllStops() | deleteAllStops() | ||||
insertStops(stops) | insertStops(stops) | ||||
} | } | ||||
} | } | ||||
No newline at end of file | 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