Skip to content

Commit e1be069

Browse files
authored
Merge pull request #341 from nl-portal/feature/add-pagesize-to-openzaak
Feature/add pagesize to openzaak
2 parents 5273767 + 67fbf0f commit e1be069

File tree

17 files changed

+61
-20
lines changed

17 files changed

+61
-20
lines changed

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ benManesVersionsVersion=0.51.0
1010
ktlintVersion=12.1.2
1111
spotlessVersion=6.25.0
1212
gradleDockerComposeVersion=0.17.12
13-
dokkaVersion=1.9.20
13+
dokkaVersion=2.0.0
1414

1515
org.gradle.jvmargs=-Xmx6g -XX:MaxMetaspaceSize=2048m
1616
org.gradle.workers.max=10
17-
version=1.4.35-SNAPSHOT
17+
version=1.4.36-SNAPSHOT

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

product/src/main/kotlin/nl/nlportal/product/domain/Product.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class Product(
4444
val eigenschappen: ObjectNode?,
4545
val parameters: ObjectNode?,
4646
@GraphQLIgnore
47-
val taken: List<UUID>,
47+
@Deprecated("will be removed in a future release.")
48+
val taken: List<UUID>?,
4849
@GraphQLIgnore
4950
val zaken: List<UUID>,
5051
val documenten: List<String>,

product/src/main/kotlin/nl/nlportal/product/graphql/ProductQuery.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ class ProductQuery(
9595
productName = productName,
9696
pageNumber = 1,
9797
isOpen = isOpen,
98-
).take(pageSize ?: 20)
98+
pageSize = pageSize,
99+
)
99100
}
100101

101102
@GraphQLDescription("Get list of taken by product name ")

product/src/main/kotlin/nl/nlportal/product/service/ProductService.kt

+6-5
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ class ProductService(
145145
productTypeId: UUID?,
146146
productName: String,
147147
pageNumber: Int,
148+
pageSize: Int? = null,
148149
isOpen: Boolean? = null,
149150
): List<Zaak> {
150151
val productType = getProductType(productTypeId, productName)
@@ -159,7 +160,7 @@ class ProductService(
159160
.page(pageNumber)
160161
.withAuthentication(authentication)
161162
.ofZaakTypes(productType.zaaktypen.map { it })
162-
163+
pageSize?.let { request.pageSize(it) }
163164
isOpen?.let {
164165
request.isOpen(isOpen)
165166
}
@@ -195,10 +196,10 @@ class ProductService(
195196

196197
val zaken =
197198
getProductZaken(
198-
authentication,
199-
productTypeId,
200-
productName,
201-
pageNumber,
199+
authentication = authentication,
200+
productTypeId = productTypeId,
201+
productName = productName,
202+
pageNumber = pageNumber,
202203
)
203204

204205
val producten =

zgw/objectenapi/src/main/kotlin/nl/nlportal/zgw/objectenapi/domain/ObjectSearchParameter.kt

+1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ enum class Comparator(val value: String) {
3838
LOWER_THAN("lt"),
3939
LOWER_THAN_OR_EQUAL_TO("lte"),
4040
STRING_CONTAINS("icontains"),
41+
IN_LIST("in"),
4142
}

zgw/zaken-api/src/main/kotlin/nl/nlportal/zakenapi/client/request/PagedRetrieve.kt

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import nl.nlportal.zakenapi.domain.ResultPage
55
interface PagedRetrieve<O : PagedRetrieve<O, T>, T> : Retrieve<ResultPage<T>> {
66
fun page(page: Int): O
77

8+
fun pageSize(pageSize: Int): O
9+
810
suspend fun retrieveAll(): List<T> {
911
val results = mutableListOf<T>()
1012
do {

zgw/zaken-api/src/main/kotlin/nl/nlportal/zakenapi/client/request/ZaakObjectenImpl.kt

+5
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class SearchZaakObjectenImpl(val zakenApiClient: ZakenApiClient) : SearchZaakObj
4747
return this
4848
}
4949

50+
override fun pageSize(pageSize: Int): SearchZaakObjecten {
51+
queryParams.add("pageSize", pageSize.toString())
52+
return this
53+
}
54+
5055
override suspend fun retrieve(): ResultPage<ZaakObject> {
5156
return this.zakenApiClient.webClient.get()
5257
.uri { it.path("/zaken/api/v1/zaakobjecten").queryParams(queryParams).build() }

zgw/zaken-api/src/main/kotlin/nl/nlportal/zakenapi/client/request/ZaakRollenImpl.kt

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ class SearchRollenImpl(val zakenApiClient: ZakenApiClient) : SearchZaakRollen {
6767
return this
6868
}
6969

70+
override fun pageSize(page: Int): SearchZaakRollen {
71+
queryParams.add("pageSize", page.toString())
72+
return this
73+
}
74+
7075
override suspend fun retrieve(): ResultPage<ZaakRol> {
7176
return this.zakenApiClient.webClient.get()
7277
.uri { it.path("/zaken/api/v1/rollen").queryParams(queryParams).build() }

zgw/zaken-api/src/main/kotlin/nl/nlportal/zakenapi/client/request/ZaakStatussenImpl.kt

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ class SearchZaakStatussenImpl(val zakenApiClient: ZakenApiClient) : SearchZaakSt
5252
return this
5353
}
5454

55+
override fun pageSize(page: Int): SearchZaakStatussen {
56+
queryParams.add("pageSize", page.toString())
57+
return this
58+
}
59+
5560
override suspend fun retrieve(): ResultPage<ZaakStatus> {
5661
return this.zakenApiClient.webClient.get()
5762
.uri { it.path("/zaken/api/v1/statussen").queryParams(queryParams).build() }

zgw/zaken-api/src/main/kotlin/nl/nlportal/zakenapi/client/request/ZakenImpl.kt

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ class SearchZakenImpl(val zakenApiClient: ZakenApiClient) : SearchZaken {
7777
return this
7878
}
7979

80+
override fun pageSize(pageSize: Int): SearchZaken {
81+
queryParams.add("pageSize", pageSize.toString())
82+
return this
83+
}
84+
8085
override suspend fun retrieve(): ResultPage<Zaak> {
8186
return this.zakenApiClient.webClient.get()
8287
.uri { it.path("/zaken/api/v1/zaken").queryParams(queryParams).build() }

zgw/zaken-api/src/main/kotlin/nl/nlportal/zakenapi/client/request/ZoekenImpl.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class ZoekenImpl(val zakenApiClient: ZakenApiClient) : Zaken {
2222

2323
class SearchZoekenImpl(val zakenApiClient: ZakenApiClient) : SearchZaken {
2424
val bodyValue: MultiValueMap<String, Any> = LinkedMultiValueMap()
25+
val queryParams: MultiValueMap<String, String> = LinkedMultiValueMap()
2526

2627
override fun withBsn(bsn: String): SearchZaken {
2728
bodyValue.add("rol__betrokkeneIdentificatie__natuurlijkPersoon__inpBsn", bsn)
@@ -68,15 +69,22 @@ class SearchZoekenImpl(val zakenApiClient: ZakenApiClient) : SearchZaken {
6869
return this
6970
}
7071

72+
// needs to be added as querystring parameter
7173
override fun page(page: Int): SearchZaken {
72-
bodyValue.add("page", page.toString())
74+
queryParams.add("page", page.toString())
75+
return this
76+
}
77+
78+
// needs to be added as querystring parameter
79+
override fun pageSize(pageSize: Int): SearchZaken {
80+
queryParams.add("pageSize", pageSize.toString())
7381
return this
7482
}
7583

7684
override suspend fun retrieve(): ResultPage<Zaak> {
7785
return this.zakenApiClient.webClient
7886
.post()
79-
.uri("/zaken/api/v1/zaken/_zoek")
87+
.uri { it.path("/zaken/api/v1/zaken/_zoek").queryParams(queryParams).build() }
8088
.contentType(MediaType.APPLICATION_JSON)
8189
.accept(MediaType.APPLICATION_JSON)
8290
.bodyValue(bodyValue)

zgw/zaken-api/src/main/kotlin/nl/nlportal/zakenapi/graphql/ZaakPage.kt

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ class ZaakPage(
1313
companion object {
1414
fun fromResultPage(
1515
pageNumber: Int,
16+
pageSize: Int,
1617
resultPage: ResultPage<Zaak>,
1718
): ZaakPage {
1819
val zaken = resultPage.results.map { it }
1920

2021
return ZaakPage(
2122
number = pageNumber,
22-
size = 100,
23+
size = pageSize,
2324
content = zaken,
2425
totalElements = resultPage.count,
2526
)

zgw/zaken-api/src/main/kotlin/nl/nlportal/zakenapi/graphql/ZaakQuery.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ open class ZaakQuery(val zakenApiService: ZakenApiService) : Query {
3535
open suspend fun getZaken(
3636
dfe: DataFetchingEnvironment,
3737
page: Int? = 1,
38+
pageSize: Int? = 20,
3839
zaakTypeUrl: String? = null,
3940
isOpen: Boolean? = null,
4041
identificatie: String? = null,
4142
): ZaakPage {
4243
return zakenApiService.getZaken(
43-
page = page!!,
44+
page = page ?: 1,
45+
pageSize = pageSize,
4446
authentication = dfe.graphQlContext[AUTHENTICATION_KEY],
4547
zaakTypeUrl = zaakTypeUrl,
4648
isOpen = isOpen,

zgw/zaken-api/src/main/kotlin/nl/nlportal/zakenapi/service/ZakenApiService.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,19 @@ class ZakenApiService(
4545
) {
4646
suspend fun getZaken(
4747
page: Int,
48+
pageSize: Int? = null,
4849
authentication: CommonGroundAuthentication,
4950
zaakTypeUrl: String?,
5051
isOpen: Boolean?,
5152
identificatie: String?,
5253
): ZaakPage {
5354
val request =
54-
zakenApiClient.zaken()
55+
zakenApiClient.zoeken()
5556
.search()
57+
.page(page)
5658
.withAuthentication(authentication)
5759

60+
pageSize?.let { request.pageSize(it) }
5861
zaakTypeUrl?.let { request.ofZaakType(it) }
5962
isOpen?.let {
6063
request.isOpen(isOpen)
@@ -69,7 +72,7 @@ class ZakenApiService(
6972
}
7073

7174
return request.retrieve().let {
72-
ZaakPage.fromResultPage(page, it)
75+
ZaakPage.fromResultPage(page, pageSize ?: 100, it)
7376
}
7477
}
7578

zgw/zaken-api/src/test/kotlin/nl/nlportal/zakenapi/graphql/ZaakQueryIT.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,11 @@ internal class ZaakQueryIT(
638638
override fun dispatch(request: RecordedRequest): MockResponse {
639639
val path = request.path?.substringBefore('?')
640640
val queryParams = request.path?.substringAfter('?')?.split('&') ?: emptyList()
641+
val bodyContent = request.body.readUtf8()
641642
val response =
642643
when (path) {
643-
"/zaken/api/v1/zaken" -> {
644-
if (queryParams.any { it.contains("ZAAK-2024-0000000001") }) {
644+
"/zaken/api/v1/zaken/_zoek" -> {
645+
if (bodyContent.contains("ZAAK-2024-0000000001")) {
645646
handleZaakListRequestOfIdentificatie()
646647
} else {
647648
handleZaakListRequest()

zgw/zaken-api/src/test/kotlin/nl/nlportal/zakenapi/graphql/ZaakQueryTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ internal class ZaakQueryTest {
4848
fun getZaken() =
4949
runTest {
5050
zaakQuery.getZaken(environment, 3, null)
51-
verify(zakenApiService).getZaken(3, authentication, null, null, null)
51+
verify(zakenApiService).getZaken(3, null, authentication, null, null, null)
5252
}
5353

5454
@Test
5555
fun `getZaken no page`() =
5656
runTest {
5757
zaakQuery.getZaken(environment)
58-
verify(zakenApiService).getZaken(1, authentication, null, null, null)
58+
verify(zakenApiService).getZaken(1, 20, authentication, null, null, null)
5959
}
6060

6161
@Test

0 commit comments

Comments
 (0)