commit 11/09/2025

This commit is contained in:
2025-09-11 16:03:33 +07:00
parent 34fc71cfbc
commit b692e2c2c9
8 changed files with 767 additions and 211 deletions

View File

@@ -222,15 +222,15 @@ class MariaDB(
*/
fun GetLogForHtml(date: String, consumer: Consumer<ArrayList<Log>>) {
val logList = ArrayList<Log>()
println("GetLogForHtml Date: $date" )
//println("GetLogForHtml Date: $date" )
if (ValiDateForLogHtml(date)) {
try {
// must convert from DD-MM-YYYY to DD/MM/YYYY, because in database we use DD/MM/YYYY
val adjusteddate = date.replace("-", "/")
val statement = connection?.prepareStatement("SELECT * FROM logs WHERE datenya = ?")
statement?.setString(1, adjusteddate)
println("GetLogForHtml Date: $adjusteddate" )
println("GetLogForHtml SQL: " +statement?.toString())
//println("GetLogForHtml Date: $adjusteddate" )
// println("GetLogForHtml SQL: " +statement?.toString())
val resultSet = statement?.executeQuery()
while (resultSet?.next() == true) {
val log = Log(
@@ -258,7 +258,7 @@ class MariaDB(
*/
fun GetLogForHtml(date: String, filter: String, consumer: Consumer<ArrayList<Log>>) {
val logList = ArrayList<Log>()
println("GetLogForHtml Date: $date Filter: $filter" )
//println("GetLogForHtml Date: $date Filter: $filter" )
if (ValiDateForLogHtml(date)) {
try {
@@ -268,8 +268,8 @@ class MariaDB(
connection?.prepareStatement("SELECT * FROM logs WHERE datenya = ? AND description LIKE ?")
statement?.setString(1, adjusteddate)
statement?.setString(2, "%$filter%")
println("GetLogForHtml Date: $adjusteddate , Filter=$filter" )
println("GetLogForHtml SQL: " +statement?.toString())
//println("GetLogForHtml Date: $adjusteddate , Filter=$filter" )
//println("GetLogForHtml SQL: " +statement?.toString())
val resultSet = statement?.executeQuery()
while (resultSet?.next() == true) {
val log = Log(
@@ -457,6 +457,29 @@ class MariaDB(
return false
}
/**
* Resort the schedulebank table, in order to reorder the index after deletions, and sort ascending by Day and Time.
* @return True if the resorting was successful, false otherwise.
*/
fun Resort_Schedulebank_by_Day_Time(): Boolean {
try {
val statement = connection?.createStatement()
// use a temporary table to reorder the index
statement?.executeUpdate("CREATE TABLE IF NOT EXISTS temp_schedulebank LIKE schedulebank")
statement?.executeUpdate("INSERT INTO temp_schedulebank (Description, Day, Time, Soundpath, Repeat, Enable, BroadcastZones, Language) SELECT Description, Day, Time, Soundpath, Repeat, Enable, BroadcastZones, Language FROM schedulebank ORDER BY Day ASC, Time ASC")
statement?.executeUpdate("TRUNCATE TABLE schedulebank")
statement?.executeUpdate("INSERT INTO schedulebank (Description, Day, Time, Soundpath, Repeat, Enable, BroadcastZones, Language) SELECT Description, Day, Time, Soundpath, Repeat, Enable, BroadcastZones, Language FROM temp_schedulebank")
statement?.executeUpdate("DROP TABLE temp_schedulebank")
Logger.info("schedulebank table resorted by Day and Time" as Any)
// reload the local list
Reload_Schedulebank()
return true
} catch (e: Exception) {
Logger.error("Error resorting schedulebank table by Day and Time: ${e.message}" as Any)
}
return false
}
/**
* Clears all entries from the schedulebank table in the database and the local list.
*/
@@ -695,6 +718,29 @@ class MariaDB(
return false
}
/**
* Resort the language link table, in order to reorder the index after deletions, and sort ascending by TAG.
* @return True if the resorting was successful, false otherwise.
*/
fun Resort_LanguageLink_by_TAG() : Boolean {
try {
val statement = connection?.createStatement()
// use a temporary table to reorder the index
statement?.executeUpdate("CREATE TABLE IF NOT EXISTS temp_languagelinking LIKE languagelinking")
statement?.executeUpdate("INSERT INTO temp_languagelinking (TAG, Language) SELECT TAG, Language FROM languagelinking ORDER BY TAG ASC")
statement?.executeUpdate("TRUNCATE TABLE languagelinking")
statement?.executeUpdate("INSERT INTO languagelinking (TAG, Language) SELECT TAG, Language FROM temp_languagelinking")
statement?.executeUpdate("DROP TABLE temp_languagelinking")
Logger.info("languagelinking table resorted by TAG" as Any)
// reload the local list
Reload_LanguageLink()
return true
} catch (e: Exception) {
Logger.error("Error resorting languagelinking table by TAG: ${e.message}" as Any)
}
return false
}
/**
* Clears all entries from the language link table in the database and the local list.
*/
@@ -945,6 +991,29 @@ class MariaDB(
return false
}
/**
* Resort the soundbank table, in order to reorder the index after deletions, and sort ascending by Description.
* @return True if the resorting was successful, false otherwise.
*/
fun Resort_Soundbank_by_Description(): Boolean {
try {
val statement = connection?.createStatement()
// use a temporary table to reorder the index
statement?.executeUpdate("CREATE TABLE IF NOT EXISTS temp_soundbank LIKE soundbank")
statement?.executeUpdate("INSERT INTO temp_soundbank (Description, TAG, Category, Language, VoiceType, Path) SELECT Description, TAG, Category, Language, VoiceType, Path FROM soundbank ORDER BY Description ASC")
statement?.executeUpdate("TRUNCATE TABLE soundbank")
statement?.executeUpdate("INSERT INTO soundbank (Description, TAG, Category, Language, VoiceType, Path) SELECT Description, TAG, Category, Language, VoiceType, Path FROM temp_soundbank")
statement?.executeUpdate("DROP TABLE temp_soundbank")
Logger.info("soundbank table resorted by Description" as Any)
// reload the local list
Reload_Soundbank()
return true
} catch (e: Exception) {
Logger.error("Error resorting soundbank table by Description: ${e.message}" as Any)
}
return false
}
/**
* Clears all entries from the soundbank table in the database and the local list.
*/
@@ -1173,6 +1242,29 @@ class MariaDB(
return false
}
/**
* Resort the messagebank table, in order to reorder the index after deletions, and sort ascending by ANN_ID.
* @return True if the resorting was successful, false otherwise.
*/
fun Resort_Messagebank_by_ANN_ID(): Boolean {
try {
val statement = connection?.createStatement()
// use a temporary table to reorder the index
statement?.executeUpdate("CREATE TABLE IF NOT EXISTS temp_messagebank LIKE messagebank")
statement?.executeUpdate("INSERT INTO temp_messagebank (Description, Language, ANN_ID, Voice_Type, Message_Detail, Message_TAGS) SELECT Description, Language, ANN_ID, Voice_Type, Message_Detail, Message_TAGS FROM messagebank ORDER BY ANN_ID ASC")
statement?.executeUpdate("TRUNCATE TABLE messagebank")
statement?.executeUpdate("INSERT INTO messagebank (Description, Language, ANN_ID, Voice_Type, Message_Detail, Message_TAGS) SELECT Description, Language, ANN_ID, Voice_Type, Message_Detail, Message_TAGS FROM temp_messagebank")
statement?.executeUpdate("DROP TABLE temp_messagebank")
Logger.info("messagebank table resorted by Description" as Any)
// reload the local list
Reload_Messagebank()
return true
} catch (e: Exception) {
Logger.error("Error resorting messagebank table by Description: ${e.message}" as Any)
}
return false
}
/**
* Exports the messagebank table to an XLSX workbook.
* @return An XSSFWorkbook containing the messagebank data.
@@ -1527,6 +1619,29 @@ class MariaDB(
return false
}
/**
* Resort the broadcast_zones table, in order to reorder the index after deletions, and sort ascending by description.
* @return True if the resorting was successful, false otherwise.
*/
fun Resort_BroadcastZones_by_description(): Boolean {
try {
val statement = connection?.createStatement()
// use a temporary table to reorder the index
statement?.executeUpdate("CREATE TABLE IF NOT EXISTS temp_broadcast_zones LIKE broadcast_zones")
statement?.executeUpdate("INSERT INTO temp_broadcast_zones (description, SoundChannel, Box, Relay) SELECT description, SoundChannel, Box, Relay FROM broadcast_zones ORDER BY description ASC")
statement?.executeUpdate("TRUNCATE TABLE broadcast_zones")
statement?.executeUpdate("INSERT INTO broadcast_zones (description, SoundChannel, Box, Relay) SELECT description, SoundChannel, Box, Relay FROM temp_broadcast_zones")
statement?.executeUpdate("DROP TABLE temp_broadcast_zones")
Logger.info("broadcast_zones table resorted by description" as Any)
// reload the local list
GetBroadcastZones()
return true
} catch (e: Exception) {
Logger.error("Error resorting broadcast_zones table by description: ${e.message}" as Any)
}
return false
}
/**
* Clears all entries from the broadcast_zones in the database.
*/