mirror of
https://github.com/corda/corda.git
synced 2025-02-23 02:22:41 +00:00
Merge pull request #7450 from corda/shams-4.9-merge-5cdbec9d
ENT-6876: 4.8 to 4.9 forward merge
This commit is contained in:
commit
c813533191
@ -709,9 +709,6 @@ class NodeVaultService(
|
||||
paging: PageSpecification,
|
||||
sorting: Sort,
|
||||
contractStateType: Class<out T>): Vault.Page<T> {
|
||||
// calculate total results where a page specification has been defined
|
||||
val totalStatesAvailable = if (paging.isDefault) -1 else queryTotalStateCount(criteria, contractStateType)
|
||||
|
||||
val (criteriaQuery, criteriaParser) = buildCriteriaQuery<Tuple>(criteria, contractStateType, sorting)
|
||||
val query = getSession().createQuery(criteriaQuery)
|
||||
query.setResultWindow(paging)
|
||||
@ -736,6 +733,13 @@ class NodeVaultService(
|
||||
ArrayList()
|
||||
)
|
||||
|
||||
val totalStatesAvailable = when {
|
||||
paging.isDefault -> -1L
|
||||
// If the first page isn't full then we know that's all the states that are available
|
||||
paging.pageNumber == DEFAULT_PAGE_NUM && states.size < paging.pageSize -> states.size.toLong()
|
||||
else -> queryTotalStateCount(criteria, contractStateType)
|
||||
}
|
||||
|
||||
return Vault.Page(states, statesMetadata, totalStatesAvailable, criteriaParser.stateTypes, otherResults)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user