jvmMain.zakadabar.lib.schedule.business.SubscriptionBl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of schedule-jvm Show documentation
Show all versions of schedule-jvm Show documentation
Kotlin/Ktor based full-stack platform
/*
* Copyright © 2020-2021, Simplexion, Hungary and contributors. Use of this source code is governed by the Apache 2.0 license.
*/
package zakadabar.lib.schedule.business
import zakadabar.core.authorize.Executor
import zakadabar.core.business.EntityBusinessLogicBase
import zakadabar.core.data.EntityId
import zakadabar.core.module.module
import zakadabar.lib.schedule.data.Subscription
import zakadabar.lib.schedule.peristence.SubscriptionPa
open class SubscriptionBl : EntityBusinessLogicBase(
boClass = Subscription::class
) {
override val pa = SubscriptionPa()
override val authorizer by provider()
open val jobBl by module()
override fun create(executor: Executor, bo: Subscription): Subscription =
pa
.create(bo)
.also {
SubscriptionCreateEvent(
actionNamespace = it.actionNamespace,
actionType = it.actionType,
subscriptionId = it.id,
nodeUrl = it.nodeUrl,
nodeId = it.nodeId
).dispatch()
}
override fun update(executor: Executor, bo: Subscription): Subscription {
throw NotImplementedError("subscriptions cannot be updated, delete and create a new")
}
override fun delete(executor: Executor, entityId: EntityId) {
val bo = pa.readOrNull(entityId) ?: return
pa.delete(entityId)
SubscriptionDeleteEvent(
bo.actionNamespace,
bo.actionType,
bo.id
).dispatch()
}
fun DispatcherEvent.dispatch() = jobBl.dispatchEvent(this)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy