com.lsdconsulting.generatorui.service.LsdService.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lsd-distributed-generator-ui-service Show documentation
Show all versions of lsd-distributed-generator-ui-service Show documentation
This is the graphical interface providing the LSD generation functionality.
The newest version!
package com.lsdconsulting.generatorui.service
import com.lsdconsulting.generatorui.controller.InterceptedFlowResponse
import io.lsdconsulting.lsd.distributed.connector.model.InterceptedInteraction
import io.lsdconsulting.lsd.distributed.connector.repository.InterceptedDocumentAdminRepository
import io.lsdconsulting.lsd.distributed.connector.repository.InterceptedDocumentRepository
import org.springframework.stereotype.Service
import java.time.temporal.ChronoUnit
@Service
class LsdService(
private val interceptedDocumentRepository: InterceptedDocumentRepository,
private val interceptedDocumentAdminRepository: InterceptedDocumentAdminRepository
) {
fun storeInteractionsInDatabase(interceptedInteraction: InterceptedInteraction) {
interceptedDocumentRepository.save(interceptedInteraction)
}
fun findInteractionsByTraceIds(vararg traceIds: String): List =
interceptedDocumentRepository.findByTraceIds(*traceIds)
fun findMostRecentFlows(resultSizeLimit: Int?): List =
interceptedDocumentAdminRepository.findRecentFlows(resultSizeLimit?:10)
.map {
InterceptedFlowResponse(
traceId = it.initialInteraction.traceId,
initialInteraction = it.initialInteraction.serviceName + " -> " + it.initialInteraction.target,
interactionType = it.initialInteraction.interactionType.name,
profile = it.initialInteraction.profile ?: "",
duration = ChronoUnit.MILLIS.between(
it.initialInteraction.createdAt,
it.finalInteraction.createdAt
),
initiatedAt = it.initialInteraction.createdAt,
finishedAt = it.finalInteraction.createdAt,
numberOfInteractions = it.totalCapturedInteractions,
)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy