commit 09/02/2026

This commit is contained in:
2026-02-10 17:05:39 +07:00
parent e18976ace3
commit 546f2e27af
24 changed files with 1205 additions and 384 deletions

View File

@@ -236,4 +236,26 @@ class Table_Messagebank(connection: Connection) : dbFunctions<Messagebank>("mess
.map { it.ANN_ID }
.sorted()
}
// valid messagedetail is message_name [ann_id]
// so we need regex to check if messagedetail matches that format
private val messageDetailRegex = """^(.*?)\s*\[(\d+)]$""".toRegex()
/**
* Check if a messagebank entry exists based on messagedetail and languages
* @param messagedetail the messagedetail in format "message_name [ann_id]"
* @param languages a comma or semicolon separated string of languages to check
* @return true if the messagebank entry exists for all specified languages, false otherwise
*/
fun Messagebank_Exists(messagedetail: String, languages: String) : Boolean{
val match = messageDetailRegex.find(messagedetail)
val ll = languages.split(",",";").map { it.trim() }
if (match != null){
val msg = match.groupValues[1].trim()
val annid = match.groupValues[2].toUIntOrNull() ?: return false // kalau bukan number, return false
val ff = List.filter{ it.ANN_ID == annid && it.Description == msg }
return ll.all{ lang -> ff.any{ it.Language.equals(lang, ignoreCase = true) } }
}
return false
}
}