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
3 changes: 3 additions & 0 deletions src/main/java/org/mtransit/commons/FeatureFlags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ object FeatureFlags {
const val F_EXPORT_SERVICE_ID_INTS = false
// const val F_EXPORT_SERVICE_ID_INTS = true // WIP

const val F_EXPORT_STRINGS = false
// const val F_EXPORT_STRINGS = true // WIP

// @formatter:on
}
43 changes: 43 additions & 0 deletions src/main/java/org/mtransit/commons/GTFSCommons.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ object GTFSCommons {
const val T_ROUTE_K_ORIGINAL_ID_HASH = "o_id_hash"
const val T_ROUTE_K_TYPE = "type"

@JvmField
val T_ROUTE_STRINGS_COLUMN_IDX = intArrayOf(1, 2)

@JvmStatic
val T_ROUTE_SQL_CREATE = SQLCreateBuilder.getNew(T_ROUTE).apply {
appendColumn(T_ROUTE_K_ID, SQLUtils.INT_PK)
Expand Down Expand Up @@ -57,14 +60,21 @@ object GTFSCommons {
const val T_DIRECTION_K_HEADSIGN_VALUE = "headsign_value" // really?
const val T_DIRECTION_K_ROUTE_ID = "route_id"

@JvmField
val T_DIRECTION_STRINGS_COLUMN_IDX = intArrayOf(2)

@Deprecated("use T_DIRECTION instead", ReplaceWith("T_DIRECTION"))
const val T_TRIP = T_DIRECTION

@Deprecated("use T_DIRECTION_K_ID instead", ReplaceWith("T_DIRECTION_K_ID"))
const val T_TRIP_K_ID = T_DIRECTION_K_ID

@Deprecated("use T_DIRECTION_K_HEADSIGN_TYPE instead", ReplaceWith("T_DIRECTION_K_HEADSIGN_TYPE"))
const val T_TRIP_K_HEADSIGN_TYPE = T_DIRECTION_K_HEADSIGN_TYPE

@Deprecated("use T_DIRECTION_K_HEADSIGN_VALUE instead", ReplaceWith("T_DIRECTION_K_HEADSIGN_VALUE"))
const val T_TRIP_K_HEADSIGN_VALUE = T_DIRECTION_K_HEADSIGN_VALUE

@Deprecated("use T_DIRECTION_K_ROUTE_ID instead", ReplaceWith("T_DIRECTION_K_ROUTE_ID"))
const val T_TRIP_K_ROUTE_ID = T_DIRECTION_K_ROUTE_ID

Expand Down Expand Up @@ -113,6 +123,9 @@ object GTFSCommons {
const val T_STOP_K_ACCESSIBLE = "a11y"
const val T_STOP_K_ORIGINAL_ID_HASH = "o_id_hash"

@JvmField
val T_STOP_STRINGS_COLUMN_IDX = intArrayOf(2)

@JvmStatic
val T_STOP_SQL_CREATE = SQLCreateBuilder.getNew(T_STOP).apply {
appendColumn(T_STOP_K_ID, SQLUtils.INT_PK)
Expand Down Expand Up @@ -151,14 +164,19 @@ object GTFSCommons {

@Deprecated("use T_DIRECTION_STOPS instead", ReplaceWith("T_DIRECTION_STOPS"))
const val T_TRIP_STOPS = T_DIRECTION_STOPS

@Deprecated("use T_DIRECTION_STOPS_K_ID instead", ReplaceWith("T_DIRECTION_STOPS_K_ID"))
const val T_TRIP_STOPS_K_ID = T_DIRECTION_STOPS_K_ID

@Deprecated("use T_DIRECTION_STOPS_K_DIRECTION_ID instead", ReplaceWith("T_DIRECTION_STOPS_K_DIRECTION_ID"))
const val T_TRIP_STOPS_K_TRIP_ID = T_DIRECTION_STOPS_K_DIRECTION_ID

@Deprecated("use T_DIRECTION_STOPS_K_STOP_ID instead", ReplaceWith("T_DIRECTION_STOPS_K_STOP_ID"))
const val T_TRIP_STOPS_K_STOP_ID = T_DIRECTION_STOPS_K_STOP_ID

@Deprecated("use T_DIRECTION_STOPS_K_STOP_SEQUENCE instead", ReplaceWith("T_DIRECTION_STOPS_K_STOP_SEQUENCE"))
const val T_TRIP_STOPS_K_STOP_SEQUENCE = T_DIRECTION_STOPS_K_STOP_SEQUENCE

@Deprecated("use T_DIRECTION_STOPS_K_NO_PICKUP instead", ReplaceWith("T_DIRECTION_STOPS_K_NO_PICKUP"))
const val T_TRIP_STOPS_K_NO_PICKUP = T_DIRECTION_STOPS_K_NO_PICKUP

Expand Down Expand Up @@ -264,6 +282,31 @@ object GTFSCommons {

// endregion Service Dates

// region Strings

const val STRINGS_SEPARATOR = " "

const val T_STRINGS = "strings"
const val T_STRINGS_K_ID = SQLUtils.BASE_COLUMNS_ID
const val T_STRINGS_K_STRING = "string"

@JvmStatic
val T_STRINGS_SQL_CREATE = SQLCreateBuilder.getNew(T_STRINGS).apply {
appendColumn(T_STRINGS_K_ID, SQLUtils.INT_PK_AUTO) // SQLite will determine next ID based on largest value in table, even after manual insert w/ custom ID value
appendColumn(T_STRINGS_K_STRING, SQLUtils.TXT, unique = true)
}.build()

@JvmStatic
val T_STRINGS_SQL_INSERT = SQLInsertBuilder.getNew(T_STRINGS).apply {
appendColumn(T_STRINGS_K_ID) // need to insert known string IDS+Int (Foreign Key used in other tables)
appendColumn(T_STRINGS_K_STRING)
}.build()

@JvmStatic
val T_STRINGS_SQL_DROP = SQLUtils.getSQLDropIfExistsQuery(T_STRINGS)

// endregion Strings

@JvmField
val DEFAULT_ID_HASH: Int? = null

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/mtransit/commons/sql/SQLUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,12 @@ object SQLUtils {
append(P2)
}

@JvmName("unquotesUnescapeExt")
fun String.unquotesUnescape() = unquotes(this).unescape()

@JvmName("unescapeExt")
fun String.unescape() = unescapeString(this)

@JvmStatic
fun escapeString(string: String): String {
return STRING_DELIMITER + string + STRING_DELIMITER
Expand Down