Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and Update for Compatibility with Exposed 0.54.0 and Kotlin JVM 2.0.0 #639

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
21 changes: 19 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 1.5.8
## What's Changed
* Fix the following issues by @mgrati in [#646](https://github.com/kopiLeft/Galite/pull/646)
* Do not lose database connection when refreshing a galite application navigator tab.
* Minimize the number of actors called by the same keyboard shortcuts.
* Fix the issue of the random crash observed in galite applications when trying to open a list dialog.
* Fix calendar picker component : Force applying the changes added by the date picker component to the galite field model by @sebai-dhia in [#645](https://github.com/kopiLeft/Galite/pull/645)

**Full Changelog**: [1.5.7 ... 1.5.8](https://github.com/kopiLeft/Galite/compare/1.5.7...1.5.8)

# 1.5.7
## What's Changed
* Fix : Implement ImageHandler in Vaadin Flow to fix fatal error when loading an image list and show images on the list by @sebai-dhia in [#642](https://github.com/kopiLeft/Galite/pull/642)
* Fix abnormal behavior of the list button and menu query in the ProductForm by @sebai-dhia in [#644](https://github.com/kopiLeft/Galite/pull/644)

**Full Changelog**: [1.5.6 ... 1.5.7](https://github.com/kopiLeft/Galite/compare/1.5.6...1.5.7)

# 1.5.6
## What's Changed
* Fix : Allow LEFT JOIN for nullable fields with non nullable fields in Galite forms by @mgrati in [#640](https://github.com/kopiLeft/Galite/pull/640)
Expand All @@ -15,10 +32,10 @@

# 1.5.4
## What's Changed
* Feat : Add color picker field to Galite :
* Feat : Add color picker field to Galite :
* Add a new field type "Color" to Galite by @achraf-dridi in [#625](https://github.com/kopiLeft/Galite/pull/625)
* Convert the value type of the color field to an integer instead of blob by @achraf-dridi in [#631](https://github.com/kopiLeft/Galite/pull/631)
* Fix : Fix the found bugs in the module "Factory Generator" of Galite Utils
* Fix : Fix the found bugs in the module "Factory Generator" of Galite Utils
* Fix generated classes in the event when the xsd contains attributes that are named as one of the hard keywords of Kotlin by @achraf-dridi in [#629](https://github.com/kopiLeft/Galite/pull/629)
* Avoid creating the schemaorg_apache_xmlbeans package containing copies of the *.xsd files by @yahiaoui97 [#628](https://github.com/kopiLeft/Galite/pull/628)
* Add toCalendar method in the generated factory classes by @achraf-dridi [#627](https://github.com/kopiLeft/Galite/pull/627)
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.kopi.galite.gradle.configureMavenCentralPom
import org.kopi.galite.gradle.signPublication

plugins {
id("org.jetbrains.kotlin.jvm") version "1.9.0" apply false
id("org.jetbrains.kotlin.jvm") version "2.0.0" apply false
id("maven-publish")
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}
Expand Down Expand Up @@ -82,7 +82,7 @@ allprojects {
pom {
configureMavenCentralPom(project)
}
signPublication(project)
// signPublication(project)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Versions {
const val KARIBU_TESTING = "1.3.23"
const val ENHANCED_DIALOG = "23.1.2"

const val EXPOSED = "0.42.1"
const val EXPOSED = "0.54.0"
const val HIKARI = "5.1.0"
const val H2 = "1.4.199"
const val POSTGRES_NG = "0.8.6"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ public JImage(URL location) {
/**
*
*/
public int getWidth() {
public int getImageWidth() {
return getIconWidth();
}

/**
*
*/
public int getHeight() {
public int getImageHeight() {
return getIconHeight();
}

Expand Down
9 changes: 6 additions & 3 deletions galite-core/src/main/kotlin/org/kopi/galite/visual/Message.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2022 kopiLeft Services SARL, Tunis TN
* Copyright (c) 1990-2022 kopiRight Managed Solutions GmbH, Wien AT
* Copyright (c) 2013-2024 kopiLeft Services SARL, Tunis TN
* Copyright (c) 1990-2024 kopiRight Managed Solutions GmbH, Wien AT
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -62,7 +62,10 @@ object Message {
fun getMessage(source: String = VISUAL_KOPI_MESSAGES_LOCALIZATION_RESOURCE,
ident: String,
params: Any? = null): String {
val params = if (params is Array<*>?) params as Array<Any?>? else arrayOf(params)
val params = when (params) {
is Array<*> -> params.map { it }.toTypedArray() // Convert to Array<Any?>
else -> arrayOf(params)
}

val manager = if (ApplicationContext.isApplicationContextInitialized) {
ApplicationContext.getLocalizationManager()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2022 kopiLeft Services SARL, Tunis TN
* Copyright (c) 1990-2022 kopiRight Managed Solutions GmbH, Wien AT
* Copyright (c) 2013-2024 kopiLeft Services SARL, Tunis TN
* Copyright (c) 1990-2024 kopiRight Managed Solutions GmbH, Wien AT
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -59,7 +59,10 @@ object MessageCode {
@Suppress("UNCHECKED_CAST")
@JvmOverloads
fun getMessage(key: String, params: Any? = null, withKey: Boolean = true): String {
val params = if (params is Array<*>?) params as Array<Any?>? else arrayOf(params)
val params = when (params) {
is Array<*> -> params.map { it }.toTypedArray() // Convert to Array<Any?>
else -> arrayOf(params)
}

if (!keyPattern.matcher(key).matches()) {
throw InconsistencyException("Malformed message key '$key'")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2022 kopiLeft Services SARL, Tunis TN
* Copyright (c) 1990-2022 kopiRight Managed Solutions GmbH, Wien AT
* Copyright (c) 2013-2024 kopiLeft Services SARL, Tunis TN
* Copyright (c) 1990-2024 kopiRight Managed Solutions GmbH, Wien AT
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -36,11 +36,11 @@ object VDatabaseUtils {

fun checkForeignKeys_(id: Int, queryTable: Table){
transaction {
val query1 = References.slice(
val query1 = References.select(
References.table,
References.column,
References.action
).select {
).where {
References.reference eq queryTable.tableName
}.orderBy(References.action to SortOrder.DESC)
val action = query1.forEach { query1Row ->
Expand All @@ -50,14 +50,14 @@ object VDatabaseUtils {
}
when (query1Row[References.action][0]) {
'R' -> transaction {
val query2 = auxTable.slice(auxTable.id).select { auxTable.column eq id }
val query2 = auxTable.select(auxTable.id).where { auxTable.column eq id }
if (query2.toList()[1] != null) {
throw VExecFailedException(MessageCode.getMessage("VIS-00021", arrayOf<Any>(query1Row[References.column],
query1Row[References.table])))
}
}
'C' -> transaction {
val query2 = auxTable.slice(auxTable.id).select { auxTable.column eq id }
val query2 = auxTable.select(auxTable.id).where { auxTable.column eq id }
query2.forEach {
checkForeignKeys(it[auxTable.id], query1Row[References.table])
}
Expand All @@ -78,11 +78,11 @@ object VDatabaseUtils {
fun checkForeignKeys(id: Int, table: String) {
// FIXME : this should be re-implemented
transaction {
val query1 = References.slice(
val query1 = References.select(
References.table,
References.column,
References.action
).select {
).where {
References.reference eq table
}.orderBy(References.action to SortOrder.DESC)
val action = query1.forEach { query1Row ->
Expand All @@ -92,14 +92,14 @@ object VDatabaseUtils {
}
when (query1Row[References.action][0]) {
'R' -> transaction {
val query2 = auxTable.slice(auxTable.id).select { auxTable.column eq id }
val query2 = auxTable.select(auxTable.id).where { auxTable.column eq id }
if (query2.toList()[1] != null) {
throw VExecFailedException(MessageCode.getMessage("VIS-00021", arrayOf<Any>(query1Row[References.column],
query1Row[References.table])))
}
}
'C' -> transaction {
val query2 = auxTable.slice(auxTable.id).select { auxTable.column eq id }
val query2 = auxTable.select(auxTable.id).where { auxTable.column eq id }
query2.forEach {
checkForeignKeys(it[auxTable.id], query1Row[References.table])
}
Expand All @@ -123,9 +123,9 @@ object VDatabaseUtils {
var id = integer("ID")
}
val query = if (condition != null) {
auxTable.slice(auxTable.id).select { condition }.forUpdate()
auxTable.select(auxTable.id).where { condition }.forUpdate()
} else {
auxTable.slice(auxTable.id).selectAll().forUpdate()
auxTable.select(auxTable.id).forUpdate()
}

query.forEach {
Expand Down
64 changes: 32 additions & 32 deletions galite-core/src/main/kotlin/org/kopi/galite/visual/VMenuTree.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2022 kopiLeft Services SARL, Tunis TN
* Copyright (c) 1990-2022 kopiRight Managed Solutions GmbH, Wien AT
* Copyright (c) 2013-2024 kopiLeft Services SARL, Tunis TN
* Copyright (c) 1990-2024 kopiRight Managed Solutions GmbH, Wien AT
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -88,15 +88,15 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti

companion object {

private val SELECT_MODULES = Modules.slice(
private val SELECT_MODULES = Modules.select(
Modules.id,
Modules.parent,
Modules.shortName,
Modules.sourceName,
Modules.objectName,
Modules.priority,
Modules.symbol
).selectAll().orderBy(Modules.priority to SortOrder.DESC)
).orderBy(Modules.priority to SortOrder.DESC)

const val CMD_QUIT = 0
const val CMD_OPEN = 1
Expand Down Expand Up @@ -360,7 +360,7 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti
if (it[Modules.symbol] != null && it[Modules.symbol] != 0) {
val symbol = it[Modules.symbol] as Int

Symbols.select { Symbols.id eq symbol }.forEach { res ->
Symbols.selectAll().where { Symbols.id eq symbol }.forEach { res ->
icon = res[Symbols.objectName]
}
}
Expand Down Expand Up @@ -388,8 +388,8 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti
modules,
Modules
.innerJoin(GroupRights.innerJoin(GroupParties, { group }, { group }), { id }, { GroupRights.module })
.slice(Modules.id, GroupRights.access, Modules.priority)
.select { GroupParties.user inSubQuery (Groups.slice(Groups.id).select { Groups.shortName eq groupName }) }
.select(Modules.id, GroupRights.access, Modules.priority)
.where { GroupParties.user inSubQuery (Groups.select(Groups.id).where { Groups.shortName eq groupName }) }
.orderBy(Modules.priority to SortOrder.ASC, Modules.id to SortOrder.ASC)
.withDistinct()
)
Expand All @@ -399,8 +399,8 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti
modules,
Modules
.innerJoin(GroupRights.innerJoin(GroupParties, { group }, { group }), { id }, { GroupRights.module })
.slice(Modules.id, GroupRights.access, Modules.priority)
.select { GroupParties.user inSubQuery (Users.slice(Users.id).select { Users.shortName eq menuTreeUser }) }
.select(Modules.id, GroupRights.access, Modules.priority)
.where { GroupParties.user inSubQuery (Users.select(Users.id).where { Users.shortName eq menuTreeUser }) }
.orderBy(Modules.priority to SortOrder.ASC, Modules.id to SortOrder.ASC)
.withDistinct()
)
Expand All @@ -410,8 +410,8 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti
modules,
Modules
.innerJoin(GroupRights.innerJoin(GroupParties, { group }, { group }), { id }, { GroupRights.module })
.slice(Modules.id, GroupRights.access, Modules.priority)
.select { GroupParties.user eq getUserID() }
.select(Modules.id, GroupRights.access, Modules.priority)
.where { GroupParties.user eq getUserID() }
.orderBy(Modules.priority to SortOrder.ASC, Modules.id to SortOrder.ASC)
.withDistinct()
)
Expand All @@ -424,28 +424,28 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti
groupName != null -> {
fetchRights(modules,
Modules.innerJoin(GroupRights, { id }, { module })
.slice(Modules.id, GroupRights.access, Modules.priority)
.select {
(GroupRights.group inSubQuery (Groups.slice(Groups.id).select { Groups.shortName eq groupName }))
.select(Modules.id, GroupRights.access, Modules.priority)
.where {
(GroupRights.group inSubQuery (Groups.select(Groups.id).where { Groups.shortName eq groupName }))
}
.orderBy(Modules.priority to SortOrder.ASC, Modules.id to SortOrder.ASC)
.withDistinct())
}
menuTreeUser != null -> {
fetchRights(modules,
Modules.innerJoin(GroupRights, { id }, { module })
.slice(Modules.id, GroupRights.access, Modules.priority)
.select {
(GroupRights.group inSubQuery (Users.slice(Users.id).select { Users.shortName eq menuTreeUser }))
.select(Modules.id, GroupRights.access, Modules.priority)
.where {
(GroupRights.group inSubQuery (Users.select(Users.id).where { Users.shortName eq menuTreeUser }))
}
.orderBy(Modules.priority to SortOrder.ASC, Modules.id to SortOrder.ASC)
.withDistinct())
}
else -> {
fetchRights(modules,
Modules.innerJoin(GroupRights, { id }, { module })
.slice(Modules.id, GroupRights.access, Modules.priority)
.select { (GroupRights.group eq getUserID()) }
.select(Modules.id, GroupRights.access, Modules.priority)
.where { (GroupRights.group eq getUserID()) }
.orderBy(Modules.priority to SortOrder.ASC, Modules.id to SortOrder.ASC)
.withDistinct())
}
Expand All @@ -457,26 +457,26 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti
groupName != null -> {
fetchRights(modules,
Modules.innerJoin(UserRights, { id }, { module })
.slice(Modules.id, UserRights.access, Modules.priority)
.select {
(UserRights.user inSubQuery ( Groups.slice(Groups.id).select { Groups.shortName eq groupName }))
.select(Modules.id, UserRights.access, Modules.priority)
.where {
(UserRights.user inSubQuery ( Groups.select(Groups.id).where { Groups.shortName eq groupName }))
}
.orderBy(Modules.priority to SortOrder.ASC, Modules.id to SortOrder.ASC))
}
menuTreeUser != null -> {
fetchRights(modules,
Modules.innerJoin(UserRights, { id }, { module })
.slice(Modules.id, UserRights.access, Modules.priority)
.select {
(UserRights.user inSubQuery (Users.slice(Users.id).select { Users.shortName eq menuTreeUser }))
.select(Modules.id, UserRights.access, Modules.priority)
.where {
(UserRights.user inSubQuery (Users.select(Users.id).where { Users.shortName eq menuTreeUser }))
}
.orderBy(Modules.priority to SortOrder.ASC, Modules.id to SortOrder.ASC))
}
else -> {
fetchRights(modules,
Modules.innerJoin(UserRights, { id }, { module })
.slice(Modules.id, UserRights.access, Modules.priority)
.select { UserRights.user eq getUserID() }
.select(Modules.id, UserRights.access, Modules.priority)
.where { UserRights.user eq getUserID() }
.orderBy(Modules.priority to SortOrder.ASC, Modules.id to SortOrder.ASC))
}
}
Expand Down Expand Up @@ -507,11 +507,11 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti
private fun fetchFavorites() {
transaction {
val query = if (isSuperUser && menuTreeUser != null) {
Favorites.slice(Favorites.module, Favorites.id).select {
Favorites.user inSubQuery (Users.slice(Users.id).select { Users.shortName eq menuTreeUser })
Favorites.select(Favorites.module, Favorites.id).where {
Favorites.user inSubQuery (Users.select(Users.id).where { Users.shortName eq menuTreeUser })
}.orderBy(Favorites.id)
} else {
Favorites.slice(Favorites.module, Favorites.id).select { Favorites.user eq getUserID() }.orderBy(Favorites.id)
Favorites.select(Favorites.module, Favorites.id).where { Favorites.user eq getUserID() }.orderBy(Favorites.id)
}
query.forEach {
if (it[Favorites.module] != 0) {
Expand Down Expand Up @@ -572,7 +572,7 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti
Favorites.insert {
it[this.id] = FavoritesId.nextIntVal()
it[ts] = (System.currentTimeMillis() / 1000).toInt()
it[user] = Users.slice(Users.id).select { Users.shortName eq menuTreeUser.toString() }
it[user] = Users.select(Users.id).where { Users.shortName eq menuTreeUser.toString() }
it[module] = id
}
} else {
Expand All @@ -596,7 +596,7 @@ class VMenuTree constructor(ctxt: Connection? = ApplicationContext.getDBConnecti
try {
transaction {
if (menuTreeUser != null) {
val idSubQuery = Users.slice(Users.id).select { Users.shortName eq menuTreeUser.orEmpty() }
val idSubQuery = Users.select(Users.id).where { Users.shortName eq menuTreeUser.orEmpty() }
Favorites.deleteWhere {
(Favorites.user eqSubQuery idSubQuery) and (Favorites.module eq id)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ interface Image : Serializable {
* Returns the `Image` width
* @return The image width
*/
fun getWidth(): Int
fun getImageWidth(): Int

/**
* Returns the `Image` height
* @return The image height
*/
fun getHeight(): Int
fun getImageHeight(): Int

/**
* Returns the `Image` description
Expand Down
Loading