s2.spring.sourcing.ssm.S2SourcingSsmAdapter.kt Maven / Gradle / Ivy
package s2.spring.sourcing.ssm
import f2.dsl.fnc.invoke
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.json.Json
import org.springframework.beans.factory.annotation.Autowired
import s2.dsl.automate.Evt
import s2.dsl.automate.S2State
import s2.dsl.automate.model.WithS2Id
import s2.dsl.automate.model.WithS2State
import s2.dsl.automate.ssm.toSsm
import s2.sourcing.dsl.event.EventRepository
import s2.sourcing.dsl.snap.SnapRepository
import s2.sourcing.dsl.view.View
import s2.spring.automate.sourcing.S2AutomateDeciderSpring
import s2.spring.automate.sourcing.S2AutomateDeciderSpringAdapter
import ssm.chaincode.dsl.model.Agent
import ssm.chaincode.dsl.model.uri.ChaincodeUri
import ssm.data.dsl.features.query.DataSsmSessionGetQueryFunction
import ssm.data.dsl.features.query.DataSsmSessionListQueryFunction
import ssm.data.dsl.features.query.DataSsmSessionLogListQueryFunction
import ssm.tx.dsl.features.ssm.SsmInitCommand
import ssm.tx.dsl.features.ssm.SsmTxInitFunction
import ssm.tx.dsl.features.ssm.SsmTxSessionPerformActionFunction
import ssm.tx.dsl.features.ssm.SsmTxSessionStartFunction
abstract class S2SourcingSsmAdapter(
executor: EXECUTOR,
view: View,
snapRepository: SnapRepository? = null
): S2AutomateDeciderSpringAdapter(executor, view, snapRepository) where
STATE : S2State,
ENTITY : WithS2State,
ENTITY : WithS2Id,
EVENT: WithS2Id,
EVENT: Evt,
EXECUTOR : S2AutomateDeciderSpring {
@Autowired
lateinit var ssmTxInitFunction: SsmTxInitFunction
@Autowired
lateinit var ssmSessionStartFunction: SsmTxSessionStartFunction
@Autowired
lateinit var ssmSessionPerformActionFunction: SsmTxSessionPerformActionFunction
@Autowired
lateinit var dataSsmSessionGetQueryFunction: DataSsmSessionGetQueryFunction
@Autowired
lateinit var dataSsmSessionListQueryFunction: DataSsmSessionListQueryFunction
@Autowired
lateinit var dataSsmSessionLogFunction: DataSsmSessionLogListQueryFunction
override fun eventStore(): EventRepository = runBlocking {
val automate = automate()
val signer = signerAgent()
val chaincodeUri = chaincodeUri()
EventPersisterSsm(automate, entityType()).also { ee ->
ee.ssmSessionStartFunction = ssmSessionStartFunction
ee.dataSsmSessionLogFunction = dataSsmSessionLogFunction
ee.ssmSessionPerformActionFunction = ssmSessionPerformActionFunction
ee.dataSsmSessionGetQueryFunction = dataSsmSessionGetQueryFunction
ee.dataSsmSessionListQueryFunction = dataSsmSessionListQueryFunction
ee.chaincodeUri = chaincodeUri
ee.agentSigner = signer
ee.json = json()
ee.versioning = versioning
ssmTxInitFunction.invoke(
SsmInitCommand(
signerName = signer.name,
ssm = automate.toSsm(permisive),
agent = ee.agentSigner,
chaincodeUri = chaincodeUri
)
)
}
}
open fun json(): Json = Json
abstract fun chaincodeUri(): ChaincodeUri
abstract fun signerAgent(): Agent
open var permisive = false
open var versioning = false
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy