net.nemerosa.ontrack.kdsl.spec.search.SearchOntrackExtensions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ontrack-kdsl Show documentation
Show all versions of ontrack-kdsl Show documentation
Ontrack module: ontrack-kdsl
package net.nemerosa.ontrack.kdsl.spec.search
import net.nemerosa.ontrack.kdsl.connector.graphql.paginate
import net.nemerosa.ontrack.kdsl.connector.graphql.schema.SearchQuery
import net.nemerosa.ontrack.kdsl.connector.graphqlConnector
import net.nemerosa.ontrack.kdsl.connector.support.PaginatedList
import net.nemerosa.ontrack.kdsl.connector.support.emptyPaginatedList
import net.nemerosa.ontrack.kdsl.spec.Ontrack
fun Ontrack.search(token: String): PaginatedList =
graphqlConnector.query(
SearchQuery(token, 40)
)?.paginate(
pageInfo = { it.search()?.pageInfo()?.fragments()?.pageInfoContent() },
pageItems = { it.search()?.pageItems() }
)?.map {
SearchResult(
title = it.title() ?: "",
description = it.description() ?: "",
accuracy = it.accuracy() ?: 0.0,
type = SearchResultType(
feature = it.type()?.feature()?.id() ?: "",
id = it.type()?.id() ?: "",
name = it.type()?.name() ?: "",
description = it.type()?.description() ?: "",
),
)
} ?: emptyPaginatedList()
© 2015 - 2024 Weber Informatics LLC | Privacy Policy