Skip to content

Commit

Permalink
feat(bridge): Put pagination size in config property
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfkaeser committed May 25, 2023
1 parent 34f7681 commit 87d9fd7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2021,2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

package com.catenax.bpdm.bridge.dummy.config

import org.springframework.boot.context.properties.ConfigurationProperties


@ConfigurationProperties(prefix = "bpdm.bridge")
data class BridgeConfigProperties(
// Page size for querying Gate
val queryPageSize: Int = 100
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.catenax.bpdm.bridge.dummy.service

import com.catenax.bpdm.bridge.dummy.config.BridgeConfigProperties
import com.catenax.bpdm.bridge.dummy.dto.GateAddressInfo
import com.catenax.bpdm.bridge.dummy.dto.GateLegalEntityInfo
import com.catenax.bpdm.bridge.dummy.dto.GateSiteInfo
Expand All @@ -35,11 +36,10 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType
import org.springframework.stereotype.Service
import java.time.Instant

private const val pageSize = 100

@Service
class GateQueryService(
val gateClient: GateClient
val gateClient: GateClient,
val bridgeConfigProperties: BridgeConfigProperties
) {

private val logger = KotlinLogging.logger { }
Expand All @@ -53,7 +53,7 @@ class GateQueryService(
val pageResponse = gateClient.changelog().getChangelogEntriesLsaType(
lsaType = null,
fromTime = modifiedAfter,
paginationRequest = PaginationRequest(page, pageSize)
paginationRequest = PaginationRequest(page, bridgeConfigProperties.queryPageSize)
)
page++
totalPages = pageResponse.totalPages
Expand Down Expand Up @@ -128,7 +128,7 @@ class GateQueryService(
val pageResponse = gateClient.sharingState().getSharingStates(
lsaType = lsaType,
externalIds = externalIds,
paginationRequest = PaginationRequest(page, pageSize)
paginationRequest = PaginationRequest(page, bridgeConfigProperties.queryPageSize)
)
page++
totalPages = pageResponse.totalPages
Expand All @@ -153,7 +153,7 @@ class GateQueryService(
do {
val pageResponse = gateClient.legalEntities().getLegalEntitiesByExternalIds(
externalIds = externalIds,
paginationRequest = PaginationStartAfterRequest(pageStartAfter, pageSize)
paginationRequest = PaginationStartAfterRequest(pageStartAfter, bridgeConfigProperties.queryPageSize)
)
pageStartAfter = pageResponse.nextStartAfter
validContent.addAll(pageResponse.content)
Expand All @@ -176,7 +176,7 @@ class GateQueryService(
do {
val pageResponse = gateClient.sites().getSitesByExternalIds(
externalIds = externalIds,
paginationRequest = PaginationStartAfterRequest(pageStartAfter, pageSize)
paginationRequest = PaginationStartAfterRequest(pageStartAfter, bridgeConfigProperties.queryPageSize)
)
pageStartAfter = pageResponse.nextStartAfter
validContent.addAll(pageResponse.content)
Expand All @@ -199,7 +199,7 @@ class GateQueryService(
do {
val pageResponse = gateClient.addresses().getAddressesByExternalIds(
externalIds = externalIds,
paginationRequest = PaginationStartAfterRequest(pageStartAfter, pageSize)
paginationRequest = PaginationStartAfterRequest(pageStartAfter, bridgeConfigProperties.queryPageSize)
)
pageStartAfter = pageResponse.nextStartAfter
validContent.addAll(pageResponse.content)
Expand Down
7 changes: 5 additions & 2 deletions bpdm-bridge-dummy/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ [email protected]@
bpdm.description=@project.description@
bpdm.version=@project.version@
##
#Change default port
# Change default port
server.port=8083
##
#Logging Configuration
# Logging Configuration
bpdm.logging.unknown-user=Anonymous
##
# Page size for querying Gate
bpdm.bridge.query-page-size=100
##
# Connection to Pool and Gate
bpdm.pool.base-url=http://localhost:8080/
bpdm.gate.base-url=http://localhost:8081/
Expand Down

0 comments on commit 87d9fd7

Please sign in to comment.