Skip to content

Commit

Permalink
Merge pull request #203 from catenax-ng/feat/api_rename_bpn_fields
Browse files Browse the repository at this point in the history
Feat/api rename bpn fields
  • Loading branch information
nicoprow authored May 30, 2023
2 parents bc791a8 + 77e8522 commit ddcb1fb
Show file tree
Hide file tree
Showing 27 changed files with 230 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GateUpdateService(
) {
for (entity in responseWrapper.entities) {
val externalId = entity.index
buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, entity.legalEntity.bpn, true)
buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, entity.legalEntity.bpnl, true)
?.let { gateClient.sharingState().upsertSharingState(it) }
}
for (errorInfo in responseWrapper.errors) {
Expand All @@ -57,7 +57,7 @@ class GateUpdateService(
externalIdByBpn: Map<String, String>
) {
for (entity in responseWrapper.entities) {
val bpn = entity.legalEntity.bpn
val bpn = entity.legalEntity.bpnl
val externalId = externalIdByBpn[bpn]
buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, bpn, false)
?.let { gateClient.sharingState().upsertSharingState(it) }
Expand All @@ -76,7 +76,7 @@ class GateUpdateService(
) {
for (entity in responseWrapper.entities) {
val externalId = entity.index
buildSuccessSharingStateDto(LsaType.Site, externalId, entity.site.bpn, true)
buildSuccessSharingStateDto(LsaType.Site, externalId, entity.site.bpns, true)
?.let { gateClient.sharingState().upsertSharingState(it) }
}
for (errorInfo in responseWrapper.errors) {
Expand All @@ -92,7 +92,7 @@ class GateUpdateService(
externalIdByBpn: Map<String, String>
) {
for (entity in responseWrapper.entities) {
val bpn = entity.site.bpn
val bpn = entity.site.bpns
val externalId = externalIdByBpn[bpn]
buildSuccessSharingStateDto(LsaType.Site, externalId, bpn, false)
?.let { gateClient.sharingState().upsertSharingState(it) }
Expand All @@ -111,7 +111,7 @@ class GateUpdateService(
) {
for (entity in responseWrapper.entities) {
val externalId = entity.index
buildSuccessSharingStateDto(LsaType.Address, externalId, entity.address.bpn, true)
buildSuccessSharingStateDto(LsaType.Address, externalId, entity.address.bpna, true)
?.let { gateClient.sharingState().upsertSharingState(it) }
}
for (errorInfo in responseWrapper.errors) {
Expand All @@ -127,7 +127,7 @@ class GateUpdateService(
externalIdByBpn: Map<String, String>
) {
for (entity in responseWrapper.entities) {
val bpn = entity.bpn
val bpn = entity.bpna
val externalId = externalIdByBpn[bpn]
buildSuccessSharingStateDto(LsaType.Address, externalId, bpn, false)
?.let { gateClient.sharingState().upsertSharingState(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PoolUpdateService(
val updateRequests = entriesToUpdate.map {
LegalEntityPartnerUpdateRequest(
legalEntity = it.legalEntity,
bpn = it.bpn!!
bpnl = it.bpn!!
)
}

Expand All @@ -71,7 +71,7 @@ class PoolUpdateService(
SitePartnerCreateRequest(
site = entry.site,
index = entry.externalId,
bpnParent = leParentBpn
bpnlParent = leParentBpn
)
}
}
Expand All @@ -90,7 +90,7 @@ class PoolUpdateService(
val updateRequests = entriesToUpdate.map {
SitePartnerUpdateRequest(
site = it.site,
bpn = it.bpn!!
bpns = it.bpn!!
)
}

Expand Down Expand Up @@ -142,7 +142,7 @@ class PoolUpdateService(
val updateRequests = entriesToUpdate.map {
AddressPartnerUpdateRequest(
address = it.address,
bpn = it.bpn!!
bpna = it.bpn!!
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.time.Instant
@Schema(name = "LegalEntityResponse", description = "Legal entity record")
data class LegalEntityResponse(
@get:Schema(description = "Business Partner Number of this legal entity")
val bpn: String,
val bpnl: String,

@ArraySchema(arraySchema = Schema(description = "All identifiers of the business partner, including BPN information"))
val identifiers: Collection<LegalEntityIdentifierResponse> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import java.time.Instant
data class LogisticAddressResponse(

@get:Schema(description = "Business Partner Number of this address")
val bpn: String,
val bpna: String,

@get:Schema(
description = "Name of the logistic address of the business partner. This is not according to official\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import java.time.Instant
@Schema(name = "SiteResponse", description = "Site of a legal entity")
data class SiteResponse(
@get:Schema(description = "Business Partner Number, main identifier value for sites")
val bpn: String,
val bpns: String,

@get:Schema(description = "Site name")
val name: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AddressService(

//Search entries in the pool with BPNs found in the local mirror
val bpnSet = partnersWithLocalBpn.map { it.bpn }.toSet()
val addressesByBpnMap = poolClient.searchAddresses(bpnSet).associateBy { it.bpn }
val addressesByBpnMap = poolClient.searchAddresses(bpnSet).associateBy { it.bpna }

if (bpnSet.size > addressesByBpnMap.size) {
logger.warn { "Requested ${bpnSet.size} addresses from pool, but only ${addressesByBpnMap.size} were found." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class LegalEntityService(

//Search entries in the pool with BPNs found in the local mirror
val bpnSet = partnersWithLocalBpn.map { it.bpn }.toSet()
val legalEntitiesByBpnMap = poolClient.searchLegalEntities(bpnSet).associateBy { it.bpn }
val legalEntitiesByBpnMap = poolClient.searchLegalEntities(bpnSet).associateBy { it.bpnl }
val legalAddressesByBpnMap = poolClient.searchLegalAddresses(bpnSet).associateBy { it.bpnLegalEntity }

if (bpnSet.size > legalEntitiesByBpnMap.size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SiteService(
val partnersWithLocalBpn = outputSaasMappingService.mapWithLocalBpn(partnersWithExternalId, augmentedPartnerResponse.values)

val bpnSet = partnersWithLocalBpn.map { it.bpn }.toSet()
val sitesByBpnMap = poolClient.searchSites(bpnSet).associateBy { it.bpn }
val sitesByBpnMap = poolClient.searchSites(bpnSet).associateBy { it.bpns }
val mainAddressesByBpnMap = poolClient.searchMainAddresses(bpnSet).associateBy { it.bpnSite }

if (bpnSet.size > sitesByBpnMap.size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ object ResponseValues {
)

val logisticAddress1 = LogisticAddressResponse(
bpn = CommonValues.bpnAddress1,
bpna = CommonValues.bpnAddress1,
physicalPostalAddress = address1,
bpnLegalEntity = CommonValues.bpn1,
bpnSite = "BPNS0000000001XY",
Expand All @@ -212,7 +212,7 @@ object ResponseValues {
)

val logisticAddress2 = LogisticAddressResponse(
bpn = CommonValues.bpnAddress2,
bpna = CommonValues.bpnAddress2,
physicalPostalAddress = address2,
bpnLegalEntity = CommonValues.bpn2,
bpnSite = "BPNS0000000002XY",
Expand All @@ -222,7 +222,7 @@ object ResponseValues {


val legalEntityResponse1 = LegalEntityResponse(
bpn = CommonValues.bpn1,
bpnl = CommonValues.bpn1,
identifiers = listOf(identifier1, identifier2),
legalName = name1,
legalForm = legalForm1,
Expand All @@ -234,7 +234,7 @@ object ResponseValues {
)

val legalEntityResponse2 = LegalEntityResponse(
bpn = CommonValues.bpn2,
bpnl = CommonValues.bpn2,
identifiers = listOf(identifier3, identifier4),
legalName = name3,
legalForm = legalForm2,
Expand Down Expand Up @@ -293,15 +293,15 @@ object ResponseValues {
)

val siteResponse1 = SiteResponse(
bpn = CommonValues.bpnSite1,
bpns = CommonValues.bpnSite1,
name = CommonValues.nameSite1,
states = listOf(),
bpnLegalEntity = CommonValues.bpn1,
createdAt = CommonValues.now,
updatedAt = CommonValues.now
)
val siteResponse2 = SiteResponse(
bpn = CommonValues.bpnSite2,
bpns = CommonValues.bpnSite2,
name = CommonValues.nameSite2,
states = listOf(),
bpnLegalEntity = CommonValues.bpn2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,20 @@ interface PoolAddressApi {
): PageResponse<AddressMatchResponse>

@Operation(
summary = "Get address partners by bpn",
summary = "Get address partners by bpna",
description = "Get business partners of type address by bpn-a ignoring case."
)
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "Found address with specified bpn"),
ApiResponse(responseCode = "200", description = "Found address with specified bpna"),
ApiResponse(responseCode = "400", description = "On malformed request parameters", content = [Content()]),
ApiResponse(responseCode = "404", description = "No address found under specified bpn", content = [Content()])
ApiResponse(responseCode = "404", description = "No address found under specified bpna", content = [Content()])
]
)
@GetMapping("/{bpn}")
@GetExchange("/{bpn}")
@GetMapping("/{bpna}")
@GetExchange("/{bpna}")
fun getAddress(
@Parameter(description = "Bpn value") @PathVariable bpn: String
@Parameter(description = "Bpn value") @PathVariable bpna: String
): LogisticAddressResponse

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ interface PoolLegalEntityApi {
@Operation(
summary = "Confirms that the data of a legal entity business partner is still up to date.",
description = "Confirms that the data of a business partner is still up to date " +
"by saving the current timestamp at the time this POST-request is made as this business partner's \"currentness\". Ignores case of bpn."
"by saving the current timestamp at the time this POST-request is made as this business partner's \"currentness\". Ignores case of bpnl."
)
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "Business partner's \"currentness\" successfully updated"),
ApiResponse(responseCode = "400", description = "On malformed request parameters", content = [Content()]),
ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()])
ApiResponse(responseCode = "404", description = "No business partner found for specified bpnl", content = [Content()])
]
)
@PostMapping("/{bpn}/confirm-up-to-date")
@PostExchange("/{bpn}/confirm-up-to-date")
@PostMapping("/{bpnl}/confirm-up-to-date")
@PostExchange("/{bpnl}/confirm-up-to-date")
fun setLegalEntityCurrentness(
@Parameter(description = "Bpn value") @PathVariable bpn: String
@Parameter(description = "Bpnl value") @PathVariable bpnl: String
)

@Operation(
Expand All @@ -134,19 +134,19 @@ interface PoolLegalEntityApi {

@Operation(
summary = "Get site partners of a legal entity",
description = "Get business partners of type site belonging to a business partner of type legal entity, identified by the business partner's bpn ignoring case."
description = "Get business partners of type site belonging to a business partner of type legal entity, identified by the business partner's bpnl ignoring case."
)
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "The sites for the specified bpn"),
ApiResponse(responseCode = "200", description = "The sites for the specified bpnl"),
ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]),
ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()])
ApiResponse(responseCode = "404", description = "No business partner found for specified bpnl", content = [Content()])
]
)
@GetMapping("/{bpn}/sites")
@GetExchange("/{bpn}/sites")
@GetMapping("/{bpnl}/sites")
@GetExchange("/{bpnl}/sites")
fun getSites(
@Parameter(description = "Bpn value") @PathVariable bpn: String,
@Parameter(description = "Bpnl value") @PathVariable bpnl: String,
@ParameterObject paginationRequest: PaginationRequest
): PageResponse<SiteResponse>

Expand All @@ -161,10 +161,10 @@ interface PoolLegalEntityApi {
ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()])
]
)
@GetMapping("/{bpn}/addresses")
@GetExchange("/{bpn}/addresses")
@GetMapping("/{bpnl}/addresses")
@GetExchange("/{bpnl}/addresses")
fun getAddresses(
@Parameter(description = "Bpn value") @PathVariable bpn: String,
@Parameter(description = "Bpn value") @PathVariable bpnl: String,
@ParameterObject paginationRequest: PaginationRequest
): PageResponse<LogisticAddressResponse>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ
@Schema(name = "AddressPartnerUpdateRequest", description = "Request for updating a business partner record of type address")
data class AddressPartnerUpdateRequest(
@Schema(description = "Business Partner Number of this address")
val bpn: String,
val bpna: String,

@field:JsonUnwrapped
val address: LogisticAddressDto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ
@Schema(name = "LegalEntityUpdateRequest", description = "Request for updating a business partner record of type legal entity")
data class LegalEntityPartnerUpdateRequest(
@Schema(description = "Business Partner Number")
val bpn: String,
val bpnl: String,

@field:JsonUnwrapped
val legalEntity: LegalEntityDto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ data class SitePartnerCreateRequest(
val site: SiteDto,

@Schema(description = "Business Partner Number of the legal entity this site belongs to")
val bpnParent: String,
val bpnlParent: String,

@Schema(description = "User defined index to conveniently match this entry to the corresponding entry in the response")
val index: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ
@Schema(name = "SitePartnerUpdateRequest", description = "Request for updating a business partner record of type site")
data class SitePartnerUpdateRequest(
@Schema(description = "Business Partner Number of this site")
val bpn: String,
val bpns: String,

@field:JsonUnwrapped
val site: SiteDto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class AddressController(
}

override fun getAddress(
bpn: String
bpna: String
): LogisticAddressResponse {
return addressService.findByBpn(bpn.uppercase())
return addressService.findByBpn(bpna.uppercase())
}

override fun searchAddresses(
Expand All @@ -68,7 +68,7 @@ class AddressController(

override fun createAddresses(
requests: Collection<AddressPartnerCreateRequest>
): AddressPartnerCreateResponseWrapper {
): AddressPartnerCreateResponseWrapper {
return businessPartnerBuildService.createAddresses(requests)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ class LegalEntityController(
}


override fun setLegalEntityCurrentness(bpn: String) {
businessPartnerBuildService.setBusinessPartnerCurrentness(bpn.uppercase())
override fun setLegalEntityCurrentness(bpnl: String) {
businessPartnerBuildService.setBusinessPartnerCurrentness(bpnl.uppercase())
}

override fun searchSites(
Expand All @@ -86,18 +86,18 @@ class LegalEntityController(
}

override fun getSites(
bpn: String,
bpnl: String,
paginationRequest: PaginationRequest
): PageResponse<SiteResponse> {
return siteService.findByPartnerBpn(bpn.uppercase(), paginationRequest.page, paginationRequest.size)
return siteService.findByPartnerBpn(bpnl.uppercase(), paginationRequest.page, paginationRequest.size)
}


override fun getAddresses(
bpn: String,
bpnl: String,
paginationRequest: PaginationRequest
): PageResponse<LogisticAddressResponse> {
return addressService.findByPartnerBpn(bpn.uppercase(), paginationRequest.page, paginationRequest.size)
return addressService.findByPartnerBpn(bpnl.uppercase(), paginationRequest.page, paginationRequest.size)
}


Expand All @@ -114,7 +114,8 @@ class LegalEntityController(
return businessPartnerBuildService.createLegalEntities(businessPartners)
}

override fun updateBusinessPartners(businessPartners: Collection<LegalEntityPartnerUpdateRequest>
override fun updateBusinessPartners(
businessPartners: Collection<LegalEntityPartnerUpdateRequest>
): LegalEntityPartnerUpdateResponseWrapper {
return businessPartnerBuildService.updateLegalEntities(businessPartners)
}
Expand Down
Loading

0 comments on commit ddcb1fb

Please sign in to comment.