commit 09/10/2025
User Management belum kelar
This commit is contained in:
@@ -29,7 +29,7 @@ lateinit var audioPlayer: AudioPlayer
|
||||
val StreamerOutputs: MutableMap<String, BarixConnection> = HashMap()
|
||||
lateinit var udpreceiver: UDPReceiver
|
||||
lateinit var tcpreceiver: TCPReceiver
|
||||
const val version = "0.0.2 (23/09/2025)"
|
||||
const val version = "0.0.4 (09/10/2025)"
|
||||
// AAS 64 channels
|
||||
const val max_channel = 64
|
||||
|
||||
|
||||
@@ -286,6 +286,23 @@ class Somecodes {
|
||||
return value is String && value.isNotBlank()
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if all strings in a list are valid non-blank strings.
|
||||
* @param values The list of strings to check.
|
||||
* @return True if all strings in the list are valid non-blank strings, false otherwise.
|
||||
*/
|
||||
fun ValidStrings(values: List<String>) : Boolean{
|
||||
if (values.isNotEmpty()){
|
||||
for (v in values){
|
||||
if (!ValidString(v)){
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a string is a valid file path and the file exists.
|
||||
* @param value The string to check.
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.tinylog.Logger
|
||||
import java.sql.Connection
|
||||
import java.sql.DriverManager
|
||||
import java.util.function.Consumer
|
||||
import kotlin.math.max
|
||||
|
||||
/**
|
||||
* A class to manage a connection to a MariaDB database.
|
||||
@@ -1949,9 +1948,9 @@ class MariaDB(
|
||||
val statement = connection.createStatement()
|
||||
// use a temporary table to reorder the index
|
||||
statement?.executeUpdate("CREATE TABLE IF NOT EXISTS temp_${super.dbName} LIKE ${super.dbName}")
|
||||
statement?.executeUpdate("INSERT INTO temp_${super.dbName} (username, password, location, soundbank_tags, messagebank_ann_id, broadcastzones) SELECT username, password, location, soundbank_tags, messagebank_ann_id, broadcastzones FROM ${super.dbName} ORDER BY username ")
|
||||
statement?.executeUpdate("INSERT INTO temp_${super.dbName} (username, password, location, airline_tags, city_tags, messagebank_ann_id, broadcastzones) SELECT username, password, location, airline_tags, city_tags, messagebank_ann_id, broadcastzones FROM ${super.dbName} ORDER BY username ")
|
||||
statement?.executeUpdate("TRUNCATE TABLE ${super.dbName}")
|
||||
statement?.executeUpdate("INSERT INTO ${super.dbName} (username, password, location, soundbank_tags, messagebank_ann_id, broadcastzones) SELECT username, password, location, soundbank_tags, messagebank_ann_id, broadcastzones FROM temp_${super.dbName}")
|
||||
statement?.executeUpdate("INSERT INTO ${super.dbName} (username, password, location, airline_tags, city_tags, messagebank_ann_id, broadcastzones) SELECT username, password, location, airline_tags, city_tags, messagebank_ann_id, broadcastzones FROM temp_${super.dbName}")
|
||||
statement?.executeUpdate("DROP TABLE temp_${super.dbName}")
|
||||
Logger.info("${super.dbName} table resorted by index" as Any)
|
||||
// reload the local list
|
||||
@@ -2254,24 +2253,21 @@ class MariaDB(
|
||||
* @return a list of Soundbank with Category City and matching tag
|
||||
*/
|
||||
fun Find_Soundbank_City(tag: String) : List<Soundbank>{
|
||||
val lowerTag = tag.lowercase()
|
||||
return soundDB.List
|
||||
.filter{ it.Category== Category.City.name }
|
||||
.filter { it.TAG.lowercase()==lowerTag}
|
||||
.filter { it.TAG.equals(tag,true)}
|
||||
}
|
||||
|
||||
fun Find_Soundbank_AirplaneName(tag: String) : List<Soundbank>{
|
||||
val lowerTag = tag.lowercase()
|
||||
return soundDB.List
|
||||
.filter{ it.Category== Category.Airplane_Name.name }
|
||||
.filter { it.TAG.lowercase()==lowerTag}
|
||||
.filter { it.TAG.equals(tag,true)}
|
||||
}
|
||||
|
||||
fun Find_Soundbank_Places(tag: String) : List<Soundbank>{
|
||||
val lowerTag = tag.lowercase()
|
||||
return soundDB.List
|
||||
.filter{ it.Category== Category.Places.name }
|
||||
.filter { it.TAG.lowercase()==lowerTag}
|
||||
.filter { it.TAG.equals(tag,true)}
|
||||
}
|
||||
|
||||
fun Find_Soundbank_Shalat(tag: String) : List<Soundbank>{
|
||||
@@ -2282,25 +2278,74 @@ class MariaDB(
|
||||
}
|
||||
|
||||
fun Find_Soundbank_Sequence(tag: String) : List<Soundbank>{
|
||||
val lowerTag = tag.lowercase()
|
||||
|
||||
return soundDB.List
|
||||
.filter{ it.Category== Category.Sequence.name }
|
||||
.filter { it.TAG.lowercase()==lowerTag}
|
||||
.filter { it.TAG.equals(tag,true)}
|
||||
}
|
||||
|
||||
fun Find_Soundbank_Reason(tag: String) : List<Soundbank>{
|
||||
val lowerTag = tag.lowercase()
|
||||
return soundDB.List
|
||||
.filter{ it.Category== Category.Reason.name }
|
||||
.filter { it.TAG.lowercase()==lowerTag}
|
||||
.filter { it.TAG.equals(tag,true)}
|
||||
}
|
||||
|
||||
fun Find_Soundbank_Procedure(tag: String) : List<Soundbank> {
|
||||
val lowerTag = tag.lowercase()
|
||||
return soundDB.List
|
||||
.filter { it.Category == Category.Procedure.name }
|
||||
.filter { it.TAG.lowercase() == lowerTag }
|
||||
.filter { it.TAG.equals(tag,true) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all distinct airline code tags from soundbank
|
||||
* @return a list of distinct airline code tags sorted alphabetically
|
||||
*/
|
||||
fun Get_AirlineCode_Tags(): List<String> {
|
||||
return soundDB.List
|
||||
.filter { it.Category == Category.Airline_Code.name }
|
||||
.map { it.TAG }
|
||||
.distinct()
|
||||
.sorted()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all distinct city tags from soundbank
|
||||
* @return a list of distinct city tags sorted alphabetically
|
||||
*/
|
||||
fun Get_City_Tags(): List<String> {
|
||||
return soundDB.List
|
||||
.filter { it.Category == Category.City.name }
|
||||
.map { it.TAG }
|
||||
.distinct()
|
||||
.sorted()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all distinct message ID from messagebank
|
||||
* @return a list of distinct ANN_ID sorted numerically
|
||||
*/
|
||||
fun Get_MessageID_List(): List<UInt> {
|
||||
return messageDB.List
|
||||
.distinctBy { it.ANN_ID }
|
||||
.map { it.ANN_ID }
|
||||
.sorted()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all distinct broadcast zone descriptions from broadcastDB
|
||||
* @return a list of distinct broadcast zone descriptions sorted alphabetically
|
||||
*/
|
||||
fun Get_BroadcastZone_List(): List<String> {
|
||||
return broadcastDB.List
|
||||
.distinctBy { it.description }
|
||||
.map { it.description }
|
||||
.sorted()
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a username already exists in the userDB (case-insensitive)
|
||||
*/
|
||||
fun Username_exists(username: String): Boolean {
|
||||
return userDB.List.any { it.username.equals(username, ignoreCase = true) }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,22 @@ data class UserDB(var index: UInt, var username: String, var password: String, v
|
||||
override fun toString(): String {
|
||||
return "UserDB(index=$index, username='$username', location='$location', airline_tags='$airline_tags', city_tags='$city_tags', messagebank_ann_id='$messagebank_ann_id', broadcastzones='$broadcastzones')"
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this UserDB object with another UserDB object for equality.
|
||||
* Two UserDB objects are considered equal if all their properties are equal, except for the index property.
|
||||
*/
|
||||
fun isEqual(other: UserDB?): Boolean {
|
||||
if (other == null) return false
|
||||
return this.username == other.username &&
|
||||
this.password == other.password &&
|
||||
this.location == other.location &&
|
||||
this.airline_tags == other.airline_tags &&
|
||||
this.city_tags == other.city_tags &&
|
||||
this.messagebank_ann_id == other.messagebank_ann_id &&
|
||||
this.broadcastzones == other.broadcastzones
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
4
src/web/KeyValueMessage.kt
Normal file
4
src/web/KeyValueMessage.kt
Normal file
@@ -0,0 +1,4 @@
|
||||
package web
|
||||
|
||||
class KeyValueMessage(val key: String, val value: String) {
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user