com.infobip.kafkistry.sql.sources.common.kt Maven / Gradle / Ivy
@file:Suppress("JpaDataSourceORMInspection")
package com.infobip.kafkistry.sql.sources
import org.apache.kafka.clients.admin.ConfigEntry
import com.infobip.kafkistry.kafka.ConfigValue
import com.infobip.kafkistry.model.KafkaClusterIdentifier
import jakarta.persistence.Column
import jakarta.persistence.Embeddable
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
fun Map.Entry.toKafkaConfigEntry() = KafkaConfigEntry().apply {
key = [email protected]
value = [email protected]
}
fun Map.Entry.toExistingKafkaConfigEntry() = ExistingConfigEntry().apply {
val mapEntry = this@toExistingKafkaConfigEntry
entry = KafkaConfigEntry().apply {
key = mapEntry.key
value = mapEntry.value.value
}
with(mapEntry.value) {
[email protected] = default
[email protected] = readOnly
[email protected] = sensitive
configSource = source
}
}
@Embeddable
class PresenceCluster {
lateinit var cluster: KafkaClusterIdentifier
}
@Suppress("RedundantGetter") //for hibernate annotations on get()
@Embeddable
class ExistingConfigEntry {
lateinit var entry: KafkaConfigEntry
@Column(nullable = false)
var isDefault: Boolean? = null
@Column(name = "isDefault", nullable = false)
get() = field
@Column(nullable = false)
var isReadOnly: Boolean? = null
@Column(name = "isReadOnly", nullable = false)
get() = field
@Column(nullable = false)
var isSensitive: Boolean? = null
@Column(name = "isSensitive", nullable = false)
get() = field
@Column(nullable = false)
@Enumerated(EnumType.STRING)
var configSource: ConfigEntry.ConfigSource? = null
@Enumerated(EnumType.STRING)
get() = field
}
@Embeddable
class KafkaConfigEntry {
lateinit var key: String
var value: String? = null
}