Changeset View
Changeset View
Standalone View
Standalone View
src/it/reyboz/bustorino/data/gtfs/GtfsDBDao.kt
- This file was moved from src/it/reyboz/bustorino/data/gtfs/StaticGtfsDao.kt.
Show All 15 Lines | BusTO - Data components | ||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
package it.reyboz.bustorino.data.gtfs | package it.reyboz.bustorino.data.gtfs | ||||
import androidx.lifecycle.LiveData | import androidx.lifecycle.LiveData | ||||
import androidx.room.* | import androidx.room.* | ||||
@Dao | @Dao | ||||
interface StaticGtfsDao { | interface GtfsDBDao { | ||||
@Query("SELECT * FROM "+GtfsRoute.DB_TABLE+" ORDER BY "+GtfsRoute.COL_SORT_ORDER) | @Query("SELECT * FROM "+GtfsRoute.DB_TABLE) | ||||
fun getAllRoutes() : LiveData<List<GtfsRoute>> | fun getAllRoutes() : LiveData<List<GtfsRoute>> | ||||
@Query("SELECT "+GtfsTrip.COL_TRIP_ID+" FROM "+GtfsTrip.DB_TABLE) | @Query("SELECT "+GtfsTrip.COL_TRIP_ID+" FROM "+GtfsTrip.DB_TABLE) | ||||
fun getAllTripsIDs() : List<String> | fun getAllTripsIDs() : List<String> | ||||
@Query("SELECT "+GtfsStop.COL_STOP_ID+" FROM "+GtfsStop.DB_TABLE) | @Query("SELECT "+GtfsStop.COL_STOP_ID+" FROM "+GtfsStop.DB_TABLE) | ||||
fun getAllStopsIDs() : List<Int> | 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) | ||||
} | } | ||||
@Transaction | |||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | @Insert(onConflict = OnConflictStrategy.REPLACE) | ||||
fun insertRoutes(users: List<GtfsRoute>) | fun insertRoutes(routes: List<GtfsRoute>) | ||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | @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>) | ||||
Show All 23 Lines | fun updateAllStops(stops: List<GtfsStop>){ | ||||
deleteAllStops() | deleteAllStops() | ||||
insertStops(stops) | insertStops(stops) | ||||
} | } | ||||
@Query("DELETE FROM "+GtfsStopTime.DB_TABLE) | @Query("DELETE FROM "+GtfsStopTime.DB_TABLE) | ||||
fun deleteAllStopTimes() | fun deleteAllStopTimes() | ||||
@Query("DELETE FROM "+GtfsService.DB_TABLE) | @Query("DELETE FROM "+GtfsService.DB_TABLE) | ||||
fun deleteAllServices() | fun deleteAllServices() | ||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | |||||
fun insertFeeds(feeds: List<GtfsFeed>) | |||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | |||||
fun insertAgencies(agencies: List<GtfsAgency>) | |||||
@Transaction | |||||
fun insertAgenciesWithFeeds(feeds: List<GtfsFeed>, agencies: List<GtfsAgency>){ | |||||
insertFeeds(feeds) | |||||
insertAgencies(agencies) | |||||
} | |||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | |||||
fun insertPatterns(patterns: List<MatoPattern>) | |||||
@Insert(onConflict = OnConflictStrategy.REPLACE) | |||||
fun insertPatternStops(patternStops: List<PatternStop>) | |||||
} | } | ||||
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