Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Adapt mapping to the new Generic Data Model #67

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/********************************************************************************
* Copyright (c) 2022,2023 BMW Group AG
* Copyright (c) 2022,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 org.eclipse.tractusx.valueaddedservice.dto.bpdm.gate;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class GateBusinessPartnerLegalEntityDto {
private String legalEntityBpn;
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ public class GateBusinessPartnerOutputDto {
private List<String> nameParts;
private Collection<BusinessPartnerRole> roles;
private boolean isOwnCompanyData;
private String legalEntityBpn;
private GateBusinessPartnerLegalEntityDto legalEntity;
private String legalName;
private String shortName;
private String siteBpn;
private String addressBpn;
private GateBusinessPartnerPostalAddressDto postalAddress;
private GateBusinessPartnerSiteDto site;
private GateBusinessPartnerPostalAddressDto address;

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
@Setter
@ToString
public class GateBusinessPartnerPostalAddressDto {
private String addressBpn;
private AddressType addressType;
private PhysicalPostalAddressDto physicalPostalAddress;
private AlternativePostalAddressDto alternativePostalAddress;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/********************************************************************************
* Copyright (c) 2022,2023 BMW Group AG
* Copyright (c) 2022,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 org.eclipse.tractusx.valueaddedservice.dto.bpdm.gate;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Setter
@Getter
@ToString
public class GateBusinessPartnerSiteDto {
private String siteBpn;
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,18 @@ private HttpEntity<Object> createHttpEntity(Object body) {
}
private Map<AddressType, Map<String, Collection<BusinessPartnerRole>>> processBusinessPartners(List<GateBusinessPartnerOutputDto> list) {
Map<AddressType, Map<String, Collection<BusinessPartnerRole>>> map = new HashMap<>();
list.forEach(dto -> Optional.ofNullable(dto.getPostalAddress().getAddressType()).ifPresent(type -> processAddressType(map, type, dto)));
list.forEach(dto -> Optional.ofNullable(dto.getAddress().getAddressType()).ifPresent(type -> processAddressType(map, type, dto)));
return map;
}

private void processAddressType(Map<AddressType, Map<String, Collection<BusinessPartnerRole>>> map, AddressType addressType, GateBusinessPartnerOutputDto dto) {
if (EnumSet.of(AddressType.LegalAndSiteMainAddress, AddressType.LegalAddress).contains(addressType)) {
addToList(map, AddressType.LegalAddress, dto.getRoles(),dto.getLegalEntityBpn());
addToList(map, AddressType.LegalAddress, dto.getRoles(),dto.getLegalEntity().getLegalEntityBpn());
}
if (EnumSet.of(AddressType.LegalAndSiteMainAddress, AddressType.SiteMainAddress).contains(addressType)) {
addToList(map, AddressType.SiteMainAddress, dto.getRoles(),dto.getSiteBpn());
addToList(map, AddressType.SiteMainAddress, dto.getRoles(),dto.getSite().getSiteBpn());
}
addToList(map, AddressType.AdditionalAddress, dto.getRoles(),dto.getAddressBpn());
addToList(map, AddressType.AdditionalAddress, dto.getRoles(),dto.getAddress().getAddressBpn());
}

private void addToList(Map<AddressType, Map<String,Collection<BusinessPartnerRole>>> map, AddressType key, Collection<BusinessPartnerRole> roles, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,29 +260,56 @@ public static void mocKConnectionToBpdmGateGeneric(WireMockServer mockServer) th
" \"totalElements\": 4,\n" +
" \"totalPages\": 1,\n" +
" \"page\": 0,\n" +
" \"contentSize\": 1,\n" +
" \"contentSize\": 4,\n" +
" \"content\": [\n" +
" \n" +
" {\n" +
" \"externalId\": \"12237777\",\n" +
" \"nameParts\": [\n" +
" \"E2E Tests 1223 Generic Endpoint Company 1\"\n" +
" ],\n" +
" \"shortName\": \"Generic Endpoint Company 1\",\n" +
" \"identifiers\": [\n" +
" {\n" +
" \"type\": \"CUSTOM_ID_TYPE\",\n" +
" \"value\": \"12237777\",\n" +
" \"issuingBody\": \"CUSTOM_ISSUE_BODY\"\n" +
" }\n" +
" ],\n" +
" \"legalName\": null,\n" +
" \"legalForm\": null,\n" +
" \"states\": [],\n" +
" \"classifications\": [],\n" +
" \"roles\": [\n" +
" \"SUPPLIER\"\n" +
" ],\n" +
" \"postalAddress\": {\n" +
" \"isOwnCompanyData\": false,\n" +
" \"legalEntity\": {\n" +
" \"legalEntityBpn\": \"BPNL00000007QTKE\",\n" +
" \"legalName\": null,\n" +
" \"shortName\": \"Generic Endpoint Company 1\",\n" +
" \"legalForm\": null,\n" +
" \"classifications\": [],\n" +
" \"confidenceCriteria\": {\n" +
" \"sharedByOwner\": false,\n" +
" \"checkedByExternalDataSource\": false,\n" +
" \"numberOfBusinessPartners\": 1,\n" +
" \"lastConfidenceCheckAt\": \"2024-01-04T09:47:12.667671\",\n" +
" \"nextConfidenceCheckAt\": \"2024-01-04T09:47:12.667671\",\n" +
" \"confidenceLevel\": 0\n" +
" }\n" +
" },\n" +
" \"site\": {\n" +
" \"siteBpn\": \"BPNS0000000001YN\",\n" +
" \"name\": null,\n" +
" \"confidenceCriteria\": {\n" +
" \"sharedByOwner\": false,\n" +
" \"checkedByExternalDataSource\": false,\n" +
" \"numberOfBusinessPartners\": 1,\n" +
" \"lastConfidenceCheckAt\": \"2024-01-05T09:26:02.009513\",\n" +
" \"nextConfidenceCheckAt\": \"2024-01-05T09:26:02.009513\",\n" +
" \"confidenceLevel\": 0\n" +
" }\n" +
" },\n" +
" \"address\": {\n" +
" \"addressBpn\": \"BPNA000000006X3N\",\n" +
" \"name\": null,\n" +
" \"addressType\": \"LegalAndSiteMainAddress\",\n" +
" \"physicalPostalAddress\": {\n" +
" \"geographicCoordinates\": null,\n" +
Expand All @@ -300,6 +327,7 @@ public static void mocKConnectionToBpdmGateGeneric(WireMockServer mockServer) th
" \"nameSuffix\": null,\n" +
" \"additionalNameSuffix\": null,\n" +
" \"houseNumber\": \"1\",\n" +
" \"houseNumberSupplement\": null,\n" +
" \"milestone\": null,\n" +
" \"direction\": null\n" +
" },\n" +
Expand All @@ -309,8 +337,27 @@ public static void mocKConnectionToBpdmGateGeneric(WireMockServer mockServer) th
" \"floor\": null,\n" +
" \"door\": null\n" +
" },\n" +
" \"alternativePostalAddress\": null\n" +
" }\n" +
" \"alternativePostalAddress\": {\n" +
" \"geographicCoordinates\": null,\n" +
" \"country\": null,\n" +
" \"administrativeAreaLevel1\": null,\n" +
" \"postalCode\": null,\n" +
" \"city\": null,\n" +
" \"deliveryServiceType\": null,\n" +
" \"deliveryServiceQualifier\": null,\n" +
" \"deliveryServiceNumber\": null\n" +
" },\n" +
" \"confidenceCriteria\": {\n" +
" \"sharedByOwner\": false,\n" +
" \"checkedByExternalDataSource\": false,\n" +
" \"numberOfBusinessPartners\": 1,\n" +
" \"lastConfidenceCheckAt\": \"2024-01-04T09:47:12.667671\",\n" +
" \"nextConfidenceCheckAt\": \"2024-01-04T09:47:12.667671\",\n" +
" \"confidenceLevel\": 0\n" +
" }\n" +
" },\n" +
" \"createdAt\": \"2023-11-14T18:17:00.030818Z\",\n" +
" \"updatedAt\": \"2023-11-14T18:17:00.030823Z\"\n" +
" }\n" +
" ]\n" +
"}\n")));
Expand Down