From cad2ae0af9ed2062edfa1ca0cf68e2ddd10a6d2b Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Tue, 30 May 2023 15:54:48 +0100 Subject: [PATCH 01/83] feat(Gate-Pool): Add workflow to push images to dockerhub --- .github/workflows/build-docker.yaml | 63 +++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index d1f92ee27..bb54cc69a 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -16,24 +16,27 @@ on: type: boolean description: Whether to also push created image or just build it - env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }}/${{ inputs.imageName }} + DOCKER_IMAGE_NAMESPACE: "tractusx" + DOCKER_IMAGE_NAME: ${{ inputs.imageName }} + jobs: build-docker: runs-on: ubuntu-latest permissions: packages: write + steps: - name: Checkout uses: actions/checkout@v3 # Create SemVer or ref tags dependent of trigger event - name: Docker meta - id: meta + id: meta1 uses: docker/metadata-action@v4 with: images: | @@ -59,5 +62,57 @@ jobs: context: . push: ${{ inputs.push }} file: ${{ inputs.dockerfilePath }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + tags: ${{ steps.meta1.outputs.tags }} + labels: ${{ steps.meta1.outputs.labels }} + + # Create SemVer or ref tags dependent of trigger event + - name: Docker meta hub + id: meta2 + uses: docker/metadata-action@v4 + with: + images: | + ${{ env.DOCKER_IMAGE_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} + # Automatically prepare image tags; See action docs for more examples. + # semver patter will generate tags like these for example :1 :1.2 :1.2.3 + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}} + type=semver,pattern={{major}}.{{minor}} + + - name: DockerHub login + env: + DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} + if: env.DOCKER_HUB_USER == '' + uses: docker/login-action@v2 + with: + # Use existing DockerHub credentials present as secrets + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + - name: Build and push + env: + DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} + if: env.DOCKER_HUB_USER == '' + uses: docker/build-push-action@v3 + with: + context: . + # Build image for verification purposes on every trigger event. Only push if event is not a PR + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta2.outputs.tags }} + labels: ${{ steps.meta2.outputs.labels }} + + # https://github.com/peter-evans/dockerhub-description + # Important step to push image description to DockerHub + - name: Update Docker Hub description + env: + DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} + if: env.DOCKER_HUB_USER == '' + uses: peter-evans/dockerhub-description@v3 + with: + # readme-filepath defaults to toplevel README.md, Only necessary if you have a dedicated file with your 'Notice for docker images' + # readme-filepath: path/to/dedicated/notice-for-docker-image.md + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} + repository: ${{ env.DOCKER_IMAGE_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} From df7ef87fdc19351d1098dfe090e1c92a1b9ba623 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Wed, 31 May 2023 14:25:51 +0100 Subject: [PATCH 02/83] feat(Gate-Pool): Add trigger from branch --- .github/workflows/build-docker-all.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docker-all.yaml b/.github/workflows/build-docker-all.yaml index 7bc9ac707..7325949fb 100644 --- a/.github/workflows/build-docker-all.yaml +++ b/.github/workflows/build-docker-all.yaml @@ -15,6 +15,7 @@ on: branches: - main - rc/** + - feat/dockerhub_images_release pull_request: branches: - main From 632ebbff766730f2baa28c747ae51f495025e1db Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 1 Jun 2023 16:33:56 +0100 Subject: [PATCH 03/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 57 +++++++++-------------------- 1 file changed, 18 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index bb54cc69a..7573a5ab3 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -16,12 +16,13 @@ on: type: boolean description: Whether to also push created image or just build it + env: # Use docker.io for Docker Hub if empty REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }}/${{ inputs.imageName }} - DOCKER_IMAGE_NAMESPACE: "tractusx" + DOCKER_HUB_REGISTRY_NAMESPACE: tractusx DOCKER_IMAGE_NAME: ${{ inputs.imageName }} jobs: @@ -29,14 +30,13 @@ jobs: runs-on: ubuntu-latest permissions: packages: write - steps: - name: Checkout uses: actions/checkout@v3 # Create SemVer or ref tags dependent of trigger event - name: Docker meta - id: meta1 + id: meta uses: docker/metadata-action@v4 with: images: | @@ -56,63 +56,42 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v3 + - name: Build and push to GHCR Registry ${{ env.REGISTRY }}/${{env.IMAGE_NAME }} + uses: docker/build-push-action@v4 with: context: . push: ${{ inputs.push }} file: ${{ inputs.dockerfilePath }} - tags: ${{ steps.meta1.outputs.tags }} - labels: ${{ steps.meta1.outputs.labels }} - - # Create SemVer or ref tags dependent of trigger event - - name: Docker meta hub - id: meta2 - uses: docker/metadata-action@v4 - with: - images: | - ${{ env.DOCKER_IMAGE_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} - # Automatically prepare image tags; See action docs for more examples. - # semver patter will generate tags like these for example :1 :1.2 :1.2.3 - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}} - type=semver,pattern={{major}}.{{minor}} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - - name: DockerHub login + - name: Login to Docker Hub env: DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} - if: env.DOCKER_HUB_USER == '' + if: env.DOCKER_HUB_USER != '' uses: docker/login-action@v2 with: - # Use existing DockerHub credentials present as secrets username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: Build and push + - name: Build and push for Docker Hub ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} env: DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} - if: env.DOCKER_HUB_USER == '' - uses: docker/build-push-action@v3 + if: env.DOCKER_HUB_USER != '' + uses: docker/build-push-action@v4 with: context: . - # Build image for verification purposes on every trigger event. Only push if event is not a PR - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta2.outputs.tags }} - labels: ${{ steps.meta2.outputs.labels }} + push: ${{ inputs.push }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} - # https://github.com/peter-evans/dockerhub-description - # Important step to push image description to DockerHub - name: Update Docker Hub description env: DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} - if: env.DOCKER_HUB_USER == '' + if: env.DOCKER_HUB_USER != '' uses: peter-evans/dockerhub-description@v3 with: - # readme-filepath defaults to toplevel README.md, Only necessary if you have a dedicated file with your 'Notice for docker images' - # readme-filepath: path/to/dedicated/notice-for-docker-image.md username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - repository: ${{ env.DOCKER_IMAGE_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} + repository: ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} + readme-filepath: DOCKER_NOTICE.md From 50f35981e8e70386322c3a2eb9ec011ca607f669 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 1 Jun 2023 17:58:54 +0100 Subject: [PATCH 04/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 7573a5ab3..6f44c95d4 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -68,7 +68,6 @@ jobs: - name: Login to Docker Hub env: DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} - if: env.DOCKER_HUB_USER != '' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_HUB_USER }} @@ -77,7 +76,6 @@ jobs: - name: Build and push for Docker Hub ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} env: DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} - if: env.DOCKER_HUB_USER != '' uses: docker/build-push-action@v4 with: context: . @@ -88,7 +86,6 @@ jobs: - name: Update Docker Hub description env: DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} - if: env.DOCKER_HUB_USER != '' uses: peter-evans/dockerhub-description@v3 with: username: ${{ secrets.DOCKER_HUB_USER }} From f23c735010f9b869cdecec2aa96f209765bf7e7d Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 2 Jun 2023 10:14:37 +0100 Subject: [PATCH 05/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 6f44c95d4..d7f1de7ec 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -66,16 +66,12 @@ jobs: labels: ${{ steps.meta.outputs.labels }} - name: Login to Docker Hub - env: - DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - name: Build and push for Docker Hub ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} - env: - DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} uses: docker/build-push-action@v4 with: context: . @@ -84,8 +80,6 @@ jobs: labels: ${{ steps.meta.outputs.labels }} - name: Update Docker Hub description - env: - DOCKER_HUB_USER: ${{ secrets.DOCKER_HUB_USER }} uses: peter-evans/dockerhub-description@v3 with: username: ${{ secrets.DOCKER_HUB_USER }} From 03b4b74d55f340ac4c423ce9cb6cad6064cca912 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 2 Jun 2023 10:24:29 +0100 Subject: [PATCH 06/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index d7f1de7ec..62eeb8f4e 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -68,6 +68,7 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v2 with: + registry: ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }} username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} From 19925a1468128c740b1a0f752aacb18d1a0cb2c5 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 2 Jun 2023 10:26:24 +0100 Subject: [PATCH 07/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 62eeb8f4e..e02d8c89b 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -68,7 +68,7 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v2 with: - registry: ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }} + registry: ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} From be12aca3491cc493d3ada26da87bc79e938ffb16 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 2 Jun 2023 10:26:45 +0100 Subject: [PATCH 08/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index e02d8c89b..029bafff3 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -65,7 +65,7 @@ jobs: tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - - name: Login to Docker Hub + - name: Login to Docker Hub ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }} uses: docker/login-action@v2 with: registry: ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} From 299a0e91d8875511f6fb22f25a7b7bc505c93837 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 2 Jun 2023 10:48:33 +0100 Subject: [PATCH 09/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- DOCKER_NOTICE.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 DOCKER_NOTICE.md diff --git a/DOCKER_NOTICE.md b/DOCKER_NOTICE.md new file mode 100644 index 000000000..56917a319 --- /dev/null +++ b/DOCKER_NOTICE.md @@ -0,0 +1,30 @@ +## Notice for Docker image + +DockerHub: [https://hub.docker.com/r/tractusx/portal-frontend](https://hub.docker.com/r/tractusx/portal-frontend) + +Eclipse Tractus-X product(s) installed within the image: + +__Portal frontend__ + +- GitHub: https://github.com/eclipse-tractusx/bpdm +- Project home: https://projects.eclipse.org/projects/automotive.tractusx +- Dockerfile: https://github.com/eclipse-tractusx/bpdm-gate/Dockerfile https://github.com/eclipse-tractusx/bpdm-pool/Dockerfile https://github.com/eclipse-tractusx/bpdm-bridge-dummy/Dockerfile +- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/portal-frontend/blob/main/LICENSE) + +__Used base images__ + + +Docker Hub: + +* [eclipse-temurin](https://hub.docker.com/_/eclipse-temurin) +* [17-jre-alpine](https://hub.docker.com/layers/library/eclipse-temurin/17-jre-alpine/images/sha256-02c04793fa49ad5cd193c961403223755f9209a67894622e05438598b32f210e?context=explore) + +Source: + +* [temurin-build](https://github.com/adoptium/temurin-build) +* [temurin docker repo info](https://github.com/docker-library/repo-info/tree/master/repos/eclipse-temurin) + +As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained). + +As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies +with any relevant licenses for all software contained within. \ No newline at end of file From 71cd0cc60c2436767d038aea5000aecb549f4e82 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 2 Jun 2023 10:54:22 +0100 Subject: [PATCH 10/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- DOCKER_NOTICE.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/DOCKER_NOTICE.md b/DOCKER_NOTICE.md index 56917a319..760716c04 100644 --- a/DOCKER_NOTICE.md +++ b/DOCKER_NOTICE.md @@ -1,30 +1,30 @@ ## Notice for Docker image -DockerHub: [https://hub.docker.com/r/tractusx/portal-frontend](https://hub.docker.com/r/tractusx/portal-frontend) +DockerHub: [https://hub.docker.com/r/tractusx/bpdm](https://hub.docker.com/r/tractusx/bpdm) Eclipse Tractus-X product(s) installed within the image: -__Portal frontend__ +__ BPDM __ -- GitHub: https://github.com/eclipse-tractusx/bpdm -- Project home: https://projects.eclipse.org/projects/automotive.tractusx -- Dockerfile: https://github.com/eclipse-tractusx/bpdm-gate/Dockerfile https://github.com/eclipse-tractusx/bpdm-pool/Dockerfile https://github.com/eclipse-tractusx/bpdm-bridge-dummy/Dockerfile -- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/portal-frontend/blob/main/LICENSE) - -__Used base images__ +Eclipse Tractus-X product(s) installed within the image: +- GitHub: https://github.com/eclipse-tractusx/bpdm> +- Project home: https://projects.eclipse.org/projects/automotive.tractusx +- Pool Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-pool/Dockerfile> +- Gate Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-gate/Dockerfile> +- Bridge Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-brige-dumy/Dockerfile> +- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/bpdm/blob/main/LICENSE) -Docker Hub: -* [eclipse-temurin](https://hub.docker.com/_/eclipse-temurin) -* [17-jre-alpine](https://hub.docker.com/layers/library/eclipse-temurin/17-jre-alpine/images/sha256-02c04793fa49ad5cd193c961403223755f9209a67894622e05438598b32f210e?context=explore) +**Used base image** -Source: +- [eclipse-temurin:17-jre-alpine](https://github.com/adoptium/containers) +- Official Eclipse Temurin DockerHub page: https://hub.docker.com/_/eclipse-temurin +- Eclipse Temurin Project: https://projects.eclipse.org/projects/adoptium.temurin +- Additional information about the Eclipse Temurin images: https://github.com/docker-library/repo-info/tree/master/repos/eclipse-temurin -* [temurin-build](https://github.com/adoptium/temurin-build) -* [temurin docker repo info](https://github.com/docker-library/repo-info/tree/master/repos/eclipse-temurin) -As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained). +As with all Docker images, these likely also contain other software which may be under other licenses +(such as Bash, etc. from the base distribution, along with any direct or indirect dependencies of the primary software being contained). -As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies -with any relevant licenses for all software contained within. \ No newline at end of file +As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within. \ No newline at end of file From 5144d71d4c47908ca43983cd7c590841e298a3fe Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 2 Jun 2023 11:15:33 +0100 Subject: [PATCH 11/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 35 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 029bafff3..f7696264f 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -48,22 +48,25 @@ jobs: type=semver,pattern={{major}} type=semver,pattern={{major}}.{{minor}} - - name: Log into registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push to GHCR Registry ${{ env.REGISTRY }}/${{env.IMAGE_NAME }} - uses: docker/build-push-action@v4 - with: - context: . - push: ${{ inputs.push }} - file: ${{ inputs.dockerfilePath }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} +# - name: Log into registry ${{ env.REGISTRY }} +# if: github.event_name != 'pull_request' +# uses: docker/login-action@v2 +# with: +# registry: ${{ env.REGISTRY }} +# username: ${{ github.actor }} +# password: ${{ secrets.GITHUB_TOKEN }} +# +# - name: Build and push to GHCR Registry ${{ env.REGISTRY }}/${{env.IMAGE_NAME }} +# uses: docker/build-push-action@v4 +# with: +# context: . +# push: ${{ inputs.push }} +# file: ${{ inputs.dockerfilePath }} +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} +# +# - name: Checkout from registry ${{ env.REGISTRY }} +# uses: actions/checkout@v3 - name: Login to Docker Hub ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }} uses: docker/login-action@v2 From 175e3f5c2bd7247829de8641114c8d93d0ee0191 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 2 Jun 2023 11:18:28 +0100 Subject: [PATCH 12/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index f7696264f..51af54a4f 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -18,8 +18,6 @@ on: env: - # Use docker.io for Docker Hub if empty - REGISTRY: ghcr.io # github.repository as / IMAGE_NAME: ${{ github.repository }}/${{ inputs.imageName }} DOCKER_HUB_REGISTRY_NAMESPACE: tractusx From 768c7452449ec944022bd23f0d99d7532431156e Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 2 Jun 2023 11:27:35 +0100 Subject: [PATCH 13/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 51af54a4f..fc67cb2a5 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -69,7 +69,6 @@ jobs: - name: Login to Docker Hub ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }} uses: docker/login-action@v2 with: - registry: ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} From 426e54a0eb5796e7f27622270822f219df1a3ce3 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Wed, 31 May 2023 16:20:11 +0200 Subject: [PATCH 14/83] feat(api): #179 Pool API: Legal Entity Response should include Legal Address --- .../bridge/dummy/service/GateUpdateService.kt | 4 +- .../dto/response/LegalEntityResponse.kt | 8 +- .../dto/response/PoolLegalEntityResponse.kt | 32 +--- .../api/model/LegalEntityGateInputRequest.kt | 3 +- .../gate/api/model/LegalEntityGateOutput.kt | 7 +- .../bpdm/gate/service/LegalEntityService.kt | 24 +-- .../tractusx/bpdm/gate/util/ResponseValues.kt | 51 ++--- .../LegalEntityPartnerUpdateRequest.kt | 2 +- .../model/response/BusinessPartnerResponse.kt | 10 +- .../response/LegalEntityMatchResponse.kt | 9 +- .../LegalEntityPartnerCreateResponse.kt | 13 +- .../service/BusinessPartnerFetchService.kt | 6 +- .../bpdm/pool/service/ResponseMappings.kt | 32 +++- .../controller/OpenSearchControllerIT.kt | 2 +- .../BusinessPartnerLegacyControllerIT.kt | 9 +- .../controller/LegalEntityControllerIT.kt | 48 ++--- .../LegalEntityControllerSearchIT.kt | 20 +- .../pool/controller/SuggestionControllerIT.kt | 10 +- .../tractusx/bpdm/pool/util/ResponseValues.kt | 174 +++++++++++++----- 19 files changed, 278 insertions(+), 186 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt index d79a8e11a..8da1877f2 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt @@ -41,7 +41,7 @@ class GateUpdateService( ) { for (entity in responseWrapper.entities) { val externalId = entity.index - buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, entity.legalEntity.bpnl, true) + buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, entity.poolLegalEntity.bpnl, true) ?.let { gateClient.sharingState().upsertSharingState(it) } } for (errorInfo in responseWrapper.errors) { @@ -57,7 +57,7 @@ class GateUpdateService( externalIdByBpn: Map ) { for (entity in responseWrapper.entities) { - val bpn = entity.legalEntity.bpnl + val bpn = entity.poolLegalEntity.bpnl val externalId = externalIdByBpn[bpn] buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, bpn, false) ?.let { gateClient.sharingState().upsertSharingState(it) } diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt index 8565e6070..2571e47e2 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt @@ -47,6 +47,9 @@ data class LegalEntityResponse( @ArraySchema(arraySchema = Schema(description = "Relations to other business partners")) val relations: Collection = emptyList(), + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressResponse, + @get:Schema(description = "The timestamp the business partner data was last indicated to be still current") val currentness: Instant, @@ -54,5 +57,6 @@ data class LegalEntityResponse( val createdAt: Instant, @get:Schema(description = "The timestamp the business partner data was last updated") - val updatedAt: Instant -) + val updatedAt: Instant, + + ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt index 5eee89e06..b5c6db780 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt @@ -19,42 +19,14 @@ package org.eclipse.tractusx.bpdm.common.dto.response -import io.swagger.v3.oas.annotations.media.ArraySchema import io.swagger.v3.oas.annotations.media.Schema -import java.time.Instant @Schema(name = "PoolLegalEntityResponse", description = "Legal entity record") data class PoolLegalEntityResponse( - @get:Schema(description = "Business Partner Number of this legal entity") - val bpnl: String, - - @ArraySchema(arraySchema = Schema(description = "All identifiers of the business partner, including BPN information")) - val identifiers: Collection = emptyList(), @get:Schema(description = "Legal name the partner goes by") val legalName: String, - @get:Schema(description = "Abbreviated name or shorthand") - val legalShortName: String? = null, - - @get:Schema(description = "Legal form of the business partner") - val legalForm: LegalFormResponse? = null, - - @ArraySchema(arraySchema = Schema(description = "Business status")) - val states: Collection = emptyList(), - - @ArraySchema(arraySchema = Schema(description = "Classifications")) - val classifications: Collection = emptyList(), - - @ArraySchema(arraySchema = Schema(description = "Relations to other business partners")) - val relations: Collection = emptyList(), - - @get:Schema(description = "The timestamp the business partner data was last indicated to be still current") - val currentness: Instant, - - @get:Schema(description = "The timestamp the business partner data was created") - val createdAt: Instant, - - @get:Schema(description = "The timestamp the business partner data was last updated") - val updatedAt: Instant + @Schema(description = "Legal Entity") + val legalEntity: LegalEntityResponse, ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt index 214da1c51..b9571200e 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model -import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto @@ -31,7 +30,7 @@ data class LegalEntityGateInputRequest( val legalNameParts: Array = emptyArray(), - @field:JsonUnwrapped + @Schema(description = "legal Enity") val legalEntity: LegalEntityDto, @Schema(description = "ID the record has in the external system where the record originates from", required = true) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt index 1c53115ba..6cdbcf9ed 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt @@ -20,11 +20,9 @@ package org.eclipse.tractusx.bpdm.gate.api.model -import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @@ -33,12 +31,9 @@ data class LegalEntityGateOutput( val legalNameParts: Array = emptyArray(), - @field:JsonUnwrapped + @Schema(description = "Legal Entity") val legalEntity: LegalEntityResponse, - @Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressResponse, - @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index fe1dbc3f1..cfe6772a8 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -99,7 +99,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.bpnl } + val legalEntitiesByBpnMap = poolClient.searchLegalEntities(bpnSet).associateBy { it.legalEntity.bpnl } val legalAddressesByBpnMap = poolClient.searchLegalAddresses(bpnSet).associateBy { it.bpnLegalEntity } if (bpnSet.size > legalEntitiesByBpnMap.size) { @@ -136,19 +136,19 @@ class LegalEntityService( fun toLegalEntityOutput(externalId: String, legalEntityPool: PoolLegalEntityResponse, legalAddress: LogisticAddressResponse): LegalEntityGateOutput = LegalEntityGateOutput( legalEntity = LegalEntityResponse( - bpnl = legalEntityPool.bpnl, - identifiers = legalEntityPool.identifiers, - legalShortName = legalEntityPool.legalShortName, - legalForm = legalEntityPool.legalForm, - states = legalEntityPool.states, - classifications = legalEntityPool.classifications, - relations = legalEntityPool.relations, - currentness = legalEntityPool.currentness, - createdAt = legalEntityPool.createdAt, - updatedAt = legalEntityPool.updatedAt, + bpnl = legalEntityPool.legalEntity.bpnl, + identifiers = legalEntityPool.legalEntity.identifiers, + legalShortName = legalEntityPool.legalEntity.legalShortName, + legalForm = legalEntityPool.legalEntity.legalForm, + states = legalEntityPool.legalEntity.states, + classifications = legalEntityPool.legalEntity.classifications, + relations = legalEntityPool.legalEntity.relations, + currentness = legalEntityPool.legalEntity.currentness, + createdAt = legalEntityPool.legalEntity.createdAt, + updatedAt = legalEntityPool.legalEntity.updatedAt, + legalAddress = legalEntityPool.legalEntity.legalAddress, ), legalNameParts = arrayOf(legalEntityPool.legalName), - legalAddress = legalAddress, externalId = externalId ) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index bc9bef591..8a68726b5 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -201,29 +201,36 @@ object ResponseValues { ) val legalEntityResponsePool1 = PoolLegalEntityResponse( - bpnl = CommonValues.bpn1, - identifiers = listOf(identifier1, identifier2), - legalShortName = CommonValues.shortName1, legalName = CommonValues.name1, - legalForm = legalForm1, - states = listOf(leBusinessStatus1), - classifications = listOf(classification1, classification2), - currentness = CommonValues.now, - createdAt = CommonValues.now, - updatedAt = CommonValues.now + LegalEntityResponse( + bpnl = CommonValues.bpn1, + identifiers = listOf(identifier1, identifier2), + legalShortName = CommonValues.shortName1, + legalForm = legalForm1, + states = listOf(leBusinessStatus1), + classifications = listOf(classification1, classification2), + currentness = CommonValues.now, + createdAt = CommonValues.now, + updatedAt = CommonValues.now, + legalAddress = logisticAddress1 + ) + ) val legalEntityResponsePool2 = PoolLegalEntityResponse( - bpnl = CommonValues.bpn2, - identifiers = listOf(identifier3, identifier4), - legalShortName = CommonValues.shortName3, legalName = CommonValues.name3, - legalForm = legalForm2, - states = listOf(leBusinessStatus2), - classifications = listOf(classification3, classification4), - currentness = CommonValues.now, - createdAt = CommonValues.now, - updatedAt = CommonValues.now + LegalEntityResponse( + bpnl = CommonValues.bpn2, + identifiers = listOf(identifier3, identifier4), + legalShortName = CommonValues.shortName3, + legalForm = legalForm2, + states = listOf(leBusinessStatus2), + classifications = listOf(classification3, classification4), + currentness = CommonValues.now, + createdAt = CommonValues.now, + updatedAt = CommonValues.now, + legalAddress = logisticAddress2 + ) ) val legalEntityResponseGate1 = LegalEntityResponse( @@ -235,7 +242,8 @@ object ResponseValues { classifications = listOf(classification1, classification2), currentness = CommonValues.now, createdAt = CommonValues.now, - updatedAt = CommonValues.now + updatedAt = CommonValues.now, + legalAddress = logisticAddress1, ) val legalEntityResponseGate2 = LegalEntityResponse( @@ -247,7 +255,8 @@ object ResponseValues { classifications = listOf(classification3, classification4), currentness = CommonValues.now, createdAt = CommonValues.now, - updatedAt = CommonValues.now + updatedAt = CommonValues.now, + legalAddress = logisticAddress2, ) val legalEntityGateInputResponse1 = LegalEntityGateInputResponse( @@ -288,14 +297,12 @@ object ResponseValues { val legalEntityGateOutput1 = LegalEntityGateOutput( legalEntity = legalEntityResponseGate1, legalNameParts = arrayOf(CommonValues.name1), - legalAddress = logisticAddress1, externalId = CommonValues.externalId1 ) val legalEntityGateOutput2 = LegalEntityGateOutput( legalEntity = legalEntityResponseGate2, legalNameParts = arrayOf(CommonValues.name3), - legalAddress = logisticAddress2, externalId = CommonValues.externalId2 ) diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt index c31930cab..f7969d077 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt @@ -27,7 +27,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "LegalEntityUpdateRequest", description = "Request for updating a business partner record of type legal entity") +@Schema(name = "LegalEntityPartnerUpdateRequest", description = "Request for updating a business partner record of type legal entity") data class LegalEntityPartnerUpdateRequest( @Schema(description = "Business Partner Number") val bpnl: String, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt index 94e6f6324..ee5abed1f 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt @@ -19,11 +19,10 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response -import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse -import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @@ -32,8 +31,11 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ data class BusinessPartnerResponse( val uuid: String, - @field:JsonUnwrapped - val legalEntity: PoolLegalEntityResponse, + @get:Schema(description = "Legal name the partner goes by") + val legalName: String, + + @Schema(description = "Legal Entity") + val legalEntity: LegalEntityResponse, val addresses: Collection, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt index 2f92ce040..e1dd9a46c 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt @@ -20,13 +20,16 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse +import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse @Schema(name = "LegalEntityMatchResponse", description = "Match with score for a business partner record of type legal entity") data class LegalEntityMatchResponse( @Schema(description = "Relative quality score of the match. The higher the better") val score: Float, - @Schema(description = "Matched legal entity business partner record") - val legalEntity: PoolLegalEntityResponse + @get:Schema(description = "Legal name the partner goes by") + val legalName: String, + + @Schema(description = "Legal Entity") + val legalEntity: LegalEntityResponse ) diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt index 1ffecbfd5..f473ba586 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt @@ -19,21 +19,20 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response -import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse -import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse +import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema(name = "LegalEntityPartnerCreateResponse", description = "Created business partner of type legal entity") data class LegalEntityPartnerCreateResponse( - @field:JsonUnwrapped - val legalEntity: PoolLegalEntityResponse, - @Schema(description = "Address of the official seat of this of the legal entity") - val legalAddress: LogisticAddressResponse, + @get:Schema(description = "Legal name the partner goes by") + val legalName: String, + + @Schema(description = "Legal Entity") + val legalEntity: LegalEntityResponse, @Schema(description = "User defined index to conveniently match this entry to the corresponding entry from the request") val index: String? diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt index 825bddf0c..2bad56676 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt @@ -50,7 +50,7 @@ class BusinessPartnerFetchService( * Fetch a business partner by [bpn] and return as [PoolLegalEntityResponse] */ fun findLegalEntityIgnoreCase(bpn: String): PoolLegalEntityResponse { - return findLegalEntityOrThrow(bpn).toDto() + return findLegalEntityOrThrow(bpn).toPoolLegalEntity() } fun findBusinessPartnerIgnoreCase(bpn: String): BusinessPartnerResponse { @@ -63,7 +63,7 @@ class BusinessPartnerFetchService( */ @Transactional fun findLegalEntityIgnoreCase(identifierType: String, identifierValue: String): PoolLegalEntityResponse { - return findLegalEntityOrThrow(identifierType, identifierValue).toDto() + return findLegalEntityOrThrow(identifierType, identifierValue).toPoolLegalEntity() } @@ -85,7 +85,7 @@ class BusinessPartnerFetchService( */ @Transactional fun fetchDtosByBpns(bpns: Collection): Collection { - return fetchByBpns(bpns).map { it.toDto() } + return fetchByBpns(bpns).map { it.toPoolLegalEntity() } } /** diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 5097dcfef..a48ee5490 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -33,7 +33,7 @@ fun Page.toDto(dtoContent: Collection): PageResponse { } fun LegalEntity.toMatchDto(score: Float): LegalEntityMatchResponse { - return LegalEntityMatchResponse(score, this.toDto()) + return LegalEntityMatchResponse(score = score, legalEntity = this.toDto(), legalName = this.legalName.value) } fun LegalEntity.toBusinessPartnerMatchDto(score: Float): BusinessPartnerMatchResponse { @@ -43,16 +43,34 @@ fun LegalEntity.toBusinessPartnerMatchDto(score: Float): BusinessPartnerMatchRes fun LegalEntity.toUpsertDto(entryId: String?): LegalEntityPartnerCreateResponse { return LegalEntityPartnerCreateResponse( legalEntity = toDto(), - legalAddress = legalAddress.toDto(), - index = entryId + index = entryId, + legalName = legalName.value, ) } -fun LegalEntity.toDto(): PoolLegalEntityResponse { +fun LegalEntity.toPoolLegalEntity(): PoolLegalEntityResponse { return PoolLegalEntityResponse( + legalName = legalName.value, + LegalEntityResponse( + bpnl = bpn, + identifiers = identifiers.map { it.toDto() }, + legalShortName = legalName.shortName, + legalForm = legalForm?.toDto(), + states = states.map { it.toDto() }, + classifications = classifications.map { it.toDto() }, + relations = startNodeRelations.plus(endNodeRelations).map { it.toDto() }, + currentness = currentness, + createdAt = createdAt, + updatedAt = updatedAt, + legalAddress = legalAddress.toDto() + ) + ) +} + +fun LegalEntity.toDto(): LegalEntityResponse { + return LegalEntityResponse( bpnl = bpn, identifiers = identifiers.map { it.toDto() }, - legalName = legalName.value, legalShortName = legalName.shortName, legalForm = legalForm?.toDto(), states = states.map { it.toDto() }, @@ -60,7 +78,8 @@ fun LegalEntity.toDto(): PoolLegalEntityResponse { relations = startNodeRelations.plus(endNodeRelations).map { it.toDto() }, currentness = currentness, createdAt = createdAt, - updatedAt = updatedAt + updatedAt = updatedAt, + legalAddress = legalAddress.toDto() ) } @@ -70,6 +89,7 @@ fun LegalEntity.toBusinessPartnerDto(): BusinessPartnerResponse { legalEntity = toDto(), addresses = listOf(legalAddress.toDto()), sites = emptyList(), + legalName = legalName.value, ) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt index 6717be619..a56c1f19d 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt @@ -223,7 +223,7 @@ class OpenSearchControllerIT @Autowired constructor( val pageResult = searchBusinessPartnerByName(name) assertThat(pageResult.content).isNotEmpty - assertThat(pageResult.content.first()).matches { it.legalEntity.legalName == name } + assertThat(pageResult.content.first()).matches { it.legalName == name } } } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt index c5fd62105..ba8efbaff 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt @@ -150,10 +150,11 @@ class BusinessPartnerLegacyControllerIT @Autowired constructor( private fun convertCreateResponse(toConvert: LegalEntityPartnerCreateResponse): BusinessPartnerResponse { return BusinessPartnerResponse( - "", - toConvert.legalEntity, - listOf(toConvert.legalAddress), - emptyList() + uuid = "", + legalName = toConvert.legalName, + legalEntity = toConvert.legalEntity, + addresses = listOf(toConvert.legalEntity.legalAddress), + sites = emptyList() ) } } \ No newline at end of file diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt index db7d4dc01..9e9afa5e4 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat +import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.pool.Application @@ -152,17 +153,17 @@ class LegalEntityControllerIT @Autowired constructor( val createResponse = poolClient.legalEntities().createBusinessPartners(given) .entities.single() val givenBpnL = createResponse.legalEntity.bpnl - val givenBpnA = createResponse.legalAddress.bpna + val givenBpnA = createResponse.legalEntity.legalAddress.bpna val expected = with(ResponseValues.legalEntityUpsert3) { copy( legalEntity = legalEntity.copy( - bpnl = givenBpnL + bpnl = givenBpnL, + legalAddress = legalEntity.legalAddress.copy( + bpna = givenBpnA, + bpnLegalEntity = givenBpnL + ) ), - legalAddress = legalAddress.copy( - bpna = givenBpnA, - bpnLegalEntity = givenBpnL - ) ) } @@ -187,7 +188,7 @@ class LegalEntityControllerIT @Autowired constructor( val createResponse = poolClient.legalEntities().createBusinessPartners(given) val createdEntity = createResponse.entities.toList()[1] val bpnL = createdEntity.legalEntity.bpnl - val bpnA = createdEntity.legalAddress.bpna + val bpnA = createdEntity.legalEntity.legalAddress.bpna val toUpdate = listOf( RequestValues.legalEntityUpdate3.copy(bpnl = "NONEXISTENT"), @@ -197,13 +198,14 @@ class LegalEntityControllerIT @Autowired constructor( val expected = with(ResponseValues.legalEntityUpsert3) { copy( legalEntity = legalEntity.copy( - bpnl = bpnL + bpnl = bpnL, + legalAddress = legalEntity.legalAddress.copy( + bpna = bpnA, + bpnLegalEntity = bpnL + ) ), - legalAddress = legalAddress.copy( - bpna = bpnA, - bpnLegalEntity = bpnL + ) - ) } val response = poolClient.legalEntities().updateBusinessPartners(toUpdate) @@ -231,7 +233,7 @@ class LegalEntityControllerIT @Autowired constructor( val givenLegalEntities = testHelpers.createBusinessPartnerStructure(givenStructures).map { it.legalEntity } val expected = givenLegalEntities - .map { toLegalAddressResponse(it.legalAddress) } + .map { toLegalAddressResponse(it.legalEntity.legalAddress) } val bpnsToSearch = givenLegalEntities.map { it.legalEntity.bpnl } val response = poolClient.legalEntities().searchLegalAddresses(bpnsToSearch) @@ -259,7 +261,7 @@ class LegalEntityControllerIT @Autowired constructor( val givenLegalEntities = testHelpers.createBusinessPartnerStructure(givenStructures).map { it.legalEntity } val expected = givenLegalEntities - .map { toLegalAddressResponse(it.legalAddress) } + .map { toLegalAddressResponse(it.legalEntity.legalAddress) } .take(2) val bpnsToSearch = expected.map { it.bpnLegalEntity }.plus("NONEXISTENT") @@ -292,7 +294,7 @@ class LegalEntityControllerIT @Autowired constructor( .take(2) // only search for a subset of the existing legal entities val bpnsToSearch = expected.map { it.bpnl } - val response = poolClient.legalEntities().searchSites(bpnsToSearch).body + val response = poolClient.legalEntities().searchSites(bpnsToSearch).body?.map { it.legalEntity } assertThat(response) .usingRecursiveComparison() @@ -320,7 +322,7 @@ class LegalEntityControllerIT @Autowired constructor( .first() // search for first val identifierToFind = expected.identifiers.first() - val response = poolClient.legalEntities().getLegalEntity(identifierToFind.value, identifierToFind.type.technicalKey) + val response = poolClient.legalEntities().getLegalEntity(identifierToFind.value, identifierToFind.type.technicalKey).legalEntity assertThat(response) .usingRecursiveComparison() @@ -350,7 +352,7 @@ class LegalEntityControllerIT @Autowired constructor( var identifierToFind = expected.identifiers.first() identifierToFind = identifierToFind.copy(value = changeCase(identifierToFind.value)) - val response = poolClient.legalEntities().getLegalEntity(identifierToFind.value, identifierToFind.type.technicalKey) + val response = poolClient.legalEntities().getLegalEntity(identifierToFind.value, identifierToFind.type.technicalKey).legalEntity assertThat(response) .usingRecursiveComparison() @@ -379,7 +381,7 @@ class LegalEntityControllerIT @Autowired constructor( val bpnToFind = expected.bpnl - val response = poolClient.legalEntities().getLegalEntity(bpnToFind) + val response = poolClient.legalEntities().getLegalEntity(bpnToFind).legalEntity assertThat(response) .usingRecursiveComparison() @@ -407,7 +409,7 @@ class LegalEntityControllerIT @Autowired constructor( .first() // search for first val bpnToFind = changeCase(expected.bpnl) - val response = poolClient.legalEntities().getLegalEntity(bpnToFind) + val response = poolClient.legalEntities().getLegalEntity(bpnToFind).legalEntity assertThat(response) .usingRecursiveComparison() @@ -436,7 +438,7 @@ class LegalEntityControllerIT @Autowired constructor( .take(2) // only search for a subset of the existing legal entities val bpnsToSearch = expected.map { it.bpnl }.plus("NONEXISTENT") // also search for nonexistent BPN - val response = poolClient.legalEntities().searchSites(bpnsToSearch).body + val response = poolClient.legalEntities().searchSites(bpnsToSearch).body?.map { it.legalEntity } assertThat(response) .usingRecursiveComparison() @@ -464,7 +466,7 @@ class LegalEntityControllerIT @Autowired constructor( poolClient.legalEntities().setLegalEntityCurrentness(bpnL) - val updatedCurrentness = poolClient.legalEntities().getLegalEntity(bpnL).currentness + val updatedCurrentness = poolClient.legalEntities().getLegalEntity(bpnL).legalEntity.currentness assertThat(updatedCurrentness).isBetween(instantBeforeCurrentnessUpdate, Instant.now()) } @@ -488,7 +490,7 @@ class LegalEntityControllerIT @Autowired constructor( testHelpers.assertRecursively(actuals) .ignoringFieldsOfTypes(Instant::class.java) - .ignoringFieldsMatchingRegexes(".*${PoolLegalEntityResponse::bpnl.name}") + .ignoringFieldsMatchingRegexes(".*${LegalEntityResponse::bpnl.name}") .isEqualTo(expected) } @@ -509,7 +511,7 @@ class LegalEntityControllerIT @Autowired constructor( .exchange().expectStatus().isOk .returnResult() .responseBody - .blockFirst()!!.currentness + .blockFirst()!!.legalEntity.currentness private fun changeCase(value: String): String { return if (value.uppercase() != value) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt index 54e2d63bc..c2fc976e3 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt @@ -21,8 +21,8 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest @@ -66,8 +66,10 @@ class LegalEntityControllerSearchIT @Autowired constructor( ) ) - private lateinit var givenPartner1: PoolLegalEntityResponse - private lateinit var givenPartner2: PoolLegalEntityResponse + private lateinit var givenPartner1: LegalEntityResponse + private lateinit var givenPartner2: LegalEntityResponse + private lateinit var legalName1: String + private lateinit var legalName2: String @BeforeEach fun beforeEach() { @@ -78,6 +80,8 @@ class LegalEntityControllerSearchIT @Autowired constructor( val givenStructure = testHelpers.createBusinessPartnerStructure(listOf(partnerStructure1, partnerStructure2)) givenPartner1 = with(givenStructure[0].legalEntity) { legalEntity } givenPartner2 = with(givenStructure[1].legalEntity) { legalEntity } + legalName1 = givenStructure[0].legalEntity.legalName + legalName2 = givenStructure[1].legalEntity.legalName testHelpers.startSyncAndAwaitSuccess(webTestClient, EndpointValues.OPENSEARCH_SYNC_PATH) } @@ -93,8 +97,8 @@ class LegalEntityControllerSearchIT @Autowired constructor( val expected = PageResponse( 2, 1, 0, 2, listOf( - LegalEntityMatchResponse(0f, givenPartner1), - LegalEntityMatchResponse(0f, givenPartner2) + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner1, legalName = legalName1), + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2) ) ) @@ -113,12 +117,12 @@ class LegalEntityControllerSearchIT @Autowired constructor( val expectedFirstPage = PageResponse( 2, 2, 0, 1, listOf( - LegalEntityMatchResponse(0f, givenPartner1) + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner1, legalName = legalName1) ) ) val expectedSecondPage = PageResponse( 2, 2, 1, 1, listOf( - LegalEntityMatchResponse(0f, givenPartner2) + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2) ) ) @@ -139,7 +143,7 @@ class LegalEntityControllerSearchIT @Autowired constructor( val expected = PageResponse( 1, 1, 0, 1, listOf( - LegalEntityMatchResponse(0f, givenPartner2) + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2) ) ) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt index ed6808a9d..345f9c760 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt @@ -69,12 +69,12 @@ class SuggestionControllerIT @Autowired constructor( .build() private val expectedLegalEntity = ResponseValues.legalEntityUpsert1.legalEntity - private val expectedLegalEntityName = expectedLegalEntity.legalName - private val expectedLegalAddress = ResponseValues.legalEntityUpsert1.legalAddress + private val expectedLegalEntityName = ResponseValues.legalEntityUpsert1.legalName + private val expectedLegalAddress = ResponseValues.legalEntityUpsert1.legalEntity.legalAddress private val expectedSite = ResponseValues.siteUpsert2 private val nonlatinLegalEntity = ResponseValues.legalEntityUpsert3.legalEntity - private val nonlatinLegalAddress = ResponseValues.legalEntityUpsert3.legalAddress + private val nonlatinLegalAddress = ResponseValues.legalEntityUpsert3.legalEntity.legalAddress private val nonlatinSite = ResponseValues.siteUpsert3 @JvmStatic @@ -94,7 +94,7 @@ class SuggestionControllerIT @Autowired constructor( Arguments.of( expectedLegalEntity.legalForm!!.name, EndpointValues.CATENA_SUGGESTION_LE_LEGAL_FORM_PATH, - expectedLegalEntity.legalName + expectedLegalEntityName ), Arguments.of( expectedLegalEntity.states.first().officialDenotation, @@ -147,7 +147,7 @@ class SuggestionControllerIT @Autowired constructor( @JvmStatic fun argumentsSuggestPropertyValuesNonLatin(): Stream = Stream.of( - Arguments.of(nonlatinLegalEntity.legalName, EndpointValues.CATENA_SUGGESTION_LE_NAME_PATH), + Arguments.of(ResponseValues.legalEntityUpsert3.legalName, EndpointValues.CATENA_SUGGESTION_LE_NAME_PATH), Arguments.of(nonlatinLegalEntity.legalForm!!.name, EndpointValues.CATENA_SUGGESTION_LE_LEGAL_FORM_PATH), Arguments.of(nonlatinSite.site.name, EndpointValues.CATENA_SUGGESTION_SITE_NAME_PATH), Arguments.of( diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt index f2d29739e..9ae6784fb 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt @@ -243,94 +243,178 @@ object ResponseValues { val legalEntity1 = PoolLegalEntityResponse( - bpnl = CommonValues.bpnL1, legalName = CommonValues.name1, - identifiers = listOf(identifier1), - legalForm = legalForm1, - states = listOf(leStatus1), - classifications = listOf(classification1, classification2), - currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), - createdAt = CommonValues.now, - updatedAt = CommonValues.now + LegalEntityResponse( + bpnl = CommonValues.bpnL1, + identifiers = listOf(identifier1), + legalForm = legalForm1, + states = listOf(leStatus1), + classifications = listOf(classification1, classification2), + currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), + createdAt = CommonValues.now, + updatedAt = CommonValues.now, + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnA1, + physicalPostalAddress = PhysicalPostalAddressResponse( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null, + areaPart = AreaDistrictResponse( + administrativeAreaLevel1 = null, + administrativeAreaLevel2 = null, + district = null, + ), + street = null, + baseAddress = BasePostalAddressResponse( + geographicCoordinates = null, + country = country1, + postalCode = null, + city = CommonValues.locality1, + ) + ), + bpnLegalEntity = null, + bpnSite = null, + createdAt = Instant.now(), + updatedAt = Instant.now() + ) + ) ) val legalEntity2 = PoolLegalEntityResponse( - bpnl = CommonValues.bpnL2, legalName = CommonValues.name3, - identifiers = listOf(identifier2), - legalForm = legalForm2, - states = listOf(leStatus2), - classifications = listOf(classification3, classification4), - currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), - createdAt = CommonValues.now, - updatedAt = CommonValues.now + LegalEntityResponse( + bpnl = CommonValues.bpnL2, + identifiers = listOf(identifier2), + legalForm = legalForm2, + states = listOf(leStatus2), + classifications = listOf(classification3, classification4), + currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), + createdAt = CommonValues.now, + updatedAt = CommonValues.now, + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnA1, + physicalPostalAddress = PhysicalPostalAddressResponse( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null, + areaPart = AreaDistrictResponse( + administrativeAreaLevel1 = null, + administrativeAreaLevel2 = null, + district = null, + ), + street = null, + baseAddress = BasePostalAddressResponse( + geographicCoordinates = null, + country = country2, + postalCode = null, + city = CommonValues.locality3, + ) + ), + bpnLegalEntity = null, + bpnSite = null, + createdAt = Instant.now(), + updatedAt = Instant.now() + ) + ) ) val legalEntity3 = PoolLegalEntityResponse( - bpnl = CommonValues.bpnL3, legalName = CommonValues.name5, - identifiers = listOf(identifier3), - legalForm = legalForm3, - states = listOf(leStatus3), - classifications = listOf(classification5), - currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), - createdAt = CommonValues.now, - updatedAt = CommonValues.now + LegalEntityResponse( + bpnl = CommonValues.bpnL3, + identifiers = listOf(identifier3), + legalForm = legalForm3, + states = listOf(leStatus3), + classifications = listOf(classification5), + currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), + createdAt = CommonValues.now, + updatedAt = CommonValues.now, + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnA1, + physicalPostalAddress = PhysicalPostalAddressResponse( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null, + areaPart = AreaDistrictResponse( + administrativeAreaLevel1 = null, + administrativeAreaLevel2 = null, + district = null, + ), + street = null, + baseAddress = BasePostalAddressResponse( + geographicCoordinates = null, + country = country3, + postalCode = null, + city = CommonValues.locality5, + ) + ), + bpnLegalEntity = null, + bpnSite = null, + createdAt = Instant.now(), + updatedAt = Instant.now() + ) + ) ) val legalEntityUpsert1 = LegalEntityPartnerCreateResponse( - legalEntity = PoolLegalEntityResponse( + legalName = CommonValues.name1, + legalEntity = LegalEntityResponse( bpnl = CommonValues.bpnL1, - legalName = CommonValues.name1, identifiers = listOf(LegalEntityIdentifierResponse(CommonValues.identifierValue1, RequestValues.identifierType1, CommonValues.issuingBody1)), legalForm = legalForm1, states = listOf(leStatus1), classifications = listOf(classification1, classification2), currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), createdAt = CommonValues.now, - updatedAt = CommonValues.now - ), - legalAddress = addressPartner1.copy( - bpnLegalEntity = legalEntity1.bpnl, - isLegalAddress = true + updatedAt = CommonValues.now, + legalAddress = addressPartner1.copy( + bpnLegalEntity = legalEntity1.legalEntity.bpnl, + isLegalAddress = true + ), ), index = CommonValues.index1 ) val legalEntityUpsert2 = LegalEntityPartnerCreateResponse( - legalEntity = PoolLegalEntityResponse( + legalName = CommonValues.name3, + legalEntity = LegalEntityResponse( bpnl = CommonValues.bpnL2, - legalName = CommonValues.name3, identifiers = listOf(LegalEntityIdentifierResponse(CommonValues.identifierValue2, RequestValues.identifierType2, CommonValues.issuingBody2)), legalForm = legalForm2, states = listOf(leStatus2), classifications = listOf(classification3, classification4), currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), createdAt = CommonValues.now, - updatedAt = CommonValues.now - ), - legalAddress = addressPartner2.copy( - bpnLegalEntity = legalEntity2.bpnl, - isLegalAddress = true + updatedAt = CommonValues.now, + legalAddress = addressPartner2.copy( + bpnLegalEntity = legalEntity2.legalEntity.bpnl, + isLegalAddress = true + ), ), index = CommonValues.index2 ) val legalEntityUpsert3 = LegalEntityPartnerCreateResponse( - legalEntity = PoolLegalEntityResponse( + legalName = CommonValues.name5, + legalEntity = LegalEntityResponse( bpnl = CommonValues.bpnL3, - legalName = CommonValues.name5, identifiers = listOf(LegalEntityIdentifierResponse(CommonValues.identifierValue3, RequestValues.identifierType3, CommonValues.issuingBody3)), legalForm = legalForm3, states = listOf(leStatus3), classifications = listOf(classification5), currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), createdAt = CommonValues.now, - updatedAt = CommonValues.now - ), - legalAddress = addressPartner3.copy( - bpnLegalEntity = legalEntity3.bpnl, - isLegalAddress = true + updatedAt = CommonValues.now, + legalAddress = addressPartner3.copy( + bpnLegalEntity = legalEntity3.legalEntity.bpnl, + isLegalAddress = true + ) ), index = CommonValues.index3 ) From 95561376877134557cc477e684a5b0c02cdd4bbc Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 1 Jun 2023 10:06:30 +0200 Subject: [PATCH 15/83] feat(api): #179 Pool API: Legal Entity Response should fix after merge --- .../bpdm/common/dto/response/PoolLegalEntityResponse.kt | 6 +++++- .../tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt | 3 ++- .../tractusx/bpdm/gate/service/LegalEntityService.kt | 5 +---- .../bpdm/gate/controller/LegalEntityControllerInputIT.kt | 2 +- .../bpdm/pool/api/model/response/BusinessPartnerResponse.kt | 3 ++- .../pool/api/model/response/LegalEntityMatchResponse.kt | 6 +++++- .../api/model/response/LegalEntityPartnerCreateResponse.kt | 3 ++- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt index b5c6db780..e03651b1f 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt @@ -19,14 +19,18 @@ package org.eclipse.tractusx.bpdm.common.dto.response +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema(name = "PoolLegalEntityResponse", description = "Legal entity record") data class PoolLegalEntityResponse( @get:Schema(description = "Legal name the partner goes by") val legalName: String, - @Schema(description = "Legal Entity") + @field:JsonUnwrapped val legalEntity: LegalEntityResponse, ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt index 6cdbcf9ed..c3392a82d 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model +import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse @@ -31,7 +32,7 @@ data class LegalEntityGateOutput( val legalNameParts: Array = emptyArray(), - @Schema(description = "Legal Entity") + @field:JsonUnwrapped val legalEntity: LegalEntityResponse, @Schema(description = "ID the record has in the external system where the record originates from") diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index cfe6772a8..aacd35b76 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -22,11 +22,8 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse -import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse -import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas -import org.eclipse.tractusx.bpdm.common.dto.saas.FetchResponse -import org.eclipse.tractusx.bpdm.common.exception.BpdmMappingException import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt index 262c01a21..96d70fa97 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt @@ -61,7 +61,7 @@ internal class LegalEntityControllerInputIT @Autowired constructor( private val webTestClient: WebTestClient, private val objectMapper: ObjectMapper, val gateClient: GateClient, - private val legalEntityRepository: LegalEntityRepository + private val legalEntityRepository: LegalEntityRepository, ) { companion object { @RegisterExtension diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt index ee5abed1f..4d9884f7b 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response +import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse @@ -34,7 +35,7 @@ data class BusinessPartnerResponse( @get:Schema(description = "Legal name the partner goes by") val legalName: String, - @Schema(description = "Legal Entity") + @field:JsonUnwrapped val legalEntity: LegalEntityResponse, val addresses: Collection, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt index e1dd9a46c..d67302d8d 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt @@ -19,9 +19,13 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema(name = "LegalEntityMatchResponse", description = "Match with score for a business partner record of type legal entity") data class LegalEntityMatchResponse( @Schema(description = "Relative quality score of the match. The higher the better") @@ -30,6 +34,6 @@ data class LegalEntityMatchResponse( @get:Schema(description = "Legal name the partner goes by") val legalName: String, - @Schema(description = "Legal Entity") + @field:JsonUnwrapped val legalEntity: LegalEntityResponse ) diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt index f473ba586..ce71a92ac 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response +import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse @@ -31,7 +32,7 @@ data class LegalEntityPartnerCreateResponse( @get:Schema(description = "Legal name the partner goes by") val legalName: String, - @Schema(description = "Legal Entity") + @field:JsonUnwrapped val legalEntity: LegalEntityResponse, @Schema(description = "User defined index to conveniently match this entry to the corresponding entry from the request") From d95a2dc167dd017f2a3e584531317086b0c38f42 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 1 Jun 2023 14:13:08 +0200 Subject: [PATCH 16/83] feat(api): #179 Pool API: Legal Entity Response should include Legal Address fix bug in bridge --- .../catenax/bpdm/bridge/dummy/service/GateUpdateService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt index 8da1877f2..d79a8e11a 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt @@ -41,7 +41,7 @@ class GateUpdateService( ) { for (entity in responseWrapper.entities) { val externalId = entity.index - buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, entity.poolLegalEntity.bpnl, true) + buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, entity.legalEntity.bpnl, true) ?.let { gateClient.sharingState().upsertSharingState(it) } } for (errorInfo in responseWrapper.errors) { @@ -57,7 +57,7 @@ class GateUpdateService( externalIdByBpn: Map ) { for (entity in responseWrapper.entities) { - val bpn = entity.poolLegalEntity.bpnl + val bpn = entity.legalEntity.bpnl val externalId = externalIdByBpn[bpn] buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, bpn, false) ?.let { gateClient.sharingState().upsertSharingState(it) } From 19371ffda6a0eed3d5f94c0ce86c0ae7a3c09b85 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 1 Jun 2023 11:16:47 +0200 Subject: [PATCH 17/83] feat(api): #202 API: Delivery Service Qualifier in Alternative Postal Address --- .../tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt | 3 +++ .../common/dto/response/AlternativePostalAddressResponse.kt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt index 77efb8d65..13a333433 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt @@ -40,4 +40,7 @@ data class AlternativePostalAddressDto( @get:Schema(description = "The type of this specified delivery") val deliveryServiceType: DeliveryServiceType = DeliveryServiceType.PO_BOX, + + @get:Schema(description = "Delivery Service Qualifier") + val deliveryServiceQualifier: String = "", ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/AlternativePostalAddressResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/AlternativePostalAddressResponse.kt index 334359ca7..57b988195 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/AlternativePostalAddressResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/AlternativePostalAddressResponse.kt @@ -40,4 +40,7 @@ data class AlternativePostalAddressResponse( @get:Schema(description = "The type of this specified delivery") val type: DeliveryServiceType = DeliveryServiceType.PO_BOX, + + @get:Schema(description = "Delivery Service Qualifier") + val deliveryServiceQualifier: String = "", ) From 8d1bdc445071dfdcdb7ba283213d2005ce68944e Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 1 Jun 2023 14:04:22 +0200 Subject: [PATCH 18/83] feat(api): #183 Gate API: Add Street Name Suffix and Prefix Fields - refactor LegalEntityResponse to separate pool and gate LogisticAddressResponse --- .../common/dto/response/LegalEntityResponse.kt | 6 +----- .../dto/response/PoolLegalEntityResponse.kt | 3 +++ .../gate/api/model/LegalEntityGateOutput.kt | 4 ++++ .../bpdm/gate/service/LegalEntityService.kt | 2 +- .../tractusx/bpdm/gate/util/ResponseValues.kt | 18 +++++++++--------- .../model/response/BusinessPartnerResponse.kt | 3 +++ .../model/response/LegalEntityMatchResponse.kt | 6 +++++- .../LegalEntityPartnerCreateResponse.kt | 4 ++++ .../bpdm/pool/service/ResponseMappings.kt | 14 ++++++++++---- 9 files changed, 40 insertions(+), 20 deletions(-) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt index 2571e47e2..8b20c0bbd 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt @@ -47,9 +47,6 @@ data class LegalEntityResponse( @ArraySchema(arraySchema = Schema(description = "Relations to other business partners")) val relations: Collection = emptyList(), - @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressResponse, - @get:Schema(description = "The timestamp the business partner data was last indicated to be still current") val currentness: Instant, @@ -58,5 +55,4 @@ data class LegalEntityResponse( @get:Schema(description = "The timestamp the business partner data was last updated") val updatedAt: Instant, - - ) +) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt index e03651b1f..adae89ecc 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PoolLegalEntityResponse.kt @@ -33,4 +33,7 @@ data class PoolLegalEntityResponse( @field:JsonUnwrapped val legalEntity: LegalEntityResponse, + + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressResponse, ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt index c3392a82d..3fcd86c33 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt @@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse +import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @@ -35,6 +36,9 @@ data class LegalEntityGateOutput( @field:JsonUnwrapped val legalEntity: LegalEntityResponse, + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressResponse, + @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index aacd35b76..001dee55a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -143,8 +143,8 @@ class LegalEntityService( currentness = legalEntityPool.legalEntity.currentness, createdAt = legalEntityPool.legalEntity.createdAt, updatedAt = legalEntityPool.legalEntity.updatedAt, - legalAddress = legalEntityPool.legalEntity.legalAddress, ), + legalAddress = legalEntityPool.legalAddress, legalNameParts = arrayOf(legalEntityPool.legalName), externalId = externalId ) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 8a68726b5..7d486b0c4 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -202,7 +202,8 @@ object ResponseValues { val legalEntityResponsePool1 = PoolLegalEntityResponse( legalName = CommonValues.name1, - LegalEntityResponse( + legalAddress = logisticAddress1, + legalEntity = LegalEntityResponse( bpnl = CommonValues.bpn1, identifiers = listOf(identifier1, identifier2), legalShortName = CommonValues.shortName1, @@ -212,14 +213,14 @@ object ResponseValues { currentness = CommonValues.now, createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = logisticAddress1 ) ) val legalEntityResponsePool2 = PoolLegalEntityResponse( legalName = CommonValues.name3, - LegalEntityResponse( + legalAddress = logisticAddress2, + legalEntity = LegalEntityResponse( bpnl = CommonValues.bpn2, identifiers = listOf(identifier3, identifier4), legalShortName = CommonValues.shortName3, @@ -229,7 +230,6 @@ object ResponseValues { currentness = CommonValues.now, createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = logisticAddress2 ) ) @@ -243,7 +243,6 @@ object ResponseValues { currentness = CommonValues.now, createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = logisticAddress1, ) val legalEntityResponseGate2 = LegalEntityResponse( @@ -256,7 +255,6 @@ object ResponseValues { currentness = CommonValues.now, createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = logisticAddress2, ) val legalEntityGateInputResponse1 = LegalEntityGateInputResponse( @@ -285,7 +283,7 @@ object ResponseValues { legalEntity = RequestValues.legalEntity1, externalId = CommonValues.externalId1, bpn = CommonValues.bpn1, - processStartedAt = null, + processStartedAt = null ) val newLegalEntityGateInputResponse2 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity2, @@ -297,13 +295,15 @@ object ResponseValues { val legalEntityGateOutput1 = LegalEntityGateOutput( legalEntity = legalEntityResponseGate1, legalNameParts = arrayOf(CommonValues.name1), - externalId = CommonValues.externalId1 + externalId = CommonValues.externalId1, + legalAddress = logisticAddress1, ) val legalEntityGateOutput2 = LegalEntityGateOutput( legalEntity = legalEntityResponseGate2, legalNameParts = arrayOf(CommonValues.name3), - externalId = CommonValues.externalId2 + externalId = CommonValues.externalId2, + legalAddress = logisticAddress2, ) val siteResponse1 = SiteResponse( diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt index 4d9884f7b..e26f2a288 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt @@ -38,6 +38,9 @@ data class BusinessPartnerResponse( @field:JsonUnwrapped val legalEntity: LegalEntityResponse, + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressResponse, + val addresses: Collection, val sites: Collection, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt index d67302d8d..4ac786ac1 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityMatchResponse.kt @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse +import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @@ -35,5 +36,8 @@ data class LegalEntityMatchResponse( val legalName: String, @field:JsonUnwrapped - val legalEntity: LegalEntityResponse + val legalEntity: LegalEntityResponse, + + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressResponse, ) diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt index ce71a92ac..a78207f38 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/LegalEntityPartnerCreateResponse.kt @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse +import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @@ -35,6 +36,9 @@ data class LegalEntityPartnerCreateResponse( @field:JsonUnwrapped val legalEntity: LegalEntityResponse, + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressResponse, + @Schema(description = "User defined index to conveniently match this entry to the corresponding entry from the request") val index: String? ) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index a48ee5490..42c648cf0 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -33,7 +33,12 @@ fun Page.toDto(dtoContent: Collection): PageResponse { } fun LegalEntity.toMatchDto(score: Float): LegalEntityMatchResponse { - return LegalEntityMatchResponse(score = score, legalEntity = this.toDto(), legalName = this.legalName.value) + return LegalEntityMatchResponse( + score = score, + legalEntity = this.toDto(), + legalName = this.legalName.value, + legalAddress = legalAddress.toDto(), + ) } fun LegalEntity.toBusinessPartnerMatchDto(score: Float): BusinessPartnerMatchResponse { @@ -43,6 +48,7 @@ fun LegalEntity.toBusinessPartnerMatchDto(score: Float): BusinessPartnerMatchRes fun LegalEntity.toUpsertDto(entryId: String?): LegalEntityPartnerCreateResponse { return LegalEntityPartnerCreateResponse( legalEntity = toDto(), + legalAddress = legalAddress.toDto(), index = entryId, legalName = legalName.value, ) @@ -51,7 +57,8 @@ fun LegalEntity.toUpsertDto(entryId: String?): LegalEntityPartnerCreateResponse fun LegalEntity.toPoolLegalEntity(): PoolLegalEntityResponse { return PoolLegalEntityResponse( legalName = legalName.value, - LegalEntityResponse( + legalAddress = legalAddress.toDto(), + legalEntity = LegalEntityResponse( bpnl = bpn, identifiers = identifiers.map { it.toDto() }, legalShortName = legalName.shortName, @@ -62,7 +69,6 @@ fun LegalEntity.toPoolLegalEntity(): PoolLegalEntityResponse { currentness = currentness, createdAt = createdAt, updatedAt = updatedAt, - legalAddress = legalAddress.toDto() ) ) } @@ -79,7 +85,6 @@ fun LegalEntity.toDto(): LegalEntityResponse { currentness = currentness, createdAt = createdAt, updatedAt = updatedAt, - legalAddress = legalAddress.toDto() ) } @@ -88,6 +93,7 @@ fun LegalEntity.toBusinessPartnerDto(): BusinessPartnerResponse { uuid = "", legalEntity = toDto(), addresses = listOf(legalAddress.toDto()), + legalAddress = legalAddress.toDto(), sites = emptyList(), legalName = legalName.value, ) From 71a87cc71903c5b58d5a11d0c6a8462c6c3b353e Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 1 Jun 2023 15:44:34 +0200 Subject: [PATCH 19/83] feat(api): #183 Gate API: Add Street Name Suffix and Prefix Fields - refactor LogisticAddressDto to separate pool and gate classes --- .../bridge/dummy/dto/GateLegalEntityInfo.kt | 2 + .../bridge/dummy/service/GateQueryService.kt | 1 + .../bridge/dummy/service/PoolUpdateService.kt | 2 + .../bpdm/common/dto/LegalEntityDto.kt | 2 - .../bpdm/common/service/SaasMappings.kt | 2 - .../api/model/LegalEntityGateInputRequest.kt | 4 + .../api/model/LegalEntityGateInputResponse.kt | 4 + .../gate/service/InputSaasMappingService.kt | 2 + .../bpdm/gate/service/LegalEntityService.kt | 1 + .../bpdm/gate/service/ResponseMappings.kt | 4 +- .../gate/service/SaasRequestMappingService.kt | 2 +- .../tractusx/bpdm/gate/util/RequestValues.kt | 6 +- .../tractusx/bpdm/gate/util/ResponseValues.kt | 5 + .../LegalEntityPartnerCreateRequest.kt | 4 + .../LegalEntityPartnerUpdateRequest.kt | 9 +- .../service/BusinessPartnerBuildService.kt | 8 +- .../BusinessPartnerLegacyControllerIT.kt | 3 +- .../controller/LegalEntityControllerIT.kt | 26 +-- .../LegalEntityControllerSearchIT.kt | 16 +- .../pool/controller/SuggestionControllerIT.kt | 4 +- .../tractusx/bpdm/pool/util/RequestValues.kt | 15 +- .../tractusx/bpdm/pool/util/ResponseValues.kt | 173 +++++++++--------- 22 files changed, 165 insertions(+), 130 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt index 84f3cc1d4..9e73f6856 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt @@ -20,10 +20,12 @@ package com.catenax.bpdm.bridge.dummy.dto import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto +import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto data class GateLegalEntityInfo( val legalNameParts: Array = emptyArray(), val legalEntity: LegalEntityDto, + val legalAddress: LogisticAddressDto, val externalId: String, val bpn: String? ) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt index e979235e0..c53fe3e5f 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt @@ -79,6 +79,7 @@ class GateQueryService( return entries.map { GateLegalEntityInfo( legalEntity = it.legalEntity, + legalAddress = it.legalAddress, externalId = it.externalId, bpn = bpnByExternalId[it.externalId] ) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index 7d442ac85..d8a250b55 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -41,6 +41,7 @@ class PoolUpdateService( val createRequests = entriesToCreate.map { LegalEntityPartnerCreateRequest( legalEntity = it.legalEntity, + legalAddress = it.legalAddress, index = it.externalId, legalName = it.legalNameParts[0] ) @@ -54,6 +55,7 @@ class PoolUpdateService( val updateRequests = entriesToUpdate.map { LegalEntityPartnerUpdateRequest( legalEntity = it.legalEntity, + legalAddress = it.legalAddress, bpnl = it.bpn!!, legalName = it.legalNameParts[0] ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/LegalEntityDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/LegalEntityDto.kt index 794bd3c8b..ab8e6e085 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/LegalEntityDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/LegalEntityDto.kt @@ -39,7 +39,5 @@ data class LegalEntityDto( @ArraySchema(arraySchema = Schema(description = "Classifications", required = false)) val classifications: Collection = emptyList(), - @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressDto, ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt index 8c8ce8b80..d3a92c20b 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt @@ -74,8 +74,6 @@ object SaasMappings { legalForm = toOptionalReference(legalForm), states = toLegalEntityStatesDtos(status), classifications = toDto(profile), - // TODO Known issue: For now the legal address is not a separate business partner in SaaS, therefore its properties name, states, identifiers are missing! - legalAddress = convertSaasAdressesToLogisticAddressDto(addresses, id) ) } diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt index b9571200e..0472f650a 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto +import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @@ -33,6 +34,9 @@ data class LegalEntityGateInputRequest( @Schema(description = "legal Enity") val legalEntity: LegalEntityDto, + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressDto, + @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt index 3afee8394..2f315c37a 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto +import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer import java.time.LocalDateTime @@ -35,6 +36,9 @@ data class LegalEntityGateInputResponse( @field:JsonUnwrapped val legalEntity: LegalEntityDto, + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressDto, + @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt index 6eaf2dd02..cfd3d2aa6 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt @@ -40,6 +40,8 @@ class InputSaasMappingService( fun toInputLegalEntity(businessPartner: BusinessPartnerSaas): LegalEntityGateInputResponse { return LegalEntityGateInputResponse( legalEntity = businessPartner.toLegalEntityDto(), + // TODO Known issue: For now the legal address is not a separate business partner in SaaS, therefore its properties name, states, identifiers are missing! + legalAddress = SaasMappings.convertSaasAdressesToLogisticAddressDto(businessPartner.addresses, businessPartner.id), externalId = businessPartner.externalId!!, bpn = businessPartner.identifiers.find { it.type?.technicalKey == SaasMappings.BPN_TECHNICAL_KEY }?.value, processStartedAt = businessPartner.lastModifiedAt, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 001dee55a..f2aba3b24 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -161,6 +161,7 @@ private fun toValidSingleLegalEntity(legalEntity: LegalEntity): LegalEntityGateI return LegalEntityGateInputResponse( legalEntity = legalEntity.toLegalEntityDto(), + legalAddress = legalEntity.legalAddress.toLogisticAddressDto(), bpn = legalEntity.bpn, externalId = legalEntity.externalId ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index b8ef2eba9..8d77f9bf0 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -144,7 +144,7 @@ fun ChangelogEntry.toGateDto(): ChangelogResponse { fun LegalEntityGateInputRequest.toLegalEntity(): LegalEntity { val addressInputRequest = AddressGateInputRequest( - address = legalEntity.legalAddress, + address = legalAddress, externalId = getMainAddressForLegalEntityExternalId(externalId), legalEntityExternalId = externalId ) @@ -295,7 +295,6 @@ fun LegalEntity.toLegalEntityDto(): LegalEntityDto { return LegalEntityDto( legalForm = legalForm, legalShortName = legalName.shortName, - legalAddress = legalAddress.toLogisticAddressDto(), states = mapToLegalEntityStateDto(states), classifications = mapToLegalEntityClassificationsDto(classifications), identifiers = mapToLegalEntityIdentifierDto(identifiers) @@ -324,6 +323,7 @@ fun LegalEntity.LegalEntityGateInputResponse(legalEntity: LegalEntity): LegalEnt return LegalEntityGateInputResponse( legalEntity = legalEntity.toLegalEntityDto(), + legalAddress = legalAddress.toLogisticAddressDto(), externalId = legalEntity.externalId, bpn = legalEntity.bpn, processStartedAt = null diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt index 5b386acf0..4d7487fa3 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt @@ -49,7 +49,7 @@ class SaasRequestMappingService( legalForm = toLegalFormSaas(legalEntity.legalForm), profile = toPartnerProfileSaas(legalEntity.classifications), // TODO Known issue: name, state, BPN-A and identifiers of the legal address are not transferred to SaaS yet!! - addresses = toAddressesSaasModel(legalEntity.legalAddress) + addresses = toAddressesSaasModel(request.legalAddress) ) } diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index 1a3348d4f..7761fbb6a 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -236,7 +236,6 @@ object RequestValues { legalForm = CommonValues.legalFormTechnicalKey1, states = listOf(leBusinessStatus1), classifications = listOf(classification1, classification2), - legalAddress = address1 ) val legalEntity2 = LegalEntityDto( @@ -245,7 +244,6 @@ object RequestValues { legalForm = CommonValues.legalFormTechnicalKey2, states = listOf(leBusinessStatus2), classifications = listOf(classification3, classification4), - legalAddress = address2 ) val legalEntity3 = LegalEntityDto( @@ -254,11 +252,11 @@ object RequestValues { legalForm = CommonValues.legalFormTechnicalKey1, states = listOf(leBusinessStatus1), classifications = listOf(classification1, classification2), - legalAddress = address3 ) val legalEntityGateInputRequest1 = LegalEntityGateInputRequest( legalEntity = legalEntity1, + legalAddress = address1, legalNameParts = arrayOf(CommonValues.name1), externalId = CommonValues.externalId1, bpn = CommonValues.bpn1 @@ -266,6 +264,7 @@ object RequestValues { val legalEntityGateInputRequest2 = LegalEntityGateInputRequest( legalEntity = legalEntity2, + legalAddress = address2, legalNameParts = arrayOf(CommonValues.name3), externalId = CommonValues.externalId2, bpn = CommonValues.bpn2 @@ -273,6 +272,7 @@ object RequestValues { val legalEntityGateInputRequest3 = LegalEntityGateInputRequest( legalEntity = legalEntity3, + legalAddress = address3, legalNameParts = arrayOf(CommonValues.name1), externalId = CommonValues.externalId3, bpn = CommonValues.bpn3 diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 7d486b0c4..51d635632 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -259,6 +259,7 @@ object ResponseValues { val legalEntityGateInputResponse1 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity1, + legalAddress = RequestValues.address1, externalId = CommonValues.externalId1, bpn = CommonValues.bpn1, processStartedAt = SaasValues.modificationTime1, @@ -266,6 +267,7 @@ object ResponseValues { val legalEntityGateInputResponse2 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity2, + legalAddress = RequestValues.address2, externalId = CommonValues.externalId2, bpn = CommonValues.bpn2, processStartedAt = SaasValues.modificationTime2, @@ -273,6 +275,7 @@ object ResponseValues { val legalEntityGateInputResponse3 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity3, + legalAddress = RequestValues.address3, externalId = CommonValues.externalId3, bpn = CommonValues.bpn3, processStartedAt = null, @@ -281,12 +284,14 @@ object ResponseValues { //Values without processStartedAt value val newLegalEntityGateInputResponse1 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity1, + legalAddress = RequestValues.address1, externalId = CommonValues.externalId1, bpn = CommonValues.bpn1, processStartedAt = null ) val newLegalEntityGateInputResponse2 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity2, + legalAddress = RequestValues.address2, externalId = CommonValues.externalId2, bpn = CommonValues.bpn2, processStartedAt = null, diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerCreateRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerCreateRequest.kt index f1c478d59..81c400a93 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerCreateRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerCreateRequest.kt @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto +import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @@ -35,6 +36,9 @@ data class LegalEntityPartnerCreateRequest( @field:JsonUnwrapped val legalEntity: LegalEntityDto, + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressDto, + @Schema(description = "User defined index to conveniently match this entry to the corresponding entry in the response") val index: String? ) diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt index f7969d077..a7423025a 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto +import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @@ -36,5 +37,9 @@ data class LegalEntityPartnerUpdateRequest( val legalName: String, @field:JsonUnwrapped - val legalEntity: LegalEntityDto -) + val legalEntity: LegalEntityDto, + + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressDto, + + ) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index 06b02a4af..0b7aca386 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -66,7 +66,7 @@ class BusinessPartnerBuildService( val validRequests = filterLegalEntityDuplicatesByIdentifier(requests, errors) val legalEntityMetadataMap = metadataMappingService.mapRequests(validRequests.map { it.legalEntity }) - val addressMetadataMap = metadataMappingService.mapRequests(validRequests.map { it.legalEntity.legalAddress }) + val addressMetadataMap = metadataMappingService.mapRequests(validRequests.map { it.legalAddress }) val bpnLs = bpnIssuingService.issueLegalEntityBpns(validRequests.size) val bpnAs = bpnIssuingService.issueAddressBpns(validRequests.size) @@ -74,7 +74,7 @@ class BusinessPartnerBuildService( val legalEntityWithIndexByBpnMap = validRequests .mapIndexed { i, request -> val legalEntity = createLegalEntity(request.legalEntity, bpnLs[i], request.legalName, legalEntityMetadataMap) - legalEntity.legalAddress = createLogisticAddress(request.legalEntity.legalAddress, bpnAs[i], legalEntity, addressMetadataMap) + legalEntity.legalAddress = createLogisticAddress(request.legalAddress, bpnAs[i], legalEntity, addressMetadataMap) Pair(legalEntity, request.index) } .associateBy { (legalEntity, _) -> legalEntity.bpn } @@ -161,7 +161,7 @@ class BusinessPartnerBuildService( logger.info { "Update ${requests.size} legal entities" } val legalEntityMetadataMap = metadataMappingService.mapRequests(requests.map { it.legalEntity }) - val addressMetadataMap = metadataMappingService.mapRequests(requests.map { it.legalEntity.legalAddress }) + val addressMetadataMap = metadataMappingService.mapRequests(requests.map { it.legalAddress }) val bpnsToFetch = requests.map { it.bpnl } val legalEntities = legalEntityRepository.findDistinctByBpnIn(bpnsToFetch) @@ -176,7 +176,7 @@ class BusinessPartnerBuildService( legalEntities.forEach { val request = requestByBpnMap.get(it.bpn)!! updateLegalEntity(it, request.legalEntity, request.legalName, legalEntityMetadataMap) - updateLogisticAddress(it.legalAddress, request.legalEntity.legalAddress, addressMetadataMap) + updateLogisticAddress(it.legalAddress, request.legalAddress, addressMetadataMap) } changelogService.createChangelogEntries(legalEntities.map { ChangelogEntryDto(it.bpn, ChangelogType.UPDATE, ChangelogSubject.LEGAL_ENTITY) }) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt index ba8efbaff..42c7dfda7 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt @@ -153,7 +153,8 @@ class BusinessPartnerLegacyControllerIT @Autowired constructor( uuid = "", legalName = toConvert.legalName, legalEntity = toConvert.legalEntity, - addresses = listOf(toConvert.legalEntity.legalAddress), + legalAddress = toConvert.legalAddress, + addresses = listOf(toConvert.legalAddress), sites = emptyList() ) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt index 9e9afa5e4..a6af76b5a 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt @@ -153,16 +153,16 @@ class LegalEntityControllerIT @Autowired constructor( val createResponse = poolClient.legalEntities().createBusinessPartners(given) .entities.single() val givenBpnL = createResponse.legalEntity.bpnl - val givenBpnA = createResponse.legalEntity.legalAddress.bpna + val givenBpnA = createResponse.legalAddress.bpna val expected = with(ResponseValues.legalEntityUpsert3) { copy( + legalAddress = legalAddress.copy( + bpna = givenBpnA, + bpnLegalEntity = givenBpnL + ), legalEntity = legalEntity.copy( bpnl = givenBpnL, - legalAddress = legalEntity.legalAddress.copy( - bpna = givenBpnA, - bpnLegalEntity = givenBpnL - ) ), ) } @@ -188,7 +188,7 @@ class LegalEntityControllerIT @Autowired constructor( val createResponse = poolClient.legalEntities().createBusinessPartners(given) val createdEntity = createResponse.entities.toList()[1] val bpnL = createdEntity.legalEntity.bpnl - val bpnA = createdEntity.legalEntity.legalAddress.bpna + val bpnA = createdEntity.legalAddress.bpna val toUpdate = listOf( RequestValues.legalEntityUpdate3.copy(bpnl = "NONEXISTENT"), @@ -197,14 +197,14 @@ class LegalEntityControllerIT @Autowired constructor( val expected = with(ResponseValues.legalEntityUpsert3) { copy( + legalAddress = legalAddress.copy( + bpna = bpnA, + bpnLegalEntity = bpnL + ), legalEntity = legalEntity.copy( bpnl = bpnL, - legalAddress = legalEntity.legalAddress.copy( - bpna = bpnA, - bpnLegalEntity = bpnL - ) ), - + ) } @@ -233,7 +233,7 @@ class LegalEntityControllerIT @Autowired constructor( val givenLegalEntities = testHelpers.createBusinessPartnerStructure(givenStructures).map { it.legalEntity } val expected = givenLegalEntities - .map { toLegalAddressResponse(it.legalEntity.legalAddress) } + .map { toLegalAddressResponse(it.legalAddress) } val bpnsToSearch = givenLegalEntities.map { it.legalEntity.bpnl } val response = poolClient.legalEntities().searchLegalAddresses(bpnsToSearch) @@ -261,7 +261,7 @@ class LegalEntityControllerIT @Autowired constructor( val givenLegalEntities = testHelpers.createBusinessPartnerStructure(givenStructures).map { it.legalEntity } val expected = givenLegalEntities - .map { toLegalAddressResponse(it.legalEntity.legalAddress) } + .map { toLegalAddressResponse(it.legalAddress) } .take(2) val bpnsToSearch = expected.map { it.bpnLegalEntity }.plus("NONEXISTENT") diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt index c2fc976e3..4e4a3f49e 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse +import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl @@ -70,6 +71,8 @@ class LegalEntityControllerSearchIT @Autowired constructor( private lateinit var givenPartner2: LegalEntityResponse private lateinit var legalName1: String private lateinit var legalName2: String + private lateinit var legalAddress1: LogisticAddressResponse + private lateinit var legalAddress2: LogisticAddressResponse @BeforeEach fun beforeEach() { @@ -82,7 +85,8 @@ class LegalEntityControllerSearchIT @Autowired constructor( givenPartner2 = with(givenStructure[1].legalEntity) { legalEntity } legalName1 = givenStructure[0].legalEntity.legalName legalName2 = givenStructure[1].legalEntity.legalName - + legalAddress1 = givenStructure[0].legalEntity.legalAddress + legalAddress2 = givenStructure[1].legalEntity.legalAddress testHelpers.startSyncAndAwaitSuccess(webTestClient, EndpointValues.OPENSEARCH_SYNC_PATH) } @@ -97,8 +101,8 @@ class LegalEntityControllerSearchIT @Autowired constructor( val expected = PageResponse( 2, 1, 0, 2, listOf( - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner1, legalName = legalName1), - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2) + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner1, legalName = legalName1, legalAddress = legalAddress1), + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) ) ) @@ -117,12 +121,12 @@ class LegalEntityControllerSearchIT @Autowired constructor( val expectedFirstPage = PageResponse( 2, 2, 0, 1, listOf( - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner1, legalName = legalName1) + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner1, legalName = legalName1, legalAddress = legalAddress1) ) ) val expectedSecondPage = PageResponse( 2, 2, 1, 1, listOf( - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2) + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) ) ) @@ -143,7 +147,7 @@ class LegalEntityControllerSearchIT @Autowired constructor( val expected = PageResponse( 1, 1, 0, 1, listOf( - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2) + LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) ) ) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt index 345f9c760..b1a2b696b 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt @@ -70,11 +70,11 @@ class SuggestionControllerIT @Autowired constructor( private val expectedLegalEntity = ResponseValues.legalEntityUpsert1.legalEntity private val expectedLegalEntityName = ResponseValues.legalEntityUpsert1.legalName - private val expectedLegalAddress = ResponseValues.legalEntityUpsert1.legalEntity.legalAddress + private val expectedLegalAddress = ResponseValues.legalEntityUpsert1.legalAddress private val expectedSite = ResponseValues.siteUpsert2 private val nonlatinLegalEntity = ResponseValues.legalEntityUpsert3.legalEntity - private val nonlatinLegalAddress = ResponseValues.legalEntityUpsert3.legalEntity.legalAddress + private val nonlatinLegalAddress = ResponseValues.legalEntityUpsert3.legalAddress private val nonlatinSite = ResponseValues.siteUpsert3 @JvmStatic diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt index c7c499465..67ca13e88 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt @@ -162,8 +162,8 @@ object RequestValues { legalForm = CommonValues.legalFormTechnicalKey1, states = listOf(leStatus1), classifications = listOf(classification1, classification2), - legalAddress = logisticAddress1 ), + legalAddress = logisticAddress1, legalName = CommonValues.name1, index = CommonValues.index1 ) @@ -175,8 +175,8 @@ object RequestValues { legalForm = CommonValues.legalFormTechnicalKey2, states = listOf(leStatus2), classifications = listOf(classification3, classification4), - legalAddress = logisticAddress2 ), + legalAddress = logisticAddress2, legalName = CommonValues.name3, index = CommonValues.index2 ) @@ -188,8 +188,8 @@ object RequestValues { legalForm = CommonValues.legalFormTechnicalKey3, states = listOf(leStatus3), classifications = listOf(classification5), - legalAddress = logisticAddress3 ), + legalAddress = logisticAddress3, legalName = CommonValues.name5, index = CommonValues.index3 ) @@ -197,19 +197,22 @@ object RequestValues { val legalEntityUpdate1 = LegalEntityPartnerUpdateRequest( bpnl = CommonValues.bpnL1, legalName = legalEntityCreate1.legalName, - legalEntity = legalEntityCreate1.legalEntity + legalEntity = legalEntityCreate1.legalEntity, + legalAddress = legalEntityCreate1.legalAddress, ) val legalEntityUpdate2 = LegalEntityPartnerUpdateRequest( bpnl = CommonValues.bpnL2, legalName = legalEntityCreate2.legalName, - legalEntity = legalEntityCreate2.legalEntity + legalEntity = legalEntityCreate2.legalEntity, + legalAddress = legalEntityCreate2.legalAddress, ) val legalEntityUpdate3 = LegalEntityPartnerUpdateRequest( bpnl = CommonValues.bpnL3, legalName = legalEntityCreate3.legalName, - legalEntity = legalEntityCreate3.legalEntity + legalEntity = legalEntityCreate3.legalEntity, + legalAddress = legalEntityCreate3.legalAddress, ) val siteCreate1 = SitePartnerCreateRequest( diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt index 9ae6784fb..138293ce5 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt @@ -253,32 +253,32 @@ object ResponseValues { currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = LogisticAddressResponse( - bpna = CommonValues.bpnA1, - physicalPostalAddress = PhysicalPostalAddressResponse( - companyPostalCode = null, - industrialZone = null, - building = null, - floor = null, - door = null, - areaPart = AreaDistrictResponse( - administrativeAreaLevel1 = null, - administrativeAreaLevel2 = null, - district = null, - ), - street = null, - baseAddress = BasePostalAddressResponse( - geographicCoordinates = null, - country = country1, - postalCode = null, - city = CommonValues.locality1, - ) + ), + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnA1, + physicalPostalAddress = PhysicalPostalAddressResponse( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null, + areaPart = AreaDistrictResponse( + administrativeAreaLevel1 = null, + administrativeAreaLevel2 = null, + district = null, ), - bpnLegalEntity = null, - bpnSite = null, - createdAt = Instant.now(), - updatedAt = Instant.now() - ) + street = null, + baseAddress = BasePostalAddressResponse( + geographicCoordinates = null, + country = country1, + postalCode = null, + city = CommonValues.locality1, + ) + ), + bpnLegalEntity = null, + bpnSite = null, + createdAt = Instant.now(), + updatedAt = Instant.now() ) ) @@ -293,32 +293,32 @@ object ResponseValues { currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = LogisticAddressResponse( - bpna = CommonValues.bpnA1, - physicalPostalAddress = PhysicalPostalAddressResponse( - companyPostalCode = null, - industrialZone = null, - building = null, - floor = null, - door = null, - areaPart = AreaDistrictResponse( - administrativeAreaLevel1 = null, - administrativeAreaLevel2 = null, - district = null, - ), - street = null, - baseAddress = BasePostalAddressResponse( - geographicCoordinates = null, - country = country2, - postalCode = null, - city = CommonValues.locality3, - ) + ), + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnA1, + physicalPostalAddress = PhysicalPostalAddressResponse( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null, + areaPart = AreaDistrictResponse( + administrativeAreaLevel1 = null, + administrativeAreaLevel2 = null, + district = null, ), - bpnLegalEntity = null, - bpnSite = null, - createdAt = Instant.now(), - updatedAt = Instant.now() - ) + street = null, + baseAddress = BasePostalAddressResponse( + geographicCoordinates = null, + country = country2, + postalCode = null, + city = CommonValues.locality3, + ) + ), + bpnLegalEntity = null, + bpnSite = null, + createdAt = Instant.now(), + updatedAt = Instant.now() ) ) @@ -333,32 +333,32 @@ object ResponseValues { currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = LogisticAddressResponse( - bpna = CommonValues.bpnA1, - physicalPostalAddress = PhysicalPostalAddressResponse( - companyPostalCode = null, - industrialZone = null, - building = null, - floor = null, - door = null, - areaPart = AreaDistrictResponse( - administrativeAreaLevel1 = null, - administrativeAreaLevel2 = null, - district = null, - ), - street = null, - baseAddress = BasePostalAddressResponse( - geographicCoordinates = null, - country = country3, - postalCode = null, - city = CommonValues.locality5, - ) + ), + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnA1, + physicalPostalAddress = PhysicalPostalAddressResponse( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null, + areaPart = AreaDistrictResponse( + administrativeAreaLevel1 = null, + administrativeAreaLevel2 = null, + district = null, ), - bpnLegalEntity = null, - bpnSite = null, - createdAt = Instant.now(), - updatedAt = Instant.now() - ) + street = null, + baseAddress = BasePostalAddressResponse( + geographicCoordinates = null, + country = country3, + postalCode = null, + city = CommonValues.locality5, + ) + ), + bpnLegalEntity = null, + bpnSite = null, + createdAt = Instant.now(), + updatedAt = Instant.now() ) ) @@ -373,10 +373,11 @@ object ResponseValues { currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = addressPartner1.copy( - bpnLegalEntity = legalEntity1.legalEntity.bpnl, - isLegalAddress = true + ), + legalAddress = addressPartner1.copy( + bpnLegalEntity = legalEntity1.legalEntity.bpnl, + isLegalAddress = true ), index = CommonValues.index1 ) @@ -392,10 +393,10 @@ object ResponseValues { currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = addressPartner2.copy( - bpnLegalEntity = legalEntity2.legalEntity.bpnl, - isLegalAddress = true - ), + ), + legalAddress = addressPartner2.copy( + bpnLegalEntity = legalEntity2.legalEntity.bpnl, + isLegalAddress = true ), index = CommonValues.index2 ) @@ -411,10 +412,10 @@ object ResponseValues { currentness = SaasValues.createdTime1.toInstant(ZoneOffset.UTC), createdAt = CommonValues.now, updatedAt = CommonValues.now, - legalAddress = addressPartner3.copy( - bpnLegalEntity = legalEntity3.legalEntity.bpnl, - isLegalAddress = true - ) + ), + legalAddress = addressPartner3.copy( + bpnLegalEntity = legalEntity3.legalEntity.bpnl, + isLegalAddress = true ), index = CommonValues.index3 ) From fbef164b1cd41fe0ce5f0f45f3079d8cb82ff1e8 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 1 Jun 2023 17:00:29 +0200 Subject: [PATCH 20/83] feat(api): #183 Gate API: Add Street Name Suffix and Prefix Fields - add PhysicalPostalAddressGateDto --- .../bpdm/bridge/dummy/dto/GateAddressInfo.kt | 4 +- .../bridge/dummy/dto/GateLegalEntityInfo.kt | 4 +- .../bpdm/bridge/dummy/dto/GateSiteInfo.kt | 4 +- .../bridge/dummy/service/PoolUpdateService.kt | 67 ++++++++++++-- .../bpdm/common/dto/BasePhysicalAddressDto.kt | 41 +++++++++ .../common/dto/PhysicalPostalAddressDto.kt | 16 +--- .../bpdm/common/service/SaasMappings.kt | 12 +-- .../gate/api/model/AddressGateInputRequest.kt | 3 +- .../api/model/AddressGateInputResponse.kt | 5 +- .../api/model/BusinessPartnerCandidateDto.kt | 3 +- .../api/model/LegalEntityGateInputRequest.kt | 3 +- .../api/model/LegalEntityGateInputResponse.kt | 3 +- .../gate/api/model/LogisticAddressGateDto.kt | 48 ++++++++++ .../api/model/PhysicalPostalAddressGateDto.kt | 45 ++++++++++ .../bpdm/gate/api/model/SiteGateDto.kt | 36 ++++++++ .../gate/api/model/SiteGateInputRequest.kt | 3 +- .../gate/api/model/SiteGateInputResponse.kt | 3 +- .../bpdm/gate/api/model/StreetGateDto.kt | 51 +++++++++++ .../gate/service/InputSaasMappingService.kt | 38 -------- .../bpdm/gate/service/ResponseMappings.kt | 46 +++++----- .../service/SaasDtoToSaasAddressMapping.kt | 22 ++--- .../gate/service/SaasLookupMappingService.kt | 4 +- .../gate/service/SaasRequestMappingService.kt | 8 +- .../SaasDtoToSaasAddressMappingTest.kt | 39 +++++--- .../tractusx/bpdm/gate/util/RequestValues.kt | 88 ++++++++++--------- .../service/BusinessPartnerBuildService.kt | 10 +-- .../service/SaasAddressToDtoMappingTest.kt | 9 +- .../tractusx/bpdm/pool/util/RequestValues.kt | 32 ++++--- 28 files changed, 446 insertions(+), 201 deletions(-) create mode 100644 bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BasePhysicalAddressDto.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateAddressInfo.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateAddressInfo.kt index 479fc02c5..76629db2f 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateAddressInfo.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateAddressInfo.kt @@ -19,10 +19,10 @@ package com.catenax.bpdm.bridge.dummy.dto -import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto +import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto data class GateAddressInfo( - val address: LogisticAddressDto, + val address: LogisticAddressGateDto, val externalId: String, val legalEntityExternalId: String?, val siteExternalId: String?, diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt index 9e73f6856..a0c2f1b86 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt @@ -20,12 +20,12 @@ package com.catenax.bpdm.bridge.dummy.dto import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto -import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto +import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto data class GateLegalEntityInfo( val legalNameParts: Array = emptyArray(), val legalEntity: LegalEntityDto, - val legalAddress: LogisticAddressDto, + val legalAddress: LogisticAddressGateDto, val externalId: String, val bpn: String? ) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateSiteInfo.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateSiteInfo.kt index 165c27565..10f9171ef 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateSiteInfo.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateSiteInfo.kt @@ -19,10 +19,10 @@ package com.catenax.bpdm.bridge.dummy.dto -import org.eclipse.tractusx.bpdm.common.dto.SiteDto +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateDto data class GateSiteInfo( - val site: SiteDto, + val site: SiteGateDto, val externalId: String, val legalEntityExternalId: String, val bpn: String? diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index d8a250b55..dd3e679f6 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -23,6 +23,12 @@ import com.catenax.bpdm.bridge.dummy.dto.GateAddressInfo import com.catenax.bpdm.bridge.dummy.dto.GateLegalEntityInfo import com.catenax.bpdm.bridge.dummy.dto.GateSiteInfo import mu.KotlinLogging +import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto +import org.eclipse.tractusx.bpdm.common.dto.PhysicalPostalAddressDto +import org.eclipse.tractusx.bpdm.common.dto.SiteDto +import org.eclipse.tractusx.bpdm.common.dto.StreetDto +import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto +import org.eclipse.tractusx.bpdm.gate.api.model.PhysicalPostalAddressGateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient import org.eclipse.tractusx.bpdm.pool.api.model.request.* @@ -37,11 +43,38 @@ class PoolUpdateService( private val logger = KotlinLogging.logger { } + fun gateToPoolPhysicalAddress(gateDto: PhysicalPostalAddressGateDto): PhysicalPostalAddressDto { + + return PhysicalPostalAddressDto( + baseAddress = gateDto.baseAddress, + areaPart = gateDto.areaPart, + basePhysicalAddress = gateDto.basePhysicalAddress, + street = StreetDto( + name = gateDto.street?.name, + houseNumber = gateDto.street?.houseNumber, + milestone = gateDto.street?.milestone, + direction = gateDto.street?.direction, + ), + ) + } + + fun gateToPoolLogisticAddress(gateDto: LogisticAddressGateDto): LogisticAddressDto { + + return LogisticAddressDto( + name = gateDto.name, + states = gateDto.states, + identifiers = gateDto.identifiers, + physicalPostalAddress = gateToPoolPhysicalAddress(gateDto.physicalPostalAddress), + alternativePostalAddress = gateDto.alternativePostalAddress + ) + } + + fun createLegalEntitiesInPool(entriesToCreate: Collection): LegalEntityPartnerCreateResponseWrapper { val createRequests = entriesToCreate.map { LegalEntityPartnerCreateRequest( legalEntity = it.legalEntity, - legalAddress = it.legalAddress, + legalAddress = gateToPoolLogisticAddress(it.legalAddress), index = it.externalId, legalName = it.legalNameParts[0] ) @@ -55,7 +88,7 @@ class PoolUpdateService( val updateRequests = entriesToUpdate.map { LegalEntityPartnerUpdateRequest( legalEntity = it.legalEntity, - legalAddress = it.legalAddress, + legalAddress = gateToPoolLogisticAddress(it.legalAddress), bpnl = it.bpn!!, legalName = it.legalNameParts[0] ) @@ -73,7 +106,11 @@ class PoolUpdateService( leParentBpnByExternalId[entry.legalEntityExternalId] ?.let { leParentBpn -> SitePartnerCreateRequest( - site = entry.site, + site = SiteDto( + name = entry.site.name, + states = entry.site.states, + mainAddress = gateToPoolLogisticAddress(entry.site.mainAddress), + ), index = entry.externalId, bpnlParent = leParentBpn ) @@ -93,7 +130,11 @@ class PoolUpdateService( fun updateSitesInPool(entriesToUpdate: Collection): SitePartnerUpdateResponseWrapper { val updateRequests = entriesToUpdate.map { SitePartnerUpdateRequest( - site = it.site, + site = SiteDto( + name = it.site.name, + states = it.site.states, + mainAddress = gateToPoolLogisticAddress(it.site.mainAddress), + ), bpns = it.bpn!! ) } @@ -110,7 +151,7 @@ class PoolUpdateService( leParentBpnByExternalId[entry.legalEntityExternalId] ?.let { leParentBpn -> AddressPartnerCreateRequest( - address = entry.address, + address = gateToPoolLogisticAddress(entry.address), index = entry.externalId, bpnParent = leParentBpn ) @@ -124,7 +165,13 @@ class PoolUpdateService( siteParentBpnByExternalId[entry.siteExternalId] ?.let { siteParentBpn -> AddressPartnerCreateRequest( - address = entry.address, + address = LogisticAddressDto( + name = entry.address.name, + states = entry.address.states, + identifiers = entry.address.identifiers, + physicalPostalAddress = gateToPoolPhysicalAddress(entry.address.physicalPostalAddress), + alternativePostalAddress = entry.address.alternativePostalAddress + ), index = entry.externalId, bpnParent = siteParentBpn ) @@ -145,7 +192,13 @@ class PoolUpdateService( fun updateAddressesInPool(entriesToUpdate: Collection): AddressPartnerUpdateResponseWrapper { val updateRequests = entriesToUpdate.map { AddressPartnerUpdateRequest( - address = it.address, + address = LogisticAddressDto( + name = it.address.name, + states = it.address.states, + identifiers = it.address.identifiers, + physicalPostalAddress = gateToPoolPhysicalAddress(it.address.physicalPostalAddress), + alternativePostalAddress = it.address.alternativePostalAddress + ), bpna = it.bpn!! ) } diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BasePhysicalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BasePhysicalAddressDto.kt new file mode 100644 index 000000000..17da3f4bd --- /dev/null +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/BasePhysicalAddressDto.kt @@ -0,0 +1,41 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.common.dto + +import io.swagger.v3.oas.annotations.media.Schema + +@Schema(name = "BasePhysicalAddressDto", description = "Address record for the basical physical address fields") +data class BasePhysicalAddressDto( + + @get:Schema(description = "A separate postal code for a company, also known as postcode, PIN or ZIP Code") + val companyPostalCode: String? = null, + + @get:Schema(description = "The practice of designating an area for industrial development") + val industrialZone: String? = null, + + @get:Schema(description = "Describes a specific building within the address") + val building: String? = null, + + @get:Schema(description = "Describes the floor/level the delivery shall take place") + val floor: String? = null, + + @get:Schema(description = "Describes the door/room/suite on the respective floor the delivery shall take place") + val door: String? = null, +) \ No newline at end of file diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt index 2fff25842..c2ee4980e 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/PhysicalPostalAddressDto.kt @@ -37,18 +37,6 @@ data class PhysicalPostalAddressDto( @field:JsonUnwrapped val areaPart: AreaDistrictDto, - @get:Schema(description = "A separate postal code for a company, also known as postcode, PIN or ZIP Code") - val companyPostalCode: String? = null, - - @get:Schema(description = "The practice of designating an area for industrial development") - val industrialZone: String? = null, - - @get:Schema(description = "Describes a specific building within the address") - val building: String? = null, - - @get:Schema(description = "Describes the floor/level the delivery shall take place") - val floor: String? = null, - - @get:Schema(description = "Describes the door/room/suite on the respective floor the delivery shall take place") - val door: String? = null, + @field:JsonUnwrapped + val basePhysicalAddress: BasePhysicalAddressDto ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt index d3a92c20b..06f2b2c97 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt @@ -203,11 +203,13 @@ object SaasMappings { } return PhysicalPostalAddressDto( - companyPostalCode = map.companyPostCode(), - industrialZone = map.industrialZone(), - building = map.building(), - floor = map.floor(), - door = map.door(), + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = map.companyPostCode(), + industrialZone = map.industrialZone(), + building = map.building(), + floor = map.floor(), + door = map.door(), + ), areaPart = AreaDistrictDto( administrativeAreaLevel1 = map.adminAreaLevel1(), administrativeAreaLevel2 = map.adminAreaLevel2(), diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt index 14020d1cd..dc6b54920 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @@ -32,7 +31,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ ) data class AddressGateInputRequest( @field:JsonUnwrapped - val address: LogisticAddressDto, + val address: LogisticAddressGateDto, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt index bf0cea128..d7642a7eb 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt @@ -22,8 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema - -import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer import java.time.LocalDateTime @@ -33,8 +31,9 @@ import java.time.LocalDateTime "Only one of either legal entity or site external id can be set for an address." ) data class AddressGateInputResponse( + @field:JsonUnwrapped - val address: LogisticAddressDto, + val address: LogisticAddressGateDto, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt index 2849b7433..57a5a8018 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model import io.swagger.v3.oas.annotations.media.ArraySchema import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.GenericIdentifierDto -import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.dto.NameDto data class BusinessPartnerCandidateDto( @@ -36,5 +35,5 @@ data class BusinessPartnerCandidateDto( val legalForm: String? = null, @Schema(description = "Address of this partner") - val address: LogisticAddressDto + val address: LogisticAddressGateDto ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt index 0472f650a..1c7ec2bd6 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto -import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @@ -35,7 +34,7 @@ data class LegalEntityGateInputRequest( val legalEntity: LegalEntityDto, @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressDto, + val legalAddress: LogisticAddressGateDto, @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt index 2f315c37a..74b0abf43 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt @@ -23,7 +23,6 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto -import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer import java.time.LocalDateTime @@ -37,7 +36,7 @@ data class LegalEntityGateInputResponse( val legalEntity: LegalEntityDto, @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressDto, + val legalAddress: LogisticAddressGateDto, @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt new file mode 100644 index 000000000..1926e3ed1 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import io.swagger.v3.oas.annotations.media.ArraySchema +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.AddressIdentifierDto +import org.eclipse.tractusx.bpdm.common.dto.AddressStateDto +import org.eclipse.tractusx.bpdm.common.dto.AlternativePostalAddressDto + + +@Schema(name = "LogisticAddressDto", description = "Address record for a business partner") +data class LogisticAddressGateDto( + @get:Schema( + description = "Name of the logistic address of the business partner. This is not according to official\n" + + "registers but according to the name the uploading sharing member chooses." + ) + val name: String? = null, + + @ArraySchema(arraySchema = Schema(description = "Indicates if the LogisticAddress is \"Active\" or \"Inactive\".")) + val states: Collection = emptyList(), + + @ArraySchema(arraySchema = Schema(description = "List of identifiers")) + val identifiers: Collection = emptyList(), + + @get:Schema(description = "Physical postal address") + val physicalPostalAddress: PhysicalPostalAddressGateDto, + + @get:Schema(description = "Alternative postal address") + val alternativePostalAddress: AlternativePostalAddressDto? = null +) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt new file mode 100644 index 000000000..58e27b883 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt @@ -0,0 +1,45 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.AreaDistrictDto +import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto +import org.eclipse.tractusx.bpdm.common.dto.BasePostalAddressDto +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema(name = "PhysicalPostalAddress", description = "Physical Postal Address Part") +data class PhysicalPostalAddressGateDto( + + @field:JsonUnwrapped + val baseAddress: BasePostalAddressDto, + + @get:Schema(description = "Address Street") + val street: StreetGateDto? = null, + + @field:JsonUnwrapped + val areaPart: AreaDistrictDto, + + @field:JsonUnwrapped + val basePhysicalAddress: BasePhysicalAddressDto +) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt new file mode 100644 index 000000000..923c06e23 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt @@ -0,0 +1,36 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import io.swagger.v3.oas.annotations.media.ArraySchema +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.SiteStateDto + +@Schema(name = "Site", description = "Site record") +data class SiteGateDto( + @get:Schema(description = "Site name") + val name: String, + + @ArraySchema(arraySchema = Schema(description = "Business status")) + val states: Collection = emptyList(), + + @get:Schema(description = "Main address where this site resides") + val mainAddress: LogisticAddressGateDto +) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt index d75d7f191..b42937a30 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.SiteDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @@ -31,7 +30,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ ) data class SiteGateInputRequest( @field:JsonUnwrapped - val site: SiteDto, + val site: SiteGateDto, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt index 8b7b55372..7732cc602 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.SiteDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer import java.time.LocalDateTime @@ -32,7 +31,7 @@ import java.time.LocalDateTime ) data class SiteGateInputResponse( @field:JsonUnwrapped - val site: SiteDto, + val site: SiteGateDto, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt new file mode 100644 index 000000000..59358cf28 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import io.swagger.v3.oas.annotations.media.Schema + +@Schema(name = "Street", description = "A public road in a city, town, or village, typically with houses and buildings on one or both sides.") +data class StreetGateDto( + + + @get:Schema(description = "Describes the official name prefix of the Street.") + val namePrefix: String? = null, + + @get:Schema(description = "Describes the additional name prefix of the Street.") + val additionalNamePrefix: String? = null, + + @get:Schema(description = "Describes the Name of the Street.") + val name: String? = null, + + @get:Schema(description = "Describes the name suffix of the Street.") + val NameSuffix: String? = null, + + @get:Schema(description = "Describes the additional name suffix of the Street.") + val additionalNameSuffix: String? = null, + + @get:Schema(description = "Describes the House Number") + val houseNumber: String? = null, + + @get:Schema(description = "The Milestone is relevant for long roads without specific house numbers.") + val milestone: String? = null, + + @get:Schema(description = "Describes the direction") + val direction: String? = null +) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt index cfd3d2aa6..f4ef64550 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/InputSaasMappingService.kt @@ -20,13 +20,6 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas -import org.eclipse.tractusx.bpdm.common.service.SaasMappings -import org.eclipse.tractusx.bpdm.common.service.SaasMappings.toLegalEntityDto -import org.eclipse.tractusx.bpdm.common.service.SaasMappings.toLogisticAddressDto -import org.eclipse.tractusx.bpdm.common.service.SaasMappings.toSiteDto -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.springframework.stereotype.Service @@ -37,37 +30,6 @@ class InputSaasMappingService( private val bpnConfigProperties: BpnConfigProperties ) { - fun toInputLegalEntity(businessPartner: BusinessPartnerSaas): LegalEntityGateInputResponse { - return LegalEntityGateInputResponse( - legalEntity = businessPartner.toLegalEntityDto(), - // TODO Known issue: For now the legal address is not a separate business partner in SaaS, therefore its properties name, states, identifiers are missing! - legalAddress = SaasMappings.convertSaasAdressesToLogisticAddressDto(businessPartner.addresses, businessPartner.id), - externalId = businessPartner.externalId!!, - bpn = businessPartner.identifiers.find { it.type?.technicalKey == SaasMappings.BPN_TECHNICAL_KEY }?.value, - processStartedAt = businessPartner.lastModifiedAt, - ) - } - - fun toInputAddress(businessPartner: BusinessPartnerSaas, legalEntityExternalId: String?, siteExternalId: String?): AddressGateInputResponse { - return AddressGateInputResponse( - address = businessPartner.toLogisticAddressDto(), - externalId = businessPartner.externalId!!, - legalEntityExternalId = legalEntityExternalId, - siteExternalId = siteExternalId, - bpn = businessPartner.identifiers.find { it.type?.technicalKey == bpnConfigProperties.id }?.value, - processStartedAt = businessPartner.lastModifiedAt, - ) - } - - fun toInputSite(businessPartner: BusinessPartnerSaas): SiteGateInputResponse { - return SiteGateInputResponse( - site = businessPartner.toSiteDto(), - externalId = businessPartner.externalId!!, - legalEntityExternalId = toParentLegalEntityExternalId(businessPartner)!!, - bpn = businessPartner.identifiers.find { it.type?.technicalKey == bpnConfigProperties.id }?.value, - processStartedAt = businessPartner.lastModifiedAt, - ) - } fun toParentLegalEntityExternalId(businessPartner: BusinessPartnerSaas): String? { return toParentLegalEntityExternalIds(businessPartner).firstOrNull() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 8d77f9bf0..4b237c4da 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -69,7 +69,7 @@ fun AlternativePostalAddressDto.toAlternativePostalAddressEntity(): AlternativeP } -fun PhysicalPostalAddressDto.toPhysicalPostalAddressEntity(): PhysicalPostalAddress { +fun PhysicalPostalAddressGateDto.toPhysicalPostalAddressEntity(): PhysicalPostalAddress { return PhysicalPostalAddress( geographicCoordinates = baseAddress.geographicCoordinates?.toGeographicCoordinateEntity(), @@ -81,11 +81,11 @@ fun PhysicalPostalAddressDto.toPhysicalPostalAddressEntity(): PhysicalPostalAddr city = baseAddress.city, districtLevel1 = areaPart.district, street = street?.toStreetEntity(), - companyPostCode = companyPostalCode, - industrialZone = industrialZone, - building = building, - floor = floor, - door = door + companyPostCode = basePhysicalAddress.companyPostalCode, + industrialZone = basePhysicalAddress.industrialZone, + building = basePhysicalAddress.building, + floor = basePhysicalAddress.floor, + door = basePhysicalAddress.door ) } @@ -94,7 +94,7 @@ fun GeoCoordinateDto.toGeographicCoordinateEntity(): GeographicCoordinate { return GeographicCoordinate(longitude, latitude, altitude) } -private fun StreetDto.toStreetEntity(): Street { +private fun StreetGateDto.toStreetEntity(): Street { return Street( name = name, houseNumber = houseNumber, @@ -206,9 +206,9 @@ fun LogisticAddress.toAddressGateInputResponse(logisticAddressPage: LogisticAddr } //Logistic Address mapping to LogisticAddressDto -fun LogisticAddress.toLogisticAddressDto(): LogisticAddressDto { +fun LogisticAddress.toLogisticAddressDto(): LogisticAddressGateDto { - val logisticAddress = LogisticAddressDto( + val logisticAddress = LogisticAddressGateDto( name = name, states = mapToDtoStates(states), identifiers = mapToDtoIdentifiers(identifiers), @@ -249,7 +249,7 @@ fun AlternativePostalAddress.toAlternativePostalAddressDto(): AlternativePostalA } -fun PhysicalPostalAddress.toPhysicalPostalAddress(): PhysicalPostalAddressDto { +fun PhysicalPostalAddress.toPhysicalPostalAddress(): PhysicalPostalAddressGateDto { val basePostalAddressDto = BasePostalAddressDto( geographicCoordinates = geographicCoordinates?.toGeographicCoordinateDto(), @@ -265,14 +265,16 @@ fun PhysicalPostalAddress.toPhysicalPostalAddress(): PhysicalPostalAddressDto { district = districtLevel1 ) - return PhysicalPostalAddressDto( + return PhysicalPostalAddressGateDto( baseAddress = basePostalAddressDto, - companyPostalCode = companyPostCode, - industrialZone = industrialZone, - building = building, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = companyPostCode, + industrialZone = industrialZone, + building = building, + floor = floor, + door = door, + ), street = street?.toStreetDto(), - floor = floor, - door = door, areaPart = areaDistrictDto ) @@ -282,8 +284,8 @@ fun GeographicCoordinate.toGeographicCoordinateDto(): GeoCoordinateDto { return GeoCoordinateDto(longitude, latitude, altitude) } -private fun Street.toStreetDto(): StreetDto { - return StreetDto( +private fun Street.toStreetDto(): StreetGateDto { + return StreetGateDto( name = name, houseNumber = houseNumber, milestone = milestone, @@ -314,10 +316,6 @@ fun mapToLegalEntityClassificationsDto(classification: MutableSet { + fun administrativeAreas(physicalAddress: PhysicalPostalAddressGateDto?): Collection { return listOfNotNull( physicalAddress?.areaPart?.administrativeAreaLevel1?.let { AdministrativeAreaSaas( @@ -67,7 +67,7 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto } - fun postcodes(physicalAddress: PhysicalPostalAddressDto?): Collection { + fun postcodes(physicalAddress: PhysicalPostalAddressGateDto?): Collection { return listOfNotNull( postalAdress.postalCode?.let { PostCodeSaas( @@ -75,7 +75,7 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto type = SaasPostCodeType.REGULAR.toSaasTypeDto() ) }, - physicalAddress?.companyPostalCode?.let { + physicalAddress?.basePhysicalAddress?.companyPostalCode?.let { PostCodeSaas( value = it, type = SaasPostCodeType.LARGE_MAIL_USER.toSaasTypeDto() @@ -93,7 +93,7 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto ) } - fun localities(physicalAddress: PhysicalPostalAddressDto?): Collection { + fun localities(physicalAddress: PhysicalPostalAddressGateDto?): Collection { return listOfNotNull( LocalitySaas( @@ -107,7 +107,7 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto ) } - fun thoroughfares(physicalAddress: PhysicalPostalAddressDto?): Collection { + fun thoroughfares(physicalAddress: PhysicalPostalAddressGateDto?): Collection { return listOfNotNull( physicalAddress?.street?.let { ThoroughfareSaas( @@ -118,7 +118,7 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto direction = it.direction ) }, - physicalAddress?.industrialZone?.let { + physicalAddress?.basePhysicalAddress?.industrialZone?.let { ThoroughfareSaas( type = SaasThoroughfareType.INDUSTRIAL_ZONE.toSaasTypeDto(), name = it @@ -127,21 +127,21 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto ) } - fun premises(physicalAddress: PhysicalPostalAddressDto?): Collection { + fun premises(physicalAddress: PhysicalPostalAddressGateDto?): Collection { return listOfNotNull( - physicalAddress?.building?.let { + physicalAddress?.basePhysicalAddress?.building?.let { PremiseSaas( value = it, type = SaasPremiseType.BUILDING.toSaasTypeDto() ) }, - physicalAddress?.floor?.let { + physicalAddress?.basePhysicalAddress?.floor?.let { PremiseSaas( value = it, type = SaasPremiseType.LEVEL.toSaasTypeDto() ) }, - physicalAddress?.door?.let { + physicalAddress?.basePhysicalAddress?.door?.let { PremiseSaas( value = it, type = SaasPremiseType.ROOM.toSaasTypeDto() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt index 74a9ed598..e94db99f5 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt @@ -21,9 +21,9 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.GenericIdentifierDto import org.eclipse.tractusx.bpdm.common.dto.LegalEntityIdentifierDto -import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto +import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto import org.springframework.stereotype.Service @Service @@ -46,7 +46,7 @@ class SaasLookupMappingService { private fun toSaas(identifier: GenericIdentifierDto): IdentifierLookupSaas = IdentifierLookupSaas(identifier.value, TechnicalKeyLookupSaas(identifier.type)) - private fun toSaas(address: LogisticAddressDto): AddressLookupSaas = + private fun toSaas(address: LogisticAddressGateDto): AddressLookupSaas = with(address) { AddressLookupSaas( // TODO Mapping diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt index 4d7487fa3..dc17ac9a1 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt @@ -23,9 +23,7 @@ import org.eclipse.tractusx.bpdm.common.dto.* import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.common.model.SaasAddressType import org.eclipse.tractusx.bpdm.common.model.toSaasTypeDto -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.springframework.stereotype.Service @@ -141,13 +139,13 @@ class SaasRequestMappingService( ) } - private fun toAddressesSaasModel(address: LogisticAddressDto): Collection { + private fun toAddressesSaasModel(address: LogisticAddressGateDto): Collection { val physicalAddress = address.physicalPostalAddress.let { toPhysicalAddressSaasModel(it) } val alternativeAddress = address.alternativePostalAddress?.let { toAlternativeAddressSaasModel(it) } return listOfNotNull(physicalAddress, alternativeAddress) } - private fun toPhysicalAddressSaasModel(address: PhysicalPostalAddressDto): AddressSaas { + private fun toPhysicalAddressSaasModel(address: PhysicalPostalAddressGateDto): AddressSaas { val mapping = SaasDtoToSaasAddressMapping(address.baseAddress) return AddressSaas( country = mapping.country(), diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMappingTest.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMappingTest.kt index 35db79a15..0145377d6 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMappingTest.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasDtoToSaasAddressMappingTest.kt @@ -36,10 +36,15 @@ class SaasDtoToSaasAddressMappingTest { assertThat(streetDto?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction) assertThat(streetDto?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName) - assertThat(addressDto.physicalPostalAddress.industrialZone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name) - assertThat(addressDto.physicalPostalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) - assertThat(addressDto.physicalPostalAddress.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) - assertThat(addressDto.physicalPostalAddress.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.industrialZone).isEqualTo( + findObject( + addressSaas.thoroughfares, + SaasThoroughfareType.INDUSTRIAL_ZONE + )?.name + ) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) } @Test @@ -81,10 +86,15 @@ class SaasDtoToSaasAddressMappingTest { assertThat(streetDto?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction) assertThat(streetDto?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName) - assertThat(addressDto.physicalPostalAddress.industrialZone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name) - assertThat(addressDto.physicalPostalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) - assertThat(addressDto.physicalPostalAddress.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) - assertThat(addressDto.physicalPostalAddress.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.industrialZone).isEqualTo( + findObject( + addressSaas.thoroughfares, + SaasThoroughfareType.INDUSTRIAL_ZONE + )?.name + ) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) } @Test @@ -110,10 +120,15 @@ class SaasDtoToSaasAddressMappingTest { assertThat(streetDto?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction) assertThat(streetDto?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName) - assertThat(addressDto.physicalPostalAddress.industrialZone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name) - assertThat(addressDto.physicalPostalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) - assertThat(addressDto.physicalPostalAddress.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) - assertThat(addressDto.physicalPostalAddress.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.industrialZone).isEqualTo( + findObject( + addressSaas.thoroughfares, + SaasThoroughfareType.INDUSTRIAL_ZONE + )?.name + ) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) + assertThat(addressDto.physicalPostalAddress.basePhysicalAddress.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) } private fun findValue(values: Collection, enumType: SaasType): String? { diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index 7761fbb6a..60515865b 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -20,9 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.util import org.eclipse.tractusx.bpdm.common.dto.* -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.* object RequestValues { val identifier1 = @@ -113,17 +111,19 @@ object RequestValues { val geoCoordinate1 = GeoCoordinateDto(CommonValues.geoCoordinates1.first, CommonValues.geoCoordinates1.second) val geoCoordinate2 = GeoCoordinateDto(CommonValues.geoCoordinates2.first, CommonValues.geoCoordinates2.second) - val postalAddress1 = PhysicalPostalAddressDto( - industrialZone = CommonValues.industrialZone1, - building = CommonValues.building1, - floor = CommonValues.floor1, - door = CommonValues.door1, + val postalAddress1 = PhysicalPostalAddressGateDto( + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone1, + building = CommonValues.building1, + floor = CommonValues.floor1, + door = CommonValues.door1, + ), areaPart = AreaDistrictDto( administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_1, //null, administrativeAreaLevel2 = CommonValues.county1, district = CommonValues.district1, ), - street = StreetDto(name = CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1), + street = StreetGateDto(name = CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1), baseAddress = BasePostalAddressDto( geographicCoordinates = geoCoordinate1, country = CommonValues.country1, @@ -132,17 +132,19 @@ object RequestValues { ) ) - val postalAddress2 = PhysicalPostalAddressDto( - industrialZone = CommonValues.industrialZone2, - building = CommonValues.building2, - floor = CommonValues.floor2, - door = CommonValues.door2, + val postalAddress2 = PhysicalPostalAddressGateDto( + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone2, + building = CommonValues.building2, + floor = CommonValues.floor2, + door = CommonValues.door2 + ), areaPart = AreaDistrictDto( administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_2, administrativeAreaLevel2 = CommonValues.county2, district = CommonValues.district2, ), - street = StreetDto(name = CommonValues.street2, houseNumber = CommonValues.houseNumber2, direction = CommonValues.direction2), + street = StreetGateDto(name = CommonValues.street2, houseNumber = CommonValues.houseNumber2, direction = CommonValues.direction2), baseAddress = BasePostalAddressDto( geographicCoordinates = geoCoordinate2, country = CommonValues.country2, @@ -150,17 +152,19 @@ object RequestValues { city = CommonValues.city2, ) ) - val postalAddress3 = PhysicalPostalAddressDto( - industrialZone = CommonValues.industrialZone1, - building = CommonValues.building1, - floor = CommonValues.floor1, - door = CommonValues.door1, + val postalAddress3 = PhysicalPostalAddressGateDto( + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone1, + building = CommonValues.building1, + floor = CommonValues.floor1, + door = CommonValues.door1, + ), areaPart = AreaDistrictDto( administrativeAreaLevel1 = null, administrativeAreaLevel2 = CommonValues.county1, district = CommonValues.district1, ), - street = StreetDto(name = CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1), + street = StreetGateDto(name = CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1), baseAddress = BasePostalAddressDto( geographicCoordinates = geoCoordinate1, country = CommonValues.country1, @@ -170,17 +174,19 @@ object RequestValues { ) //New Values for Logistic Addresses Tests - val postalAddressLogisticAddress1 = PhysicalPostalAddressDto( - industrialZone = CommonValues.industrialZone1, - building = CommonValues.building1, - floor = CommonValues.floor1, - door = CommonValues.door1, + val postalAddressLogisticAddress1 = PhysicalPostalAddressGateDto( + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone1, + building = CommonValues.building1, + floor = CommonValues.floor1, + door = CommonValues.door1, + ), areaPart = AreaDistrictDto( administrativeAreaLevel1 = null, administrativeAreaLevel2 = CommonValues.county1, district = CommonValues.district1, ), - street = StreetDto(name = CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1), + street = StreetGateDto(name = CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1), baseAddress = BasePostalAddressDto( geographicCoordinates = geoCoordinate1, country = CommonValues.country1, @@ -189,17 +195,19 @@ object RequestValues { ) ) - val postalAddressLogisticAddress2 = PhysicalPostalAddressDto( - industrialZone = CommonValues.industrialZone2, - building = CommonValues.building2, - floor = CommonValues.floor2, - door = CommonValues.door2, + val postalAddressLogisticAddress2 = PhysicalPostalAddressGateDto( + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone2, + building = CommonValues.building2, + floor = CommonValues.floor2, + door = CommonValues.door2, + ), areaPart = AreaDistrictDto( administrativeAreaLevel1 = null, administrativeAreaLevel2 = CommonValues.county2, district = CommonValues.district2, ), - street = StreetDto(name = CommonValues.street2, houseNumber = CommonValues.houseNumber2, direction = CommonValues.direction2), + street = StreetGateDto(name = CommonValues.street2, houseNumber = CommonValues.houseNumber2, direction = CommonValues.direction2), baseAddress = BasePostalAddressDto( geographicCoordinates = geoCoordinate2, country = CommonValues.country2, @@ -208,24 +216,24 @@ object RequestValues { ) ) - val address1 = LogisticAddressDto( + val address1 = LogisticAddressGateDto( physicalPostalAddress = postalAddress1, ) - val address2 = LogisticAddressDto( + val address2 = LogisticAddressGateDto( physicalPostalAddress = postalAddress2, ) - val address3 = LogisticAddressDto( + val address3 = LogisticAddressGateDto( physicalPostalAddress = postalAddress3, ) //New Values for Logistic Address Tests - val logisticAddress1 = LogisticAddressDto( + val logisticAddress1 = LogisticAddressGateDto( physicalPostalAddress = postalAddressLogisticAddress1, ) - val logisticAddress2 = LogisticAddressDto( + val logisticAddress2 = LogisticAddressGateDto( physicalPostalAddress = postalAddressLogisticAddress2, ) @@ -278,13 +286,13 @@ object RequestValues { bpn = CommonValues.bpn3 ) - val site1 = SiteDto( + val site1 = SiteGateDto( name = CommonValues.nameSite1, states = listOf(siteBusinessStatus1), mainAddress = address1 ) - val site2 = SiteDto( + val site2 = SiteGateDto( name = CommonValues.nameSite2, states = listOf(siteBusinessStatus2), mainAddress = address2 diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index 0b7aca386..19df97ac4 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -445,11 +445,11 @@ class BusinessPartnerBuildService( city = baseAddress.city, districtLevel1 = area.district, street = physicalAddress.street?.let { createStreet(it) }, - companyPostCode = physicalAddress.companyPostalCode, - industrialZone = physicalAddress.industrialZone, - building = physicalAddress.building, - floor = physicalAddress.floor, - door = physicalAddress.door + companyPostCode = physicalAddress.basePhysicalAddress.companyPostalCode, + industrialZone = physicalAddress.basePhysicalAddress.industrialZone, + building = physicalAddress.basePhysicalAddress.building, + floor = physicalAddress.basePhysicalAddress.floor, + door = physicalAddress.basePhysicalAddress.door ) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt index 70e980291..87172b868 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt @@ -94,10 +94,11 @@ class SaasAddressToDtoMappingTest { Assertions.assertThat(streetDto?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction) Assertions.assertThat(streetDto?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName) - Assertions.assertThat(physicalAddressDto.industrialZone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name) - Assertions.assertThat(physicalAddressDto.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) - Assertions.assertThat(physicalAddressDto.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) - Assertions.assertThat(physicalAddressDto.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.industrialZone) + .isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) } private fun findValue(values: Collection, enumType: SaasType): String? { diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt index 67ca13e88..1414db1c9 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt @@ -85,11 +85,13 @@ object RequestValues { val version1 = AddressVersionDto(CommonValues.characterSet1, CommonValues.language0) val postalAddress1 = PhysicalPostalAddressDto( - companyPostalCode = CommonValues.postCode2, - industrialZone = CommonValues.industrialZone1, - building = CommonValues.building1, - floor = CommonValues.floor1, - door = CommonValues.door1, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = CommonValues.postCode2, + industrialZone = CommonValues.industrialZone1, + building = CommonValues.building1, + floor = CommonValues.floor1, + door = CommonValues.door1, + ), areaPart = AreaDistrictDto( administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_1, administrativeAreaLevel2 = CommonValues.county1, @@ -105,10 +107,12 @@ object RequestValues { ) val postalAddress2 = PhysicalPostalAddressDto( - industrialZone = CommonValues.industrialZone2, - building = CommonValues.building2, - floor = CommonValues.floor2, - door = CommonValues.door2, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone2, + building = CommonValues.building2, + floor = CommonValues.floor2, + door = CommonValues.door2 + ), areaPart = AreaDistrictDto( administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_2, administrativeAreaLevel2 = CommonValues.county2, @@ -124,10 +128,12 @@ object RequestValues { ) val postalAddress3 = PhysicalPostalAddressDto( - industrialZone = CommonValues.industrialZone3, - building = CommonValues.building3, - floor = CommonValues.floor3, - door = CommonValues.door3, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone3, + building = CommonValues.building3, + floor = CommonValues.floor3, + door = CommonValues.door3 + ), areaPart = AreaDistrictDto( administrativeAreaLevel1 = CommonValues.adminAreaLevel1RegionCode_3, administrativeAreaLevel2 = CommonValues.county3, From 8671391c4e5adb318c336340d89adbffce5f97da Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Fri, 2 Jun 2023 06:12:03 +0200 Subject: [PATCH 21/83] feat(api): #183 Gate API: Add Street Name Suffix and Prefix Fields - add PhysicalPostalAddressGateResponse --- .../response/PhysicalPostalAddressResponse.kt | 17 +---- .../bpdm/gate/api/model/AddressGateOutput.kt | 4 +- .../gate/api/model/LegalEntityGateOutput.kt | 4 +- .../gate/api/model/LogisticAddressGateDto.kt | 2 +- .../api/model/PhysicalPostalAddressGateDto.kt | 2 +- .../bpdm/gate/api/model/SiteGateOutput.kt | 4 +- .../bpdm/gate/api/model/StreetGateDto.kt | 2 +- .../response/LogisticAddressGateResponse.kt | 72 +++++++++++++++++++ .../PhysicalPostalAddressGateResponse.kt | 46 ++++++++++++ .../bpdm/gate/service/AddressService.kt | 4 +- .../bpdm/gate/service/LegalEntityService.kt | 6 +- .../tractusx/bpdm/gate/service/PoolClient.kt | 13 ++-- .../tractusx/bpdm/gate/service/SiteService.kt | 4 +- .../tractusx/bpdm/gate/util/ResponseValues.kt | 44 ++++++++---- .../bpdm/pool/service/ResponseMappings.kt | 12 ++-- .../service/SaasAddressToDtoMappingTest.kt | 9 +-- .../controller/AddressControllerSearchIT.kt | 2 +- .../pool/controller/SuggestionControllerIT.kt | 4 +- .../tractusx/bpdm/pool/util/ResponseValues.kt | 69 ++++++++++-------- 19 files changed, 232 insertions(+), 88 deletions(-) create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/LogisticAddressGateResponse.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PhysicalPostalAddressGateResponse.kt diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PhysicalPostalAddressResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PhysicalPostalAddressResponse.kt index 05eca6e50..4e3a743a8 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PhysicalPostalAddressResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/PhysicalPostalAddressResponse.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.common.dto.response import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto import org.eclipse.tractusx.bpdm.common.dto.StreetDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @@ -38,18 +39,6 @@ data class PhysicalPostalAddressResponse( @field:JsonUnwrapped val areaPart: AreaDistrictResponse, - @get:Schema(description = "A separate postal code for a company, also known as postcode, PIN or ZIP Code") - val companyPostalCode: String? = null, - - @get:Schema(description = "The practice of designating an area for industrial development") - val industrialZone: String? = null, - - @get:Schema(description = "Describes a specific building within the address") - val building: String? = null, - - @get:Schema(description = "Describes the floor/level the delivery shall take place") - val floor: String? = null, - - @get:Schema(description = "Describes the door/room/suite on the respective floor the delivery shall take place") - val door: String? = null, + @field:JsonUnwrapped + val basePhysicalAddress: BasePhysicalAddressDto ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt index 065a8ceef..b4214dba6 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutput.kt @@ -22,8 +22,8 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema( @@ -32,7 +32,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ ) data class AddressGateOutput( @field:JsonUnwrapped - val address: LogisticAddressResponse, + val address: LogisticAddressGateResponse, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt index 3fcd86c33..fcf1db486 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt @@ -24,8 +24,8 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema(name = "LegalEntityGateOutput", description = "Legal entity with references") @@ -37,7 +37,7 @@ data class LegalEntityGateOutput( val legalEntity: LegalEntityResponse, @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressResponse, + val legalAddress: LogisticAddressGateResponse, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt index 1926e3ed1..8d78e88d5 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt @@ -26,7 +26,7 @@ import org.eclipse.tractusx.bpdm.common.dto.AddressStateDto import org.eclipse.tractusx.bpdm.common.dto.AlternativePostalAddressDto -@Schema(name = "LogisticAddressDto", description = "Address record for a business partner") +@Schema(name = "LogisticAddressGateDto", description = "Address record for a business partner") data class LogisticAddressGateDto( @get:Schema( description = "Name of the logistic address of the business partner. This is not according to official\n" + diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt index 58e27b883..44946f3ce 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressGateDto.kt @@ -28,7 +28,7 @@ import org.eclipse.tractusx.bpdm.common.dto.BasePostalAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "PhysicalPostalAddress", description = "Physical Postal Address Part") +@Schema(name = "PhysicalPostalAddressGateDto", description = "Physical Postal Address Part") data class PhysicalPostalAddressGateDto( @field:JsonUnwrapped diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt index fc91a87f2..581248acb 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutput.kt @@ -22,9 +22,9 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema(name = "SiteGateOutput", description = "Site with legal entity reference.") @@ -33,7 +33,7 @@ data class SiteGateOutput( val site: SiteResponse, @Schema(description = "Main address where this site resides") - val mainAddress: LogisticAddressResponse, + val mainAddress: LogisticAddressGateResponse, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt index 59358cf28..6e4dc4b35 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/StreetGateDto.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model import io.swagger.v3.oas.annotations.media.Schema -@Schema(name = "Street", description = "A public road in a city, town, or village, typically with houses and buildings on one or both sides.") +@Schema(name = "StreetGate", description = "A public road in a city, town, or village, typically with houses and buildings on one or both sides.") data class StreetGateDto( diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/LogisticAddressGateResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/LogisticAddressGateResponse.kt new file mode 100644 index 000000000..0056f4e0c --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/LogisticAddressGateResponse.kt @@ -0,0 +1,72 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model.response + +import io.swagger.v3.oas.annotations.media.ArraySchema +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.response.AddressIdentifierResponse +import org.eclipse.tractusx.bpdm.common.dto.response.AddressStateResponse +import org.eclipse.tractusx.bpdm.common.dto.response.AlternativePostalAddressResponse +import org.eclipse.tractusx.bpdm.common.dto.response.PhysicalPostalAddressResponse +import java.time.Instant + + +@Schema(name = "LogisticAddressGateResponse", description = "Logistic address ") +data class LogisticAddressGateResponse( + + @get:Schema(description = "Business Partner Number of this address") + val bpna: String, + + @get:Schema( + description = "Name of the logistic address of the business partner. This is not according to official\n" + + "registers but according to the name the uploading sharing member chooses." + ) + val name: String? = null, + + @ArraySchema(arraySchema = Schema(description = "Address status")) + val states: Collection = emptyList(), + + @ArraySchema(arraySchema = Schema(description = "All identifiers of the Address")) + val identifiers: Collection = emptyList(), + + @get:Schema(description = "Physical postal address") + val physicalPostalAddress: PhysicalPostalAddressResponse, + + @get:Schema(description = "Alternative postal address") + val alternativePostalAddress: AlternativePostalAddressResponse? = null, + + @get:Schema(description = "BPN of the related legal entity, if available") + val bpnLegalEntity: String?, + + @get:Schema(name = "isLegalAddress", description = "Flag if this is the legal address of its related legal entity") + val isLegalAddress: Boolean = false, + + @get:Schema(description = "BPN of the related site, if available") + val bpnSite: String?, + + @get:Schema(name = "isMainAddress", description = "Flag if this is the main address of its related site") + val isMainAddress: Boolean = false, + + @get:Schema(description = "The timestamp the business partner data was created") + val createdAt: Instant, + + @get:Schema(description = "The timestamp the business partner data was last updated") + val updatedAt: Instant +) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PhysicalPostalAddressGateResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PhysicalPostalAddressGateResponse.kt new file mode 100644 index 000000000..bca849ccf --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/PhysicalPostalAddressGateResponse.kt @@ -0,0 +1,46 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model.response + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto +import org.eclipse.tractusx.bpdm.common.dto.response.AreaDistrictResponse +import org.eclipse.tractusx.bpdm.common.dto.response.BasePostalAddressResponse +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import org.eclipse.tractusx.bpdm.gate.api.model.StreetGateDto + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema(name = "PhysicalPostalGateAddress", description = "Physical Postal Address Part") +data class PhysicalPostalAddressGateResponse( + + @field:JsonUnwrapped + val baseAddress: BasePostalAddressResponse, + + @get:Schema(description = "Street") + val street: StreetGateDto? = null, + + @field:JsonUnwrapped + val areaPart: AreaDistrictResponse, + + @field:JsonUnwrapped + val basePhysicalAddress: BasePhysicalAddressDto +) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index d5033a2ee..6c475eb5a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -20,13 +20,13 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties @@ -127,7 +127,7 @@ class AddressService( ) } - fun toAddressOutput(externalId: String, address: LogisticAddressResponse): AddressGateOutput { + fun toAddressOutput(externalId: String, address: LogisticAddressGateResponse): AddressGateOutput { return AddressGateOutput( address = address, externalId = externalId diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index f2aba3b24..876ff9cc5 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -21,13 +21,13 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry @@ -130,7 +130,7 @@ class LegalEntityService( ) } - fun toLegalEntityOutput(externalId: String, legalEntityPool: PoolLegalEntityResponse, legalAddress: LogisticAddressResponse): LegalEntityGateOutput = + fun toLegalEntityOutput(externalId: String, legalEntityPool: PoolLegalEntityResponse, legalAddress: LogisticAddressGateResponse): LegalEntityGateOutput = LegalEntityGateOutput( legalEntity = LegalEntityResponse( bpnl = legalEntityPool.legalEntity.bpnl, @@ -144,7 +144,7 @@ class LegalEntityService( createdAt = legalEntityPool.legalEntity.createdAt, updatedAt = legalEntityPool.legalEntity.updatedAt, ), - legalAddress = legalEntityPool.legalAddress, + legalAddress = legalAddress, legalNameParts = arrayOf(legalEntityPool.legalName), externalId = externalId ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/PoolClient.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/PoolClient.kt index 572dbd82b..9ed08fac2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/PoolClient.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/PoolClient.kt @@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import org.eclipse.tractusx.bpdm.common.dto.request.AddressPartnerBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.response.* +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import org.eclipse.tractusx.bpdm.gate.exception.PoolRequestException import org.springframework.beans.factory.annotation.Qualifier import org.springframework.stereotype.Service @@ -52,7 +53,7 @@ class PoolClient( return legalEntities } - fun searchLegalAddresses(bpnLs: Collection): Collection { + fun searchLegalAddresses(bpnLs: Collection): Collection { if (bpnLs.isEmpty()) return emptyList() val legalAddresses = try { @@ -61,7 +62,7 @@ class PoolClient( .uri("/legal-entities/legal-addresses/search") .bodyValue(objectMapper.writeValueAsString(bpnLs)) .retrieve() - .bodyToMono>() + .bodyToMono>() .block()!! } catch (e: Exception) { throw PoolRequestException("Request to search legal addresses failed.", e) @@ -86,7 +87,7 @@ class PoolClient( return sites.content } - fun searchMainAddresses(bpnSs: Collection): Collection { + fun searchMainAddresses(bpnSs: Collection): Collection { if (bpnSs.isEmpty()) return emptyList() val mainAddresses = try { @@ -95,7 +96,7 @@ class PoolClient( .uri("/sites/main-addresses/search") .bodyValue(objectMapper.writeValueAsString(bpnSs)) .retrieve() - .bodyToMono>() + .bodyToMono>() .block()!! } catch (e: Exception) { throw PoolRequestException("Request to main addresses of sites failed.", e) @@ -103,7 +104,7 @@ class PoolClient( return mainAddresses } - fun searchAddresses(bpnAs: Collection): Collection { + fun searchAddresses(bpnAs: Collection): Collection { if (bpnAs.isEmpty()) return emptyList() val addresses = try { @@ -112,7 +113,7 @@ class PoolClient( .uri("/addresses/search") .bodyValue(objectMapper.writeValueAsString(AddressPartnerBpnSearchRequest(addresses = bpnAs))) .retrieve() - .bodyToMono>() + .bodyToMono>() .block()!! } catch (e: Exception) { throw PoolRequestException("Request to search addresses failed.", e) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index dd6d0509f..9def4a0c9 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -20,7 +20,6 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas @@ -28,6 +27,7 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties @@ -129,7 +129,7 @@ class SiteService( ) } - fun toSiteOutput(externalId: String, site: SiteResponse, mainAddress: LogisticAddressResponse) = + fun toSiteOutput(externalId: String, site: SiteResponse, mainAddress: LogisticAddressGateResponse) = SiteGateOutput( site = site, mainAddress = mainAddress, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 51d635632..e0c0fcf9c 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -20,12 +20,14 @@ package org.eclipse.tractusx.bpdm.gate.util import org.eclipse.tractusx.bpdm.common.dto.AddressIdentifierDto +import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.dto.StreetDto import org.eclipse.tractusx.bpdm.common.dto.response.* import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto import org.eclipse.tractusx.bpdm.common.service.toDto import org.eclipse.tractusx.bpdm.gate.api.model.* +import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import java.time.Instant object ResponseValues { @@ -145,10 +147,12 @@ object ResponseValues { val geoCoordinate2 = GeoCoordinateDto(CommonValues.geoCoordinates2.first, CommonValues.geoCoordinates2.second) val address1 = PhysicalPostalAddressResponse( - industrialZone = CommonValues.industrialZone1, - building = CommonValues.building1, - floor = CommonValues.floor1, - door = CommonValues.door1, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone1, + building = CommonValues.building1, + floor = CommonValues.floor1, + door = CommonValues.door1 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region1, administrativeAreaLevel2 = CommonValues.county1, @@ -164,10 +168,12 @@ object ResponseValues { ) val address2 = PhysicalPostalAddressResponse( - industrialZone = CommonValues.industrialZone2, - building = CommonValues.building2, - floor = CommonValues.floor2, - door = CommonValues.door2, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone2, + building = CommonValues.building2, + floor = CommonValues.floor2, + door = CommonValues.door2 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region2, administrativeAreaLevel2 = CommonValues.county2, @@ -182,7 +188,7 @@ object ResponseValues { ) ) - val logisticAddress1 = LogisticAddressResponse( + val logisticAddress1 = LogisticAddressGateResponse( bpna = CommonValues.bpnAddress1, physicalPostalAddress = address1, bpnLegalEntity = CommonValues.bpn1, @@ -191,7 +197,7 @@ object ResponseValues { updatedAt = Instant.now() ) - val logisticAddress2 = LogisticAddressResponse( + val logisticAddress2 = LogisticAddressGateResponse( bpna = CommonValues.bpnAddress2, physicalPostalAddress = address2, bpnLegalEntity = CommonValues.bpn2, @@ -202,7 +208,14 @@ object ResponseValues { val legalEntityResponsePool1 = PoolLegalEntityResponse( legalName = CommonValues.name1, - legalAddress = logisticAddress1, + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnAddress1, + physicalPostalAddress = address1, + bpnLegalEntity = CommonValues.bpn1, + bpnSite = "BPNS0000000001XY", + createdAt = Instant.now(), + updatedAt = Instant.now() + ), legalEntity = LegalEntityResponse( bpnl = CommonValues.bpn1, identifiers = listOf(identifier1, identifier2), @@ -219,7 +232,14 @@ object ResponseValues { val legalEntityResponsePool2 = PoolLegalEntityResponse( legalName = CommonValues.name3, - legalAddress = logisticAddress2, + legalAddress = LogisticAddressResponse( + bpna = CommonValues.bpnAddress2, + physicalPostalAddress = address2, + bpnLegalEntity = CommonValues.bpn2, + bpnSite = "BPNS0000000002XY", + createdAt = Instant.now(), + updatedAt = Instant.now() + ), legalEntity = LegalEntityResponse( bpnl = CommonValues.bpn2, identifiers = listOf(identifier3, identifier4), diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 42c648cf0..079ccaab6 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -184,11 +184,13 @@ fun PhysicalPostalAddress.toDto(): PhysicalPostalAddressResponse { administrativeAreaLevel3 = administrativeAreaLevel3, district = districtLevel1, ), - companyPostalCode = companyPostCode, - industrialZone = industrialZone, - building = building, - floor = floor, - door = door + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = companyPostCode, + industrialZone = industrialZone, + building = building, + floor = floor, + door = door + ) ) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt index 87172b868..df8dc497b 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasAddressToDtoMappingTest.kt @@ -69,10 +69,11 @@ class SaasAddressToDtoMappingTest { Assertions.assertThat(streetDto?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction) Assertions.assertThat(streetDto?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName) - Assertions.assertThat(physicalAddressDto.industrialZone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name) - Assertions.assertThat(physicalAddressDto.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) - Assertions.assertThat(physicalAddressDto.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) - Assertions.assertThat(physicalAddressDto.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.industrialZone) + .isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING)) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.floor).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.LEVEL)) + Assertions.assertThat(physicalAddressDto.basePhysicalAddress.door).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.ROOM)) } private fun checkMappingDtoPhysicalAddress(physicalAddressDto: PhysicalPostalAddressDto, addressSaas: AddressSaas) { diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt index 01e05676c..6428224f2 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt @@ -204,7 +204,7 @@ class AddressControllerSearchIT @Autowired constructor( ) val addressSearchRequest = AddressPartnerSearchRequest( - premise = givenAddress1.physicalPostalAddress.building + premise = givenAddress1.physicalPostalAddress.basePhysicalAddress.building ) val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt index b1a2b696b..63951916b 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt @@ -132,7 +132,7 @@ class SuggestionControllerIT @Autowired constructor( expectedLegalEntityName ), Arguments.of( - expectedLegalAddress.physicalPostalAddress.building, + expectedLegalAddress.physicalPostalAddress.basePhysicalAddress.building, EndpointValues.CATENA_SUGGESTION_ADDRESS_PREMISE_PATH, expectedLegalEntityName ), @@ -157,7 +157,7 @@ class SuggestionControllerIT @Autowired constructor( Arguments.of(nonlatinLegalAddress.physicalPostalAddress.baseAddress.postalCode, EndpointValues.CATENA_SUGGESTION_ADDRESS_POST_CODE_PATH), Arguments.of(nonlatinLegalAddress.physicalPostalAddress.baseAddress.city, EndpointValues.CATENA_SUGGESTION_ADDRESS_LOCALITY_PATH), Arguments.of(nonlatinLegalAddress.physicalPostalAddress.street!!.name, EndpointValues.CATENA_SUGGESTION_ADDRESS_THOROUGHFARE_PATH), - Arguments.of(nonlatinLegalAddress.physicalPostalAddress.building, EndpointValues.CATENA_SUGGESTION_ADDRESS_PREMISE_PATH), + Arguments.of(nonlatinLegalAddress.physicalPostalAddress.basePhysicalAddress.building, EndpointValues.CATENA_SUGGESTION_ADDRESS_PREMISE_PATH), // TODO check alternativePostalAddress // Arguments.of(nonlatinLegalAddress.alternativePostalAddress!!.deliveryServiceNumber, EndpointValues.CATENA_SUGGESTION_ADDRESS_POSTAL_DELIVERY_POINT_PATH) ) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt index 138293ce5..2f410461b 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.pool.util +import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto import org.eclipse.tractusx.bpdm.common.dto.StreetDto import org.eclipse.tractusx.bpdm.common.dto.response.* import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto @@ -88,11 +89,13 @@ object ResponseValues { private val classification5 = ClassificationResponse(CommonValues.classification5, null, classificationType) private val address1 = PhysicalPostalAddressResponse( - companyPostalCode = CommonValues.postCode2, - industrialZone = CommonValues.industrialZone1, - building = CommonValues.building1, - floor = CommonValues.floor1, - door = CommonValues.door1, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = CommonValues.postCode2, + industrialZone = CommonValues.industrialZone1, + building = CommonValues.building1, + floor = CommonValues.floor1, + door = CommonValues.door1 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region1, administrativeAreaLevel2 = CommonValues.county1, @@ -108,10 +111,12 @@ object ResponseValues { ) private val address2 = PhysicalPostalAddressResponse( - industrialZone = CommonValues.industrialZone2, - building = CommonValues.building2, - floor = CommonValues.floor2, - door = CommonValues.door2, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone2, + building = CommonValues.building2, + floor = CommonValues.floor2, + door = CommonValues.door2 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region2, administrativeAreaLevel2 = CommonValues.county2, @@ -127,10 +132,12 @@ object ResponseValues { ) private val address3 = PhysicalPostalAddressResponse( - industrialZone = CommonValues.industrialZone3, - building = CommonValues.building3, - floor = CommonValues.floor3, - door = CommonValues.door3, + basePhysicalAddress = BasePhysicalAddressDto( + industrialZone = CommonValues.industrialZone3, + building = CommonValues.building3, + floor = CommonValues.floor3, + door = CommonValues.door3 + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = CommonValues.adminAreaLevel1Region3, administrativeAreaLevel2 = CommonValues.county3, @@ -257,11 +264,13 @@ object ResponseValues { legalAddress = LogisticAddressResponse( bpna = CommonValues.bpnA1, physicalPostalAddress = PhysicalPostalAddressResponse( - companyPostalCode = null, - industrialZone = null, - building = null, - floor = null, - door = null, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = null, administrativeAreaLevel2 = null, @@ -297,11 +306,13 @@ object ResponseValues { legalAddress = LogisticAddressResponse( bpna = CommonValues.bpnA1, physicalPostalAddress = PhysicalPostalAddressResponse( - companyPostalCode = null, - industrialZone = null, - building = null, - floor = null, - door = null, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = null, administrativeAreaLevel2 = null, @@ -337,11 +348,13 @@ object ResponseValues { legalAddress = LogisticAddressResponse( bpna = CommonValues.bpnA1, physicalPostalAddress = PhysicalPostalAddressResponse( - companyPostalCode = null, - industrialZone = null, - building = null, - floor = null, - door = null, + basePhysicalAddress = BasePhysicalAddressDto( + companyPostalCode = null, + industrialZone = null, + building = null, + floor = null, + door = null + ), areaPart = AreaDistrictResponse( administrativeAreaLevel1 = null, administrativeAreaLevel2 = null, From f678229cfea1c193d5ec5373f54b4c67e51ec7c1 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Mon, 5 Jun 2023 06:45:02 +0200 Subject: [PATCH 22/83] feat(api): #216 Remove suggestion endpoints --- .../bpdm/pool/api/PoolSuggestionApi.kt | 229 ----- .../bpdm/pool/api/client/PoolApiClient.kt | 2 - .../bpdm/pool/api/client/PoolClientImpl.kt | 3 - .../api/model/response/SuggestionResponse.kt | 30 - .../component/opensearch/SearchService.kt | 13 - .../opensearch/impl/doc/SuggestionType.kt | 34 - .../repository/TextDocSearchRepository.kt | 156 --- .../impl/service/SearchServiceImpl.kt | 39 +- .../mock/service/SearchServiceMock.kt | 18 - .../pool/controller/SuggestionController.kt | 206 ---- .../pool/controller/SuggestionControllerIT.kt | 422 -------- .../tractusx/bpdm/pool/util/EndpointValues.kt | 19 +- .../postman/BPDM Pool.postman_collection.json | 905 ------------------ 13 files changed, 2 insertions(+), 2074 deletions(-) delete mode 100644 bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt delete mode 100644 bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SuggestionResponse.kt delete mode 100644 bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/doc/SuggestionType.kt delete mode 100644 bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/repository/TextDocSearchRepository.kt delete mode 100644 bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionController.kt delete mode 100644 bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt deleted file mode 100644 index c31736fb1..000000000 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSuggestionApi.kt +++ /dev/null @@ -1,229 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.api - -import io.swagger.v3.oas.annotations.Operation -import io.swagger.v3.oas.annotations.Parameter -import io.swagger.v3.oas.annotations.responses.ApiResponse -import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.SuggestionResponse -import org.springdoc.core.annotations.ParameterObject -import org.springframework.http.MediaType -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.service.annotation.GetExchange -import org.springframework.web.service.annotation.HttpExchange - - -@RequestMapping("/api/catena/suggestions", produces = [MediaType.APPLICATION_JSON_VALUE]) -@HttpExchange("/api/catena/suggestions") -interface PoolSuggestionApi { - @Operation( - summary = "Find best matches for given text in business partner names", - description = "Performs search on business partner names in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible names in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("legal-entities/names") - @GetExchange("legal-entities/names") - fun getNameSuggestion( - @Parameter(description = "Show names best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in business partner legal forms", - description = "Performs search on legal form names in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible legal form names in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("legal-entities/legal-forms") - @GetExchange("legal-entities/legal-forms") - fun getLegalFormSuggestion( - @Parameter(description = "Show legal form names best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in business partner sites", - description = "Performs search on site names in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible site names in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("sites/names") - @GetExchange("sites/names") - fun getSiteSuggestion( - @Parameter(description = "Show site names best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in business statuses", - description = "Performs search on business status denotations in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible business status denotations in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("legal-entities/statuses") - @GetExchange("legal-entities/statuses") - fun getStatusSuggestion( - @Parameter(description = "Show business status denotations best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in business partner classifications", - description = "Performs search on business partner classifications in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible business partner classifications in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("legal-entities/classifications") - @GetExchange("legal-entities/classifications") - fun getClassificationSuggestion( - @Parameter(description = "Show business partner classifications best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in administrative areas", - description = "Performs search on administrative area names in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible administrative area names in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("/addresses/administrative-areas") - @GetExchange("/addresses/administrative-areas") - fun getAdminAreaSuggestion( - @Parameter(description = "Show administrative area names best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in postcodes", - description = "Performs search on postcode values in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible postcode values in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("/addresses/postcodes") - @GetExchange("/addresses/postcodes") - fun getPostcodeSuggestion( - @Parameter(description = "Show postcodes best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in localities", - description = "Performs search on locality denotations in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible locality names in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("/addresses/localities") - @GetExchange("/addresses/localities") - fun getLocalitySuggestion( - @Parameter(description = "Show locality names this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in thoroughfares", - description = "Performs search on thoroughfare denotations in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible thoroughfare names in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("/addresses/thoroughfares") - @GetExchange("/addresses/thoroughfares") - fun getThoroughfareSuggestion( - @Parameter(description = "Show thoroughfare names best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in premises", - description = "Performs search on premise denotations in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible premise names in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("/addresses/premises") - @GetExchange("/addresses/premises") - fun getPremiseSuggestion( - @Parameter(description = "Show premise names best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse - - @Operation( - summary = "Find best matches for given text in postal delivery points", - description = "Performs search on postal delivery point denotations in order to find the best matches for the given text. " + - "By specifying further request parameters the set of business partners to search in can be restricted. " + - "If no text is given, the endpoint lists possible postal delivery point names in the search set.", - responses = [ApiResponse(responseCode = "200", description = "Best matches found, may be empty")] - ) - @GetMapping("/addresses/postal-delivery-points") - @GetExchange("/addresses/postal-delivery-points") - fun getPostalDeliverPointSuggestion( - @Parameter(description = "Show postal delivery point names best matching this text") @RequestParam(required = false) text: String?, - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject pageRequest: PaginationRequest - ): PageResponse -} \ No newline at end of file diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolApiClient.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolApiClient.kt index 1ab10319c..288afef22 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolApiClient.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolApiClient.kt @@ -35,8 +35,6 @@ interface PoolApiClient { fun sites(): PoolSiteApi - fun suggestions(): PoolSuggestionApi - fun opensearch(): PoolOpenSearchApi fun saas(): PoolSaasApi diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolClientImpl.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolClientImpl.kt index 2f2e389a0..ec1547e88 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolClientImpl.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolClientImpl.kt @@ -44,7 +44,6 @@ class PoolClientImpl( private val poolClientLegalEntity by lazy { httpServiceProxyFactory.createClient(PoolLegalEntityApi::class.java) } private val poolClientMetadata by lazy { httpServiceProxyFactory.createClient(PoolMetadataApi::class.java) } private val poolClientSite by lazy { httpServiceProxyFactory.createClient(PoolSiteApi::class.java) } - private val poolClientSuggestion by lazy { httpServiceProxyFactory.createClient(PoolSuggestionApi::class.java) } private val poolClientOpenSearch by lazy { httpServiceProxyFactory.createClient(PoolOpenSearchApi::class.java) } private val poolClientSaas by lazy { httpServiceProxyFactory.createClient(PoolSaasApi::class.java) } @@ -60,8 +59,6 @@ class PoolClientImpl( override fun sites() = poolClientSite - override fun suggestions() = poolClientSuggestion - override fun opensearch() = poolClientOpenSearch override fun saas() = poolClientSaas diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SuggestionResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SuggestionResponse.kt deleted file mode 100644 index e4503b524..000000000 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SuggestionResponse.kt +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.api.model.response - -import io.swagger.v3.oas.annotations.media.Schema - -@Schema(name = "SuggestionResponse", description = "Shows a ranked suggestion based on a given search text") -data class SuggestionResponse( - @Schema(description = "The suggestion text") - val suggestion: String, - @Schema(description = "Relative relevancy score indicating quality of the match, higher is better") - val relevancy: Float -) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt index 8e7c8e370..2c6e8b9d7 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt @@ -26,8 +26,6 @@ import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchReq import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.SuggestionResponse -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.SuggestionType /** * Provides search functionality on the Catena-x data for the BPDM system @@ -55,15 +53,4 @@ interface SearchService { paginationRequest: PaginationRequest ): PageResponse - - /** - * In business partners matching the [filters], find [field] values matching [text]. - */ - fun getSuggestion( - field: SuggestionType, - text: String?, - filters: BusinessPartnerSearchRequest, - paginationRequest: PaginationRequest - ): PageResponse - } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/doc/SuggestionType.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/doc/SuggestionType.kt deleted file mode 100644 index 595275ffc..000000000 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/doc/SuggestionType.kt +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc - -enum class SuggestionType(val docName: String) { - NAME(LegalEntityDoc::legalName.name), - LEGAL_FORM(LegalEntityDoc::legalForm.name), - STATUS(LegalEntityDoc::status.name), - CLASSIFICATION(LegalEntityDoc::classifications.name), - ADMIN_AREA("${LegalEntityDoc::addresses.name}.${AddressDoc::administrativeAreas.name}"), - POSTCODE("${LegalEntityDoc::addresses.name}.${AddressDoc::postCodes.name}"), - LOCALITY("${LegalEntityDoc::addresses.name}.${AddressDoc::localities.name}"), - THOROUGHFARE("${LegalEntityDoc::addresses.name}.${AddressDoc::thoroughfares.name}"), - PREMISE("${LegalEntityDoc::addresses.name}.${AddressDoc::premises.name}"), - POSTAL_DELIVERY_POINT("${LegalEntityDoc::addresses.name}.${AddressDoc::postalDeliveryPoints.name}"), - SITE(LegalEntityDoc::sites.name), -} \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/repository/TextDocSearchRepository.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/repository/TextDocSearchRepository.kt deleted file mode 100644 index d3802587a..000000000 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/repository/TextDocSearchRepository.kt +++ /dev/null @@ -1,156 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository - -import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.LEGAL_ENTITIES_INDEX_NAME -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.LegalEntityDoc -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.SuggestionType -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.TextDoc -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.util.BpdmOpenSearchQueryBuilder -import org.opensearch.action.search.SearchRequest -import org.opensearch.client.RequestOptions -import org.opensearch.client.RestHighLevelClient -import org.opensearch.index.query.QueryBuilders -import org.opensearch.search.SearchHits -import org.opensearch.search.builder.SearchSourceBuilder -import org.opensearch.search.fetch.subphase.highlight.HighlightBuilder -import org.springframework.data.domain.Pageable -import org.springframework.stereotype.Repository - -/** - * Creates and executes OpenSearch queries for querying [LegalEntityDoc] properties of type [TextDoc] - */ -@Repository -class TextDocSearchRepository( - val restHighLevelClient: RestHighLevelClient, - val bpdmQueryBuilder: BpdmOpenSearchQueryBuilder -) { - - /** - * Find TextDoc property [field] values matching keywords in [queryText], in business partners filtered by [filters] - * - * [queryText] and [filters] are converted to lowercase representation in order to work correctly with the case-sensitive prefix query. - * - * Query semantic: Return [LegalEntityDoc] [field] values that either match [queryText] exactly, or contain words in [queryText] - * or have matching prefixes of [queryText]. Only look in [field] values that belong to business partners that - * match the [filters]: For every non-null filter set the corresponding business partner field value needs to - * either match [queryText] exactly, or contain words in [queryText], or have matching prefixes of [queryText] - * - * Results are only ranked by the quality of matches from the [field], and not by the [filters]. - * Quality is also determined by the type of match: full phrase match > word match > prefix match. - * - * OpenSearch always returns the whole [LegalEntityDoc] as a result. Therefore, we extract the inner - * [TextDoc] hits and create a custom [SearchHits] collection based on the extracted hits. - * - * OpenSearch query structure: - * { - * "query":{ - * "bool": { - * "must": [ - * "nested": { - * "path": [field] path - * "query": { - * "bool":{ - * "should": [ - * {"match_phrase": [queryText] ...}, - * {"match": [queryText] ...} - * {"prefix": ...} - * . - * . for every keyword in [queryText] - * . - * {"prefix": ...} - * ] - * } - * } - * } - * ], - * "filter":[ - * "nested": { - * "path": path of [filters] field - * "query": { - * "bool":{ - * "should": [ - * {"match_phrase": [filters] field query text ...}, - * {"match": [filters] field query text ...} - * {"prefix": ...} - * . - * . for every keyword in [filters] field query text - * . - * {"prefix": ...} - * ] - * } - * } - * } - * . - * . for every non-null [filters] field - * . - * {"nested": ...} - * ] - * } - * } - * } - * - * - */ - fun findByFieldAndTextAndFilters( - field: SuggestionType, - queryText: String?, - filters: BusinessPartnerSearchRequest, - pageable: Pageable - ): SearchHits { - - - val lowerCaseQueryText = queryText?.lowercase() - val lowerCaseFilters = bpdmQueryBuilder.toLowerCaseSearchRequest(filters) - - val boolQuery = QueryBuilders.boolQuery() - - boolQuery - .must(bpdmQueryBuilder.buildNestedQuery(field.docName, lowerCaseQueryText, true)) - .filter().addAll( - bpdmQueryBuilder.toFieldTextPairs(lowerCaseFilters) - .map { (fieldName, queryText) -> bpdmQueryBuilder.buildNestedQuery(fieldName, queryText, false) }) - - val searchRequest = SearchRequest() - val searchSourceBuilder = SearchSourceBuilder() - searchSourceBuilder - .query(boolQuery) - .from(pageable.pageNumber * pageable.pageSize) - .size(pageable.pageSize) - .highlighter(HighlightBuilder().field(HighlightBuilder.Field(field.docName))) - searchRequest.indices(LEGAL_ENTITIES_INDEX_NAME) - searchRequest.source(searchSourceBuilder) - - val searchResponse = restHighLevelClient.search(searchRequest, RequestOptions.DEFAULT) - - val arrayOfSearchHits = searchResponse.hits - .flatMap { it.innerHits[field.docName] ?: emptyList() } - .sortedByDescending { it.score } - .take(pageable.pageSize) - .toTypedArray() - - return SearchHits( - arrayOfSearchHits, - org.apache.lucene.search.TotalHits(arrayOfSearchHits.size.toLong(), searchResponse.hits.totalHits!!.relation), - searchResponse.hits.maxScore - ) - } -} \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt index 46b273646..347a52846 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt @@ -29,13 +29,10 @@ import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchReq import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.SuggestionResponse import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.SuggestionType import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.TextDoc import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.AddressDocSearchRepository import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.LegalEntityDocSearchRepository -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.TextDocSearchRepository import org.eclipse.tractusx.bpdm.pool.config.OpenSearchConfigProperties import org.eclipse.tractusx.bpdm.pool.entity.LegalEntity import org.eclipse.tractusx.bpdm.pool.entity.LogisticAddress @@ -59,7 +56,6 @@ class SearchServiceImpl( val legalEntityRepository: LegalEntityRepository, val logisticAddressRepository: LogisticAddressRepository, val addressService: AddressService, - val textDocSearchRepository: TextDocSearchRepository, val businessPartnerFetchService: BusinessPartnerFetchService, val objectMapper: ObjectMapper, val openSearchConfigProperties: OpenSearchConfigProperties @@ -117,39 +113,6 @@ class SearchServiceImpl( } } - /** - * Query OpenSearch for [field] values by [text] and [filters] - * - * The found values and their hit scores are converted to [SuggestionResponse] and returned as a paginated result. - */ - override fun getSuggestion( - field: SuggestionType, - text: String?, - filters: BusinessPartnerSearchRequest, - paginationRequest: PaginationRequest - ): PageResponse { - - logger.debug { "Search index for suggestion type $field" } - - val hits = textDocSearchRepository.findByFieldAndTextAndFilters( - field, - text, - filters, - PageRequest.of(paginationRequest.page, paginationRequest.size) - ) - - logger.debug { "Returning ${hits.hits.size} suggestions for $field. (${hits.totalHits} found in total)" } - - return PageResponse( - hits.totalHits!!.value, - ceil(hits.totalHits!!.value.toDouble() / paginationRequest.size).toInt(), - paginationRequest.page, - hits.hits.size, - hits.map { hit -> - SuggestionResponse(extractTextDocText(hit.sourceAsString), hit.score) - }.toList() - ) - } private fun extractTextDocText(textDocJson: String): String { val textDoc: TextDoc = objectMapper.readValue(textDocJson) @@ -252,7 +215,7 @@ class SearchServiceImpl( val totalHits = searchResult.totalHits!!.value - missingPartners.size val totalPages = ceil(totalHits.toDouble() / paginationRequest.size).toInt() - return PageResponse(totalHits, totalPages, paginationRequest.page, addresses.size, scoreAddressPairs) + return PageResponse(totalHits, totalPages, paginationRequest.page, addresses.size, scoreAddressPairs) } } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt index 613a63322..616e01b61 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt @@ -27,15 +27,12 @@ import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchReq import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.SuggestionResponse import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.SuggestionType import org.eclipse.tractusx.bpdm.pool.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.pool.repository.LogisticAddressRepository import org.eclipse.tractusx.bpdm.pool.service.toBusinessPartnerMatchDto import org.eclipse.tractusx.bpdm.pool.service.toDto import org.eclipse.tractusx.bpdm.pool.service.toMatchDto -import org.springframework.data.domain.Page import org.springframework.data.domain.PageRequest import org.springframework.stereotype.Service @@ -90,19 +87,4 @@ class SearchServiceMock( return resultPage.toDto(resultPage.content.map { it.toBusinessPartnerMatchDto(1f) }) } - /** - * Ignores [field], [text] as well as [filters] and returns empty page of suggestions - */ - override fun getSuggestion( - field: SuggestionType, - text: String?, - filters: BusinessPartnerSearchRequest, - paginationRequest: PaginationRequest - ): PageResponse { - val emptyPage = Page.empty(PageRequest.of(paginationRequest.page, paginationRequest.size)) - - logger.info { "Mock search: Returning no suggestions" } - - return emptyPage.toDto(emptyPage.content) - } } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionController.kt deleted file mode 100644 index db500a607..000000000 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionController.kt +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.controller - -import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.pool.api.PoolSuggestionApi -import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.SuggestionResponse -import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.SuggestionType -import org.springframework.web.bind.annotation.RestController - -@RestController -class SuggestionController( - val searchService: SearchService -) : PoolSuggestionApi { - - override fun getNameSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.NAME, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - override fun getLegalFormSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.LEGAL_FORM, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - - override fun getSiteSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.SITE, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - override fun getStatusSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.STATUS, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - override fun getClassificationSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.CLASSIFICATION, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - override fun getAdminAreaSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.ADMIN_AREA, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - - override fun getPostcodeSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.POSTCODE, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - override fun getLocalitySuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.LOCALITY, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - override fun getThoroughfareSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.THOROUGHFARE, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - override fun getPremiseSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.PREMISE, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } - - - override fun getPostalDeliverPointSuggestion( - text: String?, - bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, - pageRequest: PaginationRequest - ): PageResponse { - return searchService.getSuggestion( - SuggestionType.POSTAL_DELIVERY_POINT, - text, - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), - pageRequest - ) - } -} \ No newline at end of file diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt deleted file mode 100644 index 63951916b..000000000 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SuggestionControllerIT.kt +++ /dev/null @@ -1,422 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.controller - -import com.github.tomakehurst.wiremock.core.WireMockConfiguration -import com.github.tomakehurst.wiremock.junit5.WireMockExtension -import org.assertj.core.api.Assertions.assertThat -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.pool.Application -import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl - -import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.SuggestionResponse -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service.OpenSearchSyncStarterService -import org.eclipse.tractusx.bpdm.pool.util.* -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.extension.RegisterExtension -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.Arguments -import org.junit.jupiter.params.provider.MethodSource -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.test.context.ActiveProfiles -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.DynamicPropertyRegistry -import org.springframework.test.context.DynamicPropertySource -import org.springframework.test.web.reactive.server.WebTestClient -import org.springframework.test.web.reactive.server.returnResult -import java.util.stream.Stream - -/** - * Integration tests for the look-ahead endpoints of the business partner controller - */ -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [Application::class, TestHelpers::class] -) -@ActiveProfiles(value = ["test"]) -@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class, OpenSearchContextInitializer::class]) -@AutoConfigureWebTestClient(timeout = "10000") -class SuggestionControllerIT @Autowired constructor( - val webTestClient: WebTestClient, - val openSearchSyncService: OpenSearchSyncStarterService, - val testHelpers: TestHelpers, - val poolClient: PoolClientImpl -) { - // TODO handle new data model - companion object { - @RegisterExtension - var wireMockServer: WireMockExtension = WireMockExtension.newInstance() - .options(WireMockConfiguration.wireMockConfig().dynamicPort()) - .build() - - private val expectedLegalEntity = ResponseValues.legalEntityUpsert1.legalEntity - private val expectedLegalEntityName = ResponseValues.legalEntityUpsert1.legalName - private val expectedLegalAddress = ResponseValues.legalEntityUpsert1.legalAddress - private val expectedSite = ResponseValues.siteUpsert2 - - private val nonlatinLegalEntity = ResponseValues.legalEntityUpsert3.legalEntity - private val nonlatinLegalAddress = ResponseValues.legalEntityUpsert3.legalAddress - private val nonlatinSite = ResponseValues.siteUpsert3 - - @JvmStatic - @DynamicPropertySource - fun properties(registry: DynamicPropertyRegistry) { - registry.add("bpdm.saas.host") { wireMockServer.baseUrl() } - } - - @JvmStatic - fun argumentsSuggestPropertyValues(): Stream = - Stream.of( - Arguments.of( - expectedLegalEntityName, - EndpointValues.CATENA_SUGGESTION_LE_NAME_PATH, - expectedLegalEntityName - ), - Arguments.of( - expectedLegalEntity.legalForm!!.name, - EndpointValues.CATENA_SUGGESTION_LE_LEGAL_FORM_PATH, - expectedLegalEntityName - ), - Arguments.of( - expectedLegalEntity.states.first().officialDenotation, - EndpointValues.CATENA_SUGGESTION_LE_STATUS_PATH, - expectedLegalEntityName - ), - Arguments.of( - expectedLegalEntity.classifications.first().value, - EndpointValues.CATENA_SUGGESTION_LE_CLASSIFICATION_PATH, - expectedLegalEntityName - ), - Arguments.of( - expectedSite.site.name, - EndpointValues.CATENA_SUGGESTION_SITE_NAME_PATH, - expectedLegalEntityName - ), - Arguments.of( - expectedLegalAddress.physicalPostalAddress.areaPart.administrativeAreaLevel2, - EndpointValues.CATENA_SUGGESTION_ADDRESS_ADMIN_AREA_PATH, - expectedLegalEntityName - ), - Arguments.of( - expectedLegalAddress.physicalPostalAddress.baseAddress.postalCode, - EndpointValues.CATENA_SUGGESTION_ADDRESS_POST_CODE_PATH, - expectedLegalEntityName - ), - Arguments.of( - expectedLegalAddress.physicalPostalAddress.baseAddress.city, - EndpointValues.CATENA_SUGGESTION_ADDRESS_LOCALITY_PATH, - expectedLegalEntityName - ), - Arguments.of( - expectedLegalAddress.physicalPostalAddress.street!!.name, - EndpointValues.CATENA_SUGGESTION_ADDRESS_THOROUGHFARE_PATH, - expectedLegalEntityName - ), - Arguments.of( - expectedLegalAddress.physicalPostalAddress.basePhysicalAddress.building, - EndpointValues.CATENA_SUGGESTION_ADDRESS_PREMISE_PATH, - expectedLegalEntityName - ), - // TODO check alternativePostalAddress -// Arguments.of( -// expectedLegalAddress.alternativePostalAddress!!.deliveryServiceNumber, -// EndpointValues.CATENA_SUGGESTION_ADDRESS_POSTAL_DELIVERY_POINT_PATH, -// expectedLegalEntityName -// ) - ) - - @JvmStatic - fun argumentsSuggestPropertyValuesNonLatin(): Stream = - Stream.of( - Arguments.of(ResponseValues.legalEntityUpsert3.legalName, EndpointValues.CATENA_SUGGESTION_LE_NAME_PATH), - Arguments.of(nonlatinLegalEntity.legalForm!!.name, EndpointValues.CATENA_SUGGESTION_LE_LEGAL_FORM_PATH), - Arguments.of(nonlatinSite.site.name, EndpointValues.CATENA_SUGGESTION_SITE_NAME_PATH), - Arguments.of( - nonlatinLegalAddress.physicalPostalAddress.areaPart.administrativeAreaLevel2, - EndpointValues.CATENA_SUGGESTION_ADDRESS_ADMIN_AREA_PATH - ), - Arguments.of(nonlatinLegalAddress.physicalPostalAddress.baseAddress.postalCode, EndpointValues.CATENA_SUGGESTION_ADDRESS_POST_CODE_PATH), - Arguments.of(nonlatinLegalAddress.physicalPostalAddress.baseAddress.city, EndpointValues.CATENA_SUGGESTION_ADDRESS_LOCALITY_PATH), - Arguments.of(nonlatinLegalAddress.physicalPostalAddress.street!!.name, EndpointValues.CATENA_SUGGESTION_ADDRESS_THOROUGHFARE_PATH), - Arguments.of(nonlatinLegalAddress.physicalPostalAddress.basePhysicalAddress.building, EndpointValues.CATENA_SUGGESTION_ADDRESS_PREMISE_PATH), - // TODO check alternativePostalAddress - // Arguments.of(nonlatinLegalAddress.alternativePostalAddress!!.deliveryServiceNumber, EndpointValues.CATENA_SUGGESTION_ADDRESS_POSTAL_DELIVERY_POINT_PATH) - ) - } - - val partnerStructure1 = LegalEntityStructureRequest( - legalEntity = RequestValues.legalEntityCreate1, - siteStructures = listOf( - SiteStructureRequest( - site = RequestValues.siteCreate2, - addresses = listOf(RequestValues.addressPartnerCreate3) - ) - ) - ) - - val partnerStructure2 = LegalEntityStructureRequest( - legalEntity = RequestValues.legalEntityCreate2, - siteStructures = listOf( - SiteStructureRequest( - site = RequestValues.siteCreate3, - addresses = listOf(RequestValues.addressPartnerCreate1) - ) - ) - ) - - val partnerStructure3 = LegalEntityStructureRequest( - legalEntity = RequestValues.legalEntityCreate3, - siteStructures = listOf( - SiteStructureRequest( - site = RequestValues.siteCreate1, - addresses = listOf(RequestValues.addressPartnerCreate2) - ) - ) - ) - - @BeforeEach - fun beforeEach() { - testHelpers.truncateDbTables() - openSearchSyncService.clearOpenSearch() - - testHelpers.createTestMetadata() - testHelpers.createBusinessPartnerStructure(listOf(partnerStructure1, partnerStructure2, partnerStructure3)) - openSearchSyncService.export() - } - - /** - * Given partner with property value - * When asking for a suggestion for that property - * Then show that property value - */ - @ParameterizedTest - @MethodSource("argumentsSuggestPropertyValues") - fun `suggest property values`(expectedSuggestionValue: String, endpointPath: String) { - - val page = webTestClient.get().uri(endpointPath) - .exchange() - .expectStatus().is2xxSuccessful - .returnResult>() - .responseBody - .blockFirst()!! - - - - assertThat(page.content).anyMatch { it.suggestion == expectedSuggestionValue } - } - - /** - * Given partner with property value - * When asking for a suggestion for that property value - * Then show that property value - */ - @ParameterizedTest - @MethodSource("argumentsSuggestPropertyValues") - fun `suggest by phrase`(expectedSuggestionValue: String, endpointPath: String) { - - val page = webTestClient.get() - .uri { builder -> - builder.path(endpointPath) - .queryParam(EndpointValues.TEXT_PARAM_NAME, expectedSuggestionValue) - .build() - } - .exchange() - .expectStatus().is2xxSuccessful - .returnResult>() - .responseBody - .blockFirst()!! - - assertThat(page.content).anyMatch { it.suggestion == expectedSuggestionValue } - } - - /** - * Given partner with property value - * When ask suggestion for a prefix of that value - * Then show that value - */ - @ParameterizedTest - @MethodSource("argumentsSuggestPropertyValues") - fun `suggest by prefix`(expectedSuggestionValue: String, endpointPath: String) { - - val page = webTestClient.get() - .uri { builder -> - builder.path(endpointPath) - .queryParam(EndpointValues.TEXT_PARAM_NAME, expectedSuggestionValue.substring(0, 1)) - .build() - } - .exchange() - .expectStatus().is2xxSuccessful - .returnResult>() - .responseBody - .blockFirst()!! - - assertThat(page.content).anyMatch { it.suggestion == expectedSuggestionValue } - } - - /** - * Given partner with property value that is several words - * When ask suggestion for a word in value - * Then show that value - */ - @ParameterizedTest - @MethodSource("argumentsSuggestPropertyValues") - fun `suggest by word`(expectedSuggestionValue: String, endpointPath: String) { - val queryText = expectedSuggestionValue.split("\\s".toRegex()).first() - - val page = webTestClient.get() - .uri { builder -> - builder.path(endpointPath) - .queryParam(EndpointValues.TEXT_PARAM_NAME, queryText) - .build() - } - .exchange() - .expectStatus().is2xxSuccessful - .returnResult>() - .responseBody - .blockFirst()!! - - assertThat(page.content).anyMatch { it.suggestion == expectedSuggestionValue } - } - - /** - * Given partner with property value - * When ask suggestion for text that doesn't have a word or prefix in value - * Then don't show that value - */ - @ParameterizedTest - @MethodSource("argumentsSuggestPropertyValues") - fun `don't suggest by different`(expectedSuggestionValue: String, endpointPath: String) { - val queryText = "xxxxxxDoesntMatchxxxxxx" - - val page = webTestClient.get() - .uri { builder -> - builder.path(endpointPath) - .queryParam(EndpointValues.TEXT_PARAM_NAME, queryText) - .build() - } - .exchange() - .expectStatus().is2xxSuccessful - .returnResult>() - .responseBody - .blockFirst()!! - - assertThat(page.content).noneMatch { it.suggestion == expectedSuggestionValue } - } - - /** - * Given partner with property 1 value and property 2 value - * When ask suggestion property 1 with filter by property 2 value - * Then show property 1 value 1 - */ - @ParameterizedTest - @MethodSource("argumentsSuggestPropertyValues") - fun `suggest filtered suggestions`(expectedSuggestionValue: String, endpointPath: String, filterName: String) { - val page = webTestClient.get() - .uri { builder -> - builder.path(endpointPath) - .queryParam(LegalEntityPropertiesSearchRequest::legalName.name, filterName) - .build() - } - .exchange() - .expectStatus().is2xxSuccessful - .returnResult>() - .responseBody - .blockFirst()!! - - assertThat(page.content).anyMatch { it.suggestion == expectedSuggestionValue } - } - - /** - * Given partner with property 1 value and property 2 value - * When ask suggestion for a word in property 1 value with filter by property 2 value - * Then show property 1 value - */ - @ParameterizedTest - @MethodSource("argumentsSuggestPropertyValues") - fun `suggest by word in filtered suggestions`(expectedSuggestionValue: String, endpointPath: String, filterName: String) { - val page = webTestClient.get() - .uri { builder -> - builder.path(endpointPath) - .queryParam(EndpointValues.TEXT_PARAM_NAME, expectedSuggestionValue) - .queryParam(LegalEntityPropertiesSearchRequest::legalName.name, filterName) - .build() - } - .exchange() - .expectStatus().is2xxSuccessful - .returnResult>() - .responseBody - .blockFirst()!! - - assertThat(page.content).anyMatch { it.suggestion == expectedSuggestionValue } - } - - /** - * Given partner with property 1 value and property 2 value - * When ask suggestion for a word in property 1 value with filter by other than property 2 value - * Then don't show property 1 value - */ - @ParameterizedTest - @MethodSource("argumentsSuggestPropertyValues") - fun `don't suggest by word when filtered out`(expectedSuggestionValue: String, endpointPath: String) { - val filterName = SaasValues.legalEntity2.names.first().value - - val page = webTestClient.get() - .uri { builder -> - builder.path(endpointPath) - .queryParam(EndpointValues.TEXT_PARAM_NAME, expectedSuggestionValue) - .queryParam(LegalEntityPropertiesSearchRequest::legalName.name, filterName) - .build() - } - .exchange() - .expectStatus().is2xxSuccessful - .returnResult>() - .responseBody - .blockFirst()!! - - assertThat(page.content).noneMatch { it.suggestion == expectedSuggestionValue } - } - - /** - * Given partner with property value in non-latin characters - * When ask suggestion for that value - * Then show that value - */ - @ParameterizedTest - @MethodSource("argumentsSuggestPropertyValuesNonLatin") - fun `suggest by non-latin characters`(expectedSuggestionValue: String, endpointPath: String) { - val expectedName = SaasValues.legalEntity3.names.first().value - - val page = webTestClient.get() - .uri { builder -> - builder.path(EndpointValues.CATENA_SUGGESTION_LE_NAME_PATH) - .queryParam(EndpointValues.TEXT_PARAM_NAME, expectedName) - .build() - } - .exchange() - .expectStatus().is2xxSuccessful - .returnResult>() - .responseBody - .blockFirst()!! - - assertThat(page.content).anyMatch { it.suggestion == expectedName } - } -} \ No newline at end of file diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/EndpointValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/EndpointValues.kt index a89398868..a4739dcca 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/EndpointValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/EndpointValues.kt @@ -30,27 +30,10 @@ object EndpointValues { const val CATENA_CHANGELOG_PATH_POSTFIX = "/changelog" const val CATENA_LEGAL_ENTITY_PATH = "$CATENA_PATH/legal-entities" - const val SAAS_SYNCH_PATH = "/api/saas/business-partner/sync" + const val OPENSEARCH_SYNC_PATH = "api/opensearch/business-partner" const val CATENA_METADATA_IDENTIFIER_TYPE_PATH = "$CATENA_PATH/identifier-types" - const val CATENA_METADATA_IDENTIFIER_STATUS_PATH = "$CATENA_PATH/identifier-status" - const val CATENA_METADATA_ISSUING_BODY_PATH = "$CATENA_PATH/issuing-bodies" const val CATENA_METADATA_LEGAL_FORM_PATH = "$CATENA_PATH/legal-forms" - const val CATENA_SUGGESTION_PATH = "$CATENA_PATH/suggestions" - const val CATENA_SUGGESTION_LEGAL_ENTITIES_PATH = "$CATENA_SUGGESTION_PATH/legal-entities" - const val CATENA_SUGGESTION_LE_NAME_PATH = "$CATENA_SUGGESTION_LEGAL_ENTITIES_PATH/names" - const val CATENA_SUGGESTION_LE_LEGAL_FORM_PATH = "$CATENA_SUGGESTION_LEGAL_ENTITIES_PATH/legal-forms" - const val CATENA_SUGGESTION_LE_STATUS_PATH = "$CATENA_SUGGESTION_LEGAL_ENTITIES_PATH/statuses" - const val CATENA_SUGGESTION_LE_CLASSIFICATION_PATH = "$CATENA_SUGGESTION_LEGAL_ENTITIES_PATH/classifications" - const val CATENA_SUGGESTION_SITES_PATH = "$CATENA_SUGGESTION_PATH/sites" - const val CATENA_SUGGESTION_SITE_NAME_PATH = "$CATENA_SUGGESTION_SITES_PATH/names" - const val CATENA_SUGGESTION_ADDRESS_PATH = "$CATENA_SUGGESTION_PATH/addresses" - const val CATENA_SUGGESTION_ADDRESS_ADMIN_AREA_PATH = "$CATENA_SUGGESTION_ADDRESS_PATH/administrative-areas" - const val CATENA_SUGGESTION_ADDRESS_POST_CODE_PATH = "$CATENA_SUGGESTION_ADDRESS_PATH/postcodes" - const val CATENA_SUGGESTION_ADDRESS_LOCALITY_PATH = "$CATENA_SUGGESTION_ADDRESS_PATH/localities" - const val CATENA_SUGGESTION_ADDRESS_THOROUGHFARE_PATH = "$CATENA_SUGGESTION_ADDRESS_PATH/thoroughfares" - const val CATENA_SUGGESTION_ADDRESS_PREMISE_PATH = "$CATENA_SUGGESTION_ADDRESS_PATH/premises" - const val CATENA_SUGGESTION_ADDRESS_POSTAL_DELIVERY_POINT_PATH = "$CATENA_SUGGESTION_ADDRESS_PATH/postal-delivery-points" } \ No newline at end of file diff --git a/docs/postman/BPDM Pool.postman_collection.json b/docs/postman/BPDM Pool.postman_collection.json index 70be4ca95..18e21c32d 100644 --- a/docs/postman/BPDM Pool.postman_collection.json +++ b/docs/postman/BPDM Pool.postman_collection.json @@ -952,911 +952,6 @@ } ] }, - { - "name": "Suggestion Controller", - "item": [ - { - "name": "Site Name Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/sites/names?text=sindel&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "sites", - "names" - ], - "query": [ - { - "key": "text", - "value": "sindel" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Legal Entity Name Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/legal-entities/names?text=other&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "legal-entities", - "names" - ], - "query": [ - { - "key": "text", - "value": "other" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Legal Entity Legal Form Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/legal-entities/legal-forms?text=custom&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "legal-entities", - "legal-forms" - ], - "query": [ - { - "key": "text", - "value": "custom" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Legal Entity Classification Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/legal-entities/classifications?text=far&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "legal-entities", - "classifications" - ], - "query": [ - { - "key": "text", - "value": "far" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Legal Entity Status Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/legal-entities/statuses?text=ac&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "legal-entities", - "statuses" - ], - "query": [ - { - "key": "text", - "value": "ac" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Admin Area Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/addresses/administrative-areas?text=bav&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "addresses", - "administrative-areas" - ], - "query": [ - { - "key": "text", - "value": "bav" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Postcode Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/addresses/postcodes?text=70&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "addresses", - "postcodes" - ], - "query": [ - { - "key": "text", - "value": "70" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Locality Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/addresses/localities?text=st&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "addresses", - "localities" - ], - "query": [ - { - "key": "text", - "value": "st" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Premise Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/addresses/premises?text=bu&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "addresses", - "premises" - ], - "query": [ - { - "key": "text", - "value": "bu" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Thoroughfare Suggestions", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/suggestions/addresses/thoroughfares?text=stutt&page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "suggestions", - "addresses", - "thoroughfares" - ], - "query": [ - { - "key": "text", - "value": "stutt" - }, - { - "key": "name", - "value": "", - "disabled": true - }, - { - "key": "legalForm", - "value": "", - "disabled": true - }, - { - "key": "status", - "value": "", - "disabled": true - }, - { - "key": "classification", - "value": "", - "disabled": true - }, - { - "key": "administrativeArea", - "value": "", - "disabled": true - }, - { - "key": "postCode", - "value": "", - "disabled": true - }, - { - "key": "locality", - "value": "", - "disabled": true - }, - { - "key": "thoroughfare", - "value": "", - "disabled": true - }, - { - "key": "premise", - "value": "", - "disabled": true - }, - { - "key": "postalDeliveryPoint", - "value": "", - "disabled": true - }, - { - "key": "siteName", - "value": "", - "disabled": true - }, - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - } - ] - }, { "name": "SaaS Controller", "item": [ From 948b9de835ed835ce5b8659c72ccd926dcc2d94c Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Mon, 5 Jun 2023 06:47:56 +0200 Subject: [PATCH 23/83] feat(api): #216 Remove suggestion endpoints - delete unused constants --- .../opensearch/impl/service/SearchServiceImpl.kt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt index 347a52846..92ef5157e 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt @@ -20,7 +20,6 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.module.kotlin.readValue import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse @@ -30,7 +29,6 @@ import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService -import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.TextDoc import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.AddressDocSearchRepository import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.LegalEntityDocSearchRepository import org.eclipse.tractusx.bpdm.pool.config.OpenSearchConfigProperties @@ -113,12 +111,6 @@ class SearchServiceImpl( } } - - private fun extractTextDocText(textDocJson: String): String { - val textDoc: TextDoc = objectMapper.readValue(textDocJson) - return textDoc.text - } - private fun searchAndPreparePage( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest From dd51459b1a32e1384803421d2420252aae51f863 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Mon, 5 Jun 2023 06:55:49 +0200 Subject: [PATCH 24/83] feat(api): #216 Remove suggestion endpoints - delete unused vals --- .../pool/component/opensearch/impl/service/SearchServiceImpl.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt index 92ef5157e..59bf985da 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service -import com.fasterxml.jackson.databind.ObjectMapper import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse @@ -55,7 +54,6 @@ class SearchServiceImpl( val logisticAddressRepository: LogisticAddressRepository, val addressService: AddressService, val businessPartnerFetchService: BusinessPartnerFetchService, - val objectMapper: ObjectMapper, val openSearchConfigProperties: OpenSearchConfigProperties ) : SearchService { From 73073f395783ff85fea0a6dafc58948f343fb17d Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Tue, 6 Jun 2023 08:46:38 +0200 Subject: [PATCH 25/83] fix(api): #222 Wrong Schema for Entities with Error Response --- .../api/model/response/EntitiesWithErrors.kt | 70 ++++++++++++++++--- .../service/BusinessPartnerBuildService.kt | 12 ++-- 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/EntitiesWithErrors.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/EntitiesWithErrors.kt index 14f47497d..e4ba56481 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/EntitiesWithErrors.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/EntitiesWithErrors.kt @@ -22,14 +22,12 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse -@Schema(name = "EntitiesWithErrorsResponse", description = "Holds information about successfully and failed entities after the creating/updating of several objects") - -data class EntitiesWithErrors( +open class EntitiesWithErrors( @Schema(description = "Successfully created entities") - val entities: Collection, + open val entities: Collection, @Schema(description = "Errors for not created entities") - val errors: Collection> + open val errors: Collection> ) { val entityCount: Int get() = entities.size @@ -37,9 +35,59 @@ data class EntitiesWithErrors( get() = errors.size } -typealias LegalEntityPartnerCreateResponseWrapper = EntitiesWithErrors -typealias LegalEntityPartnerUpdateResponseWrapper = EntitiesWithErrors -typealias SitePartnerCreateResponseWrapper = EntitiesWithErrors -typealias SitePartnerUpdateResponseWrapper = EntitiesWithErrors -typealias AddressPartnerCreateResponseWrapper = EntitiesWithErrors -typealias AddressPartnerUpdateResponseWrapper = EntitiesWithErrors +@Schema( + name = "LegalEntityCreateWrapper", + description = "Holds information about successfully and failed entities after the creating/updating of several objects" +) +data class LegalEntityPartnerCreateResponseWrapper( + override val entities: Collection, + override val errors: Collection> +) : EntitiesWithErrors(entities, errors) + +@Schema( + name = "LegalEntityUpdateWrapper", + description = "Holds information about successfully and failed entities after the creating/updating of several objects" +) +data class LegalEntityPartnerUpdateResponseWrapper( + override val entities: Collection, + override val errors: Collection> +) : EntitiesWithErrors(entities, errors) + +@Schema( + name = "SiteCreateWrapper", + description = "Holds information about successfully and failed entities after the creating/updating of several objects" +) +data class SitePartnerCreateResponseWrapper( + override val entities: Collection, + override val errors: Collection> +) : EntitiesWithErrors(entities, errors) + +@Schema( + name = "SiteUpdateWrapper", + description = "Holds information about successfully and failed entities after the creating/updating of several objects" +) +data class SitePartnerUpdateResponseWrapper( + override val entities: Collection, + override val errors: Collection> +) : EntitiesWithErrors(entities, errors) + +@Schema( + name = "AddressCreateWrapper", + description = "Holds information about successfully and failed entities after the creating/updating of several objects" +) +data class AddressPartnerCreateResponseWrapper( + override val entities: Collection, + override val errors: Collection> +) : EntitiesWithErrors(entities, errors) + +@Schema( + name = "AddressUpdateWrapper", + description = "Holds information about successfully and failed entities after the creating/updating of several objects" +) +data class AddressPartnerUpdateResponseWrapper( + override val entities: Collection, + override val errors: Collection> +) : EntitiesWithErrors(entities, errors) + + + diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index 19df97ac4..3c91b4732 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -88,7 +88,7 @@ class BusinessPartnerBuildService( val validEntities = legalEntities.map { it.toUpsertDto(legalEntityWithIndexByBpnMap[it.bpn]!!.second) } - return EntitiesWithErrors(validEntities, errors) + return LegalEntityPartnerCreateResponseWrapper(validEntities, errors) } @Transactional @@ -125,7 +125,7 @@ class BusinessPartnerBuildService( val validEntities = sites.map { it.toUpsertDto(siteWithIndexByBpnMap[it.bpn]!!.second) } - return EntitiesWithErrors(validEntities, errors) + return SitePartnerCreateResponseWrapper(validEntities, errors) } @Transactional @@ -150,7 +150,7 @@ class BusinessPartnerBuildService( changelogService.createChangelogEntries(addressResponses.map { ChangelogEntryDto(it.address.bpna, ChangelogType.CREATE, ChangelogSubject.ADDRESS) }) - return EntitiesWithErrors(addressResponses, errors) + return AddressPartnerCreateResponseWrapper(addressResponses, errors) } /** @@ -184,7 +184,7 @@ class BusinessPartnerBuildService( val validEntities = legalEntityRepository.saveAll(legalEntities).map { it.toUpsertDto(null) } - return EntitiesWithErrors(validEntities, errors) + return LegalEntityPartnerUpdateResponseWrapper(validEntities, errors) } @Transactional @@ -212,7 +212,7 @@ class BusinessPartnerBuildService( } val validEntities = siteRepository.saveAll(sites).map { it.toUpsertDto(null) } - return EntitiesWithErrors(validEntities, errors) + return SitePartnerUpdateResponseWrapper(validEntities, errors) } fun updateAddresses(requests: Collection): AddressPartnerUpdateResponseWrapper { @@ -233,7 +233,7 @@ class BusinessPartnerBuildService( changelogService.createChangelogEntries(validAddresses.map { ChangelogEntryDto(it.bpn, ChangelogType.UPDATE, ChangelogSubject.ADDRESS) }) val addressResponses = logisticAddressRepository.saveAll(validAddresses).map { it.toDto() } - return EntitiesWithErrors(addressResponses, errors) + return AddressPartnerUpdateResponseWrapper(addressResponses, errors) } @Transactional From 3f453963e7aeebfdb57cdd1338362894d3d1870a Mon Sep 17 00:00:00 2001 From: cezaralexandremorais Date: Fri, 2 Jun 2023 11:26:55 +0100 Subject: [PATCH 26/83] fix(gate/pool): Changed information from Install.md and aplication properties, removing not needed SaaS instructions, Update Swagger-UI url, and wrote run instructions saying that the project must be run from root pom file --- INSTALL.md | 29 +++++-------------- .../src/main/resources/application.properties | 11 ------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 3156be4d8..fe8c99b44 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -7,6 +7,7 @@ This file contains information on how to configure and run the BPDM applications BPDM Pool is a SpringBoot Kotlin software project managed by Maven. The project can be run with the following command: `mvn clean spring-boot:run` +The command should be run from the root poom file ### Prerequisites @@ -15,16 +16,15 @@ The project can be run with the following command: `mvn clean spring-boot:run` * PostgreSQL 14.2 * OpenSearch 2.1.0 * Keycloak 17.0.0 (with enabled `auth` profile) -* Connection to an SaaS for the sharing process (with enabled `saas` profile) When running, the project requires a Postgresql database and an Opensearch instance to be available to connect to. Per default configuration the application expects postgres to run on `localhost` on port `5432`. Opensearch needs to run on `localhost` on port `9200` on default. -You can find and edit the default configuration for the Pool in the `application.properties`, `application-auth.properties` and `application-saas.properties` +You can find and edit the default configuration for the Pool in the `application.properties`, `application-auth.properties` files in the `resources` folder. -The REST API documentation can be accessed at http://localhost:8080/api/swagger-ui. +The REST API documentation can be accessed at http://localhost:8080/ui/swagger-ui/index.html. ### Profiles @@ -33,11 +33,11 @@ Here you can find core application configuration such as Swagger documentation, Furthermore, here you can find the configuration for the connection to the Spring datasource (currently, developed against PostgreSQL) and Opensearch. You can also run the project with Spring profiles to enable additional components on top of the default configuration. -Currently, the BPDM Pool offers the profiles `auth` and `saas`. +Currently, the BPDM Pool offers the profiles `auth`. In order to run the application with a specific profile you can use the appropriate maven flag `Dspring.profiles.active`. For example, the command `mvn clean spring-boot:run -Dspring.profiles.active=auth` starts the application with additional `auth` configuration enabled. -You can also run several profiles at once, of course: `mvn clean spring-boot:run -Dspring.profiles.active=auth,saas`. +You can also run several profiles at once, of course: `mvn clean spring-boot:run -Dspring.profiles.active=auth`. The following sections detail the configuration properties for each profile. @@ -50,7 +50,7 @@ The application uses the configured auth server URL to validate incoming tokens. For authorization purposes the application checks incoming token's permissions: -* add_company_data: For endpoints creating or updating business partner records including triggering imports from SaaS/exports to Opensearch +* add_company_data: For endpoints creating or updating business partner records * view_company_data: For read-only endpoints of business partner data The BPDM Pool looks for these permissions in the client/resource and not on the realm level. @@ -58,15 +58,6 @@ The BPDM Pool looks for these permissions in the client/resource and not on the This profile also enables/disables the login form in the auto-generated Swagger documentation. The Swagger login uses the client specified in the property `springdoc.swagger-ui.oauth.client-id`. -### SaaS - -The file `application-saas.properties` enables and configures the connection to a remote SaaS for the sharing process from which the application can import -business partner records. -Depending on whether this component is enabled, the application offers an endpoint to import records from SaaS. -If enabled the application requires the environment variable `BPDM_SAAS_KEY` to contain an API key with necessary privileges for accessing the specified -storage. -Further, you need to provide a hostname (`BPDM_SAAS_HOST`), storage ID (`BPDM_SAAS_STORAGE`) and datasource ID `BPDM_SAAS_DATASOURCE` to specify from where the records -should be imported by the application. ### Helm Deployment @@ -81,25 +72,21 @@ BPDM is a SpringBoot Kotlin software project managed by Maven and can be run wit * Maven * JDK17 -* Connection to an SaaS for the sharing process * Connection to BPDM Pool API * Keycloak 17.0.0 (with enabled `auth` or `pool-auth` profile) -When running, the BPDM Gate requires a remote SaaS storage and datasource to exchange data with. -The application expects the environment variables `BPDM_SAAS_HOST`, `BPDM_SAAS_KEY`, `BPDM_SAAS_STORAGE` and `BPDM_SAAS_DATASOURCE` to contain the hostname to connect to, the API key and -the identifiers for the storage and datasource respectively. The Gate also requires a connection to a BPDM Pool instance which is expected at `localhost` with port `8080` on default configuration. You can find and edit the default configuration for the Gate in the `application.properties`, `application-auth.properties` and `application-pool-auth.properties` files in the `resources` folder. -The REST API documentation can be accessed at http://localhost:8081/api/swagger-ui. +The REST API documentation can be accessed at http://localhost:8081/ui/swagger-ui/index.html. ### Profiles The default configuration of the application is determined by the `application.properties` file. -Here you can find core application configuration such as Swagger documentation, SaaS and BPDM Pool connection. +Here you can find core application configuration such as Swagger documentation and BPDM Pool connection. You can also run the project with Spring profiles to enable additional components on top of the default configuration. Currently, the BPDM Gate offers the profiles `auth` and `auth-pool`. diff --git a/bpdm-gate/src/main/resources/application.properties b/bpdm-gate/src/main/resources/application.properties index c3ad1ded6..b970a0e6b 100644 --- a/bpdm-gate/src/main/resources/application.properties +++ b/bpdm-gate/src/main/resources/application.properties @@ -28,17 +28,6 @@ bpdm.api.upsert-limit=100 bpdm.bpn.agency-name=Catena-X bpdm.bpn.name=Business Partner Number bpdm.bpn.id=CX_BPN -#Handle configuration of SaaS API connection -bpdm.saas.host=${BPDM_SAAS_HOST:http://localhost:1234} -bpdm.saas.storage=${BPDM_SAAS_STORAGE:storage_id} -bpdm.saas.datasource=${BPDM_SAAS_DATASOURCE:datasource_id} -bpdm.saas.legal-entity-type=LEGAL_ENTITY -bpdm.saas.site-type=ORGANIZATIONAL_UNIT -bpdm.saas.address-type=BP_ADDRESS -bpdm.saas.api-key=${BPDM_SAAS_KEY:} -bpdm.saas.data-exchange-api-url=/data-exchange/rest/v4/storages/${bpdm.saas.storage} -bpdm.saas.data-clinic-api-url=/data-clinic/rest/storages/${bpdm.saas.storage} -bpdm.saas.sharing-timeout=2d #Springdoc swagger configuration springdoc.swagger-ui.disable-swagger-default-url=true springdoc.swagger-ui.path=/ui/swagger-ui From b18a459348043efe64d18bb049c4976b0cd4bec7 Mon Sep 17 00:00:00 2001 From: cezaralexandremorais Date: Mon, 5 Jun 2023 11:14:17 +0100 Subject: [PATCH 27/83] fix(gate/pool) updated some default values for SaaS in proprieties file and updated information in INSTALL.md --- INSTALL.md | 6 +++--- bpdm-gate/src/main/resources/application.properties | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index fe8c99b44..c78aa2496 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -7,7 +7,8 @@ This file contains information on how to configure and run the BPDM applications BPDM Pool is a SpringBoot Kotlin software project managed by Maven. The project can be run with the following command: `mvn clean spring-boot:run` -The command should be run from the root poom file +In order to run the project you need to build the project from the parent pom file and depending on wich module we want to run we need to specify the module as +a target. ### Prerequisites @@ -33,11 +34,10 @@ Here you can find core application configuration such as Swagger documentation, Furthermore, here you can find the configuration for the connection to the Spring datasource (currently, developed against PostgreSQL) and Opensearch. You can also run the project with Spring profiles to enable additional components on top of the default configuration. -Currently, the BPDM Pool offers the profiles `auth`. +Currently, the BPDM Pool offers the profile `auth`. In order to run the application with a specific profile you can use the appropriate maven flag `Dspring.profiles.active`. For example, the command `mvn clean spring-boot:run -Dspring.profiles.active=auth` starts the application with additional `auth` configuration enabled. -You can also run several profiles at once, of course: `mvn clean spring-boot:run -Dspring.profiles.active=auth`. The following sections detail the configuration properties for each profile. diff --git a/bpdm-gate/src/main/resources/application.properties b/bpdm-gate/src/main/resources/application.properties index b970a0e6b..c3ad1ded6 100644 --- a/bpdm-gate/src/main/resources/application.properties +++ b/bpdm-gate/src/main/resources/application.properties @@ -28,6 +28,17 @@ bpdm.api.upsert-limit=100 bpdm.bpn.agency-name=Catena-X bpdm.bpn.name=Business Partner Number bpdm.bpn.id=CX_BPN +#Handle configuration of SaaS API connection +bpdm.saas.host=${BPDM_SAAS_HOST:http://localhost:1234} +bpdm.saas.storage=${BPDM_SAAS_STORAGE:storage_id} +bpdm.saas.datasource=${BPDM_SAAS_DATASOURCE:datasource_id} +bpdm.saas.legal-entity-type=LEGAL_ENTITY +bpdm.saas.site-type=ORGANIZATIONAL_UNIT +bpdm.saas.address-type=BP_ADDRESS +bpdm.saas.api-key=${BPDM_SAAS_KEY:} +bpdm.saas.data-exchange-api-url=/data-exchange/rest/v4/storages/${bpdm.saas.storage} +bpdm.saas.data-clinic-api-url=/data-clinic/rest/storages/${bpdm.saas.storage} +bpdm.saas.sharing-timeout=2d #Springdoc swagger configuration springdoc.swagger-ui.disable-swagger-default-url=true springdoc.swagger-ui.path=/ui/swagger-ui From 685a3bc31448d32641d7e1007db1e406d6119397 Mon Sep 17 00:00:00 2001 From: cezaralexandremorais Date: Tue, 6 Jun 2023 12:42:35 +0100 Subject: [PATCH 28/83] fix(gate) updated INSTALL.md file with information about how to run the project --- INSTALL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index c78aa2496..bc42eaca3 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -6,9 +6,9 @@ This file contains information on how to configure and run the BPDM applications BPDM Pool is a SpringBoot Kotlin software project managed by Maven. -The project can be run with the following command: `mvn clean spring-boot:run` -In order to run the project you need to build the project from the parent pom file and depending on wich module we want to run we need to specify the module as -a target. +To run the project first you need to install it from the parent pom, go to the root folder and run `mvn clean install` + +Then depending on which module you want to start go to the module subfolder you like to run and use the following command: `mvn spring-boot:run` ### Prerequisites From 68708e99729cb205739b6926fb5ae7837cc6d0df Mon Sep 17 00:00:00 2001 From: cezaralexandremorais Date: Tue, 6 Jun 2023 10:18:21 +0100 Subject: [PATCH 29/83] fix(gate) Removed BPN property from LogisticAddress , LegalEntity and Site entities, input request and response, and updated unit tests to work without BPN. Created a Migration file to drop BPN column from Site, LegalEntity and LogisticAddress --- .../gate/api/model/AddressGateInputRequest.kt | 2 -- .../api/model/AddressGateInputResponse.kt | 3 -- .../api/model/LegalEntityGateInputRequest.kt | 2 -- .../api/model/LegalEntityGateInputResponse.kt | 3 -- .../gate/api/model/SiteGateInputRequest.kt | 2 -- .../gate/api/model/SiteGateInputResponse.kt | 3 -- .../tractusx/bpdm/gate/entity/LegalEntity.kt | 3 -- .../bpdm/gate/entity/LogisticAddress.kt | 3 -- .../eclipse/tractusx/bpdm/gate/entity/Site.kt | 3 -- .../gate/service/AddressPersistenceService.kt | 1 - .../service/LegalEntityPersistenceService.kt | 2 -- .../bpdm/gate/service/LegalEntityService.kt | 1 - .../bpdm/gate/service/ResponseMappings.kt | 6 ---- .../gate/service/SaasRequestMappingService.kt | 6 ++-- .../gate/service/SitePersistenceService.kt | 2 -- ...drop_bpn_from_site_adress_legal_entity.sql | 3 ++ .../tractusx/bpdm/gate/util/RequestValues.kt | 28 +++++++++---------- .../tractusx/bpdm/gate/util/ResponseValues.kt | 13 --------- 18 files changed, 20 insertions(+), 66 deletions(-) create mode 100644 bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_from_site_adress_legal_entity.sql diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt index dc6b54920..845edc629 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputRequest.kt @@ -42,6 +42,4 @@ data class AddressGateInputRequest( @Schema(description = "External id of the related site") val siteExternalId: String? = null, - @Schema(description = "Business Partner Number") - val bpn: String? = null ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt index d7642a7eb..c5b15f6b0 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt @@ -44,9 +44,6 @@ data class AddressGateInputResponse( @Schema(description = "External id of the related site") val siteExternalId: String? = null, - @Schema(description = "Business Partner Number") - val bpn: String? = null, - @Schema(description = "Time the sharing process was started according to SaaS") val processStartedAt: LocalDateTime? = null, ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt index 1c7ec2bd6..a82785af0 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt @@ -39,6 +39,4 @@ data class LegalEntityGateInputRequest( @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, - @Schema(description = "Business Partner Number") - val bpn: String?, ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt index 74b0abf43..fd8667a02 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt @@ -41,9 +41,6 @@ data class LegalEntityGateInputResponse( @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, - @Schema(description = "Business Partner Number") - val bpn: String?, - @Schema(description = "Time the sharing process was started according to SaaS") val processStartedAt: LocalDateTime? = null, ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt index b42937a30..3701ab3cd 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt @@ -38,6 +38,4 @@ data class SiteGateInputRequest( @Schema(description = "External id of the related legal entity") val legalEntityExternalId: String, - @Schema(description = "Business Partner Number") - val bpn: String?, ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt index 7732cc602..16e5cd6fa 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt @@ -39,9 +39,6 @@ data class SiteGateInputResponse( @Schema(description = "External id of the related legal entity") val legalEntityExternalId: String, - @Schema(description = "Business Partner Number") - val bpn: String?, - @Schema(description = "Time the sharing process was started according to SaaS") val processStartedAt: LocalDateTime? = null, ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt index e22dfba33..95493ca63 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt @@ -29,9 +29,6 @@ import java.time.Instant indexes = [Index(columnList = "legal_form_id")] ) class LegalEntity( - @Column(name = "bpn") - var bpn: String?, - @Column(name = "externalId", nullable = false, unique = true) var externalId: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt index d20c80e27..bb99563fa 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt @@ -31,9 +31,6 @@ import org.eclipse.tractusx.bpdm.common.model.BaseEntity ] ) class LogisticAddress( - @Column(name = "bpn") - var bpn: String?, - @Column(name = "external_id", nullable = false, unique = true) var externalId: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt index 4baf5df32..bee5014b1 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt @@ -25,9 +25,6 @@ import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "sites") class Site( - @Column(name = "bpn") - var bpn: String?, - @Column(name = "name", nullable = false) var name: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index 563e3e4f0..5e491a22f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -67,7 +67,6 @@ class AddressPersistenceService( private fun updateAddress(address: LogisticAddress, changeAddress: AddressGateInputRequest, legalEntityRecord: LegalEntity?, siteRecord: Site?) { address.name = changeAddress.address.name - address.bpn = changeAddress.bpn address.externalId = changeAddress.externalId address.legalEntity = legalEntityRecord address.site = siteRecord diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 59ea7c114..153c27351 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -67,7 +67,6 @@ class LegalEntityPersistenceService( legalEntityRequest: LegalEntityGateInputRequest, logisticAddressRecord: LogisticAddress ): LegalEntity { - legalEntity.bpn = legalEntityRequest.bpn legalEntity.externalId = legalEntityRequest.externalId legalEntity.legalForm = legalEntityRequest.legalEntity.legalForm legalEntity.legalName = Name(value = legalEntityRequest.legalNameParts[0], shortName = legalEntityRequest.legalEntity.legalShortName) @@ -82,7 +81,6 @@ class LegalEntityPersistenceService( private fun updateAddress(address: LogisticAddress, changeAddress: LogisticAddress) { address.name = changeAddress.name - address.bpn = changeAddress.bpn address.externalId = changeAddress.externalId address.legalEntity = changeAddress.legalEntity address.siteExternalId = changeAddress.siteExternalId diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 876ff9cc5..69398cc1a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -162,7 +162,6 @@ private fun toValidSingleLegalEntity(legalEntity: LegalEntity): LegalEntityGateI return LegalEntityGateInputResponse( legalEntity = legalEntity.toLegalEntityDto(), legalAddress = legalEntity.legalAddress.toLogisticAddressDto(), - bpn = legalEntity.bpn, externalId = legalEntity.externalId ) } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 4b237c4da..f96b7be6d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -31,7 +31,6 @@ import java.time.temporal.ChronoUnit fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site?): LogisticAddress { val logisticAddress = LogisticAddress( - bpn = bpn, externalId = externalId, siteExternalId = siteExternalId.toString(), name = address.name, @@ -117,7 +116,6 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity): Site { ) val site = Site( - bpn = bpn, name = site.name, externalId = externalId, legalEntity = legalEntity @@ -150,7 +148,6 @@ fun LegalEntityGateInputRequest.toLegalEntity(): LegalEntity { ) val legalEntity = LegalEntity( - bpn = bpn, externalId = externalId, currentness = createCurrentnessTimestamp(), legalForm = legalEntity.legalForm, @@ -198,7 +195,6 @@ fun LogisticAddress.toAddressGateInputResponse(logisticAddressPage: LogisticAddr externalId = externalId, legalEntityExternalId = legalEntity?.externalId, siteExternalId = site?.externalId, - bpn = bpn, processStartedAt = null //TODO Remove ? ) @@ -323,7 +319,6 @@ fun LegalEntity.LegalEntityGateInputResponse(legalEntity: LegalEntity): LegalEnt legalEntity = legalEntity.toLegalEntityDto(), legalAddress = legalAddress.toLogisticAddressDto(), externalId = legalEntity.externalId, - bpn = legalEntity.bpn, processStartedAt = null ) } @@ -349,7 +344,6 @@ fun Site.toSiteGateInputResponse(sitePage: Site): SiteGateInputResponse { site = sitePage.toSiteDto(), externalId = externalId, legalEntityExternalId = legalEntity.externalId, - bpn = bpn, processStartedAt = null //TODO Remove this? ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt index dc17ac9a1..7d3b8c93c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt @@ -40,7 +40,7 @@ class SaasRequestMappingService( externalId = request.externalId, dataSource = saasConfigProperties.datasource, types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.LEGAL_ENTITY.name)), - identifiers = toLegalEntityIdentifiersSaas(legalEntity.identifiers, request.bpn), + identifiers = toLegalEntityIdentifiersSaas(legalEntity.identifiers, ""), names = toNamesSaas(request.legalNameParts[0]), // TODO Only the first state is passed to SaaS, any others are ignored status = legalEntity.states.map { it.toSaasModel() }.firstOrNull(), @@ -57,7 +57,7 @@ class SaasRequestMappingService( externalId = request.externalId, dataSource = saasConfigProperties.datasource, types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.ORGANIZATIONAL_UNIT.name)), - identifiers = toIdentifiersSaas(request.bpn), + identifiers = toIdentifiersSaas(""), names = toNamesSaas(site.name), status = site.states.map { it.toSaasModel() }.firstOrNull(), // TODO Known issue: Name, state, BPN-A and identifiers of the main address are not transferred to SaaS yet!! @@ -72,7 +72,7 @@ class SaasRequestMappingService( externalId = request.externalId, dataSource = saasConfigProperties.datasource, types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.BP_ADDRESS.name)), - identifiers = toAddressIdentifiersSaas(address.identifiers, request.bpn), + identifiers = toAddressIdentifiersSaas(address.identifiers, ""), names = toNamesSaas(address.name), status = address.states.map { it.toSaasModel() }.firstOrNull(), addresses = toAddressesSaasModel(address) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 48ab746a6..2f8f59ea1 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -74,7 +74,6 @@ class SitePersistenceService( private fun updateSite(site: Site, updatedSite: SiteGateInputRequest, legalEntityRecord: LegalEntity) { - site.bpn = updatedSite.bpn site.name = updatedSite.site.name site.externalId = updatedSite.externalId site.legalEntity = legalEntityRecord @@ -85,7 +84,6 @@ class SitePersistenceService( private fun updateAddress(address: LogisticAddress, changeAddress: LogisticAddress) { address.name = changeAddress.name - address.bpn = changeAddress.bpn address.externalId = changeAddress.externalId address.legalEntity = changeAddress.legalEntity address.siteExternalId = changeAddress.siteExternalId diff --git a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_from_site_adress_legal_entity.sql b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_from_site_adress_legal_entity.sql new file mode 100644 index 000000000..4f233e1e3 --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_from_site_adress_legal_entity.sql @@ -0,0 +1,3 @@ +ALTER TABLE bpdmgate.legal_entities DROP COLUMN bpn; +ALTER TABLE bpdmgate.logistic_addresses DROP COLUMN bpn; +ALTER TABLE bpdmgate.sites DROP COLUMN bpn; \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index 60515865b..c57a1b178 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -267,24 +267,24 @@ object RequestValues { legalAddress = address1, legalNameParts = arrayOf(CommonValues.name1), externalId = CommonValues.externalId1, - bpn = CommonValues.bpn1 - ) + + ) val legalEntityGateInputRequest2 = LegalEntityGateInputRequest( legalEntity = legalEntity2, legalAddress = address2, legalNameParts = arrayOf(CommonValues.name3), externalId = CommonValues.externalId2, - bpn = CommonValues.bpn2 - ) + + ) val legalEntityGateInputRequest3 = LegalEntityGateInputRequest( legalEntity = legalEntity3, legalAddress = address3, legalNameParts = arrayOf(CommonValues.name1), externalId = CommonValues.externalId3, - bpn = CommonValues.bpn3 - ) + + ) val site1 = SiteGateDto( name = CommonValues.nameSite1, @@ -302,15 +302,15 @@ object RequestValues { site = site1, externalId = CommonValues.externalIdSite1, legalEntityExternalId = CommonValues.externalId1, - bpn = CommonValues.bpnSite1 - ) + + ) val siteGateInputRequest2 = SiteGateInputRequest( site = site2, externalId = CommonValues.externalIdSite2, legalEntityExternalId = CommonValues.externalId2, - bpn = CommonValues.bpnSite2 - ) + + ) val addressGateInputRequest1 = AddressGateInputRequest( address = address1.copy( @@ -321,8 +321,8 @@ object RequestValues { ), externalId = CommonValues.externalIdAddress1, legalEntityExternalId = CommonValues.externalId1, - bpn = CommonValues.bpnAddress1 - ) + + ) val addressGateInputRequest2 = AddressGateInputRequest( address = address2.copy( @@ -333,7 +333,7 @@ object RequestValues { ), externalId = CommonValues.externalIdAddress2, siteExternalId = CommonValues.externalIdSite1, - bpn = CommonValues.bpnAddress2 - ) + + ) } \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index e0c0fcf9c..26734d755 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -281,7 +281,6 @@ object ResponseValues { legalEntity = RequestValues.legalEntity1, legalAddress = RequestValues.address1, externalId = CommonValues.externalId1, - bpn = CommonValues.bpn1, processStartedAt = SaasValues.modificationTime1, ) @@ -289,7 +288,6 @@ object ResponseValues { legalEntity = RequestValues.legalEntity2, legalAddress = RequestValues.address2, externalId = CommonValues.externalId2, - bpn = CommonValues.bpn2, processStartedAt = SaasValues.modificationTime2, ) @@ -297,7 +295,6 @@ object ResponseValues { legalEntity = RequestValues.legalEntity3, legalAddress = RequestValues.address3, externalId = CommonValues.externalId3, - bpn = CommonValues.bpn3, processStartedAt = null, ) @@ -306,14 +303,12 @@ object ResponseValues { legalEntity = RequestValues.legalEntity1, legalAddress = RequestValues.address1, externalId = CommonValues.externalId1, - bpn = CommonValues.bpn1, processStartedAt = null ) val newLegalEntityGateInputResponse2 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity2, legalAddress = RequestValues.address2, externalId = CommonValues.externalId2, - bpn = CommonValues.bpn2, processStartedAt = null, ) @@ -352,7 +347,6 @@ object ResponseValues { site = RequestValues.site1, externalId = CommonValues.externalIdSite1, legalEntityExternalId = CommonValues.externalId1, - bpn = CommonValues.bpnSite1, processStartedAt = SaasValues.modificationTime1, ) @@ -360,7 +354,6 @@ object ResponseValues { site = RequestValues.site2, externalId = CommonValues.externalIdSite2, legalEntityExternalId = CommonValues.externalId2, - bpn = CommonValues.bpnSite2, processStartedAt = SaasValues.modificationTime2, ) @@ -369,7 +362,6 @@ object ResponseValues { site = RequestValues.site1, externalId = CommonValues.externalIdSite1, legalEntityExternalId = CommonValues.externalId1, - bpn = CommonValues.bpnSite1, processStartedAt = null, ) @@ -377,7 +369,6 @@ object ResponseValues { site = RequestValues.site2, externalId = CommonValues.externalIdSite2, legalEntityExternalId = CommonValues.externalId2, - bpn = CommonValues.bpnSite2, processStartedAt = null, ) @@ -404,7 +395,6 @@ object ResponseValues { ), externalId = CommonValues.externalIdAddress1, legalEntityExternalId = CommonValues.externalId1, - bpn = CommonValues.bpnAddress1, processStartedAt = SaasValues.modificationTime1, ) @@ -419,7 +409,6 @@ object ResponseValues { ), externalId = CommonValues.externalIdAddress2, siteExternalId = CommonValues.externalIdSite1, - bpn = CommonValues.bpnAddress2, processStartedAt = SaasValues.modificationTime2, ) @@ -441,7 +430,6 @@ object ResponseValues { ), externalId = CommonValues.externalIdAddress1, legalEntityExternalId = null, - bpn = CommonValues.bpnAddress1, processStartedAt = null, ) @@ -453,7 +441,6 @@ object ResponseValues { ) ), externalId = CommonValues.externalIdAddress2, - bpn = CommonValues.bpnAddress2, siteExternalId = null, processStartedAt = null, ) From 29fcd36acaf643ed90f462116098ea7d4f3909eb Mon Sep 17 00:00:00 2001 From: cezaralexandremorais Date: Tue, 6 Jun 2023 12:34:13 +0100 Subject: [PATCH 30/83] fix(gate) added bpn property to Site, LegalEntity and LogisticAddress entities --- .../org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt | 3 +++ .../org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt | 3 +++ .../main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt | 3 +++ .../org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt | 2 +- .../V0_1_6_0__drop_bpn_from_site_adress_legal_entity.sql | 3 --- .../V0_1_6_0__drop_bpn_not_null_from_legal_entity.sql | 1 + .../org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt | 2 +- 7 files changed, 12 insertions(+), 5 deletions(-) delete mode 100644 bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_from_site_adress_legal_entity.sql create mode 100644 bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_not_null_from_legal_entity.sql diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt index 95493ca63..f5cb24bb0 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt @@ -29,6 +29,9 @@ import java.time.Instant indexes = [Index(columnList = "legal_form_id")] ) class LegalEntity( + @Column(name = "bpn") + var bpn: String? = null, + @Column(name = "externalId", nullable = false, unique = true) var externalId: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt index bb99563fa..38e5f09e4 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt @@ -31,6 +31,9 @@ import org.eclipse.tractusx.bpdm.common.model.BaseEntity ] ) class LogisticAddress( + @Column(name = "bpn") + var bpn: String? = null, + @Column(name = "external_id", nullable = false, unique = true) var externalId: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt index bee5014b1..791f345c2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt @@ -25,6 +25,9 @@ import org.eclipse.tractusx.bpdm.common.model.BaseEntity @Entity @Table(name = "sites") class Site( + @Column(name = "bpn") + var bpn: String? = null, + @Column(name = "name", nullable = false) var name: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index f96b7be6d..5dfc57076 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -118,7 +118,7 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity): Site { val site = Site( name = site.name, externalId = externalId, - legalEntity = legalEntity + legalEntity = legalEntity, ) site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) diff --git a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_from_site_adress_legal_entity.sql b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_from_site_adress_legal_entity.sql deleted file mode 100644 index 4f233e1e3..000000000 --- a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_from_site_adress_legal_entity.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE bpdmgate.legal_entities DROP COLUMN bpn; -ALTER TABLE bpdmgate.logistic_addresses DROP COLUMN bpn; -ALTER TABLE bpdmgate.sites DROP COLUMN bpn; \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_not_null_from_legal_entity.sql b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_not_null_from_legal_entity.sql new file mode 100644 index 000000000..aac72803b --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__drop_bpn_not_null_from_legal_entity.sql @@ -0,0 +1 @@ +ALTER TABLE bpdmgate.legal_entities ALTER COLUMN bpn DROP NOT NULL; \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index c57a1b178..27472342b 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -268,7 +268,7 @@ object RequestValues { legalNameParts = arrayOf(CommonValues.name1), externalId = CommonValues.externalId1, - ) + ) val legalEntityGateInputRequest2 = LegalEntityGateInputRequest( legalEntity = legalEntity2, From fef8347957d0a9fde997a854fcd4176af2de8c96 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Tue, 6 Jun 2023 14:50:34 +0100 Subject: [PATCH 31/83] feat(Pool): Rebase and Update api for searching on legal and address by name --- .../tractusx/bpdm/gate/util/CommonValues.kt | 2 + .../bpdm/pool/api/PoolLegalEntityApi.kt | 2 - .../request/AddressPartnerSearchRequest.kt | 19 +- .../request/BusinessPartnerSearchRequest.kt | 8 +- .../LegalEntityPropertiesSearchRequest.kt | 10 +- .../opensearch/impl/doc/AddressPartnerDoc.kt | 9 +- .../repository/AddressDocSearchRepository.kt | 4 +- .../impl/service/AddressToSaasMapping.kt | 1 - .../impl/service/DocumentMappingService.kt | 15 +- .../PhysicalPostalAddressToSaasMapping.kt | 1 + .../impl/util/BpdmOpenSearchQueryBuilder.kt | 35 +-- .../BusinessPartnerLegacyController.kt | 2 +- .../pool/controller/LegalEntityController.kt | 9 +- .../bpdm/pool/entity/LogisticAddress.kt | 2 +- .../service/BusinessPartnerBuildService.kt | 3 +- .../opensearch/index-mappings-addresses.json | 20 +- .../opensearch/InvalidIndexStartupIT.kt | 4 - .../opensearch/ValidIndexStartupIT.kt | 6 - .../controller/OpenSearchControllerIT.kt | 9 +- .../controller/AddressControllerSearchIT.kt | 236 ++---------------- .../LegalEntityControllerSearchIT.kt | 50 ++-- .../tractusx/bpdm/pool/util/RequestValues.kt | 9 + 22 files changed, 90 insertions(+), 366 deletions(-) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt index 26ba7c8fb..0e90b5783 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt @@ -66,6 +66,8 @@ object CommonValues { const val bpnAddress2 = "BPNA0000000002XY" const val bpnAddress3 = "BPNA0000000003X9" + const val bpnAddress1Name = "BPNAME0000000001XY" + val language1 = LanguageCode.de val language2 = LanguageCode.en diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt index 1bf9d34c1..3a0998a51 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt @@ -60,8 +60,6 @@ interface PoolLegalEntityApi { @GetExchange fun getLegalEntities( @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, @ParameterObject paginationRequest: PaginationRequest ): PageResponse diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/AddressPartnerSearchRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/AddressPartnerSearchRequest.kt index f2dd06ef3..1543de63d 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/AddressPartnerSearchRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/AddressPartnerSearchRequest.kt @@ -19,31 +19,18 @@ package org.eclipse.tractusx.bpdm.pool.api.model.request -import com.neovisionaries.i18n.CountryCode import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.media.Schema // TODO rename to LogisticAddressSearchRequest / adjust @Schema(name = "AddressPartnerSearchRequest", description = "Contains keywords used for searching in address properties") data class AddressPartnerSearchRequest constructor( - @field:Parameter(description = "Filter business partners by administrative area name") - var administrativeArea: String? = null, - @field:Parameter(description = "Filter business partners by postcode or postcodes") - var postCode: String? = null, - @field:Parameter(description = "Filter business partners by locality full denotation") - var locality: String? = null, - @field:Parameter(description = "Filter business partners by thoroughfare full denotation") - var thoroughfare: String? = null, - @field:Parameter(description = "Filter business partners by premise full denotation") - var premise: String? = null, - @field:Parameter(description = "Filter business partners by postal delivery point full denotation") - var postalDeliveryPoint: String? = null, - @field:Parameter(description = "Filter business partners by ISO 3166-1 alpha-2 country code") - var countryCode: CountryCode? = null + @field:Parameter(description = "Filter business partners by name") + var name: String? = null ) { companion object { val EmptySearchRequest = AddressPartnerSearchRequest() } +} -} diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/BusinessPartnerSearchRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/BusinessPartnerSearchRequest.kt index ca40083ed..bd02b9eb0 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/BusinessPartnerSearchRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/BusinessPartnerSearchRequest.kt @@ -20,15 +20,11 @@ package org.eclipse.tractusx.bpdm.pool.api.model.request data class BusinessPartnerSearchRequest( - val partnerProperties: LegalEntityPropertiesSearchRequest, - val addressProperties: AddressPropertiesSearchRequest, - val siteProperties: SitePropertiesSearchRequest + val partnerProperties: LegalEntityPropertiesSearchRequest ) { companion object { val EmptySearchRequest = BusinessPartnerSearchRequest( - LegalEntityPropertiesSearchRequest.EmptySearchRequest, - AddressPropertiesSearchRequest.EmptySearchRequest, - SitePropertiesSearchRequest.EmptySearchRequest + LegalEntityPropertiesSearchRequest.EmptySearchRequest ) } } \ No newline at end of file diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPropertiesSearchRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPropertiesSearchRequest.kt index 9da3960b6..6a486896e 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPropertiesSearchRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPropertiesSearchRequest.kt @@ -26,16 +26,10 @@ import io.swagger.v3.oas.annotations.media.Schema @Schema(name = "LegalEntityPropertiesSearchRequest", description = "Contains keywords used for searching in legal entity properties") data class LegalEntityPropertiesSearchRequest constructor( @field:Parameter(description = "Filter legal entities by name") - val legalName: String?, - @field:Parameter(description = "Filter legal entities by legal form name") - val legalForm: String?, - @field:Parameter(description = "Filter legal entities by status official denotation") - val status: String?, - @field:Parameter(description = "Filter legal entities by classification denotation") - val classification: String?, + val legalName: String? ) { companion object { - val EmptySearchRequest = LegalEntityPropertiesSearchRequest(null, null, null, null) + val EmptySearchRequest = LegalEntityPropertiesSearchRequest(null) } } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/doc/AddressPartnerDoc.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/doc/AddressPartnerDoc.kt index 59f6cec49..7926ca6d1 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/doc/AddressPartnerDoc.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/doc/AddressPartnerDoc.kt @@ -27,11 +27,6 @@ const val MAPPINGS_FILE_PATH_ADDRESSES = "opensearch/index-mappings-addresses.js data class AddressPartnerDoc( @JsonIgnore // ignore since this is the id and does not need to be in the document source val bpn: String, - val administrativeAreas: Collection, - val postCodes: Collection, - val localities: Collection, - val thoroughfares: Collection, - val premises: Collection, - val postalDeliveryPoints: Collection, - val countryCode: String + val name: Collection ) + diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/repository/AddressDocSearchRepository.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/repository/AddressDocSearchRepository.kt index 774085f72..5fe1afcab 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/repository/AddressDocSearchRepository.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/repository/AddressDocSearchRepository.kt @@ -91,9 +91,7 @@ class AddressDocSearchRepository( .map { (fieldName, queryText) -> bpdmQueryBuilder.buildInnerShouldQuery(fieldName, queryText) } .forEach { mustQuery.add(it) } - if (partnerSearchRequest.countryCode != null) { - boolQuery.filter(QueryBuilders.termQuery(AddressPartnerSearchRequest::countryCode.name, partnerSearchRequest.countryCode!!.name)) - } + val searchRequest = SearchRequest() val searchSourceBuilder = SearchSourceBuilder() diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AddressToSaasMapping.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AddressToSaasMapping.kt index 1e7d583a6..f7d6cd916 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AddressToSaasMapping.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AddressToSaasMapping.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service -import org.eclipse.tractusx.bpdm.common.dto.saas.CountrySaas import org.eclipse.tractusx.bpdm.common.dto.saas.GeoCoordinatesSaas interface AddressToSaasMapping { diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/DocumentMappingService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/DocumentMappingService.kt index d2318646e..730c0ae89 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/DocumentMappingService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/DocumentMappingService.kt @@ -55,8 +55,8 @@ class DocumentMappingService { fun toDocument(logisticAddress: LogisticAddress): Collection { val addresses: MutableList = mutableListOf() - - addresses.add(toAddressPartnerDoc((PhysicalPostalAddressToSaasMapping(logisticAddress.physicalPostalAddress)), logisticAddress.bpn)) + val list = listOfNotNull(logisticAddress.name) + addresses.add(toAddressPartnerDoc(list,(PhysicalPostalAddressToSaasMapping(logisticAddress.physicalPostalAddress)), logisticAddress.bpn)) // TODO OpenSearch indexing doesn't work as expected when creating two AddressPartnerDocs with the same BPN (which is the ID), only last is indexed! // For now don't index alternativePostalAddress, since this would override (more important) physicalPostalAddress! // if (logisticAddress.alternativePostalAddress != null) { @@ -81,19 +81,14 @@ class DocumentMappingService { return addresses } - fun toAddressPartnerDoc(address: AddressToSaasMapping, bpn: String): AddressPartnerDoc { + fun toAddressPartnerDoc(name: List, address: AddressToSaasMapping, bpn: String): AddressPartnerDoc { return AddressPartnerDoc( bpn = bpn, - administrativeAreas = address.administrativeAreas().map { it }, - postCodes = address.postcodes().map { it }, - localities = address.localities().map { it }, - thoroughfares = address.thoroughfares().map { it }, - premises = address.premises().map { it }, - postalDeliveryPoints = address.postalDeliveryPoints().map { it }, - countryCode = address.country() + name = name ) } + fun toAddressDoc(address: AddressToSaasMapping): AddressDoc { return AddressDoc( administrativeAreas = address.administrativeAreas().map { TextDoc(it) }, diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/PhysicalPostalAddressToSaasMapping.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/PhysicalPostalAddressToSaasMapping.kt index d01916367..62533b629 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/PhysicalPostalAddressToSaasMapping.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/PhysicalPostalAddressToSaasMapping.kt @@ -96,4 +96,5 @@ class PhysicalPostalAddressToSaasMapping(private val postalAdress: PhysicalPosta return listOf() } + } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/util/BpdmOpenSearchQueryBuilder.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/util/BpdmOpenSearchQueryBuilder.kt index 53cef4506..e62f1914c 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/util/BpdmOpenSearchQueryBuilder.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/util/BpdmOpenSearchQueryBuilder.kt @@ -77,7 +77,7 @@ class BpdmOpenSearchQueryBuilder { * Fields with no query text are omitted. */ fun toFieldTextPairs(searchRequest: BusinessPartnerSearchRequest): Collection> { - return toFieldTextPairs(searchRequest.partnerProperties) + toFieldTextPairs(searchRequest.addressProperties) + toFieldTextPairs(searchRequest.siteProperties) + return toFieldTextPairs(searchRequest.partnerProperties) } /** @@ -87,9 +87,6 @@ class BpdmOpenSearchQueryBuilder { fun toFieldTextPairs(bpSearch: LegalEntityPropertiesSearchRequest): Collection> { val bpParamPairs = mutableListOf( Pair(LegalEntityDoc::legalName.name, bpSearch.legalName), - Pair(LegalEntityDoc::legalForm.name, bpSearch.legalForm), - Pair(LegalEntityDoc::classifications.name, bpSearch.classification), - Pair(LegalEntityDoc::status.name, bpSearch.status) ) return bpParamPairs @@ -140,26 +137,23 @@ class BpdmOpenSearchQueryBuilder { */ fun toFieldTextPairs(addressSearch: AddressPartnerSearchRequest): Collection> { val addressParamPairs = listOf( - Pair(AddressPartnerDoc::localities.name, addressSearch.locality), - Pair(AddressPartnerDoc::administrativeAreas.name, addressSearch.administrativeArea), - Pair(AddressPartnerDoc::postCodes.name, addressSearch.postCode), - Pair(AddressPartnerDoc::premises.name, addressSearch.premise), - Pair(AddressPartnerDoc::postalDeliveryPoints.name, addressSearch.postalDeliveryPoint), - Pair(AddressPartnerDoc::thoroughfares.name, addressSearch.thoroughfare) + Pair(AddressPartnerDoc::name.name, addressSearch.name) + ) - return addressParamPairs.filter { (_, query) -> query != null } + return addressParamPairs + .filter { (_, query) -> query != null } .map { (fieldName, query) -> Pair(fieldName, query!!) } } + + /** * Returns a lowercase representation of [searchRequest] */ fun toLowerCaseSearchRequest(searchRequest: BusinessPartnerSearchRequest): BusinessPartnerSearchRequest { return BusinessPartnerSearchRequest( - toLowerCaseSearchRequest(searchRequest.partnerProperties), - toLowerCaseSearchRequest(searchRequest.addressProperties), - toLowerCaseSearchRequest(searchRequest.siteProperties) + toLowerCaseSearchRequest(searchRequest.partnerProperties) ) } @@ -168,10 +162,7 @@ class BpdmOpenSearchQueryBuilder { */ fun toLowerCaseSearchRequest(searchRequest: LegalEntityPropertiesSearchRequest): LegalEntityPropertiesSearchRequest { return LegalEntityPropertiesSearchRequest( - searchRequest.legalName?.lowercase(), - searchRequest.legalForm?.lowercase(), - searchRequest.status?.lowercase(), - searchRequest.classification?.lowercase() + searchRequest.legalName?.lowercase() ) } @@ -203,13 +194,7 @@ class BpdmOpenSearchQueryBuilder { */ fun toLowerCaseSearchRequest(searchRequest: AddressPartnerSearchRequest): AddressPartnerSearchRequest { return AddressPartnerSearchRequest( - searchRequest.administrativeArea?.lowercase(), - searchRequest.postCode?.lowercase(), - searchRequest.locality?.lowercase(), - searchRequest.thoroughfare?.lowercase(), - searchRequest.premise?.lowercase(), - searchRequest.postalDeliveryPoint?.lowercase(), - searchRequest.countryCode + searchRequest.name?.lowercase() ) } } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt index 78067bb85..efd804116 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt @@ -71,7 +71,7 @@ class BusinessPartnerLegacyController( @ParameterObject paginationRequest: PaginationRequest ): PageResponse { return searchService.searchBusinessPartners( - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), + BusinessPartnerSearchRequest(bpSearchRequest), paginationRequest ) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt index de9f2abdd..fbaa50965 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt @@ -25,7 +25,10 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.pool.api.PoolLegalEntityApi -import org.eclipse.tractusx.bpdm.pool.api.model.request.* +import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest +import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPartnerCreateRequest +import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPartnerUpdateRequest +import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalAddressResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerCreateResponseWrapper @@ -55,12 +58,10 @@ class LegalEntityController( override fun getLegalEntities( bpSearchRequest: LegalEntityPropertiesSearchRequest, - addressSearchRequest: AddressPropertiesSearchRequest, - siteSearchRequest: SitePropertiesSearchRequest, paginationRequest: PaginationRequest ): PageResponse { return searchService.searchLegalEntities( - BusinessPartnerSearchRequest(bpSearchRequest, addressSearchRequest, siteSearchRequest), + BusinessPartnerSearchRequest(bpSearchRequest), paginationRequest ) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LogisticAddress.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LogisticAddress.kt index 5ebe31434..f48d0b436 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LogisticAddress.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/LogisticAddress.kt @@ -43,7 +43,7 @@ class LogisticAddress( var site: Site?, @Column(name = "name") - var name: String? = null, + var name: String?, @Embedded var physicalPostalAddress: PhysicalPostalAddress, diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index 3c91b4732..0e15b082e 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -405,7 +405,8 @@ class BusinessPartnerBuildService( legalEntity = null, site = null, physicalPostalAddress = createPhysicalAddress(dto.physicalPostalAddress, metadataMap), - alternativePostalAddress = dto.alternativePostalAddress?.let { createAlternativeAddress(it, metadataMap) } + alternativePostalAddress = dto.alternativePostalAddress?.let { createAlternativeAddress(it, metadataMap) }, + name = dto.name ) updateLogisticAddress(address, dto, metadataMap) diff --git a/bpdm-pool/src/main/resources/opensearch/index-mappings-addresses.json b/bpdm-pool/src/main/resources/opensearch/index-mappings-addresses.json index 6f3697db2..5fc9f8221 100644 --- a/bpdm-pool/src/main/resources/opensearch/index-mappings-addresses.json +++ b/bpdm-pool/src/main/resources/opensearch/index-mappings-addresses.json @@ -1,26 +1,8 @@ { "dynamic": "strict", "properties": { - "administrativeAreas": { + "name": { "type": "search_as_you_type" - }, - "postCodes": { - "type": "search_as_you_type" - }, - "localities": { - "type": "search_as_you_type" - }, - "thoroughfares": { - "type": "search_as_you_type" - }, - "premises": { - "type": "search_as_you_type" - }, - "postalDeliveryPoints": { - "type": "search_as_you_type" - }, - "countryCode": { - "type": "keyword" } } } \ No newline at end of file diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/InvalidIndexStartupIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/InvalidIndexStartupIT.kt index afb00029e..f91b190d7 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/InvalidIndexStartupIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/InvalidIndexStartupIT.kt @@ -25,9 +25,7 @@ import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl -import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.LEGAL_ENTITIES_INDEX_NAME import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.MethodOrderer.OrderAnnotation @@ -133,8 +131,6 @@ class InvalidIndexStartupIT @Autowired constructor( val searchResult = poolClient.legalEntities().getLegalEntities( LegalEntityPropertiesSearchRequest.EmptySearchRequest, - AddressPropertiesSearchRequest.EmptySearchRequest, - SitePropertiesSearchRequest.EmptySearchRequest, PaginationRequest() ) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/ValidIndexStartupIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/ValidIndexStartupIT.kt index 4deae832e..6505c1bee 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/ValidIndexStartupIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/ValidIndexStartupIT.kt @@ -25,9 +25,7 @@ import org.assertj.core.api.Assertions import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl -import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.MethodOrderer import org.junit.jupiter.api.Order @@ -102,8 +100,6 @@ class ValidIndexStartupIT @Autowired constructor( //Make sure entries are indeed there val searchResult = poolClient.legalEntities().getLegalEntities( LegalEntityPropertiesSearchRequest.EmptySearchRequest, - AddressPropertiesSearchRequest.EmptySearchRequest, - SitePropertiesSearchRequest.EmptySearchRequest, PaginationRequest() ) Assertions.assertThat(searchResult.content).isNotEmpty @@ -121,8 +117,6 @@ class ValidIndexStartupIT @Autowired constructor( val searchResult = poolClient.legalEntities().getLegalEntities( LegalEntityPropertiesSearchRequest.EmptySearchRequest, - AddressPropertiesSearchRequest.EmptySearchRequest, - SitePropertiesSearchRequest.EmptySearchRequest, PaginationRequest() ) Assertions.assertThat(searchResult.content).isNotEmpty diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt index a56c1f19d..481c52441 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/controller/OpenSearchControllerIT.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.controller + import com.fasterxml.jackson.databind.ObjectMapper import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.core.WireMockConfiguration @@ -29,13 +30,9 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl -import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service.OpenSearchSyncStarterService - - import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test @@ -211,9 +208,7 @@ class OpenSearchControllerIT @Autowired constructor( private fun searchBusinessPartnerByName(name: String): PageResponse { return poolClient.legalEntities().getLegalEntities( - LegalEntityPropertiesSearchRequest(name, null, null, null), - AddressPropertiesSearchRequest.EmptySearchRequest, - SitePropertiesSearchRequest.EmptySearchRequest, + LegalEntityPropertiesSearchRequest(name), PaginationRequest() ) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt index 6428224f2..56c4ff49a 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerSearchIT.kt @@ -28,7 +28,6 @@ import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequ import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest @@ -61,6 +60,7 @@ class AddressControllerSearchIT @Autowired constructor( addresses = listOf(RequestValues.addressPartnerCreate1, RequestValues.addressPartnerCreate3) ) + val partnerStructure2 = LegalEntityStructureRequest( legalEntity = RequestValues.legalEntityCreate2, siteStructures = listOf( @@ -71,9 +71,13 @@ class AddressControllerSearchIT @Autowired constructor( ) ) + val partnerStructure3 = LegalEntityStructureRequest( + legalEntity = RequestValues.legalEntityCreate1, + addresses = listOf(RequestValues.addressPartnerCreate4) + ) + private lateinit var givenAddress1: LogisticAddressResponse - private lateinit var givenAddress2: LogisticAddressResponse - private lateinit var givenAddress3: LogisticAddressResponse + @BeforeEach @@ -83,189 +87,22 @@ class AddressControllerSearchIT @Autowired constructor( poolClient.opensearch().clear() testHelpers.createTestMetadata() - val givenStructure = testHelpers.createBusinessPartnerStructure(listOf(partnerStructure1, partnerStructure2)) + + val givenStructure = testHelpers.createBusinessPartnerStructure(listOf(partnerStructure3)) givenAddress1 = givenStructure[0].addresses[0].address // addressPartnerCreate1 - givenAddress2 = givenStructure[1].siteStructures[0].addresses[0].address // addressPartnerCreate2 - givenAddress3 = givenStructure[0].addresses[1].address // addressPartnerCreate3 testHelpers.startSyncAndAwaitSuccess(webTestClient, EndpointValues.OPENSEARCH_SYNC_PATH) } - /** - * Given addresses in OpenSearch - * When searching an address by administrative area - * Then the matching address is returned - */ - @Test - fun `search address via administrative area`() { - val expected = PageResponse( - 3, 1, 0, 3, listOf( - AddressMatchResponse(0f, givenAddress1), // addressPartnerCreate1 - AddressMatchResponse(0f, givenAddress1), // legalEntityCreate1.legalAddress - AddressMatchResponse(0f, givenAddress1), // siteCreate1.mainAddress - ) - ) - val addressSearchRequest = AddressPartnerSearchRequest( - administrativeArea = RequestValues.addressPartnerCreate1.address.physicalPostalAddress.areaPart.administrativeAreaLevel2 - ) - - val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) - - assertPageEquals(pageResponse, expected) - } - - /** - * Given addresses in OpenSearch - * When searching an address by post code - * Then the matching address is returned - */ - @Test - fun `search address via post code`() { - // regular, legal and site main address - val expected = PageResponse( - 3, 1, 0, 3, listOf( - AddressMatchResponse(0f, givenAddress1), // addressPartnerCreate1 - AddressMatchResponse(0f, givenAddress1), // legalEntityCreate1.legalAddress - AddressMatchResponse(0f, givenAddress1), // siteCreate1.mainAddress - ) - ) - - val addressSearchRequest = AddressPartnerSearchRequest( - postCode = givenAddress1.physicalPostalAddress.baseAddress.postalCode - ) - - val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) - - assertPageEquals(pageResponse, expected) - } - - /** - * Given addresses in OpenSearch - * When searching an address by locality - * Then the matching address is returned - */ - @Test - fun `search address via locality`() { - // regular, legal and site main address - val expected = PageResponse( - 3, 1, 0, 3, listOf( - AddressMatchResponse(0f, givenAddress1), // addressPartnerCreate1 - AddressMatchResponse(0f, givenAddress1), // legalEntityCreate1.legalAddress - AddressMatchResponse(0f, givenAddress1), // siteCreate1.mainAddress - ) - ) - - val addressSearchRequest = AddressPartnerSearchRequest( - locality = givenAddress1.physicalPostalAddress.baseAddress.city - ) - val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) - - assertPageEquals(pageResponse, expected) - } - - /** - * Given addresses in OpenSearch - * When searching an address by thoroughfare - * Then the matching address is returned - */ - @Test - fun `search address via thoroughfare`() { - // regular, legal and site main address - val expected = PageResponse( - 3, 1, 0, 3, listOf( - AddressMatchResponse(0f, givenAddress1), // addressPartnerCreate1 - AddressMatchResponse(0f, givenAddress1), // legalEntityCreate1.legalAddress - AddressMatchResponse(0f, givenAddress1), // siteCreate1.mainAddress - ) - ) - - val addressSearchRequest = AddressPartnerSearchRequest( - thoroughfare = givenAddress1.physicalPostalAddress.street!!.name - ) - val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) - - assertPageEquals(pageResponse, expected) - } - - /** - * Given addresses in OpenSearch - * When searching an address by premise - * Then the matching address is returned - */ - @Test - fun `search address via premise`() { - // regular, legal and site main address - val expected = PageResponse( - 3, 1, 0, 3, listOf( - AddressMatchResponse(0f, givenAddress1), // addressPartnerCreate1 - AddressMatchResponse(0f, givenAddress1), // legalEntityCreate1.legalAddress - AddressMatchResponse(0f, givenAddress1), // siteCreate1.mainAddress - ) - ) - - val addressSearchRequest = AddressPartnerSearchRequest( - premise = givenAddress1.physicalPostalAddress.basePhysicalAddress.building - ) - val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) - - assertPageEquals(pageResponse, expected) - } - - /** - * Given addresses in OpenSearch - * When searching an address by postal delivery point - * Then the matching address is returned - */ - @Test - @Disabled("TODO create alternative address") - fun `search address via postal delivery point`() { - val expected = PageResponse( - 1, 1, 0, 1, listOf( - AddressMatchResponse(0f, givenAddress1) - ) - ) - - val addressSearchRequest = AddressPartnerSearchRequest() - addressSearchRequest.postalDeliveryPoint = RequestValues.addressPartnerCreate1.address.alternativePostalAddress!!.deliveryServiceNumber - val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) - - assertPageEquals(pageResponse, expected) - } - - /** - * Given addresses in OpenSearch - * When searching an address by country code - * Then the matching address is returned - */ - @Test - fun `search address via country code`() { - // regular, legal and site main address - val expected = PageResponse( - 3, 1, 0, 3, listOf( - AddressMatchResponse(0f, givenAddress1), // addressPartnerCreate1 - AddressMatchResponse(0f, givenAddress1), // legalEntityCreate1.legalAddress - AddressMatchResponse(0f, givenAddress1), // siteCreate1.mainAddress - ) - ) - - val addressSearchRequest = AddressPartnerSearchRequest( - countryCode = givenAddress1.physicalPostalAddress.baseAddress.country.technicalKey - ) - - val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) - assertPageEquals(pageResponse, expected) - } - /** * Given addresses in OpenSearch - * When searching an address by multiple search criteria + * When searching an address by name of BPN search criteria * Then the matching address is returned */ @Test - @Disabled("TODO create alternative address") - fun `search address via multiple criteria`() { + fun `search address via name`() { val expected = PageResponse( 1, 1, 0, 1, listOf( AddressMatchResponse(0f, givenAddress1) @@ -274,73 +111,34 @@ class AddressControllerSearchIT @Autowired constructor( val addressSearchRequest = AddressPartnerSearchRequest() - addressSearchRequest.postalDeliveryPoint = RequestValues.addressPartnerCreate1.address.alternativePostalAddress!!.deliveryServiceNumber - addressSearchRequest.postCode = RequestValues.addressPartnerCreate1.address.physicalPostalAddress.baseAddress.postalCode + addressSearchRequest.name = RequestValues.addressPartnerCreate4.address.name + val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) assertPageEquals(pageResponse, expected) } - /** * Given addresses in OpenSearch - * When searching an address by multiple search criteria, one of which does not match any of the existing addresses - * Then there should be no result + * When searching an address by name of BPN that not exists in search criteria + * Then the matching address is not found */ @Test - fun `search address via multiple criteria, no match found`() { + fun `search address via name not found`() { val expected = PageResponse( 0, 0, 0, 0, emptyList() ) val addressSearchRequest = AddressPartnerSearchRequest() - addressSearchRequest.postCode = RequestValues.addressPartnerCreate1.address.physicalPostalAddress.baseAddress.postalCode - addressSearchRequest.administrativeArea = "someNonexistentValue" - val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) - - - assertPageEquals(pageResponse, expected) - } - - /** - * Given addresses in OpenSearch - * When searching an address via search terms that don't match any of the existing addresses - * Then there should be no result - */ - @Test - fun `search address, no match found`() { - val expected = PageResponse( - 0, 0, 0, 0, emptyList() - ) + addressSearchRequest.name = "NONEXISTENT" - val addressSearchRequest = AddressPartnerSearchRequest() - addressSearchRequest.administrativeArea = "someNonexistentValue" val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) assertPageEquals(pageResponse, expected) } - /** - * Given addresses in OpenSearch - * When searching an address that belongs to a site - * Then the matching address is returned - */ - @Test - fun `search address of site`() { - val expected = PageResponse( - 1, 1, 0, 1, listOf( - AddressMatchResponse(0f, givenAddress3) - ) - ) - - val addressSearchRequest = AddressPartnerSearchRequest( - postCode = givenAddress3.physicalPostalAddress.baseAddress.postalCode - ) - val pageResponse = poolClient.addresses().getAddresses(addressSearchRequest, PaginationRequest()) - assertPageEquals(pageResponse, expected) - } private fun assertPageEquals(actual: PageResponse, expected: PageResponse) { testHelpers.assertRecursively(actual) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt index 4e4a3f49e..b6193dee0 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerSearchIT.kt @@ -19,14 +19,12 @@ package org.eclipse.tractusx.bpdm.pool.controller -import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl -import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse @@ -137,42 +135,42 @@ class LegalEntityControllerSearchIT @Autowired constructor( assertPageEquals(secondPage, expectedSecondPage) } - /** - * Given partners in OpenSearch - * When searching by site name - * Then business partner is found - */ - @Test - fun `search business partner by site name, result found`() { - - val expected = PageResponse( - 1, 1, 0, 1, listOf( - LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) - ) - ) - - val pageResponse = searchBusinessPartnerBySiteName(RequestValues.siteCreate2.site.name, 0, 10) - - assertPageEquals(pageResponse, expected) - } +// /** +// * Given partners in OpenSearch +// * When searching by site name +// * Then business partner is found +// */ +// @Test +// fun `search business partner by site name, result found`() { +// +// val expected = PageResponse( +// 1, 1, 0, 1, listOf( +// LegalEntityMatchResponse(score = 0f, legalEntity = givenPartner2, legalName = legalName2, legalAddress = legalAddress2) +// ) +// ) +// +// val pageResponse = searchBusinessPartnerBySiteName(RequestValues.siteCreate2.site.name, 0, 10) +// +// assertPageEquals(pageResponse, expected) +// } /** * Given partners in OpenSearch * When searching by nonexistent site name * Then no business partner is found */ - @Test - fun `search business partner by site name, no result found`() { - val foundPartners = searchBusinessPartnerBySiteName("nonexistent name", 0, 10).content - assertThat(foundPartners).isEmpty() - } +// @Test +// fun `search business partner by site name, no result found`() { +// val foundPartners = searchBusinessPartnerBySiteName("nonexistent name", 0, 10).content +// assertThat(foundPartners).isEmpty() +// } private fun searchBusinessPartnerBySiteName(siteName: String, page: Int, size: Int): PageResponse { val sitePropertiesSearchRequest = SitePropertiesSearchRequest(siteName) return poolClient.legalEntities().getLegalEntities( LegalEntityPropertiesSearchRequest.EmptySearchRequest, - AddressPropertiesSearchRequest.EmptySearchRequest, sitePropertiesSearchRequest, PaginationRequest(page, size) + PaginationRequest(page, size) ) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt index 1414db1c9..5e3de2ed3 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt @@ -159,6 +159,9 @@ object RequestValues { val logisticAddress3 = LogisticAddressDto( physicalPostalAddress = postalAddress3, ) + val logisticAddress4 = LogisticAddressDto( + physicalPostalAddress = postalAddress1, name = CommonValues.name1 + ) val legalEntityCreate1 = LegalEntityPartnerCreateRequest( @@ -284,6 +287,12 @@ object RequestValues { index = CommonValues.index3 ) + val addressPartnerCreate4 = AddressPartnerCreateRequest( + address = logisticAddress4, + bpnParent = legalEntityUpdate3.bpnl, + index = CommonValues.index3 + ) + val addressPartnerUpdate1 = AddressPartnerUpdateRequest( bpna = CommonValues.bpnA1, address = logisticAddress1 From 853a2890cfc439f4786ba65718527e2786d0c757 Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Mon, 5 Jun 2023 16:16:10 +0200 Subject: [PATCH 32/83] feat(Gate): remove type-matching endpoints and logic - remove business partner type-match endpoint - remove business partner controller - remove the associated DTOs - remove type match configuration - remove type-matching tests --- .../bridge/dummy/service/GateQueryService.kt | 6 +- .../bridge/dummy/service/GateUpdateService.kt | 2 +- .../bridge/dummy/service/PoolUpdateService.kt | 2 +- .../bpdm/bridge/dummy/service/SyncService.kt | 2 +- .../bpdm/gate/api/GateBusinessPartnerApi.kt | 55 ---- .../bpdm/gate/api/GateChangelogApi.kt | 2 +- .../bpdm/gate/api/GateSharingStateApi.kt | 2 +- .../bpdm/gate/api/client/GateClient.kt | 2 - .../bpdm/gate/api/client/GateClientImpl.kt | 3 - .../api/model/BusinessPartnerCandidateDto.kt | 39 --- .../tractusx/bpdm/gate/api/model/LsaType.kt | 15 +- ...ypeMatchResponse.kt => OptionalLsaType.kt} | 15 +- .../bpdm/gate/api/model/SharingStateDto.kt | 1 - .../api/model/response/ChangelogResponse.kt | 1 + .../gate/config/TypeMatchConfigProperties.kt | 7 - .../controller/BusinessPartnerController.kt | 41 --- .../gate/controller/ChangelogController.kt | 2 +- .../gate/controller/SharingStateController.kt | 2 +- .../bpdm/gate/entity/ChangelogEntry.kt | 2 +- .../tractusx/bpdm/gate/entity/SharingState.kt | 2 +- .../gate/repository/ChangelogRepository.kt | 2 +- .../gate/repository/SharingStateRepository.kt | 2 +- .../bpdm/gate/service/AddressService.kt | 4 +- .../bpdm/gate/service/ChangelogService.kt | 2 +- .../bpdm/gate/service/LegalEntityService.kt | 2 +- .../gate/service/SaasLookupMappingService.kt | 61 ----- .../bpdm/gate/service/SharingStateService.kt | 2 +- .../tractusx/bpdm/gate/service/SiteService.kt | 2 +- .../bpdm/gate/service/TypeMatchingService.kt | 101 ------- .../src/main/resources/application.properties | 2 - .../controller/BusinessPartnerControllerIT.kt | 249 ------------------ .../controller/SharingStateControllerIT.kt | 2 +- .../tractusx/bpdm/gate/util/CommonValues.kt | 4 +- .../tractusx/bpdm/gate/util/EndpointValues.kt | 4 - 34 files changed, 28 insertions(+), 614 deletions(-) delete mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt delete mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt rename bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/Extensions.kt => bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LsaType.kt (57%) rename bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/{response/TypeMatchResponse.kt => OptionalLsaType.kt} (82%) delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt delete mode 100644 bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt index c53fe3e5f..4438ed334 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt @@ -26,12 +26,8 @@ import com.catenax.bpdm.bridge.dummy.dto.GateSiteInfo import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.springframework.stereotype.Service import java.time.Instant diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt index d79a8e11a..5f6086282 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt @@ -22,9 +22,9 @@ package com.catenax.bpdm.bridge.dummy.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.pool.api.model.response.* import org.springframework.stereotype.Service import java.time.LocalDateTime diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index dd3e679f6..138eb67b6 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -28,8 +28,8 @@ import org.eclipse.tractusx.bpdm.common.dto.PhysicalPostalAddressDto import org.eclipse.tractusx.bpdm.common.dto.SiteDto import org.eclipse.tractusx.bpdm.common.dto.StreetDto import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.PhysicalPostalAddressGateDto -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient import org.eclipse.tractusx.bpdm.pool.api.model.request.* import org.eclipse.tractusx.bpdm.pool.api.model.response.* diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/SyncService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/SyncService.kt index 3750696ca..66977f99f 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/SyncService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/SyncService.kt @@ -21,7 +21,7 @@ package com.catenax.bpdm.bridge.dummy.service import com.catenax.bpdm.bridge.dummy.entity.SyncType import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.springframework.stereotype.Service import java.time.Instant diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt deleted file mode 100644 index 2385425ae..000000000 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateBusinessPartnerApi.kt +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.api - -import io.swagger.v3.oas.annotations.Operation -import io.swagger.v3.oas.annotations.media.Content -import io.swagger.v3.oas.annotations.responses.ApiResponse -import io.swagger.v3.oas.annotations.responses.ApiResponses -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto -import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse -import org.springframework.http.MediaType -import org.springframework.web.bind.annotation.PostMapping -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.service.annotation.HttpExchange -import org.springframework.web.service.annotation.PostExchange - -@RequestMapping("/api/catena/business-partners", produces = [MediaType.APPLICATION_JSON_VALUE]) -@HttpExchange("/api/catena/business-partners") -interface GateBusinessPartnerApi { - - @Operation( - summary = "Determine the LSA type of a business partner candidate", - description = "For one business partner candidate this request determines its likely type of either legal entity, site or address." + - "It is possible that no type could be determined." + - "The candidate needs to contain either a name or an identifier as a minimum requirement." - ) - @ApiResponses( - value = [ - ApiResponse(responseCode = "200", description = "Records were successfully processed."), - ApiResponse(responseCode = "400", description = "No name and no identifier given, or malformed request", content = [Content()]) - ] - ) - @PostMapping("/type-match") - @PostExchange("/type-match") - fun determineLsaType(@RequestBody candidate: BusinessPartnerCandidateDto): TypeMatchResponse - -} \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt index f41a85c23..330b11540 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt @@ -28,8 +28,8 @@ import jakarta.validation.Valid import jakarta.validation.constraints.NotEmpty import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt index e4eecf839..cd3d4bb5c 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt @@ -27,8 +27,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses import jakarta.validation.Valid import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.web.bind.annotation.* diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClient.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClient.kt index 250f310cb..6f979c905 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClient.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClient.kt @@ -25,8 +25,6 @@ interface GateClient { fun addresses(): GateAddressApi - fun businessPartners(): GateBusinessPartnerApi - fun legalEntities(): GateLegalEntityApi fun sites(): GateSiteApi diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClientImpl.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClientImpl.kt index 68041a07e..85c60756f 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClientImpl.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/GateClientImpl.kt @@ -37,7 +37,6 @@ class GateClientImpl( } private val gateClientAddress by lazy { httpServiceProxyFactory.createClient(GateAddressApi::class.java) } - private val gateClientBusinessPartner by lazy { httpServiceProxyFactory.createClient(GateBusinessPartnerApi::class.java) } private val gateClientLegalEntity by lazy { httpServiceProxyFactory.createClient(GateLegalEntityApi::class.java) } private val gateClientSite by lazy { httpServiceProxyFactory.createClient(GateSiteApi::class.java) } private val gateClientChangelog by lazy { httpServiceProxyFactory.createClient(GateChangelogApi::class.java) } @@ -45,8 +44,6 @@ class GateClientImpl( override fun addresses() = gateClientAddress - override fun businessPartners() = gateClientBusinessPartner - override fun legalEntities() = gateClientLegalEntity override fun sites() = gateClientSite diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt deleted file mode 100644 index 57a5a8018..000000000 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerCandidateDto.kt +++ /dev/null @@ -1,39 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.api.model - -import io.swagger.v3.oas.annotations.media.ArraySchema -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.GenericIdentifierDto -import org.eclipse.tractusx.bpdm.common.dto.NameDto - -data class BusinessPartnerCandidateDto( - @ArraySchema(arraySchema = Schema(description = "Identifiers of this partner candidate", required = false)) - val identifiers: Collection = emptyList(), - - @ArraySchema(arraySchema = Schema(description = "Names the partner goes by"), minItems = 1) - val names: Collection, - - @Schema(description = "Technical key of the legal form") - val legalForm: String? = null, - - @Schema(description = "Address of this partner") - val address: LogisticAddressGateDto -) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/Extensions.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LsaType.kt similarity index 57% rename from bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/Extensions.kt rename to bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LsaType.kt index 7365fc714..edc676704 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/Extensions.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LsaType.kt @@ -17,15 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.util +package org.eclipse.tractusx.bpdm.gate.api.model -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.module.kotlin.readValue -import com.github.tomakehurst.wiremock.admin.model.ServeEventQuery -import com.github.tomakehurst.wiremock.junit5.WireMockExtension -import com.github.tomakehurst.wiremock.stubbing.StubMapping - -inline fun WireMockExtension.deserializeMatchedRequests(stubMapping: StubMapping, objectMapper: ObjectMapper): Collection { - val requestBodies = getServeEvents(ServeEventQuery.forStubMapping(stubMapping)).serveEvents.map { it.request.bodyAsString } - return requestBodies.map { objectMapper.readValue(it) } +enum class LsaType { + LegalEntity, + Site, + Address } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/TypeMatchResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/OptionalLsaType.kt similarity index 82% rename from bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/TypeMatchResponse.kt rename to bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/OptionalLsaType.kt index 6c4716602..690c06273 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/TypeMatchResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/OptionalLsaType.kt @@ -17,22 +17,11 @@ * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ -package org.eclipse.tractusx.bpdm.gate.api.model.response - -data class TypeMatchResponse( - val score: Float, - val type: OptionalLsaType -) +package org.eclipse.tractusx.bpdm.gate.api.model enum class OptionalLsaType { LegalEntity, Site, Address, None -} - -enum class LsaType { - LegalEntity, - Site, - Address -} +} \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SharingStateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SharingStateDto.kt index 8250670e9..98598ebe8 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SharingStateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SharingStateDto.kt @@ -21,7 +21,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import java.time.LocalDateTime @Schema( diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt index ddc95f7d7..ade06daa2 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ChangelogResponse.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import java.time.Instant @Schema(name = "ChangelogResponse", description = "Changelog entry for a business partner") diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/TypeMatchConfigProperties.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/TypeMatchConfigProperties.kt index c83edcef2..0ce6ddb41 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/TypeMatchConfigProperties.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/TypeMatchConfigProperties.kt @@ -19,10 +19,3 @@ package org.eclipse.tractusx.bpdm.gate.config -import org.springframework.boot.context.properties.ConfigurationProperties - - -@ConfigurationProperties(prefix = "bpdm.type-matching") -data class TypeMatchConfigProperties( - val legalEntityThreshold: Float = 0.8f -) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt deleted file mode 100644 index f382dba8c..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerController.kt +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.controller - -import org.eclipse.tractusx.bpdm.gate.api.GateBusinessPartnerApi -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto -import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse -import org.eclipse.tractusx.bpdm.gate.exception.BpdmInvalidPartnerException -import org.eclipse.tractusx.bpdm.gate.service.TypeMatchingService -import org.springframework.web.bind.annotation.RestController - -@RestController -class BusinessPartnerController( - private val typeMatchingService: TypeMatchingService -) : GateBusinessPartnerApi { - - override fun determineLsaType(candidate: BusinessPartnerCandidateDto): TypeMatchResponse { - if (candidate.names.isEmpty() && candidate.identifiers.isEmpty()) - throw BpdmInvalidPartnerException("Candidate", "Business partner candidate needs to specify either a name or identifier.") - - return typeMatchingService.determineCandidateType(candidate) - } - -} \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 5658836f8..2018c0cc3 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -22,8 +22,8 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateChangelogApi +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse import org.eclipse.tractusx.bpdm.gate.service.ChangelogService import org.springframework.validation.annotation.Validated diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt index 0a847ee29..18d20c2ce 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt @@ -23,8 +23,8 @@ import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateSharingStateApi +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.service.SharingStateService import org.springframework.web.bind.annotation.RestController diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt index 5c352f3bb..f830e5e76 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.entity import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.BaseEntity -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType @Entity diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/SharingState.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/SharingState.kt index 1abd98360..32f9cd298 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/SharingState.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/SharingState.kt @@ -22,8 +22,8 @@ package org.eclipse.tractusx.bpdm.gate.entity import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import java.time.LocalDateTime diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index 6c6afb5fe..c25bdda2f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -19,7 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.repository -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.springframework.data.jpa.domain.Specification import org.springframework.data.jpa.repository.JpaRepository diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/SharingStateRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/SharingStateRepository.kt index c530e1d89..b5e2025f7 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/SharingStateRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/SharingStateRepository.kt @@ -19,7 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.repository -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.entity.SharingState import org.springframework.data.jpa.domain.Specification import org.springframework.data.jpa.repository.JpaSpecificationExecutor diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index 6c475eb5a..d8bf32fbe 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -26,8 +26,8 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry @@ -42,12 +42,10 @@ import org.springframework.stereotype.Service @Service class AddressService( private val saasRequestMappingService: SaasRequestMappingService, - private val inputSaasMappingService: InputSaasMappingService, private val outputSaasMappingService: OutputSaasMappingService, private val saasClient: SaasClient, private val poolClient: PoolClient, private val bpnConfigProperties: BpnConfigProperties, - private val typeMatchingService: TypeMatchingService, private val changelogRepository: ChangelogRepository, private val addressPersistenceService: AddressPersistenceService, private val addressRepository: GateAddressRepository diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index e95a9fbf4..12bbe40b2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -21,9 +21,9 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byCreatedAtGreaterThan diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 69398cc1a..b0f774298 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -27,8 +27,8 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt deleted file mode 100644 index e94db99f5..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasLookupMappingService.kt +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.service - -import org.eclipse.tractusx.bpdm.common.dto.GenericIdentifierDto -import org.eclipse.tractusx.bpdm.common.dto.LegalEntityIdentifierDto -import org.eclipse.tractusx.bpdm.common.dto.saas.* -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto -import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto -import org.springframework.stereotype.Service - -@Service -class SaasLookupMappingService { - - fun toSaas(candidate: BusinessPartnerCandidateDto): BusinessPartnerLookupSaas { - return with(candidate) { - BusinessPartnerLookupSaas( - names = names.map { ValueLookupSaas(it.value) }, - identifiers = identifiers.map { toSaas(it) }, - legalForm = null, //legalForm parameter seems to have no influence on result currently - address = listOf(toSaas(address)) - ) - } - } - - private fun toSaas(identifier: LegalEntityIdentifierDto): IdentifierLookupSaas = - IdentifierLookupSaas(identifier.value, TechnicalKeyLookupSaas(identifier.type)) - - private fun toSaas(identifier: GenericIdentifierDto): IdentifierLookupSaas = - IdentifierLookupSaas(identifier.value, TechnicalKeyLookupSaas(identifier.type)) - - private fun toSaas(address: LogisticAddressGateDto): AddressLookupSaas = - with(address) { - AddressLookupSaas( - // TODO Mapping - administrativeAreas = listOf(), - country = null, - localities = listOf(), - postCodes = listOf(), - thoroughfares = listOf() - ) - } - -} \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt index 65c6d67c9..d4ef79eed 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt @@ -21,8 +21,8 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.entity.SharingState import org.eclipse.tractusx.bpdm.gate.repository.SharingStateRepository import org.eclipse.tractusx.bpdm.gate.repository.SharingStateRepository.Specs.byExternalIdsIn diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index 9def4a0c9..280353941 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -24,11 +24,11 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt deleted file mode 100644 index 63c845fe7..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TypeMatchingService.kt +++ /dev/null @@ -1,101 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.service - -import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas -import org.eclipse.tractusx.bpdm.common.dto.saas.ReferenceDataLookupRequestSaas -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto -import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType -import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse -import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties -import org.eclipse.tractusx.bpdm.gate.config.TypeMatchConfigProperties -import org.springframework.stereotype.Service - -@Service -class TypeMatchingService( - private val saasClient: SaasClient, - private val saasLookupMappingService: SaasLookupMappingService, - private val typeMatchConfigProperties: TypeMatchConfigProperties, - private val saasConfigProperties: SaasConfigProperties -) { - private val logger = KotlinLogging.logger { } - - /** - * For a candidate DTO determines its likely LSA type - * Currently can only distinguish between legal entity or nothing - */ - fun determineCandidateType(partner: BusinessPartnerCandidateDto): TypeMatchResponse { - val request = ReferenceDataLookupRequestSaas( - matchingThreshold = typeMatchConfigProperties.legalEntityThreshold, - pageSize = 1, - page = 0, - maxCandidates = 1, - businessPartner = saasLookupMappingService.toSaas(partner) - ) - val response = saasClient.lookUpReferenceData(request) - - val bestOverall = response.values.maxOfOrNull { it.matchingProfile.matchingScores.overall.value } ?: 0f - - return if (bestOverall >= typeMatchConfigProperties.legalEntityThreshold) - TypeMatchResponse(bestOverall, OptionalLsaType.LegalEntity) - else - - TypeMatchResponse(1f - bestOverall, OptionalLsaType.None) - - } - - /** - * Partitions the input into legal entities and sites for a given collection. - * Filters out any addresses with a warning since they can't be parents - */ - fun partitionIntoParentTypes(parents: Collection): Pair, Collection> { - val typeGroups = parents.groupBy { determineType(it) } - - typeGroups.keys - .filterNot { it == OptionalLsaType.LegalEntity || it == OptionalLsaType.Site } - .forEach { invalidGroup -> - typeGroups[invalidGroup]!!.forEach { - logger.warn { "Business Partner with ID ${it.externalId} is parent with invalid type $invalidGroup" } - } - } - - return Pair(typeGroups[OptionalLsaType.LegalEntity] ?: emptyList(), typeGroups[OptionalLsaType.Site] ?: emptyList()) - } - - fun determineType(partner: BusinessPartnerSaas): OptionalLsaType { - if (partner.types.isEmpty()) { - logger.warn { "Partner with ID ${partner.id} does not have any type" } - return OptionalLsaType.None - } - - if (partner.types.size > 1) { - logger.warn { "Partner with ID ${partner.id} has several types" } - } - - val partnerType = partner.types.first() - return when (partnerType.technicalKey) { - saasConfigProperties.legalEntityType -> OptionalLsaType.LegalEntity - saasConfigProperties.siteType -> OptionalLsaType.Site - saasConfigProperties.addressType -> OptionalLsaType.Address - else -> OptionalLsaType.None - } - } -} \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/application.properties b/bpdm-gate/src/main/resources/application.properties index c3ad1ded6..91605312c 100644 --- a/bpdm-gate/src/main/resources/application.properties +++ b/bpdm-gate/src/main/resources/application.properties @@ -49,8 +49,6 @@ springdoc.swagger-ui.csrf.enabled=true management.endpoint.health.probes.enabled=true management.health.livenessState.enabled=true management.health.readinessState.enabled=true -# Type Matching -bpdm.type-matching.legal-entity-threshold=0.8 # Connection to the pool # No auth on default bpdm.gate-security.pool-security-enabled=false diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt deleted file mode 100644 index 9efc5540c..000000000 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt +++ /dev/null @@ -1,249 +0,0 @@ -/******************************************************************************* - * 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 - ******************************************************************************/ - -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.controller - -import com.fasterxml.jackson.databind.ObjectMapper -import com.github.tomakehurst.wiremock.client.WireMock -import com.github.tomakehurst.wiremock.core.WireMockConfiguration -import com.github.tomakehurst.wiremock.junit5.WireMockExtension -import org.assertj.core.api.Assertions.assertThat -import org.eclipse.tractusx.bpdm.common.dto.saas.* -import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto -import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType -import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse -import org.eclipse.tractusx.bpdm.gate.config.TypeMatchConfigProperties -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues -import org.eclipse.tractusx.bpdm.gate.util.PostgreSQLContextInitializer -import org.eclipse.tractusx.bpdm.gate.util.RequestValues -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.RegisterExtension -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.http.HttpStatus -import org.springframework.http.HttpStatusCode -import org.springframework.test.context.ActiveProfiles -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.DynamicPropertyRegistry -import org.springframework.test.context.DynamicPropertySource -import org.springframework.web.reactive.function.client.WebClientResponseException - - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) -class BusinessPartnerControllerIT @Autowired constructor( - private val objectMapper: ObjectMapper, - private val typeMatchConfigProperties: TypeMatchConfigProperties, - val gateClient: GateClient -) { - - companion object { - @RegisterExtension - private val wireMockServer: WireMockExtension = WireMockExtension.newInstance() - .options(WireMockConfiguration.wireMockConfig().dynamicPort()) - .build() - - @JvmStatic - @DynamicPropertySource - fun properties(registry: DynamicPropertyRegistry) { - registry.add("bpdm.saas.host") { wireMockServer.baseUrl() } - } - } - - val candidate1 = BusinessPartnerCandidateDto( - identifiers = listOf(RequestValues.genericIdentifier), - names = listOf(RequestValues.name1), - address = RequestValues.address1 - ) - - /** - * Given business partner candidate whose properties are matching existing legal entity - * When invoking type match for candidate - * Then return candidate is type of legal entity - */ - @Test - fun `match legal entity type`() { - //make sure candidate is valid by providing identifier and name - val givenCandidate = with(candidate1) { - copy( - identifiers = listOf(RequestValues.genericIdentifier), - names = listOf(RequestValues.name1) - ) - } - - val expectedScore = typeMatchConfigProperties.legalEntityThreshold - val expected = TypeMatchResponse(expectedScore, OptionalLsaType.LegalEntity) - - setLookupMockResponse(expectedScore) - - val typeResponseValue = gateClient.businessPartners().determineLsaType(givenCandidate) - - assertThat(typeResponseValue).isEqualTo(expected) - } - - /** - * Given business partner candidate whose properties are not matching known legal entity - * When invoking type match for candidate - * Then return candidate is of no type - */ - @Test - fun `match no type`() { - //make sure candidate is valid by providing identifier and name - val givenCandidate = with(candidate1) { - copy( - identifiers = listOf(RequestValues.genericIdentifier), - names = listOf(RequestValues.name1) - ) - } - - val mockedScore = (typeMatchConfigProperties.legalEntityThreshold - 1.0f).coerceAtLeast(0.0f) - val expected = TypeMatchResponse(1f - mockedScore, OptionalLsaType.None) - - setLookupMockResponse(mockedScore) - - val typeResponseValue = gateClient.businessPartners().determineLsaType(givenCandidate) - - assertThat(typeResponseValue).isEqualTo(expected) - } - - /** - * Given business partner candidate without name - * When invoking type match for candidate - * Then candidate accepted for type matching - */ - @Test - fun `accept candidate without name`() { - //create candidate without name - val givenCandidate = with(candidate1) { - copy( - identifiers = listOf(RequestValues.genericIdentifier), - names = emptyList() - ) - } - - setLookupMockResponse(0.5f) - - try { - gateClient.businessPartners().determineLsaType(givenCandidate) - } catch (e: WebClientResponseException) { - assertEquals(HttpStatus.OK, e.statusCode) - } - - } - - /** - * Given business partner candidate without identifier - * When invoking type match for candidate - * Then candidate accepted for type matching - */ - @Test - fun `accept candidate without identifier`() { - //create candidate without identifier - val givenCandidate = with(candidate1) { - copy( - identifiers = emptyList(), - names = listOf(RequestValues.name1) - ) - } - - setLookupMockResponse(0.5f) - - try { - gateClient.businessPartners().determineLsaType(givenCandidate) - } catch (e: WebClientResponseException) { - assertEquals(HttpStatus.OK, e.statusCode) - } - - } - - /** - * Given business partner candidate without identifier and name - * When invoking type match for candidate - * Then return 400 - */ - @Test - fun `refuse candidate without name and identifier`() { - //create candidate without identifier - val givenCandidate = with(candidate1) { - copy( - identifiers = emptyList(), - names = emptyList() - ) - } - - setLookupMockResponse(0.5f) - - try { - gateClient.businessPartners().determineLsaType(givenCandidate) - } catch (e: WebClientResponseException) { - val statusCode: HttpStatusCode = e.statusCode - val statusCodeValue: Int = statusCode.value() - assertTrue(statusCodeValue in 400..499) - } - - } - - private fun setLookupMockResponse(overallScore: Float) { - val mockedResponse = ReferenceDataLookupResponseSaas( - 1, 1, 0, 1, - listOf( - BusinessPartnerLookupMatchSaas( - "0", - MatchingProfileSaas( - MatchingScoresSaas(MatchingScoreSaas(0.5f), MatchingScoreSaas(0.5f), MatchingScoreSaas(overallScore)) - ) - ) - ) - ) - - wireMockServer.stubFor( - WireMock.post(WireMock.urlPathMatching(EndpointValues.SAAS_MOCK_REFERENCE_DATA_LOOKUP_PATH)) - .willReturn( - WireMock.aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockedResponse)) - ) - ) - } - - -} \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateControllerIT.kt index abe53016e..d52ccefe5 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateControllerIT.kt @@ -24,9 +24,9 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError.* +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType import org.eclipse.tractusx.bpdm.gate.util.DbTestHelpers import org.eclipse.tractusx.bpdm.gate.util.PostgreSQLContextInitializer import org.junit.jupiter.api.BeforeEach diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt index 0e90b5783..dd3d3f6cf 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt @@ -26,8 +26,8 @@ import org.eclipse.tractusx.bpdm.common.model.BusinessStateType import org.eclipse.tractusx.bpdm.common.model.CharacterSet import org.eclipse.tractusx.bpdm.common.model.ClassificationType import org.eclipse.tractusx.bpdm.common.model.NameType -import org.eclipse.tractusx.bpdm.gate.api.model.response.LsaType -import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.OptionalLsaType import java.time.Instant import java.time.LocalDateTime diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/EndpointValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/EndpointValues.kt index 32e726630..edbf8a659 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/EndpointValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/EndpointValues.kt @@ -25,14 +25,10 @@ object EndpointValues { const val SAAS_MOCK_BUSINESS_PARTNER_PATH = "$SAAS_MOCK_DATA_EXCHANGE_API_PATH/businesspartners" const val SAAS_MOCK_RELATIONS_PATH = "$SAAS_MOCK_DATA_EXCHANGE_API_PATH/relations" const val SAAS_MOCK_DELETE_RELATIONS_PATH = "$SAAS_MOCK_RELATIONS_PATH/delete" - const val SAAS_MOCK_FETCH_BUSINESS_PARTNER_PATH = "$SAAS_MOCK_BUSINESS_PARTNER_PATH/fetch" const val SAAS_MOCK_DATA_CLINIC_API_PATH = "/test-saas-data-clinic-api/test-saas-storage" const val SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH = "$SAAS_MOCK_DATA_CLINIC_API_PATH/augmentedbusinesspartners" - const val SAAS_MOCK_REFERENCE_DATA_API_PATH = "/test-saas-reference-data-api" - const val SAAS_MOCK_REFERENCE_DATA_LOOKUP_PATH = "$SAAS_MOCK_REFERENCE_DATA_API_PATH/businesspartners/lookup" - const val SAAS_MOCK_DATA_VALIDATION_API_PATH = "/test-saas-data-validation-api" const val SAAS_MOCK_DATA_VALIDATION_BUSINESSPARTNER_PATH = "$SAAS_MOCK_DATA_VALIDATION_API_PATH/businesspartners/validate" From 85c7186bb84cb02938f1cc75354d55e2e0344139 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:27:35 +0200 Subject: [PATCH 33/83] fix(api): #233 Site Response should include Main Address #233 --- .../tractusx/bpdm/pool/api/PoolSiteApi.kt | 6 +-- .../api/model/response/SitePoolResponse.kt | 37 +++++++++++++++++++ .../bpdm/pool/controller/SiteController.kt | 6 +-- .../bpdm/pool/service/ResponseMappings.kt | 17 ++++++++- .../tractusx/bpdm/pool/service/SiteService.kt | 9 +++-- .../bpdm/pool/controller/SiteControllerIT.kt | 18 +++++++-- .../tractusx/bpdm/pool/util/ResponseValues.kt | 6 +-- 7 files changed, 81 insertions(+), 18 deletions(-) create mode 100644 bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolResponse.kt diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt index b84981fc1..c1c75f5a1 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolSiteApi.kt @@ -28,12 +28,12 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerUpdateRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateResponseWrapper import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerUpdateResponseWrapper +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.web.bind.annotation.* @@ -79,7 +79,7 @@ interface PoolSiteApi { @GetExchange("/{bpn}") fun getSite( @Parameter(description = "Bpn value") @PathVariable bpn: String - ): SiteResponse + ): SitePoolResponse @Operation( summary = "Search site partners by BPNs and/or parent BPNs", @@ -96,7 +96,7 @@ interface PoolSiteApi { fun searchSites( @RequestBody siteSearchRequest: SiteBpnSearchRequest, @ParameterObject paginationRequest: PaginationRequest - ): PageResponse + ): PageResponse @Operation( summary = "Create new site business partners", diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolResponse.kt new file mode 100644 index 000000000..5221053b2 --- /dev/null +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/SitePoolResponse.kt @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.pool.api.model.response + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse +import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema(name = "SitePoolResponse", description = "Site with legal entity reference.") +data class SitePoolResponse( + @field:JsonUnwrapped + val site: SiteResponse, + + @Schema(description = "Main address where this site resides") + val mainAddress: LogisticAddressResponse, +) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt index be2e96302..34230dcd7 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteController.kt @@ -22,13 +22,13 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.pool.api.PoolSiteApi import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerCreateRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePartnerUpdateRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.MainAddressResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateResponseWrapper import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerUpdateResponseWrapper +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolResponse import org.eclipse.tractusx.bpdm.pool.service.AddressService import org.eclipse.tractusx.bpdm.pool.service.BusinessPartnerBuildService import org.eclipse.tractusx.bpdm.pool.service.SiteService @@ -49,14 +49,14 @@ class SiteController( override fun getSite( bpn: String - ): SiteResponse { + ): SitePoolResponse { return siteService.findByBpn(bpn.uppercase()) } override fun searchSites( siteSearchRequest: SiteBpnSearchRequest, paginationRequest: PaginationRequest - ): PageResponse { + ): PageResponse { return siteService.findByPartnerBpns(siteSearchRequest, paginationRequest) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 079ccaab6..96d962ab7 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -245,7 +245,22 @@ fun Site.toDto(): SiteResponse { states = states.map { it.toDto() }, bpnLegalEntity = legalEntity.bpn, createdAt = createdAt, - updatedAt = updatedAt + updatedAt = updatedAt, + ) +} + +fun Site.toPoolDto(): SitePoolResponse { + return SitePoolResponse( + + site = SiteResponse( + bpn, + name, + states = states.map { it.toDto() }, + bpnLegalEntity = legalEntity.bpn, + createdAt = createdAt, + updatedAt = updatedAt, + ), + mainAddress = mainAddress.toDto() ) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt index 18f8a05d6..f5c63e2f6 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SiteService.kt @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.SiteBpnSearchRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolResponse import org.eclipse.tractusx.bpdm.pool.entity.Site import org.eclipse.tractusx.bpdm.pool.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.pool.repository.SiteRepository @@ -46,18 +47,18 @@ class SiteService( return page.toDto(page.content.map { it.toDto() }) } - fun findByPartnerBpns(siteSearchRequest: SiteBpnSearchRequest, paginationRequest: PaginationRequest): PageResponse { + fun findByPartnerBpns(siteSearchRequest: SiteBpnSearchRequest, paginationRequest: PaginationRequest): PageResponse { val partners = if (siteSearchRequest.legalEntities.isNotEmpty()) legalEntityRepository.findDistinctByBpnIn(siteSearchRequest.legalEntities) else emptyList() val sitePage = siteRepository.findByLegalEntityInOrBpnIn(partners, siteSearchRequest.sites, PageRequest.of(paginationRequest.page, paginationRequest.size)) fetchSiteDependencies(sitePage.toSet()) - return sitePage.toDto(sitePage.content.map { it.toDto() }) + return sitePage.toDto(sitePage.content.map { it.toPoolDto() }) } - fun findByBpn(bpn: String): SiteResponse { + fun findByBpn(bpn: String): SitePoolResponse { val site = siteRepository.findByBpn(bpn) ?: throw BpdmNotFoundException("Site", bpn) - return site.toDto() + return site.toPoolDto() } private fun fetchSiteDependencies(sites: Set) { diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt index 3a5fffdf3..a62708bff 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt @@ -27,6 +27,7 @@ import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl import org.eclipse.tractusx.bpdm.pool.api.model.response.SiteCreateError import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePartnerCreateResponse +import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.SiteUpdateError import org.eclipse.tractusx.bpdm.pool.util.* import org.junit.jupiter.api.BeforeEach @@ -64,7 +65,7 @@ class SiteControllerIT @Autowired constructor( .let { bpn -> requestSitesOfLegalEntity(bpn).content.single().bpns } .let { bpnSite -> requestSite(bpnSite) } .let { siteResponse -> - assertThat(siteResponse.bpnLegalEntity).isEqualTo(importedPartner.legalEntity.bpnl) + assertThat(siteResponse.site.bpnLegalEntity).isEqualTo(importedPartner.legalEntity.bpnl) } } @@ -143,12 +144,21 @@ class SiteControllerIT @Autowired constructor( val siteSearchRequest = SiteBpnSearchRequest(listOf(bpnL1, bpnL2)) val searchResult = poolClient.sites().searchSites(siteSearchRequest, PaginationRequest()) - val expectedSiteWithReference1 = ResponseValues.site1.copy(bpnLegalEntity = bpnL1) - val expectedSiteWithReference2 = ResponseValues.site2.copy(bpnLegalEntity = bpnL1) - val expectedSiteWithReference3 = ResponseValues.site3.copy(bpnLegalEntity = bpnL2) + val expectedSiteWithReference1 = + SitePoolResponse( + site = ResponseValues.site1.copy(bpnLegalEntity = bpnL1), + mainAddress = ResponseValues.addressPartner1.copy(isMainAddress = true, bpnSite = CommonValues.bpnS1) + ) + val expectedSiteWithReference2 = + SitePoolResponse(site = ResponseValues.site2.copy(bpnLegalEntity = bpnL1), mainAddress = ResponseValues.addressPartner2) + val expectedSiteWithReference3 = + SitePoolResponse(site = ResponseValues.site3.copy(bpnLegalEntity = bpnL2), mainAddress = ResponseValues.addressPartner3) testHelpers.assertRecursively(searchResult.content) .ignoringFieldsOfTypes(Instant::class.java) + .ignoringFields( + SitePoolResponse::mainAddress.name + "." + LogisticAddressResponse::bpna.name, + ) .isEqualTo(listOf(expectedSiteWithReference1, expectedSiteWithReference2, expectedSiteWithReference3)) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt index 2f410461b..e35c51a95 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt @@ -200,7 +200,7 @@ object ResponseValues { states = listOf(siteStatus1), bpnLegalEntity = CommonValues.bpnL1, createdAt = CommonValues.now, - updatedAt = CommonValues.now + updatedAt = CommonValues.now, ) val site2 = SiteResponse( @@ -209,7 +209,7 @@ object ResponseValues { states = listOf(siteStatus2), bpnLegalEntity = CommonValues.bpnL2, createdAt = CommonValues.now, - updatedAt = CommonValues.now + updatedAt = CommonValues.now, ) val site3 = SiteResponse( @@ -218,7 +218,7 @@ object ResponseValues { states = listOf(siteStatus3), bpnLegalEntity = CommonValues.bpnL3, createdAt = CommonValues.now, - updatedAt = CommonValues.now + updatedAt = CommonValues.now, ) val siteUpsert1 = SitePartnerCreateResponse( From 8b935312fd0370db5b336010f6de95087316b682 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Wed, 7 Jun 2023 08:02:12 +0200 Subject: [PATCH 34/83] fix(api): #233 Site Response should include Main Address #233 - fix tests --- .../bpdm/pool/controller/SiteControllerIT.kt | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt index a62708bff..f89a04b7c 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt @@ -107,11 +107,20 @@ class SiteControllerIT @Autowired constructor( val siteSearchRequest = SiteBpnSearchRequest(emptyList(), listOf(bpnS1, bpnS2)) val searchResult = poolClient.sites().searchSites(siteSearchRequest, PaginationRequest()) - val expectedSiteWithReference1 = ResponseValues.site1.copy(bpnLegalEntity = bpnL) - val expectedSiteWithReference2 = ResponseValues.site2.copy(bpnLegalEntity = bpnL) + val expectedSiteWithReference1 = SitePoolResponse( + site = ResponseValues.site1.copy(bpnLegalEntity = bpnL), + mainAddress = ResponseValues.addressPartner1.copy(isMainAddress = true, bpnSite = CommonValues.bpnS1) + ) + val expectedSiteWithReference2 = SitePoolResponse( + site = ResponseValues.site2.copy(bpnLegalEntity = bpnL), + mainAddress = ResponseValues.addressPartner2.copy(isMainAddress = true, bpnSite = CommonValues.bpnS2) + ) testHelpers.assertRecursively(searchResult.content) .ignoringFieldsOfTypes(Instant::class.java) + .ignoringFields( + SitePoolResponse::mainAddress.name + "." + LogisticAddressResponse::bpna.name, + ) .isEqualTo(listOf(expectedSiteWithReference1, expectedSiteWithReference2)) } @@ -150,9 +159,15 @@ class SiteControllerIT @Autowired constructor( mainAddress = ResponseValues.addressPartner1.copy(isMainAddress = true, bpnSite = CommonValues.bpnS1) ) val expectedSiteWithReference2 = - SitePoolResponse(site = ResponseValues.site2.copy(bpnLegalEntity = bpnL1), mainAddress = ResponseValues.addressPartner2) + SitePoolResponse( + site = ResponseValues.site2.copy(bpnLegalEntity = bpnL1), + mainAddress = ResponseValues.addressPartner2.copy(isMainAddress = true, bpnSite = CommonValues.bpnS2) + ) val expectedSiteWithReference3 = - SitePoolResponse(site = ResponseValues.site3.copy(bpnLegalEntity = bpnL2), mainAddress = ResponseValues.addressPartner3) + SitePoolResponse( + site = ResponseValues.site3.copy(bpnLegalEntity = bpnL2), + mainAddress = ResponseValues.addressPartner3.copy(isMainAddress = true, bpnSite = CommonValues.bpnS3) + ) testHelpers.assertRecursively(searchResult.content) .ignoringFieldsOfTypes(Instant::class.java) From 1ec40f8c26b52a7a27f85962bbac01e58209c85c Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Mon, 5 Jun 2023 15:36:00 +0200 Subject: [PATCH 35/83] feat(Gate): remove validation endpoints and logic - remove all three business partner validation endpoints - remove the associated DTOs - remove validation method from SaaS client - remove validation service fixes issue #234 --- .../common/dto/saas/ValidationRequestSaas.kt | 62 ------- .../common/dto/saas/ValidationResponseSaas.kt | 36 ---- .../bpdm/common/service/ValidationMapper.kt | 66 ------- .../tractusx/bpdm/gate/api/GateAddressApi.kt | 17 -- .../bpdm/gate/api/GateLegalEntityApi.kt | 17 -- .../tractusx/bpdm/gate/api/GateSiteApi.kt | 17 -- .../api/model/response/ValidationResponse.kt | 35 ---- .../tractusx/bpdm/gate/config/SaasConfig.kt | 5 - .../bpdm/gate/controller/AddressController.kt | 9 +- .../gate/controller/LegalEntityController.kt | 9 +- .../bpdm/gate/controller/SiteController.kt | 9 +- .../tractusx/bpdm/gate/service/SaasClient.kt | 167 ------------------ .../bpdm/gate/service/ValidationService.kt | 90 ---------- .../controller/AddressControllerInputIT.kt | 94 ---------- .../LegalEntityControllerInputIT.kt | 68 ------- .../gate/controller/SiteControllerInputIT.kt | 93 ---------- 16 files changed, 3 insertions(+), 791 deletions(-) delete mode 100644 bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/saas/ValidationRequestSaas.kt delete mode 100644 bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/saas/ValidationResponseSaas.kt delete mode 100644 bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/ValidationMapper.kt delete mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ValidationResponse.kt delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/saas/ValidationRequestSaas.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/saas/ValidationRequestSaas.kt deleted file mode 100644 index 5865aa67d..000000000 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/saas/ValidationRequestSaas.kt +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.common.dto.saas - -data class ValidationRequestSaas( - val businessPartner: BusinessPartnerValidationSaas, -) - -data class BusinessPartnerValidationSaas( - val addresses: Collection, - val identifiers: Collection, - val legalForm: NameValidationSaas?, - val names: Collection -) - -data class AddressValidationSaas( - val administrativeAreas: Collection, - val country: CountryValidationSaas?, - val localities: Collection, - val postalDeliveryPoints: Collection, - val postCodes: Collection, - val premises: Collection, - val thoroughfares: Collection -) - -data class IdentifierValidationSaas( - val type: TechnicalKeyValidationSaas, - val value: String -) - -data class ValueValidationSaas( - val value: String -) - -data class TechnicalKeyValidationSaas( - val technicalKey: String -) - -data class NameValidationSaas( - val name: String -) - -data class CountryValidationSaas( - val shortName: String -) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/saas/ValidationResponseSaas.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/saas/ValidationResponseSaas.kt deleted file mode 100644 index cf0eea2ae..000000000 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/saas/ValidationResponseSaas.kt +++ /dev/null @@ -1,36 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.common.dto.saas - -data class ValidationResponseSaas( - val dataDefects: Collection = emptyList() -) - -data class DataDefectSaas( - val violationLevel: ViolationLevel = ViolationLevel.NO_DEFECT, - val violationMessage: String = "" -) - -enum class ViolationLevel { - NO_DEFECT, - INFO, - WARNING, - ERROR -} diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/ValidationMapper.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/ValidationMapper.kt deleted file mode 100644 index cf7d1059b..000000000 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/ValidationMapper.kt +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.common.service - -import org.eclipse.tractusx.bpdm.common.dto.saas.* - -/** - * This class provides functions for mapping the regular SaaS Business Partner model to its corresponding validation model - **/ -class ValidationMapper { - - fun toValidation(partner: BusinessPartnerSaas) = - with(partner) { - BusinessPartnerValidationSaas( - addresses = addresses.map { toValidation(it) }, - identifiers = identifiers.map { toValidationSaas(it) }, - legalForm = legalForm?.name?.let { NameValidationSaas(it) }, - names = names.map { ValueValidationSaas(it.value) } - ) - } - - - fun toValidation(address: AddressSaas) = - with(address) { - AddressValidationSaas( - administrativeAreas = administrativeAreas.map { ValueValidationSaas(it.value!!) }, - country = CountryValidationSaas(country?.shortName?.alpha2!!), - localities = localities.map { ValueValidationSaas(it.value!!) }, - postalDeliveryPoints = postalDeliveryPoints.map { ValueValidationSaas(it.value!!) }, - postCodes = postCodes.map { ValueValidationSaas(it.value!!) }, - premises = premises.map { ValueValidationSaas(it.value!!) }, - thoroughfares = thoroughfares.mapNotNull { toValidationSaas(it) } - ) - } - - private fun toValidationSaas(identifier: IdentifierSaas) = - IdentifierValidationSaas(TechnicalKeyValidationSaas(identifier.type?.technicalKey!!), identifier.value!!) - - private fun toValidationSaas(thoroughfare: ThoroughfareSaas): ValueValidationSaas? { - // Validate only street name and number; ignore direction, shortName (milestone) - val validationString = listOfNotNull(thoroughfare.name, thoroughfare.number) - .joinToString(separator = " ") - return when (validationString) { - "" -> null - else -> ValueValidationSaas(validationString) - } - } - -} \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt index fb3b31518..e225a9529 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt @@ -32,7 +32,6 @@ import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -129,20 +128,4 @@ interface GateAddressApi { @RequestBody(required = false) externalIds: Collection? ): PageOutputResponse - @Operation( - summary = "Validate an address partner", - description = "Determines errors in an address partner record which keep it from entering the sharing process" - ) - @ApiResponses( - value = [ - ApiResponse(responseCode = "200", description = "A validation response with possible errors"), - ApiResponse(responseCode = "400", description = "On malformed address requests", content = [Content()]), - ] - ) - @PostMapping("/input/addresses/validation") - @PostExchange("/input/addresses/validation") - fun validateSite( - @RequestBody addressInput: AddressGateInputRequest - ): ValidationResponse - } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt index 5ae65fcda..84ef0311d 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt @@ -32,7 +32,6 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -125,20 +124,4 @@ interface GateLegalEntityApi { @RequestBody(required = false) externalIds: Collection? ): PageOutputResponse - @Operation( - summary = "Validate a legal entity", - description = "Determines errors in a legal entity record which keep it from entering the sharing process" - ) - @ApiResponses( - value = [ - ApiResponse(responseCode = "200", description = "A validation response with possible errors"), - ApiResponse(responseCode = "400", description = "On malformed legal entity requests", content = [Content()]), - ] - ) - @PostMapping("/input/legal-entities/validation") - @PostExchange("/input/legal-entities/validation") - fun validateLegalEntity( - @RequestBody legalEntityInput: LegalEntityGateInputRequest - ): ValidationResponse - } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt index b332209e9..794374e03 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt @@ -32,7 +32,6 @@ import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -125,20 +124,4 @@ interface GateSiteApi { @RequestBody(required = false) externalIds: Collection? ): PageOutputResponse - @Operation( - summary = "Validate a site", - description = "Determines errors in a site record which keep it from entering the sharing process" - ) - @ApiResponses( - value = [ - ApiResponse(responseCode = "200", description = "A validation response with possible errors"), - ApiResponse(responseCode = "400", description = "On malformed site requests", content = [Content()]), - ] - ) - @PostMapping("/input/sites/validation") - @PostExchange("/input/sites/validation") - fun validateSite( - @RequestBody siteInput: SiteGateInputRequest - ): ValidationResponse - } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ValidationResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ValidationResponse.kt deleted file mode 100644 index b1ff38577..000000000 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/ValidationResponse.kt +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.api.model.response - -import io.swagger.v3.oas.annotations.media.Schema - -@Schema(description = "Contains overall result of a sharing process validation request") -data class ValidationResponse( - @Schema(description = "Overall status of the result of the validation") - val status: ValidationStatus, - @Schema(description = "All found validation errors of this record") - val errors: Collection -) - -enum class ValidationStatus { - OK, - ERROR -} \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/SaasConfig.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/SaasConfig.kt index 4ea6865fe..a23ea021a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/SaasConfig.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/SaasConfig.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.config -import org.eclipse.tractusx.bpdm.common.service.ValidationMapper import org.springframework.beans.factory.annotation.Qualifier import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -49,8 +48,4 @@ class SaasConfig( .defaultHeader("x-api-key", saasProperties.apiKey) .build() } - - @Bean - fun validationMapper() = - ValidationMapper() } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt index 43275f165..26fb34279 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt @@ -27,11 +27,9 @@ import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.AddressService -import org.eclipse.tractusx.bpdm.gate.service.ValidationService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.RestController @@ -39,8 +37,7 @@ import org.springframework.web.bind.annotation.RestController @RestController class AddressController( private val addressService: AddressService, - private val apiConfigProperties: ApiConfigProperties, - private val validationService: ValidationService + private val apiConfigProperties: ApiConfigProperties ) : GateAddressApi { override fun upsertAddresses(addresses: Collection): ResponseEntity { @@ -78,8 +75,4 @@ class AddressController( return addressService.getAddressesOutput(externalIds, paginationRequest.limit, paginationRequest.startAfter) } - override fun validateSite(addressInput: AddressGateInputRequest): ValidationResponse { - return validationService.validate(addressInput) - } - } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt index c4e6c54b0..4d0b4df6e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt @@ -27,11 +27,9 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.LegalEntityService -import org.eclipse.tractusx.bpdm.gate.service.ValidationService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.RestController @@ -39,8 +37,7 @@ import org.springframework.web.bind.annotation.RestController @RestController class LegalEntityController( val legalEntityService: LegalEntityService, - val apiConfigProperties: ApiConfigProperties, - val validationService: ValidationService + val apiConfigProperties: ApiConfigProperties ) : GateLegalEntityApi { override fun upsertLegalEntities(legalEntities: Collection): ResponseEntity { @@ -73,8 +70,4 @@ class LegalEntityController( return legalEntityService.getLegalEntitiesOutput(externalIds, paginationRequest.limit, paginationRequest.startAfter) } - override fun validateLegalEntity(legalEntityInput: LegalEntityGateInputRequest): ValidationResponse { - return validationService.validate(legalEntityInput) - } - } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt index 804c5b7c4..2af617653 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt @@ -27,11 +27,9 @@ import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.SiteService -import org.eclipse.tractusx.bpdm.gate.service.ValidationService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.RestController @@ -39,8 +37,7 @@ import org.springframework.web.bind.annotation.RestController @RestController class SiteController( val siteService: SiteService, - val apiConfigProperties: ApiConfigProperties, - val validationService: ValidationService + val apiConfigProperties: ApiConfigProperties ) : GateSiteApi { override fun upsertSites(sites: Collection): ResponseEntity { @@ -70,8 +67,4 @@ class SiteController( return siteService.getSitesOutput(externalIds, paginationRequest.limit, paginationRequest.startAfter) } - override fun validateSite(siteInput: SiteGateInputRequest): ValidationResponse { - return validationService.validate(siteInput) - } - } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasClient.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasClient.kt index a9c51adbb..438e8d1bd 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasClient.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasClient.kt @@ -21,7 +21,6 @@ package org.eclipse.tractusx.bpdm.gate.service import com.fasterxml.jackson.databind.ObjectMapper import org.eclipse.tractusx.bpdm.common.dto.saas.* -import org.eclipse.tractusx.bpdm.common.service.SaasMappings import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties import org.eclipse.tractusx.bpdm.gate.exception.SaasRequestException import org.springframework.beans.factory.annotation.Qualifier @@ -31,17 +30,11 @@ import org.springframework.web.reactive.function.client.bodyToMono import java.time.Instant private const val BUSINESS_PARTNER_PATH = "/businesspartners" -private const val FETCH_BUSINESS_PARTNER_PATH = "$BUSINESS_PARTNER_PATH/fetch" - -private const val RELATIONS_PATH = "/relations" -private const val DELETE_RELATIONS_PATH = "$RELATIONS_PATH/delete" const val PARENT_RELATION_TYPE_KEY = "PARENT" private const val LOOKUP_PATH = "/businesspartners/lookup" -private const val VALIDATE_BUSINESS_PARTNER_PATH = "/businesspartners/validate" - @Service class SaasClient( @Qualifier("saasClient") @@ -89,83 +82,6 @@ class SaasClient( return partnerCollection } - fun deleteParentRelations(businessPartners: Collection) { - val relationsToDelete = businessPartners - .flatMap { businessPartner -> - businessPartner.relations - .filter { it.type?.technicalKey == PARENT_RELATION_TYPE_KEY } - .filter { it.endNode == businessPartner.externalId } - } - .map { SaasMappings.toRelationToDelete(it) } - if (relationsToDelete.isNotEmpty()) { - deleteRelations(relationsToDelete) - } - } - - fun deleteRelations(relations: Collection) { - try { - webClient - .post() - .uri(saasConfigProperties.dataExchangeApiUrl + DELETE_RELATIONS_PATH) - .bodyValue(objectMapper.writeValueAsString(DeleteRelationsRequestSaas(relations))) - .retrieve() - .bodyToMono() - .block()!! - } catch (e: Exception) { - throw SaasRequestException("Delete relations request failed.", e) - } - } - - fun upsertLegalEntities(legalEntities: List) { - return upsertBusinessPartners(legalEntities) - } - - fun upsertSites(sites: Collection) { - return upsertBusinessPartners(sites) - } - - fun upsertAddresses(addresses: Collection) { - return upsertBusinessPartners(addresses) - } - - private fun upsertBusinessPartners(businessPartners: Collection) { - val upsertRequest = - UpsertRequest( - saasConfigProperties.datasource, - businessPartners, - listOf(UpsertRequest.SaasFeatures.UPSERT_BY_EXTERNAL_ID, UpsertRequest.SaasFeatures.API_ERROR_ON_FAILURES) - ) - - try { - webClient - .put() - .uri(saasConfigProperties.dataExchangeApiUrl + BUSINESS_PARTNER_PATH) - .bodyValue(objectMapper.writeValueAsString(upsertRequest)) - .retrieve() - .bodyToMono() - .block()!! - } catch (e: Exception) { - throw SaasRequestException("Upsert business partners request failed.", e) - } - } - - fun getBusinessPartner(externalId: String): FetchResponse { - val fetchRequest = FetchRequest(saasConfigProperties.datasource, externalId, featuresOn = listOf(FetchRequest.SaasFeatures.FETCH_RELATIONS)) - - val fetchResponse = try { - webClient - .post() - .uri(saasConfigProperties.dataExchangeApiUrl + FETCH_BUSINESS_PARTNER_PATH) - .bodyValue(objectMapper.writeValueAsString(fetchRequest)) - .retrieve() - .bodyToMono() - .block()!! - } catch (e: Exception) { - throw SaasRequestException("Fetch business partners request failed.", e) - } - return fetchResponse - } - fun getLegalEntities(limit: Int? = null, startAfter: String? = null, externalIds: Collection? = null) = getBusinessPartners(limit, startAfter, externalIds, saasConfigProperties.legalEntityType, listOf("USE_NEXT_START_AFTER")) @@ -219,87 +135,4 @@ class SaasClient( } return partnerCollection } - - fun upsertSiteRelations(relations: Collection) { - val relationsSaas = relations.map { - RelationSaas( - startNode = it.legalEntityExternalId, - startNodeDataSource = saasConfigProperties.datasource, - endNode = it.siteExternalId, - endNodeDataSource = saasConfigProperties.datasource, - type = TypeKeyNameSaas(technicalKey = PARENT_RELATION_TYPE_KEY) - ) - }.toList() - upsertBusinessPartnerRelations(relationsSaas) - } - - fun upsertAddressRelations(legalEntityRelations: Collection, siteRelations: Collection) { - val legalEntityRelationsSaas = legalEntityRelations.map { - RelationSaas( - startNode = it.legalEntityExternalId, - startNodeDataSource = saasConfigProperties.datasource, - endNode = it.addressExternalId, - endNodeDataSource = saasConfigProperties.datasource, - type = TypeKeyNameSaas(technicalKey = PARENT_RELATION_TYPE_KEY) - ) - }.toList() - val siteRelationsSaas = siteRelations.map { - RelationSaas( - startNode = it.siteExternalId, - startNodeDataSource = saasConfigProperties.datasource, - endNode = it.addressExternalId, - endNodeDataSource = saasConfigProperties.datasource, - type = TypeKeyNameSaas(technicalKey = PARENT_RELATION_TYPE_KEY) - ) - }.toList() - upsertBusinessPartnerRelations(legalEntityRelationsSaas.plus(siteRelationsSaas)) - } - - fun validateBusinessPartner(validationRequest: ValidationRequestSaas): ValidationResponseSaas { - return try { - webClient - .post() - .uri(saasConfigProperties.dataValidationApiUrl + VALIDATE_BUSINESS_PARTNER_PATH) - .bodyValue(objectMapper.writeValueAsString(validationRequest)) - .retrieve() - .bodyToMono() - .block()!! - } catch (e: Exception) { - throw SaasRequestException("Validate business partner request failed.", e) - } - } - - private fun upsertBusinessPartnerRelations(relations: Collection) { - val upsertRelationsRequest = UpsertRelationsRequestSaas(relations) - val upsertResponse = try { - webClient - .put() - .uri(saasConfigProperties.dataExchangeApiUrl + RELATIONS_PATH) - .bodyValue(objectMapper.writeValueAsString(upsertRelationsRequest)) - .retrieve() - .bodyToMono() - .block()!! - } catch (e: Exception) { - throw SaasRequestException("Upsert business partner relations request failed.", e) - } - - if (upsertResponse.failures.isNotEmpty() || upsertResponse.numberOfFailed > 0) { - throw SaasRequestException("Upsert business partner relations request failed for some relations.") - } - } - - data class SiteLegalEntityRelation( - val siteExternalId: String, - val legalEntityExternalId: String - ) - - data class AddressLegalEntityRelation( - val addressExternalId: String, - val legalEntityExternalId: String - ) - - data class AddressSiteRelation( - val addressExternalId: String, - val siteExternalId: String - ) } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt deleted file mode 100644 index 49233787b..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ValidationService.kt +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.service - -import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas -import org.eclipse.tractusx.bpdm.common.dto.saas.ValidationRequestSaas -import org.eclipse.tractusx.bpdm.common.dto.saas.ValidationResponseSaas -import org.eclipse.tractusx.bpdm.common.dto.saas.ViolationLevel -import org.eclipse.tractusx.bpdm.common.service.ValidationMapper -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus -import org.springframework.stereotype.Service - -/** - * Service giving feedback about whether a business partner record is valid for entering the sharing process - */ -@Service -class ValidationService( - private val saasClient: SaasClient, - private val siteService: SiteService, - private val addressService: AddressService, - private val validationMapper: ValidationMapper, - private val saasRequestMappingService: SaasRequestMappingService -) { - - /** - * Validates a legal entity, listing all errors which will keep it from entering the sharing process - */ - fun validate(legalEntityInput: LegalEntityGateInputRequest): ValidationResponse { - val partnerModel = saasRequestMappingService.toSaasModel(legalEntityInput) - return validate(partnerModel) - } - - /** - * Validates a lsite, listing all errors which will keep it from entering the sharing process - */ - fun validate(siteInput: SiteGateInputRequest): ValidationResponse { - val partnerModel = siteService.toSaasModels(listOf(siteInput)).first() - return validate(partnerModel) - } - - /** - * Validates an address, listing all errors which will keep it from entering the sharing process - */ - fun validate(addressInput: AddressGateInputRequest): ValidationResponse { - val partnerModel = addressService.toSaasModels(listOf(addressInput)).first() - return validate(partnerModel) - } - - private fun validate(partner: BusinessPartnerSaas): ValidationResponse { - val validationModel = validationMapper.toValidation(partner) - - val validationRequest = ValidationRequestSaas(validationModel) - val validationResponse = saasClient.validateBusinessPartner(validationRequest) - - return toGateResponse(validationResponse) - } - - - private fun toGateResponse(validationResponse: ValidationResponseSaas): ValidationResponse { - val errors = validationResponse.dataDefects - .filter { it.violationLevel == ViolationLevel.ERROR } - .map { it.violationMessage } - - return ValidationResponse( - status = if (errors.isNotEmpty()) ValidationStatus.ERROR else ValidationStatus.OK, - errors = errors - ) - } -} \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerInputIT.kt index cf9450238..6c16f75a9 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerInputIT.kt @@ -38,7 +38,6 @@ package org.eclipse.tractusx.bpdm.gate.controller -import com.fasterxml.jackson.databind.ObjectMapper import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension @@ -47,11 +46,8 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.util.* -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertNotEquals import org.junit.jupiter.api.BeforeEach @@ -70,7 +66,6 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti @ActiveProfiles("test") @ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class AddressControllerInputIT @Autowired constructor( - private val objectMapper: ObjectMapper, val gateClient: GateClient, private val gateAddressRepository: GateAddressRepository, val testHelpers: DbTestHelpers, @@ -361,93 +356,4 @@ internal class AddressControllerInputIT @Autowired constructor( } } - - /** - * Given valid address partner - * When validate that address partner - * Then response is OK and no errors - */ - @Test - fun `validate a valid address partner`() { - val address = RequestValues.addressGateInputRequest2 - - val mockParent = SaasValues.siteBusinessPartner1 - val mockParentResponse = PagedResponseSaas(1, null, null, 1, listOf(mockParent)) - wireMockServer.stubFor( - get(urlPathMatching(SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockParentResponse)) - ) - ) - - val mockDefects = listOf( - DataDefectSaas(ViolationLevel.INFO, "Info"), - DataDefectSaas(ViolationLevel.NO_DEFECT, "No Defect"), - DataDefectSaas(ViolationLevel.WARNING, "Warning"), - ) - val mockResponse = ValidationResponseSaas(mockDefects) - wireMockServer.stubFor( - post(urlPathMatching(EndpointValues.SAAS_MOCK_DATA_VALIDATION_BUSINESSPARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockResponse)) - ) - ) - - val actualResponse = gateClient.addresses().validateSite(address) - - val expectedResponse = ValidationResponse(ValidationStatus.OK, emptyList()) - - assertThat(actualResponse).isEqualTo(expectedResponse) - } - - /** - * Given invalid address partner - * When validate that address partner - * Then response is ERROR and contain error description - */ - @Test - fun `validate an invalid site`() { - val address = RequestValues.addressGateInputRequest2 - - - val mockParent = SaasValues.siteBusinessPartner1 - val mockParentResponse = PagedResponseSaas(1, null, null, 1, listOf(mockParent)) - wireMockServer.stubFor( - get(urlPathMatching(SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockParentResponse)) - ) - ) - - - val mockErrorMessage = "Validation error" - val mockDefects = listOf( - DataDefectSaas(ViolationLevel.ERROR, mockErrorMessage), - DataDefectSaas(ViolationLevel.INFO, "Info"), - DataDefectSaas(ViolationLevel.NO_DEFECT, "No Defect"), - DataDefectSaas(ViolationLevel.WARNING, "Warning"), - ) - - val mockResponse = ValidationResponseSaas(mockDefects) - wireMockServer.stubFor( - post(urlPathMatching(EndpointValues.SAAS_MOCK_DATA_VALIDATION_BUSINESSPARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockResponse)) - ) - ) - - val actualResponse = gateClient.addresses().validateSite(address) - - val expectedResponse = ValidationResponse(ValidationStatus.ERROR, listOf(mockErrorMessage)) - - assertThat(actualResponse).isEqualTo(expectedResponse) - } } \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt index 96d70fa97..492b648c3 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt @@ -32,8 +32,6 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.GATE_API_INPUT_LEGAL_ENTITIES_PATH @@ -307,72 +305,6 @@ internal class LegalEntityControllerInputIT @Autowired constructor( } - /** - * Given valid legal entity - * When validate that legal entity - * Then response is OK and no errors - */ - @Test - fun `validate a valid legal entity`() { - val legalEntity = RequestValues.legalEntityGateInputRequest1 - - val mockDefects = listOf( - DataDefectSaas(ViolationLevel.INFO, "Info"), - DataDefectSaas(ViolationLevel.NO_DEFECT, "No Defect"), - DataDefectSaas(ViolationLevel.WARNING, "Warning"), - ) - val mockResponse = ValidationResponseSaas(mockDefects) - wireMockServer.stubFor( - post(urlPathMatching(EndpointValues.SAAS_MOCK_DATA_VALIDATION_BUSINESSPARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockResponse)) - ) - ) - - val actualResponse = gateClient.legalEntities().validateLegalEntity(legalEntity) - - val expectedResponse = ValidationResponse(ValidationStatus.OK, emptyList()) - - assertThat(actualResponse).isEqualTo(expectedResponse) - } - - /** - * Given invalid legal entity - * When validate that legal entity - * Then response is ERROR and contain error description - */ - @Test - fun `validate an invalid legal entity`() { - val legalEntity = RequestValues.legalEntityGateInputRequest1 - - val mockErrorMessage = "Validation error" - val mockDefects = listOf( - DataDefectSaas(ViolationLevel.ERROR, mockErrorMessage), - DataDefectSaas(ViolationLevel.INFO, "Info"), - DataDefectSaas(ViolationLevel.NO_DEFECT, "No Defect"), - DataDefectSaas(ViolationLevel.WARNING, "Warning"), - ) - - val mockResponse = ValidationResponseSaas(mockDefects) - wireMockServer.stubFor( - post(urlPathMatching(EndpointValues.SAAS_MOCK_DATA_VALIDATION_BUSINESSPARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockResponse)) - ) - ) - - val actualResponse = gateClient.legalEntities().validateLegalEntity(legalEntity) - - val expectedResponse = ValidationResponse(ValidationStatus.ERROR, listOf(mockErrorMessage)) - - assertThat(actualResponse).isEqualTo(expectedResponse) - - } - /** * When upserting legal entities * Then SaaS upsert api should be called with the legal entity data mapped to the SaaS data model diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt index 4226e15c2..851e8cbb6 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.controller -import com.fasterxml.jackson.databind.ObjectMapper import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension @@ -28,8 +27,6 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.ValidationStatus import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH @@ -53,7 +50,6 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti @ActiveProfiles("test") @ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class SiteControllerInputIT @Autowired constructor( - private val objectMapper: ObjectMapper, val gateClient: GateClient, private val siteRepository: SiteRepository, private val dbTestHelpers: DbTestHelpers @@ -386,93 +382,4 @@ internal class SiteControllerInputIT @Autowired constructor( } } - - /** - * Given valid site - * When validate that site - * Then response is OK and no errors - */ - @Test - fun `validate a valid site`() { - val site = RequestValues.siteGateInputRequest1 - - val mockParent = SaasValues.legalEntityResponse1 - val mockParentResponse = PagedResponseSaas(1, null, null, 1, listOf(mockParent)) - wireMockServer.stubFor( - get(urlPathMatching(SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockParentResponse)) - ) - ) - - val mockDefects = listOf( - DataDefectSaas(ViolationLevel.INFO, "Info"), - DataDefectSaas(ViolationLevel.NO_DEFECT, "No Defect"), - DataDefectSaas(ViolationLevel.WARNING, "Warning"), - ) - val mockResponse = ValidationResponseSaas(mockDefects) - wireMockServer.stubFor( - post(urlPathMatching(EndpointValues.SAAS_MOCK_DATA_VALIDATION_BUSINESSPARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockResponse)) - ) - ) - - val actualResponse = gateClient.sites().validateSite(site) - - val expectedResponse = ValidationResponse(ValidationStatus.OK, emptyList()) - - assertThat(actualResponse).isEqualTo(expectedResponse) - } - - /** - * Given invalid site - * When validate that site - * Then response is ERROR and contain error description - */ - @Test - fun `validate an invalid site`() { - val site = RequestValues.siteGateInputRequest1 - - - val mockParent = SaasValues.legalEntityResponse1 - val mockParentResponse = PagedResponseSaas(1, null, null, 1, listOf(mockParent)) - wireMockServer.stubFor( - get(urlPathMatching(SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockParentResponse)) - ) - ) - - - val mockErrorMessage = "Validation error" - val mockDefects = listOf( - DataDefectSaas(ViolationLevel.ERROR, mockErrorMessage), - DataDefectSaas(ViolationLevel.INFO, "Info"), - DataDefectSaas(ViolationLevel.NO_DEFECT, "No Defect"), - DataDefectSaas(ViolationLevel.WARNING, "Warning"), - ) - - val mockResponse = ValidationResponseSaas(mockDefects) - wireMockServer.stubFor( - post(urlPathMatching(EndpointValues.SAAS_MOCK_DATA_VALIDATION_BUSINESSPARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody(objectMapper.writeValueAsString(mockResponse)) - ) - ) - - val actualResponse = gateClient.sites().validateSite(site) - - val expectedResponse = ValidationResponse(ValidationStatus.ERROR, listOf(mockErrorMessage)) - - assertThat(actualResponse).isEqualTo(expectedResponse) - } } \ No newline at end of file From a16f8f6fa49d891a735daab06801d6151baf9e8f Mon Sep 17 00:00:00 2001 From: alexsilva Date: Thu, 1 Jun 2023 13:05:14 +0100 Subject: [PATCH 36/83] feat(gate): Added new Output PUT endpoint, changed logic for Output Fetch, added composite key on addresses (externalid + datatype). Altered database queries according new datatype --- .../bpdm/common/model/OutputInputEnum.kt | 25 +++++ .../tractusx/bpdm/gate/api/GateAddressApi.kt | 24 ++++- .../api/model/AddressGateOutputResponse.kt | 49 +++++++++ .../bpdm/gate/controller/AddressController.kt | 18 ++-- .../bpdm/gate/entity/LogisticAddress.kt | 5 + .../gate/repository/GateAddressRepository.kt | 6 +- .../gate/service/AddressPersistenceService.kt | 35 ++++-- .../bpdm/gate/service/AddressService.kt | 100 ++++++++++++------ .../bpdm/gate/service/ResponseMappings.kt | 26 ++++- .../V0_1_6_0__add_input_or_output_collumn.sql | 11 ++ .../controller/AddressControllerOutputIT.kt | 6 +- 11 files changed, 243 insertions(+), 62 deletions(-) create mode 100644 bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/OutputInputEnum.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt create mode 100644 bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/OutputInputEnum.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/OutputInputEnum.kt new file mode 100644 index 000000000..8b59261e2 --- /dev/null +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/OutputInputEnum.kt @@ -0,0 +1,25 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.common.model + +enum class OutputInputEnum { + Input, + Output +} \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt index e225a9529..005d1315d 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt @@ -29,9 +29,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput -import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -124,8 +122,24 @@ interface GateAddressApi { @PostMapping("/output/addresses/search") @PostExchange("/output/addresses/search") fun getAddressesOutput( - @ParameterObject @Valid paginationRequest: PaginationStartAfterRequest, + @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody(required = false) externalIds: Collection? - ): PageOutputResponse + ): PageResponse + + @Operation( + summary = "Create or update output addresses.", //TODO Needs description update + description = "Create or update addresses. " + + "Test new endpoint" + + ) + @ApiResponses( + value = [ + ApiResponse(responseCode = "200", description = "Addresses were successfully updated or created"), + ApiResponse(responseCode = "400", description = "On malformed address request", content = [Content()]), + ] + ) + @PutMapping("/output/addresses") + @PutExchange("/output/addresses") + fun putAddressesOutput(@RequestBody addresses: Collection): ResponseEntity } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt new file mode 100644 index 000000000..becca747e --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema( + name = "AddressGateInputResponse", description = "Address with legal entity or site references. " + + "Only one of either legal entity or site external id can be set for an address." +) +data class AddressGateOutputResponse( + @field:JsonUnwrapped + val address: LogisticAddressDto, + + @Schema(description = "ID the record has in the external system where the record originates from") + val externalId: String, + + @Schema(description = "External id of the related legal entity") + val legalEntityExternalId: String? = null, + + @Schema(description = "External id of the related site") + val siteExternalId: String? = null, + + @Schema(description = "Business Partner Number") + val bpn: String? = null, + + ) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt index 26fb34279..8a8a72561 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt @@ -24,9 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateAddressApi import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput -import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.AddressService @@ -69,10 +67,18 @@ class AddressController( } override fun getAddressesOutput( - paginationRequest: PaginationStartAfterRequest, + paginationRequest: PaginationRequest, externalIds: Collection? - ): PageOutputResponse { - return addressService.getAddressesOutput(externalIds, paginationRequest.limit, paginationRequest.startAfter) + ): PageResponse { + return addressService.getAddressesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) + } + + override fun putAddressesOutput(addresses: Collection): ResponseEntity { + if (addresses.size > apiConfigProperties.upsertLimit || addresses.map { it.externalId }.containsDuplicates()) { + return ResponseEntity(HttpStatus.BAD_REQUEST) + } + addressService.upsertOutputAddresses(addresses) + return ResponseEntity(HttpStatus.OK) } } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt index 38e5f09e4..d4e28226b 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.entity import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.BaseEntity +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum @Entity @Table( @@ -51,6 +52,10 @@ class LogisticAddress( @Column(name = "name") var name: String? = null, + @Column(name = "data_type") + @Enumerated(EnumType.STRING) + var dataType: OutputInputEnum, + @Embedded var physicalPostalAddress: PhysicalPostalAddress, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/GateAddressRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/GateAddressRepository.kt index 059a9bb6b..c2ed8428b 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/GateAddressRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/GateAddressRepository.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.repository +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.entity.LogisticAddress import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable @@ -31,6 +32,9 @@ interface GateAddressRepository : PagingAndSortingRepository?, pageable: Pageable): Page + fun findByExternalIdAndDataType(externalId: String, dataType: OutputInputEnum): LogisticAddress + fun findByExternalIdInAndDataType(externalId: Collection?, dataType: OutputInputEnum, pageable: Pageable): Page + + fun findByDataType(dataType: OutputInputEnum, pageable: Pageable): Page } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index 5e491a22f..e7916cca4 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.service import jakarta.transaction.Transactional +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity @@ -46,16 +47,13 @@ class AddressPersistenceService( val addressRecord = gateAddressRepository.findByExternalIdIn(externalIdColl) addresses.forEach { address -> - val legalEntityRecord = - address.legalEntityExternalId?.let { legalEntityRepository.findByExternalId(it) } + + val legalEntityRecord = address.legalEntityExternalId?.let { legalEntityRepository.findByExternalId(it) } val siteRecord = address.siteExternalId?.let { siteEntityRepository.findByExternalId(it) } -// if(legalEntityRecord == null && siteRecord == null) { -// throw BpdmNotFoundException("Business Partner", "Error") -// } + val fullAddress = address.toAddressGate(legalEntityRecord, siteRecord, OutputInputEnum.Input) - val fullAddress = address.toAddressGate(legalEntityRecord, siteRecord) - addressRecord.find { it.externalId == address.externalId }?.let { existingAddress -> + addressRecord.find { it.externalId == address.externalId && it.dataType == OutputInputEnum.Input }?.let { existingAddress -> updateAddress(existingAddress, address, legalEntityRecord, siteRecord) gateAddressRepository.save(existingAddress) } ?: run { @@ -79,4 +77,27 @@ class AddressPersistenceService( } + @Transactional + fun persistOutputAddress(addresses: Collection) { + + val externalIdColl: MutableCollection = mutableListOf() + addresses.forEach { externalIdColl.add(it.externalId) } + + val addressRecord = gateAddressRepository.findByExternalIdIn(externalIdColl) + + addresses.forEach { address -> + val legalEntityRecord = address.legalEntityExternalId?.let { legalEntityRepository.findByExternalId(it) } + val siteRecord = address.siteExternalId?.let { siteEntityRepository.findByExternalId(it) } + + val fullAddress = address.toAddressGate(legalEntityRecord, siteRecord, OutputInputEnum.Output) + + addressRecord.find { it.externalId == address.externalId && it.dataType == OutputInputEnum.Output }?.let { existingAddress -> + updateAddress(existingAddress, address, legalEntityRecord, siteRecord) + gateAddressRepository.save(existingAddress) + } ?: run { + gateAddressRepository.save(fullAddress) + } + } + } + } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index d8bf32fbe..a1ff153b6 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -23,12 +23,13 @@ import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.entity.LogisticAddress @@ -55,9 +56,9 @@ class AddressService( fun getAddresses(page: Int, size: Int, externalIds: Collection? = null): PageResponse { val logisticAddressPage = if (externalIds != null) { - addressRepository.findByExternalIdIn(externalIds, PageRequest.of(page, size)) + addressRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Input, PageRequest.of(page, size)) } else { - addressRepository.findAll(PageRequest.of(page, size)) + addressRepository.findByDataType(OutputInputEnum.Input, PageRequest.of(page, size)) } return PageResponse( @@ -77,7 +78,8 @@ class AddressService( fun getAddressByExternalId(externalId: String): AddressGateInputResponse { - val logisticAddress = addressRepository.findByExternalId(externalId) ?: throw BpdmNotFoundException("Logistic Address", externalId) + val logisticAddress = + addressRepository.findByExternalIdAndDataType(externalId, OutputInputEnum.Input) ?: throw BpdmNotFoundException("Logistic Address", externalId) return logisticAddress.toAddressGateInputResponse(logisticAddress) @@ -87,44 +89,63 @@ class AddressService( * Get addresses by first fetching addresses from "augmented business partners" in SaaS. Augmented business partners from SaaS should contain a BPN, * which is then used to fetch the data for the addresses from the bpdm pool. */ - fun getAddressesOutput(externalIds: Collection?, limit: Int, startAfter: String?): PageOutputResponse { - val partnerResponse = saasClient.getAddresses(limit = limit, startAfter = startAfter, externalIds = externalIds) - val partners = partnerResponse.values + fun getAddressesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { - val partnersWithExternalId = outputSaasMappingService.mapWithExternalId(partners) - val augmentedPartnerResponse = saasClient.getAugmentedAddresses(externalIds = partnersWithExternalId.map { it.externalId }) - val partnersWithLocalBpn = outputSaasMappingService.mapWithLocalBpn(partnersWithExternalId, augmentedPartnerResponse.values) + val logisticAddressPage = addressRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) - //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.bpna } - - if (bpnSet.size > addressesByBpnMap.size) { - logger.warn { "Requested ${bpnSet.size} addresses from pool, but only ${addressesByBpnMap.size} were found." } - } - - val partnersWithPoolBpn = partnersWithLocalBpn.filter { addressesByBpnMap[it.bpn] != null } - val bpnByExternalIdMap = partnersWithPoolBpn.map { Pair(it.partner.externalId!!, it.bpn) }.toMap() + return PageResponse( + page = page, + totalElements = logisticAddressPage.totalElements, + totalPages = logisticAddressPage.totalPages, + contentSize = logisticAddressPage.content.size, + content = toValidOutputLogisticAddresses(logisticAddressPage), + ) - //Evaluate the sharing status of the legal entities - val sharingStatus = outputSaasMappingService.evaluateSharingStatus(partners, partnersWithLocalBpn, partnersWithPoolBpn) + } - val validAddresses = sharingStatus.validExternalIds.map { externalId -> - val bpn = bpnByExternalIdMap[externalId]!! - val address = addressesByBpnMap[bpn]!! - toAddressOutput(externalId, address) + private fun toValidOutputLogisticAddresses(logisticAddressPage: Page): List { + return logisticAddressPage.content.map { logisticAddress -> + logisticAddress.toAddressGateOutputResponse(logisticAddress) } - - return PageOutputResponse( - total = partnerResponse.total, - nextStartAfter = partnerResponse.nextStartAfter, - content = validAddresses, - invalidEntries = partners.size - sharingStatus.validExternalIds.size, // difference between all entries from SaaS and valid content - pending = sharingStatus.pendingExternalIds, - errors = sharingStatus.errors, - ) } +// val partnerResponse = saasClient.getAddresses(limit = limit, startAfter = startAfter, externalIds = externalIds) +// val partners = partnerResponse.values +// +// val partnersWithExternalId = outputSaasMappingService.mapWithExternalId(partners) +// val augmentedPartnerResponse = saasClient.getAugmentedAddresses(externalIds = partnersWithExternalId.map { it.externalId }) +// val partnersWithLocalBpn = outputSaasMappingService.mapWithLocalBpn(partnersWithExternalId, augmentedPartnerResponse.values) +// +// //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.bpna } +// +// if (bpnSet.size > addressesByBpnMap.size) { +// logger.warn { "Requested ${bpnSet.size} addresses from pool, but only ${addressesByBpnMap.size} were found." } +// } +// +// val partnersWithPoolBpn = partnersWithLocalBpn.filter { addressesByBpnMap[it.bpn] != null } +// val bpnByExternalIdMap = partnersWithPoolBpn.map { Pair(it.partner.externalId!!, it.bpn) }.toMap() +// +// //Evaluate the sharing status of the legal entities +// val sharingStatus = outputSaasMappingService.evaluateSharingStatus(partners, partnersWithLocalBpn, partnersWithPoolBpn) +// +// val validAddresses = sharingStatus.validExternalIds.map { externalId -> +// val bpn = bpnByExternalIdMap[externalId]!! +// val address = addressesByBpnMap[bpn]!! +// toAddressOutput(externalId, address) +// } +// +// return PageOutputResponse( +// total = partnerResponse.total, +// nextStartAfter = partnerResponse.nextStartAfter, +// content = validAddresses, +// invalidEntries = partners.size - sharingStatus.validExternalIds.size, // difference between all entries from SaaS and valid content +// pending = sharingStatus.pendingExternalIds, +// errors = sharingStatus.errors, +// ) +// } + fun toAddressOutput(externalId: String, address: LogisticAddressGateResponse): AddressGateOutput { return AddressGateOutput( address = address, @@ -150,6 +171,15 @@ class AddressService( addressPersistenceService.persistAddressBP(addresses) } + fun upsertOutputAddresses(addresses: Collection) { + +// addresses.forEach { address -> +// changelogRepository.save(ChangelogEntry(address.externalId, LsaType.Address)) +// } + + addressPersistenceService.persistOutputAddress(addresses) + } + /** * Fetches parent information and converts the given [addresses] to their corresponding SaaS models */ diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 5dfc57076..b08f285c7 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.dto.* import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.entity.* @@ -28,7 +29,7 @@ import org.springframework.data.domain.Page import java.time.Instant import java.time.temporal.ChronoUnit -fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site?): LogisticAddress { +fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site?, datatype: OutputInputEnum): LogisticAddress { val logisticAddress = LogisticAddress( externalId = externalId, @@ -37,7 +38,8 @@ fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site? physicalPostalAddress = address.physicalPostalAddress.toPhysicalPostalAddressEntity(), alternativePostalAddress = address.alternativePostalAddress?.toAlternativePostalAddressEntity(), legalEntity = legalEntity, - site = site + site = site, + dataType = datatype ) logisticAddress.identifiers.addAll(this.address.identifiers.map { toEntityIdentifier(it, logisticAddress) }.toSet()) @@ -122,7 +124,7 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity): Site { ) site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) - site.mainAddress = addressInputRequest.toAddressGate(legalEntity, site) + site.mainAddress = addressInputRequest.toAddressGate(legalEntity, site, OutputInputEnum.Input) return site } @@ -157,7 +159,7 @@ fun LegalEntityGateInputRequest.toLegalEntity(): LegalEntity { legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) - legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null) + legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, OutputInputEnum.Input) return legalEntity @@ -347,4 +349,18 @@ fun Site.toSiteGateInputResponse(sitePage: Site): SiteGateInputResponse { processStartedAt = null //TODO Remove this? ) -} \ No newline at end of file +} + +//Logistic Address mapping to AddressGateInputResponse +fun LogisticAddress.toAddressGateOutputResponse(logisticAddressPage: LogisticAddress): AddressGateOutputResponse { + + val addressGateOutputResponse = AddressGateOutputResponse( + address = logisticAddressPage.toLogisticAddressDto(), + externalId = externalId, + legalEntityExternalId = legalEntity?.externalId, + siteExternalId = site?.externalId, + bpn = bpn, + ) + + return addressGateOutputResponse +} diff --git a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql new file mode 100644 index 000000000..d0e39a011 --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql @@ -0,0 +1,11 @@ +-- ALTER TABLE logistic_addresses ADD COLUMN data_type varchar(255) NOT NULL, +-- ADD CONSTRAINT uk_data_type UNIQUE (data_type); + +-- Remove the existing unique constraint on external_id +ALTER TABLE logistic_addresses +DROP CONSTRAINT IF EXISTS uk_7xolefhhm30nlfrp5fc25a3i2; + +-- Add the composite unique constraint on external_id and data_type +ALTER TABLE logistic_addresses +ADD COLUMN data_type VARCHAR(255) NOT NULL, +ADD CONSTRAINT uk_external_id_data_type UNIQUE (external_id, data_type); \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt index 7d96f88af..3dc132b34 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt @@ -43,12 +43,12 @@ import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError -import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.util.* @@ -184,7 +184,7 @@ internal class AddressControllerOutputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter, limit) + val paginationValue = PaginationRequest(0, 10) val pageResponse = gateClient.addresses().getAddressesOutput(paginationValue, emptyList()) assertThat(pageResponse).isEqualTo( @@ -283,7 +283,7 @@ internal class AddressControllerOutputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter, limit) + val paginationValue = PaginationRequest(0, 10) val pageResponse = gateClient.addresses().getAddressesOutput(paginationValue, listOf(CommonValues.externalIdAddress1, CommonValues.externalIdAddress2)) assertThat(pageResponse).isEqualTo( From a1f10f91d86ab93fef028246a51bf9dd3cd4c769 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Fri, 2 Jun 2023 13:48:57 +0100 Subject: [PATCH 37/83] feat(gate): Added new Output PUT endpoint (Sites/LegalEntity), added composite key on Sites/LegalEntity (externalid + datatype). Changed Repository calls accounting to dataType field --- .../bpdm/gate/api/GateLegalEntityApi.kt | 14 +++++++++ .../tractusx/bpdm/gate/api/GateSiteApi.kt | 14 +++++++++ .../api/model/AddressGateOutputResponse.kt | 2 +- .../gate/controller/LegalEntityController.kt | 8 +++++ .../bpdm/gate/controller/SiteController.kt | 8 +++++ .../tractusx/bpdm/gate/entity/LegalEntity.kt | 7 ++++- .../eclipse/tractusx/bpdm/gate/entity/Site.kt | 5 ++++ .../gate/repository/GateAddressRepository.kt | 2 +- .../gate/repository/LegalEntityRepository.kt | 7 ++++- .../bpdm/gate/repository/SiteRepository.kt | 7 ++++- .../gate/service/AddressPersistenceService.kt | 29 ++----------------- .../bpdm/gate/service/AddressService.kt | 7 ++--- .../service/LegalEntityPersistenceService.kt | 12 ++++---- .../bpdm/gate/service/LegalEntityService.kt | 16 ++++++---- .../bpdm/gate/service/ResponseMappings.kt | 13 +++++---- .../gate/service/SitePersistenceService.kt | 9 +++--- .../tractusx/bpdm/gate/service/SiteService.kt | 15 ++++++---- .../V0_1_6_0__add_input_or_output_collumn.sql | 27 +++++++++++++---- 18 files changed, 136 insertions(+), 66 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt index 84ef0311d..63979ad81 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt @@ -124,4 +124,18 @@ interface GateLegalEntityApi { @RequestBody(required = false) externalIds: Collection? ): PageOutputResponse + @Operation( + summary = "Create or update legal entities output.", + description = "Create or update legal entities. " //TODO need better description + ) + @ApiResponses( + value = [ + ApiResponse(responseCode = "200", description = "Legal entities were successfully updated or created"), + ApiResponse(responseCode = "400", description = "On malformed legal entity request", content = [Content()]), + ] + ) + @PutMapping("/output/legal-entities") + @PutExchange("/output/legal-entities") + fun upsertLegalEntitiesOutput(@RequestBody legalEntities: Collection): ResponseEntity + } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt index 794374e03..4d0550703 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt @@ -124,4 +124,18 @@ interface GateSiteApi { @RequestBody(required = false) externalIds: Collection? ): PageOutputResponse + @Operation( + summary = "Create or update sites.", + description = "Create or update sites. " //TODO Need better description + ) + @ApiResponses( + value = [ + ApiResponse(responseCode = "200", description = "Sites were successfully updated or created"), + ApiResponse(responseCode = "400", description = "On malformed site request", content = [Content()]), + ] + ) + @PutMapping("/output/sites") + @PutExchange("/output/sites") + fun upsertSitesOutput(@RequestBody sites: Collection): ResponseEntity + } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt index becca747e..ba71d965c 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt @@ -32,7 +32,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ ) data class AddressGateOutputResponse( @field:JsonUnwrapped - val address: LogisticAddressDto, + val address: LogisticAddressGateDto, @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt index 4d0b4df6e..f459b39b3 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt @@ -70,4 +70,12 @@ class LegalEntityController( return legalEntityService.getLegalEntitiesOutput(externalIds, paginationRequest.limit, paginationRequest.startAfter) } + override fun upsertLegalEntitiesOutput(legalEntities: Collection): ResponseEntity { + if (legalEntities.size > apiConfigProperties.upsertLimit || legalEntities.map { it.externalId }.containsDuplicates()) { + return ResponseEntity(HttpStatus.BAD_REQUEST) + } + legalEntityService.upsertLegalEntitiesOutput(legalEntities) + return ResponseEntity(HttpStatus.OK) + } + } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt index 2af617653..3ad39e2e8 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt @@ -67,4 +67,12 @@ class SiteController( return siteService.getSitesOutput(externalIds, paginationRequest.limit, paginationRequest.startAfter) } + override fun upsertSitesOutput(sites: Collection): ResponseEntity { + if (sites.size > apiConfigProperties.upsertLimit || sites.map { it.externalId }.containsDuplicates()) { + return ResponseEntity(HttpStatus.BAD_REQUEST) + } + siteService.upsertSitesOutput(sites) + return ResponseEntity(HttpStatus.OK) + } + } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt index f5cb24bb0..621fad714 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.entity import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.BaseEntity +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import java.time.Instant @Entity @@ -42,7 +43,11 @@ class LegalEntity( var legalForm: String?, @Column(name = "currentness", nullable = false) - var currentness: Instant + var currentness: Instant, + + @Column(name = "data_type") + @Enumerated(EnumType.STRING) + var dataType: OutputInputEnum ) : BaseEntity() { @OneToMany(mappedBy = "legalEntity", cascade = [CascadeType.ALL], orphanRemoval = true) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt index 791f345c2..10f926a07 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Site.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.entity import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.BaseEntity +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum @Entity @Table(name = "sites") @@ -34,6 +35,10 @@ class Site( @Column(name = "external_id", nullable = false, unique = true) var externalId: String, + @Column(name = "data_type") + @Enumerated(EnumType.STRING) + var dataType: OutputInputEnum, + @ManyToOne @JoinColumn(name = "legal_entity_id", nullable = false) var legalEntity: LegalEntity, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/GateAddressRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/GateAddressRepository.kt index c2ed8428b..d55dd3833 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/GateAddressRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/GateAddressRepository.kt @@ -32,7 +32,7 @@ interface GateAddressRepository : PagingAndSortingRepository?, dataType: OutputInputEnum, pageable: Pageable): Page diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/LegalEntityRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/LegalEntityRepository.kt index 05b79b307..335b10145 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/LegalEntityRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/LegalEntityRepository.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.repository +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable @@ -31,5 +32,9 @@ interface LegalEntityRepository : JpaRepository, CrudReposito fun findByExternalId(externalId: String): LegalEntity? - fun findByExternalIdIn(externalId: Collection?, pageable: Pageable): Page + fun findByExternalIdAndDataType(externalId: String, dataType: OutputInputEnum): LegalEntity? + + fun findByExternalIdInAndDataType(externalId: Collection?, dataType: OutputInputEnum, pageable: Pageable): Page + + fun findByDataType(dataType: OutputInputEnum, pageable: Pageable): Page } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/SiteRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/SiteRepository.kt index ffd7b34ba..cc5b5b4b1 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/SiteRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/SiteRepository.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.repository +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.entity.Site import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable @@ -31,6 +32,10 @@ interface SiteRepository : JpaRepository, CrudRepository fun findByExternalId(externalId: String): Site? - fun findByExternalIdIn(externalId: Collection?, pageable: Pageable): Page + fun findByExternalIdAndDataType(externalId: String, dataType: OutputInputEnum): Site? + + fun findByExternalIdInAndDataType(externalId: Collection?, dataType: OutputInputEnum, pageable: Pageable): Page + + fun findByDataType(dataType: OutputInputEnum, pageable: Pageable): Page } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index e7916cca4..7e4e3e912 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -39,7 +39,7 @@ class AddressPersistenceService( ) { @Transactional - fun persistAddressBP(addresses: Collection) { + fun persistAddressBP(addresses: Collection, dataType: OutputInputEnum) { val externalIdColl: MutableCollection = mutableListOf() addresses.forEach { externalIdColl.add(it.externalId) } @@ -51,9 +51,9 @@ class AddressPersistenceService( val legalEntityRecord = address.legalEntityExternalId?.let { legalEntityRepository.findByExternalId(it) } val siteRecord = address.siteExternalId?.let { siteEntityRepository.findByExternalId(it) } - val fullAddress = address.toAddressGate(legalEntityRecord, siteRecord, OutputInputEnum.Input) + val fullAddress = address.toAddressGate(legalEntityRecord, siteRecord, dataType) - addressRecord.find { it.externalId == address.externalId && it.dataType == OutputInputEnum.Input }?.let { existingAddress -> + addressRecord.find { it.externalId == address.externalId && it.dataType == dataType }?.let { existingAddress -> updateAddress(existingAddress, address, legalEntityRecord, siteRecord) gateAddressRepository.save(existingAddress) } ?: run { @@ -77,27 +77,4 @@ class AddressPersistenceService( } - @Transactional - fun persistOutputAddress(addresses: Collection) { - - val externalIdColl: MutableCollection = mutableListOf() - addresses.forEach { externalIdColl.add(it.externalId) } - - val addressRecord = gateAddressRepository.findByExternalIdIn(externalIdColl) - - addresses.forEach { address -> - val legalEntityRecord = address.legalEntityExternalId?.let { legalEntityRepository.findByExternalId(it) } - val siteRecord = address.siteExternalId?.let { siteEntityRepository.findByExternalId(it) } - - val fullAddress = address.toAddressGate(legalEntityRecord, siteRecord, OutputInputEnum.Output) - - addressRecord.find { it.externalId == address.externalId && it.dataType == OutputInputEnum.Output }?.let { existingAddress -> - updateAddress(existingAddress, address, legalEntityRecord, siteRecord) - gateAddressRepository.save(existingAddress) - } ?: run { - gateAddressRepository.save(fullAddress) - } - } - } - } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index a1ff153b6..af09d41e9 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -168,16 +168,13 @@ class AddressService( changelogRepository.save(ChangelogEntry(address.externalId, LsaType.Address)) } - addressPersistenceService.persistAddressBP(addresses) + addressPersistenceService.persistAddressBP(addresses, OutputInputEnum.Input) } fun upsertOutputAddresses(addresses: Collection) { -// addresses.forEach { address -> -// changelogRepository.save(ChangelogEntry(address.externalId, LsaType.Address)) -// } + addressPersistenceService.persistAddressBP(addresses, OutputInputEnum.Output) - addressPersistenceService.persistOutputAddress(addresses) } /** diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 153c27351..1f81be37d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.entity.* @@ -36,18 +37,19 @@ class LegalEntityPersistenceService( ) { @Transactional - fun persistLegalEntitiesBP(legalEntities: Collection) { + fun persistLegalEntitiesBP(legalEntities: Collection, datatype: OutputInputEnum) { //finds Legal Entity by External ID val legalEntityRecord = gateLegalEntityRepository.findDistinctByExternalIdIn(legalEntities.map { it.externalId }) //Business Partner persist legalEntities.forEach { legalEntity -> - val fullLegalEntity = legalEntity.toLegalEntity() - legalEntityRecord.find { it.externalId == legalEntity.externalId }?.let { existingLegalEntity -> + val fullLegalEntity = legalEntity.toLegalEntity(datatype) + legalEntityRecord.find { it.externalId == legalEntity.externalId && it.dataType == datatype }?.let { existingLegalEntity -> - val logisticAddressRecord = gateAddressRepository.findByExternalId(getMainAddressForLegalEntityExternalId(existingLegalEntity.externalId)) - ?: throw BpdmNotFoundException("Business Partner", "Error") + val logisticAddressRecord = + gateAddressRepository.findByExternalIdAndDataType(getMainAddressForLegalEntityExternalId(existingLegalEntity.externalId), datatype) + ?: throw BpdmNotFoundException("Business Partner", "Error") updateAddress(logisticAddressRecord, fullLegalEntity.legalAddress) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index b0f774298..fccb21d90 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput @@ -52,25 +53,30 @@ class LegalEntityService( fun upsertLegalEntities(legalEntities: Collection) { - // create changelog entry if all goes well from saasClient legalEntities.forEach { legalEntity -> changelogRepository.save(ChangelogEntry(legalEntity.externalId, LsaType.LegalEntity)) } - legalEntityPersistenceService.persistLegalEntitiesBP(legalEntities) + legalEntityPersistenceService.persistLegalEntitiesBP(legalEntities, OutputInputEnum.Input) + } + + fun upsertLegalEntitiesOutput(legalEntities: Collection) { + + legalEntityPersistenceService.persistLegalEntitiesBP(legalEntities, OutputInputEnum.Output) } fun getLegalEntityByExternalId(externalId: String): LegalEntityGateInputResponse { - val legalEntity = legalEntityRepository.findByExternalId(externalId) ?: throw BpdmNotFoundException("LegalEntity", externalId) + val legalEntity = + legalEntityRepository.findByExternalIdAndDataType(externalId, OutputInputEnum.Input) ?: throw BpdmNotFoundException("LegalEntity", externalId) return toValidSingleLegalEntity(legalEntity) } fun getLegalEntities(page: Int, size: Int, externalIds: Collection? = null): PageResponse { val legalEntitiesPage = if (externalIds != null) { - legalEntityRepository.findByExternalIdIn(externalIds, PageRequest.of(page, size)) + legalEntityRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Input, PageRequest.of(page, size)) } else { - legalEntityRepository.findAll(PageRequest.of(page, size)) + legalEntityRepository.findByDataType(OutputInputEnum.Input, PageRequest.of(page, size)) } return PageResponse( diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index b08f285c7..5b35921ac 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -109,7 +109,7 @@ fun Page.toDto(dtoContent: Collection): PageResponse { } // Site Mappers -fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity): Site { +fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputInputEnum): Site { val addressInputRequest = AddressGateInputRequest( address = site.mainAddress, @@ -121,10 +121,11 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity): Site { name = site.name, externalId = externalId, legalEntity = legalEntity, + dataType = datatype ) site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) - site.mainAddress = addressInputRequest.toAddressGate(legalEntity, site, OutputInputEnum.Input) + site.mainAddress = addressInputRequest.toAddressGate(legalEntity, site, datatype) return site } @@ -141,7 +142,7 @@ fun ChangelogEntry.toGateDto(): ChangelogResponse { ) } -fun LegalEntityGateInputRequest.toLegalEntity(): LegalEntity { +fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalEntity { val addressInputRequest = AddressGateInputRequest( address = legalAddress, @@ -153,13 +154,15 @@ fun LegalEntityGateInputRequest.toLegalEntity(): LegalEntity { externalId = externalId, currentness = createCurrentnessTimestamp(), legalForm = legalEntity.legalForm, - legalName = Name(legalNameParts[0], legalEntity.legalShortName) + legalName = Name(legalNameParts[0], legalEntity.legalShortName), + dataType = datatype ) + legalEntity.identifiers.addAll(this.legalEntity.identifiers.map { toEntityIdentifier(it, legalEntity) }) legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) - legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, OutputInputEnum.Input) + legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, datatype) return legalEntity diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 2f8f59ea1..e395b5d1e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.entity.* @@ -37,7 +38,7 @@ class SitePersistenceService( ) { @Transactional - fun persistSitesBP(sites: Collection) { + fun persistSitesBP(sites: Collection, datatype: OutputInputEnum) { //Finds Site in DB val externalIdColl: MutableCollection = mutableListOf() @@ -51,12 +52,12 @@ class SitePersistenceService( legalEntityRepository.findByExternalId(site.legalEntityExternalId) ?: throw BpdmNotFoundException("Business Partner", it) } - val fullSite = site.toSiteGate(legalEntityRecord) + val fullSite = site.toSiteGate(legalEntityRecord, datatype) - siteRecord.find { it.externalId == site.externalId }?.let { existingSite -> + siteRecord.find { it.externalId == site.externalId && it.dataType == datatype }?.let { existingSite -> val logisticAddressRecord = - addressRepository.findByExternalId(getMainAddressForSiteExternalId(site.externalId)) ?: throw BpdmNotFoundException( + addressRepository.findByExternalIdAndDataType(getMainAddressForSiteExternalId(site.externalId), datatype) ?: throw BpdmNotFoundException( "Business Partner", "Error" ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index 280353941..2c7259486 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -25,6 +25,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.LsaType +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput @@ -56,9 +57,9 @@ class SiteService( fun getSites(page: Int, size: Int, externalIds: Collection? = null): PageResponse { val sitesPage = if (externalIds != null) { - siteRepository.findByExternalIdIn(externalIds, PageRequest.of(page, size)) + siteRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Input, PageRequest.of(page, size)) } else { - siteRepository.findAll(PageRequest.of(page, size)) + siteRepository.findByDataType(OutputInputEnum.Input, PageRequest.of(page, size)) } return PageResponse( @@ -77,7 +78,7 @@ class SiteService( } fun getSiteByExternalId(externalId: String): SiteGateInputResponse { - val siteRecord = siteRepository.findByExternalId(externalId) ?: throw BpdmNotFoundException("Site", externalId) + val siteRecord = siteRepository.findByExternalIdAndDataType(externalId, OutputInputEnum.Input) ?: throw BpdmNotFoundException("Site", externalId) return siteRecord.toSiteGateInputResponse(siteRecord) } @@ -146,12 +147,16 @@ class SiteService( */ fun upsertSites(sites: Collection) { - // create changelog entry if all goes well from saasClient sites.forEach { site -> changelogRepository.save(ChangelogEntry(site.externalId, LsaType.Site)) } - sitePersistenceService.persistSitesBP(sites) + sitePersistenceService.persistSitesBP(sites, OutputInputEnum.Input) + } + + fun upsertSitesOutput(sites: Collection) { + + sitePersistenceService.persistSitesBP(sites, OutputInputEnum.Output) } /** diff --git a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql index d0e39a011..e9364e30b 100644 --- a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql +++ b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql @@ -1,11 +1,26 @@ --- ALTER TABLE logistic_addresses ADD COLUMN data_type varchar(255) NOT NULL, --- ADD CONSTRAINT uk_data_type UNIQUE (data_type); - --- Remove the existing unique constraint on external_id +-- Remove the existing unique constraint on external_id (Addresses) ALTER TABLE logistic_addresses DROP CONSTRAINT IF EXISTS uk_7xolefhhm30nlfrp5fc25a3i2; --- Add the composite unique constraint on external_id and data_type +-- Add the composite unique constraint on external_id and data_type (Addresses) ALTER TABLE logistic_addresses ADD COLUMN data_type VARCHAR(255) NOT NULL, -ADD CONSTRAINT uk_external_id_data_type UNIQUE (external_id, data_type); \ No newline at end of file +ADD CONSTRAINT uk_external_id_data_type UNIQUE (external_id, data_type); + +-- Remove the existing unique constraint on external_id (Site) +ALTER TABLE sites +DROP CONSTRAINT IF EXISTS UK_1vrdeiex4x7p93r5svtvb5b4x; + +-- Add the composite unique constraint on external_id and data_type (Site) +ALTER TABLE sites +ADD COLUMN data_type VARCHAR(255) NOT NULL, +ADD CONSTRAINT uk_external_id_data_type_site UNIQUE (external_id, data_type); + +-- Remove the existing unique constraint on external_id (Site) +ALTER TABLE legal_entities +DROP CONSTRAINT IF EXISTS uk_fn3cbtgn4mcc8qprvf6nc33rb; + +-- Add the composite unique constraint on external_id and data_type (Site) +ALTER TABLE legal_entities +ADD COLUMN data_type VARCHAR(255) NOT NULL, +ADD CONSTRAINT uk_external_id_data_type_legalentity UNIQUE (external_id, data_type); \ No newline at end of file From 81886482699cc0b6273e968521d75e3e945c3dbd Mon Sep 17 00:00:00 2001 From: alexsilva Date: Mon, 5 Jun 2023 09:01:10 +0100 Subject: [PATCH 38/83] feat(gate): Changed Search Output logic on site/legalEntity --- .../bpdm/gate/api/GateLegalEntityApi.kt | 8 +- .../tractusx/bpdm/gate/api/GateSiteApi.kt | 8 +- .../model/LegalEntityGateOutputResponse.kt | 43 +++++++++++ .../gate/api/model/SiteGateOutputResponse.kt | 48 ++++++++++++ .../gate/controller/LegalEntityController.kt | 10 +-- .../bpdm/gate/controller/SiteController.kt | 8 +- .../bpdm/gate/service/AddressService.kt | 44 ----------- .../bpdm/gate/service/LegalEntityService.kt | 75 ++++--------------- .../bpdm/gate/service/ResponseMappings.kt | 30 +++++++- .../tractusx/bpdm/gate/service/SiteService.kt | 61 ++++----------- .../LegalEntityControllerOutputIT.kt | 7 +- .../gate/controller/SiteControllerOutputIT.kt | 6 +- 12 files changed, 167 insertions(+), 181 deletions(-) create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt index 63979ad81..7d5ed1392 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt @@ -29,9 +29,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput -import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -120,9 +118,9 @@ interface GateLegalEntityApi { @PostMapping("/output/legal-entities/search") @PostExchange("/output/legal-entities/search") fun getLegalEntitiesOutput( - @ParameterObject @Valid paginationRequest: PaginationStartAfterRequest, + @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody(required = false) externalIds: Collection? - ): PageOutputResponse + ): PageResponse @Operation( summary = "Create or update legal entities output.", diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt index 4d0550703..e3755e36e 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt @@ -29,9 +29,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput -import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType import org.springframework.http.ResponseEntity @@ -120,9 +118,9 @@ interface GateSiteApi { @PostMapping("/output/sites/search") @PostExchange("/output/sites/search") fun getSitesOutput( - @ParameterObject @Valid paginationRequest: PaginationStartAfterRequest, + @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody(required = false) externalIds: Collection? - ): PageOutputResponse + ): PageResponse @Operation( summary = "Create or update sites.", diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt new file mode 100644 index 000000000..912284111 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import java.time.LocalDateTime + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema(name = "LegalEntityGateOutputResponse", description = "Legal entity with external id") +data class LegalEntityGateOutputResponse( + @field:JsonUnwrapped + val legalEntity: LegalEntityDto, + + @Schema(description = "ID the record has in the external system where the record originates from", required = true) + val externalId: String, + + @Schema(description = "Business Partner Number") + val bpn: String?, + + @Schema(description = "Time the sharing process was started according to SaaS") + val processStartedAt: LocalDateTime? = null, +) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt new file mode 100644 index 000000000..b27ae86d5 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.SiteDto +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer +import java.time.LocalDateTime + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema( + name = "SiteGateOutputResponse", description = "Site with legal entity reference" +) +data class SiteGateOutputResponse( + @field:JsonUnwrapped + val site: SiteGateDto, + + @Schema(description = "ID the record has in the external system where the record originates from") + val externalId: String, + + @Schema(description = "External id of the related legal entity") + val legalEntityExternalId: String, + + @Schema(description = "Business Partner Number") + val bpn: String?, + + @Schema(description = "Time the sharing process was started according to SaaS") + val processStartedAt: LocalDateTime? = null, +) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt index f459b39b3..aa2e25658 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt @@ -24,9 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateLegalEntityApi import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput -import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.LegalEntityService @@ -64,10 +62,10 @@ class LegalEntityController( } override fun getLegalEntitiesOutput( - paginationRequest: PaginationStartAfterRequest, + paginationRequest: PaginationRequest, externalIds: Collection? - ): PageOutputResponse { - return legalEntityService.getLegalEntitiesOutput(externalIds, paginationRequest.limit, paginationRequest.startAfter) + ): PageResponse { + return legalEntityService.getLegalEntitiesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } override fun upsertLegalEntitiesOutput(legalEntities: Collection): ResponseEntity { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt index 3ad39e2e8..a08d4f7fd 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt @@ -24,9 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateSiteApi import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput -import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.SiteService @@ -63,8 +61,8 @@ class SiteController( return siteService.getSites(page = paginationRequest.page, size = paginationRequest.size) } - override fun getSitesOutput(paginationRequest: PaginationStartAfterRequest, externalIds: Collection?): PageOutputResponse { - return siteService.getSitesOutput(externalIds, paginationRequest.limit, paginationRequest.startAfter) + override fun getSitesOutput(paginationRequest: PaginationRequest, externalIds: Collection?): PageResponse { + return siteService.getSitesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } override fun upsertSitesOutput(sites: Collection): ResponseEntity { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index af09d41e9..87912f4c1 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -109,50 +109,6 @@ class AddressService( } } -// val partnerResponse = saasClient.getAddresses(limit = limit, startAfter = startAfter, externalIds = externalIds) -// val partners = partnerResponse.values -// -// val partnersWithExternalId = outputSaasMappingService.mapWithExternalId(partners) -// val augmentedPartnerResponse = saasClient.getAugmentedAddresses(externalIds = partnersWithExternalId.map { it.externalId }) -// val partnersWithLocalBpn = outputSaasMappingService.mapWithLocalBpn(partnersWithExternalId, augmentedPartnerResponse.values) -// -// //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.bpna } -// -// if (bpnSet.size > addressesByBpnMap.size) { -// logger.warn { "Requested ${bpnSet.size} addresses from pool, but only ${addressesByBpnMap.size} were found." } -// } -// -// val partnersWithPoolBpn = partnersWithLocalBpn.filter { addressesByBpnMap[it.bpn] != null } -// val bpnByExternalIdMap = partnersWithPoolBpn.map { Pair(it.partner.externalId!!, it.bpn) }.toMap() -// -// //Evaluate the sharing status of the legal entities -// val sharingStatus = outputSaasMappingService.evaluateSharingStatus(partners, partnersWithLocalBpn, partnersWithPoolBpn) -// -// val validAddresses = sharingStatus.validExternalIds.map { externalId -> -// val bpn = bpnByExternalIdMap[externalId]!! -// val address = addressesByBpnMap[bpn]!! -// toAddressOutput(externalId, address) -// } -// -// return PageOutputResponse( -// total = partnerResponse.total, -// nextStartAfter = partnerResponse.nextStartAfter, -// content = validAddresses, -// invalidEntries = partners.size - sharingStatus.validExternalIds.size, // difference between all entries from SaaS and valid content -// pending = sharingStatus.pendingExternalIds, -// errors = sharingStatus.errors, -// ) -// } - - fun toAddressOutput(externalId: String, address: LogisticAddressGateResponse): AddressGateOutput { - return AddressGateOutput( - address = address, - externalId = externalId - ) - } - /** * Upsert addresses by: * diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index fccb21d90..8c2e9369b 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -20,17 +20,13 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutput +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.LsaType -import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository @@ -92,69 +88,26 @@ class LegalEntityService( * Get legal entities by first fetching legal entities from "augmented business partners" in SaaS. Augmented business partners from SaaS should contain a BPN, * which is then used to fetch the data for the legal entities from the bpdm pool. */ - fun getLegalEntitiesOutput(externalIds: Collection?, limit: Int, startAfter: String?): PageOutputResponse { - val partnerResponse = saasClient.getLegalEntities(limit = limit, startAfter = startAfter, externalIds = externalIds) - val partners = partnerResponse.values + fun getLegalEntitiesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { - val partnersWithExternalId = outputSaasMappingService.mapWithExternalId(partners) - val augmentedPartnerResponse = saasClient.getAugmentedLegalEntities(externalIds = partnersWithExternalId.map { it.externalId }) - val partnersWithLocalBpn = outputSaasMappingService.mapWithLocalBpn(partnersWithExternalId, augmentedPartnerResponse.values) + val legalEntityPage = legalEntityRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) - //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.legalEntity.bpnl } - val legalAddressesByBpnMap = poolClient.searchLegalAddresses(bpnSet).associateBy { it.bpnLegalEntity } - - if (bpnSet.size > legalEntitiesByBpnMap.size) { - logger.warn { "Requested ${bpnSet.size} legal entities from pool, but only ${legalEntitiesByBpnMap.size} were found." } - } - if (bpnSet.size > legalAddressesByBpnMap.size) { - logger.warn { "Requested ${bpnSet.size} legal addresses from pool, but only ${legalAddressesByBpnMap.size} were found." } - } - - //Filter only legal entities which can be found with their legal address in the Pool under the given local BPN - val partnersWithPoolBpn = partnersWithLocalBpn.filter { legalEntitiesByBpnMap[it.bpn] != null && legalAddressesByBpnMap[it.bpn] != null } - val bpnByExternalIdMap = partnersWithPoolBpn.associate { Pair(it.externalId, it.bpn) } + return PageResponse( + page = page, + totalElements = legalEntityPage.totalElements, + totalPages = legalEntityPage.totalPages, + contentSize = legalEntityPage.content.size, + content = toValidOutputLegalEntities(legalEntityPage), + ) - //Evaluate the sharing status of the legal entities - val sharingStatus = outputSaasMappingService.evaluateSharingStatus(partners, partnersWithLocalBpn, partnersWithPoolBpn) + } - val validLegalEntities = sharingStatus.validExternalIds.map { externalId -> - val bpn = bpnByExternalIdMap[externalId]!! - val legalEntity = legalEntitiesByBpnMap[bpn]!! - val legalAddress = legalAddressesByBpnMap[bpn]!! - toLegalEntityOutput(externalId, legalEntity, legalAddress) + private fun toValidOutputLegalEntities(legalEntityPage: Page): List { + return legalEntityPage.content.map { legalEntity -> + legalEntity.toLegalEntityGateOutputResponse(legalEntity) } - - return PageOutputResponse( - total = partnerResponse.total, - nextStartAfter = partnerResponse.nextStartAfter, - content = validLegalEntities, - invalidEntries = partners.size - sharingStatus.validExternalIds.size, // difference between all entries from SaaS and valid content - pending = sharingStatus.pendingExternalIds, - errors = sharingStatus.errors, - ) } - fun toLegalEntityOutput(externalId: String, legalEntityPool: PoolLegalEntityResponse, legalAddress: LogisticAddressGateResponse): LegalEntityGateOutput = - LegalEntityGateOutput( - legalEntity = LegalEntityResponse( - bpnl = legalEntityPool.legalEntity.bpnl, - identifiers = legalEntityPool.legalEntity.identifiers, - legalShortName = legalEntityPool.legalEntity.legalShortName, - legalForm = legalEntityPool.legalEntity.legalForm, - states = legalEntityPool.legalEntity.states, - classifications = legalEntityPool.legalEntity.classifications, - relations = legalEntityPool.legalEntity.relations, - currentness = legalEntityPool.legalEntity.currentness, - createdAt = legalEntityPool.legalEntity.createdAt, - updatedAt = legalEntityPool.legalEntity.updatedAt, - ), - legalAddress = legalAddress, - legalNameParts = arrayOf(legalEntityPool.legalName), - externalId = externalId - ) - private fun toValidLegalEntities(legalEntityPage: Page): List { return legalEntityPage.content.map { legalEntity -> legalEntity.LegalEntityGateInputResponse(legalEntity) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 5b35921ac..b379ec446 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -342,7 +342,7 @@ fun mapToDtoSitesStates(states: MutableSet): Collection return states.map { SiteStateDto(it.description, it.validFrom, it.validTo, it.type) } } -//LegalEntity mapping to LegalEntityGateInputResponse +//Site mapping to SiteGateInputResponse fun Site.toSiteGateInputResponse(sitePage: Site): SiteGateInputResponse { return SiteGateInputResponse( @@ -354,7 +354,7 @@ fun Site.toSiteGateInputResponse(sitePage: Site): SiteGateInputResponse { } -//Logistic Address mapping to AddressGateInputResponse +//Logistic Address mapping to AddressGateOutputResponse fun LogisticAddress.toAddressGateOutputResponse(logisticAddressPage: LogisticAddress): AddressGateOutputResponse { val addressGateOutputResponse = AddressGateOutputResponse( @@ -367,3 +367,29 @@ fun LogisticAddress.toAddressGateOutputResponse(logisticAddressPage: LogisticAdd return addressGateOutputResponse } + +//Site mapping to SiteGateOutputResponse +fun Site.toSiteGateOutputResponse(sitePage: Site): SiteGateOutputResponse { + + return SiteGateOutputResponse( + site = sitePage.toSiteDto(), + externalId = externalId, + legalEntityExternalId = legalEntity.externalId, + bpn = bpn, + processStartedAt = null //TODO Remove this? + ) + +} + +//LegalEntity mapping to LegalEntityGateOutputResponse +fun LegalEntity.toLegalEntityGateOutputResponse(legalEntity: LegalEntity): LegalEntityGateOutputResponse { + + return LegalEntityGateOutputResponse( + legalEntity = legalEntity.toLegalEntityDto(), + externalId = legalEntity.externalId, + bpn = legalEntity.bpn, + processStartedAt = null //TODO Remove this? + ) +} + + diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index 2c7259486..4023f5f3a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -21,16 +21,13 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutput -import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.entity.Site @@ -87,56 +84,26 @@ class SiteService( * Get sites by first fetching sites from "augmented business partners" in SaaS. Augmented business partners from SaaS should contain a BPN, * which is then used to fetch the data for the sites from the bpdm pool. */ - fun getSitesOutput(externalIds: Collection?, limit: Int, startAfter: String?): PageOutputResponse { - val partnerResponse = saasClient.getSites(limit = limit, startAfter = startAfter, externalIds = externalIds) - val partners = partnerResponse.values + fun getSitesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { - val partnersWithExternalId = outputSaasMappingService.mapWithExternalId(partners) - val augmentedPartnerResponse = saasClient.getAugmentedSites(externalIds = partnersWithExternalId.map { it.externalId }) - val partnersWithLocalBpn = outputSaasMappingService.mapWithLocalBpn(partnersWithExternalId, augmentedPartnerResponse.values) + val sitePage = siteRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) - val bpnSet = partnersWithLocalBpn.map { it.bpn }.toSet() - val sitesByBpnMap = poolClient.searchSites(bpnSet).associateBy { it.bpns } - val mainAddressesByBpnMap = poolClient.searchMainAddresses(bpnSet).associateBy { it.bpnSite } - - if (bpnSet.size > sitesByBpnMap.size) { - logger.warn { "Requested ${bpnSet.size} sites from pool, but only ${sitesByBpnMap.size} were found." } - } - if (bpnSet.size > mainAddressesByBpnMap.size) { - logger.warn { "Requested ${bpnSet.size} main addresses of sites from pool, but only ${mainAddressesByBpnMap.size} were found." } - } - - //Filter only sites which can be found with their main address in the Pool under the given local BPN - val partnersWithPoolBpn = partnersWithLocalBpn.filter { sitesByBpnMap[it.bpn] != null && mainAddressesByBpnMap[it.bpn] != null } - val bpnByExternalIdMap = partnersWithPoolBpn.map { Pair(it.partner.externalId!!, it.bpn) }.toMap() + return PageResponse( + page = page, + totalElements = sitePage.totalElements, + totalPages = sitePage.totalPages, + contentSize = sitePage.content.size, + content = toValidOutputSites(sitePage), + ) - //Evaluate the sharing status of the legal entities - val sharingStatus = outputSaasMappingService.evaluateSharingStatus(partners, partnersWithLocalBpn, partnersWithPoolBpn) + } - val validSites = sharingStatus.validExternalIds.map { externalId -> - val bpn = bpnByExternalIdMap[externalId]!! - val site = sitesByBpnMap[bpn]!! - val mainAddress = mainAddressesByBpnMap[bpn]!! - toSiteOutput(externalId, site, mainAddress) + private fun toValidOutputSites(sitePage: Page): List { + return sitePage.content.map { sites -> + sites.toSiteGateOutputResponse(sites) } - - return PageOutputResponse( - total = partnerResponse.total, - nextStartAfter = partnerResponse.nextStartAfter, - content = validSites, - invalidEntries = partners.size - sharingStatus.validExternalIds.size, // difference between all entries from SaaS and valid content - pending = sharingStatus.pendingExternalIds, - errors = sharingStatus.errors, - ) } - fun toSiteOutput(externalId: String, site: SiteResponse, mainAddress: LogisticAddressGateResponse) = - SiteGateOutput( - site = site, - mainAddress = mainAddress, - externalId = externalId - ) - /** * Upsert sites by: * diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt index 031d6bd8c..2aed005eb 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt @@ -23,11 +23,12 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension +import org.assertj.core.api.Assertions.assertThat +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError -import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.util.* @@ -176,7 +177,7 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter, limit) + val paginationValue = PaginationRequest(0, 10) val pageResponse = gateClient.legalEntities().getLegalEntitiesOutput(paginationValue, emptyList()) val expectedResponse = PageOutputResponse( total = total, @@ -281,7 +282,7 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter, limit) + val paginationValue = PaginationRequest(0, 10) val pageResponse = gateClient.legalEntities().getLegalEntitiesOutput(paginationValue, listOf(CommonValues.externalId1, CommonValues.externalId2)) val expectedResponse = PageOutputResponse( total = total, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt index ee30bc563..d057f3621 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt @@ -24,12 +24,12 @@ import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError -import org.eclipse.tractusx.bpdm.gate.api.model.request.PaginationStartAfterRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse import org.eclipse.tractusx.bpdm.gate.util.* @@ -182,7 +182,7 @@ internal class SiteControllerOutputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter, limit) + val paginationValue = PaginationRequest(0, 10) val pageResponseValue = gateClient.sites().getSitesOutput(paginationValue, emptyList()) assertThat(pageResponseValue).isEqualTo( @@ -295,7 +295,7 @@ internal class SiteControllerOutputIT @Autowired constructor( ) ) - val paginationValue = PaginationStartAfterRequest(startAfter, limit) + val paginationValue = PaginationRequest(0, 10) val pageResponseValue = gateClient.sites().getSitesOutput(paginationValue, listOf(CommonValues.externalIdSite1, CommonValues.externalIdSite2)) assertThat(pageResponseValue).isEqualTo( From 40a69a972a06ead2323f6fe9b015e42ef7b5feeb Mon Sep 17 00:00:00 2001 From: alexsilva Date: Mon, 5 Jun 2023 10:44:19 +0100 Subject: [PATCH 39/83] feat(gate): Added verification on persistence upon saving output data. Show 400 if there isn't an Equal Input persisted --- .../bpdm/gate/service/AddressPersistenceService.kt | 12 +++++++++--- .../gate/service/LegalEntityPersistenceService.kt | 13 ++++++++----- .../bpdm/gate/service/SitePersistenceService.kt | 13 +++++++++++-- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index 7e4e3e912..9c859de5c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -29,7 +29,9 @@ import org.eclipse.tractusx.bpdm.gate.entity.Site import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository +import org.springframework.http.HttpStatus import org.springframework.stereotype.Service +import org.springframework.web.server.ResponseStatusException @Service class AddressPersistenceService( @@ -48,8 +50,8 @@ class AddressPersistenceService( addresses.forEach { address -> - val legalEntityRecord = address.legalEntityExternalId?.let { legalEntityRepository.findByExternalId(it) } - val siteRecord = address.siteExternalId?.let { siteEntityRepository.findByExternalId(it) } + val legalEntityRecord = address.legalEntityExternalId?.let { legalEntityRepository.findByExternalIdAndDataType(it, dataType) } + val siteRecord = address.siteExternalId?.let { siteEntityRepository.findByExternalIdAndDataType(it, dataType) } val fullAddress = address.toAddressGate(legalEntityRecord, siteRecord, dataType) @@ -57,7 +59,11 @@ class AddressPersistenceService( updateAddress(existingAddress, address, legalEntityRecord, siteRecord) gateAddressRepository.save(existingAddress) } ?: run { - gateAddressRepository.save(fullAddress) + if (fullAddress.dataType == OutputInputEnum.Output && addressRecord.find { it.externalId == fullAddress.externalId && it.dataType == OutputInputEnum.Input } == null) { + throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Logistic Address doesn't exist") + } else { + gateAddressRepository.save(fullAddress) + } } } } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 1f81be37d..5b09c58c6 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -27,8 +27,10 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.entity.* import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository +import org.springframework.http.HttpStatus import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional +import org.springframework.web.server.ResponseStatusException @Service class LegalEntityPersistenceService( @@ -52,15 +54,16 @@ class LegalEntityPersistenceService( ?: throw BpdmNotFoundException("Business Partner", "Error") updateAddress(logisticAddressRecord, fullLegalEntity.legalAddress) - updateLegalEntity(existingLegalEntity, legalEntity, logisticAddressRecord) - gateLegalEntityRepository.save(existingLegalEntity) + gateLegalEntityRepository.save(existingLegalEntity) } ?: run { - - gateLegalEntityRepository.save(fullLegalEntity) + if (fullLegalEntity.dataType == OutputInputEnum.Output && legalEntityRecord.find { it.externalId == fullLegalEntity.externalId && it.dataType == OutputInputEnum.Input } == null) { + throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Legal Entity doesn't exist") + } else { + gateLegalEntityRepository.save(fullLegalEntity) + } } - } } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index e395b5d1e..8aefe380a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -27,8 +27,10 @@ import org.eclipse.tractusx.bpdm.gate.entity.* import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository +import org.springframework.http.HttpStatus import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional +import org.springframework.web.server.ResponseStatusException @Service class SitePersistenceService( @@ -49,7 +51,10 @@ class SitePersistenceService( val legalEntityRecord = site.legalEntityExternalId.let { - legalEntityRepository.findByExternalId(site.legalEntityExternalId) ?: throw BpdmNotFoundException("Business Partner", it) + legalEntityRepository.findByExternalIdAndDataType(site.legalEntityExternalId, datatype) ?: throw BpdmNotFoundException( + "Business Partner", + it + ) } val fullSite = site.toSiteGate(legalEntityRecord, datatype) @@ -68,7 +73,11 @@ class SitePersistenceService( siteRepository.save(existingSite) } ?: run { - siteRepository.save(fullSite) + if (fullSite.dataType == OutputInputEnum.Output && siteRecord.find { it.externalId == fullSite.externalId && it.dataType == OutputInputEnum.Input } == null) { + throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Site doesn't exist") + } else { + siteRepository.save(fullSite) + } } } } From 7930152b7770169984b8878852ce47b39452451c Mon Sep 17 00:00:00 2001 From: alexsilva Date: Tue, 6 Jun 2023 11:24:33 +0100 Subject: [PATCH 40/83] feat(gate): Changed migration logic to account with database data, Fixed Output unit tests according to new logic, Fixed API descriptions --- .../tractusx/bpdm/gate/api/GateAddressApi.kt | 12 +- .../bpdm/gate/api/GateLegalEntityApi.kt | 7 +- .../tractusx/bpdm/gate/api/GateSiteApi.kt | 7 +- .../bpdm/gate/service/AddressService.kt | 26 +- .../bpdm/gate/service/LegalEntityService.kt | 18 +- .../tractusx/bpdm/gate/service/SiteService.kt | 23 +- .../V0_1_6_0__add_input_or_output_collumn.sql | 6 +- .../controller/AddressControllerOutputIT.kt | 286 ++++++--------- .../LegalEntityControllerOutputIT.kt | 312 ++++++---------- .../gate/controller/SiteControllerOutputIT.kt | 344 +++++++----------- 10 files changed, 407 insertions(+), 634 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt index 005d1315d..273b08c5e 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt @@ -110,8 +110,8 @@ interface GateAddressApi { fun getAddresses(@ParameterObject @Valid paginationRequest: PaginationRequest): PageResponse @Operation( - summary = "Get page of addresses", - description = "Get page of addresses. Can optionally be filtered by external ids." + summary = "Get page of addresses (Output)", + description = "Get page of addresses (Output). Can optionally be filtered by external ids." ) @ApiResponses( value = [ @@ -127,9 +127,11 @@ interface GateAddressApi { ): PageResponse @Operation( - summary = "Create or update output addresses.", //TODO Needs description update - description = "Create or update addresses. " + - "Test new endpoint" + summary = "Create or update output addresses.", + description = "Create or update addresses (Output). " + + "Updates instead of creating a new address if an already existing external id is used. " + + "The same external id may not occur more than once in a single request. " + + "For a single request, the maximum number of addresses in the request is limited to \${bpdm.api.upsert-limit} entries." ) @ApiResponses( diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt index 7d5ed1392..04f614496 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt @@ -123,8 +123,11 @@ interface GateLegalEntityApi { ): PageResponse @Operation( - summary = "Create or update legal entities output.", - description = "Create or update legal entities. " //TODO need better description + summary = "Create or update output legal entities.", + description = "Create or update legal entities (Output). " + + "Updates instead of creating a new legal entity if an already existing external id is used. " + + "The same external id may not occur more than once in a single request. " + + "For a single request, the maximum number of legal entities in the request is limited to \${bpdm.api.upsert-limit} entries." ) @ApiResponses( value = [ diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt index e3755e36e..f10627acb 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt @@ -123,8 +123,11 @@ interface GateSiteApi { ): PageResponse @Operation( - summary = "Create or update sites.", - description = "Create or update sites. " //TODO Need better description + summary = "Create or update output sites.", + description = "Create or update sites (Output). " + + "Updates instead of creating a new site if an already existing external id is used. " + + "The same external id may not occur more than once in a single request. " + + "For a single request, the maximum number of sites in the request is limited to \${bpdm.api.upsert-limit} entries." ) @ApiResponses( value = [ diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index 87912f4c1..bac140c62 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -26,9 +26,7 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutput import org.eclipse.tractusx.bpdm.gate.api.model.LsaType -import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry @@ -45,7 +43,6 @@ class AddressService( private val saasRequestMappingService: SaasRequestMappingService, private val outputSaasMappingService: OutputSaasMappingService, private val saasClient: SaasClient, - private val poolClient: PoolClient, private val bpnConfigProperties: BpnConfigProperties, private val changelogRepository: ChangelogRepository, private val addressPersistenceService: AddressPersistenceService, @@ -86,12 +83,15 @@ class AddressService( } /** - * Get addresses by first fetching addresses from "augmented business partners" in SaaS. Augmented business partners from SaaS should contain a BPN, - * which is then used to fetch the data for the addresses from the bpdm pool. + * Get output addresses by fetching addresses from the database. */ - fun getAddressesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { + fun getAddressesOutput(externalIds: Collection? = null, page: Int, size: Int): PageResponse { - val logisticAddressPage = addressRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) + val logisticAddressPage = if (externalIds != null && externalIds.isNotEmpty()) { + addressRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) + } else { + addressRepository.findByDataType(OutputInputEnum.Output, PageRequest.of(page, size)) + } return PageResponse( page = page, @@ -110,13 +110,8 @@ class AddressService( } /** - * Upsert addresses by: - * - * - Retrieving parent legal entities and sites to check whether they exist and since their identifiers are copied to site - * - Upserting the addresses - * - Retrieving the old relations of the addresses and deleting them - * - Upserting the new relations - */ + * Upsert addresses input to the database + **/ fun upsertAddresses(addresses: Collection) { // create changelog entry if all goes well from saasClient @@ -127,6 +122,9 @@ class AddressService( addressPersistenceService.persistAddressBP(addresses, OutputInputEnum.Input) } + /** + * Upsert addresses output to the database + **/ fun upsertOutputAddresses(addresses: Collection) { addressPersistenceService.persistAddressBP(addresses, OutputInputEnum.Output) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 8c2e9369b..3d197fc44 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -37,9 +37,6 @@ import org.springframework.stereotype.Service @Service class LegalEntityService( - private val outputSaasMappingService: OutputSaasMappingService, - private val saasClient: SaasClient, - private val poolClient: PoolClient, private val changelogRepository: ChangelogRepository, private val legalEntityPersistenceService: LegalEntityPersistenceService, private val legalEntityRepository: LegalEntityRepository @@ -47,6 +44,9 @@ class LegalEntityService( private val logger = KotlinLogging.logger { } + /** + * Upsert legal entities input to the database + **/ fun upsertLegalEntities(legalEntities: Collection) { legalEntities.forEach { legalEntity -> @@ -55,6 +55,9 @@ class LegalEntityService( legalEntityPersistenceService.persistLegalEntitiesBP(legalEntities, OutputInputEnum.Input) } + /** + * Upsert legal entities output to the database + **/ fun upsertLegalEntitiesOutput(legalEntities: Collection) { legalEntityPersistenceService.persistLegalEntitiesBP(legalEntities, OutputInputEnum.Output) @@ -85,12 +88,15 @@ class LegalEntityService( } /** - * Get legal entities by first fetching legal entities from "augmented business partners" in SaaS. Augmented business partners from SaaS should contain a BPN, - * which is then used to fetch the data for the legal entities from the bpdm pool. + * Get output legal entities by first fetching legal entities from the database */ fun getLegalEntitiesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { - val legalEntityPage = legalEntityRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) + val legalEntityPage = if (externalIds != null && externalIds.isNotEmpty()) { + legalEntityRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) + } else { + legalEntityRepository.findByDataType(OutputInputEnum.Output, PageRequest.of(page, size)) + } return PageResponse( page = page, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index 4023f5f3a..3c8e7bf02 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -41,9 +41,7 @@ import org.springframework.stereotype.Service @Service class SiteService( private val saasRequestMappingService: SaasRequestMappingService, - private val outputSaasMappingService: OutputSaasMappingService, private val saasClient: SaasClient, - private val poolClient: PoolClient, private val bpnConfigProperties: BpnConfigProperties, private val changelogRepository: ChangelogRepository, private val sitePersistenceService: SitePersistenceService, @@ -81,12 +79,15 @@ class SiteService( } /** - * Get sites by first fetching sites from "augmented business partners" in SaaS. Augmented business partners from SaaS should contain a BPN, - * which is then used to fetch the data for the sites from the bpdm pool. + * Get output sites by first fetching sites from the database */ fun getSitesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { - val sitePage = siteRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) + val sitePage = if (externalIds != null && externalIds.isNotEmpty()) { + siteRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) + } else { + siteRepository.findByDataType(OutputInputEnum.Output, PageRequest.of(page, size)) + } return PageResponse( page = page, @@ -105,13 +106,8 @@ class SiteService( } /** - * Upsert sites by: - * - * - Retrieving parent legal entities to check whether they exist and since their identifiers are copied to site - * - Upserting the sites - * - Retrieving the old relations of the sites and deleting them - * - Upserting the new relations - */ + * Upsert sites input to the database + **/ fun upsertSites(sites: Collection) { sites.forEach { site -> @@ -121,6 +117,9 @@ class SiteService( sitePersistenceService.persistSitesBP(sites, OutputInputEnum.Input) } + /** + * Upsert sites output to the database + **/ fun upsertSitesOutput(sites: Collection) { sitePersistenceService.persistSitesBP(sites, OutputInputEnum.Output) diff --git a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql index e9364e30b..224f529ce 100644 --- a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql +++ b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql @@ -4,7 +4,7 @@ DROP CONSTRAINT IF EXISTS uk_7xolefhhm30nlfrp5fc25a3i2; -- Add the composite unique constraint on external_id and data_type (Addresses) ALTER TABLE logistic_addresses -ADD COLUMN data_type VARCHAR(255) NOT NULL, +ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'input', ADD CONSTRAINT uk_external_id_data_type UNIQUE (external_id, data_type); -- Remove the existing unique constraint on external_id (Site) @@ -13,7 +13,7 @@ DROP CONSTRAINT IF EXISTS UK_1vrdeiex4x7p93r5svtvb5b4x; -- Add the composite unique constraint on external_id and data_type (Site) ALTER TABLE sites -ADD COLUMN data_type VARCHAR(255) NOT NULL, +ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'input', ADD CONSTRAINT uk_external_id_data_type_site UNIQUE (external_id, data_type); -- Remove the existing unique constraint on external_id (Site) @@ -22,5 +22,5 @@ DROP CONSTRAINT IF EXISTS uk_fn3cbtgn4mcc8qprvf6nc33rb; -- Add the composite unique constraint on external_id and data_type (Site) ALTER TABLE legal_entities -ADD COLUMN data_type VARCHAR(255) NOT NULL, +ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'input', ADD CONSTRAINT uk_external_id_data_type_legalentity UNIQUE (external_id, data_type); \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt index 3dc132b34..67748f1a9 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt @@ -38,37 +38,36 @@ package org.eclipse.tractusx.bpdm.gate.controller -import com.fasterxml.jackson.databind.ObjectMapper import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas -import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError -import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.util.* -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_ADDRESSES_SEARCH_PATH -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.HttpStatus import org.springframework.test.context.ActiveProfiles import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource +import org.springframework.web.reactive.function.client.WebClientResponseException @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class AddressControllerOutputIT @Autowired constructor( - private val objectMapper: ObjectMapper, - val gateClient: GateClient + val gateClient: GateClient, + private val gateAddressRepository: GateAddressRepository, + val testHelpers: DbTestHelpers ) { companion object { @RegisterExtension @@ -89,211 +88,138 @@ internal class AddressControllerOutputIT @Autowired constructor( } } + @BeforeEach + fun beforeEach() { + testHelpers.truncateDbTables() + } + /** - * Given addresses exists in SaaS and bpdm pool - * When getting addresses page via output route - * Then addresses page should be returned + * If there is an Input Address persisted, + * upsert the Output with same external id */ @Test - fun `get addresses`() { - val expectedAddresses = listOf( - ResponseValues.addressGateOutput1, - ResponseValues.addressGateOutput2 + fun `upsert output addresses`() { + val addresses = listOf( + RequestValues.addressGateInputRequest1, + RequestValues.addressGateInputRequest2 ) - val expectedErrors = listOf( - ErrorInfo(BusinessPartnerSharingError.BpnNotInPool, "BPNA0000000003X9 not found in pool", SaasValues.addressNotInPoolResponse.externalId), - ErrorInfo( - BusinessPartnerSharingError.SharingProcessError, - "SaaS sharing process error: Error message", - SaasValues.addressSharingErrorResponse.externalId - ), - ) - val expectedPending = listOf(SaasValues.addressPendingResponse.externalId!!) - val addressesSaas = listOf( - SaasValues.addressBusinessPartner1, - SaasValues.addressBusinessPartner2, - SaasValues.addressNotInPoolResponse, - SaasValues.addressSharingErrorResponse, - SaasValues.addressPendingResponse, - ) + try { + gateClient.addresses().upsertAddresses(addresses) + gateClient.addresses().putAddressesOutput(addresses) + } catch (e: WebClientResponseException) { + Assertions.assertEquals(HttpStatus.OK, e.statusCode) + } - val addressesPool = listOf( - ResponseValues.logisticAddress1, - ResponseValues.logisticAddress2 - ) + //Check if persisted Address data + val addressExternal1 = gateAddressRepository.findByExternalIdAndDataType("address-external-1", OutputInputEnum.Output) + Assertions.assertNotEquals(addressExternal1, null) - val limit = 2 - val startAfter = "Aaa111" - val nextStartAfter = "Aaa222" - val total = 10 + val addressExternal2 = gateAddressRepository.findByExternalIdAndDataType("address-external-2", OutputInputEnum.Output) + Assertions.assertNotEquals(addressExternal2, null) - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - nextStartAfter = nextStartAfter, - total = total, - values = addressesSaas.map { AugmentedBusinessPartnerResponseSaas(it) } - ) - ) - ) - ) + } + + /** + * If there isn't an Input Address persisted, + * when upserting an output address, it should show an 400 + */ + @Test + fun `upsert output addresses, no input persisted`() { + val addresses = listOf( + RequestValues.addressGateInputRequest1, + RequestValues.addressGateInputRequest2 ) - wireMockServerSaas.stubFor( - get(urlPathMatching(EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - startAfter = startAfter, - nextStartAfter = nextStartAfter, - total = total, - values = addressesSaas - ) - ) - ) - ) + try { + gateClient.addresses().putAddressesOutput(addresses) + } catch (e: WebClientResponseException) { + Assertions.assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) + } + + } + + /** + * Given output addresses exists in the database + * When getting addresses page via output route + * Then addresses page should be returned + */ + @Test + fun `get output addresses`() { + val addresses = listOf( + RequestValues.addressGateInputRequest1, + RequestValues.addressGateInputRequest2 ) - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_ADDRESSES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PageResponse( - totalElements = addressesPool.size.toLong(), - totalPages = 1, - page = 0, - contentSize = addressesPool.size, - content = addressesPool - ) - ) - ) - ) + val expectedAddresses = listOf( + ResponseValues.logisticAddressGateInputResponse1, + ResponseValues.logisticAddressGateInputResponse2, ) - val paginationValue = PaginationRequest(0, 10) + val page = 0 + val size = 10 + + val totalElements = 2L + val totalPages = 1 + val pageValue = 0 + val contentSize = 2 + + gateClient.addresses().upsertAddresses(addresses) + gateClient.addresses().putAddressesOutput(addresses) + + + val paginationValue = PaginationRequest(page, size) val pageResponse = gateClient.addresses().getAddressesOutput(paginationValue, emptyList()) - assertThat(pageResponse).isEqualTo( - PageOutputResponse( - total = total, - nextStartAfter = nextStartAfter, - content = expectedAddresses, - invalidEntries = expectedPending.size + expectedErrors.size, - pending = expectedPending, - errors = expectedErrors, + assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*processStartedAt*").isEqualTo( + PageResponse( + totalElements = totalElements, + totalPages = totalPages, + page = pageValue, + contentSize = contentSize, + content = expectedAddresses ) ) } /** - * Given addresses exists in SaaS and bpdm pool + * Given addresses exists in the database * When getting addresses page via output route filtering by external ids * Then addresses page should be returned */ @Test fun `get addresses, filter by external ids`() { - val expectedAddresses = listOf( - ResponseValues.addressGateOutput1, - ResponseValues.addressGateOutput2 + val addresses = listOf( + RequestValues.addressGateInputRequest1, + RequestValues.addressGateInputRequest2 ) - val addressesSaas = listOf( - SaasValues.addressBusinessPartner1, - SaasValues.addressBusinessPartner2 + val expectedAddresses = listOf( + ResponseValues.logisticAddressGateInputResponse1, + ResponseValues.logisticAddressGateInputResponse2, ) - val addressesPool = listOf( - ResponseValues.logisticAddress1, - ResponseValues.logisticAddress2 - ) + val page = 0 + val size = 10 - val limit = 2 - val startAfter = "Aaa111" - val nextStartAfter = "Aaa222" - val total = 10 + val totalElements = 2L + val totalPages = 1 + val pageValue = 0 + val contentSize = 2 - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH)) - .withQueryParam("externalIds", equalTo(listOf(CommonValues.externalIdAddress1, CommonValues.externalIdAddress2).joinToString(","))) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - nextStartAfter = nextStartAfter, - total = total, - values = addressesSaas.map { AugmentedBusinessPartnerResponseSaas(it) } - ) - ) - ) - ) - ) - - wireMockServerSaas.stubFor( - get(urlPathMatching(EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - startAfter = startAfter, - nextStartAfter = nextStartAfter, - total = total, - values = addressesSaas - ) - ) - ) - ) - ) - - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_ADDRESSES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PageResponse( - totalElements = addressesPool.size.toLong(), - totalPages = 1, - page = 0, - contentSize = addressesPool.size, - content = addressesPool - ) - ) - ) - ) - ) + gateClient.addresses().upsertAddresses(addresses) + gateClient.addresses().putAddressesOutput(addresses) - val paginationValue = PaginationRequest(0, 10) + val paginationValue = PaginationRequest(page, size) val pageResponse = gateClient.addresses().getAddressesOutput(paginationValue, listOf(CommonValues.externalIdAddress1, CommonValues.externalIdAddress2)) - assertThat(pageResponse).isEqualTo( - PageOutputResponse( - total = total, - nextStartAfter = nextStartAfter, - content = expectedAddresses, - invalidEntries = 0, - pending = listOf(), - errors = listOf(), + assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*processStartedAt*").isEqualTo( + PageResponse( + totalElements = totalElements, + totalPages = totalPages, + page = pageValue, + contentSize = contentSize, + content = expectedAddresses ) ) } diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt index 2aed005eb..07d8afa0e 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt @@ -19,38 +19,35 @@ package org.eclipse.tractusx.bpdm.gate.controller -import com.fasterxml.jackson.databind.ObjectMapper import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas -import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas +import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError -import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.gate.util.* -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_LEGAL_ADDRESSES_SEARCH_PATH -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_LEGAL_ENTITIES_SEARCH_PATH -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.HttpStatus import org.springframework.test.context.ActiveProfiles import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource +import org.springframework.web.reactive.function.client.WebClientResponseException @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class LegalEntityControllerOutputIT @Autowired constructor( - private val objectMapper: ObjectMapper, val gateClient: GateClient, + private val gateLegalEntityRepository: LegalEntityRepository, private val testHelpers: DbTestHelpers ) { companion object { @@ -72,226 +69,143 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( } } + @BeforeEach + fun beforeEach() { + testHelpers.truncateDbTables() + } + /** - * Given legal entities exists in SaaS and bpdm pool - * When getting legal entities page via output route - * Then legal entities page should be returned + * If there is an Input Legal Entity persisted, + * upsert the Output with same external id */ @Test - fun `get legal entities`() { - val expectedLegalEntities = listOf( - ResponseValues.legalEntityGateOutput1, - ResponseValues.legalEntityGateOutput2 - ) - val expectedErrors = listOf( - ErrorInfo( - BusinessPartnerSharingError.BpnNotInPool, - "BPNL0000000002XY not found in pool", - SaasValues.legalEntityAugmentedNotInPoolResponse.externalId - ), - ErrorInfo( - BusinessPartnerSharingError.SharingProcessError, - "SaaS sharing process error: Error message", - SaasValues.legalEntityAugmentedSharingErrorResponse.externalId - ), - ) - val expectedPending = listOf(SaasValues.legalEntityAugmentedPendingResponse.externalId!!) - - val legalEntitiesSaas = listOf( - SaasValues.legalEntityAugmented1, - SaasValues.legalEntityAugmented2, - SaasValues.legalEntityAugmentedNotInPoolResponse, - SaasValues.legalEntityAugmentedSharingErrorResponse, - SaasValues.legalEntityAugmentedPendingResponse, - ) + fun `upsert output legal entities`() { - val legalEntitiesPool = listOf( - ResponseValues.legalEntityResponsePool1, - ResponseValues.legalEntityResponsePool2 - ) - val legalAddressesPool = listOf( - ResponseValues.logisticAddress1, - ResponseValues.logisticAddress2 + val legalEntities = listOf( + RequestValues.legalEntityGateInputRequest1, + RequestValues.legalEntityGateInputRequest2, ) - val limit = 2 - val startAfter = "Aaa111" - val nextStartAfter = "Aaa222" - val total = 10 - - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - nextStartAfter = nextStartAfter, - total = total, - values = legalEntitiesSaas.map { AugmentedBusinessPartnerResponseSaas(it) } - ) - ) - ) - ) - ) + try { + gateClient.legalEntities().upsertLegalEntities(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + } catch (e: WebClientResponseException) { + Assertions.assertEquals(HttpStatus.OK, e.statusCode) + } + + //Check if persisted Address data + val legalEntityExternal1 = gateLegalEntityRepository.findByExternalIdAndDataType(CommonValues.externalId1, OutputInputEnum.Output) + Assertions.assertNotEquals(legalEntityExternal1, null) - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - startAfter = startAfter, - nextStartAfter = nextStartAfter, - total = total, - values = legalEntitiesSaas - ) - ) - ) - ) + val legalEntityExternal2 = gateLegalEntityRepository.findByExternalIdAndDataType(CommonValues.externalId2, OutputInputEnum.Output) + Assertions.assertNotEquals(legalEntityExternal2, null) + + } + + /** + * If there isn't an Input Legal Entity persisted, + * when upserting an output Legal Entity, it should show an 400 + */ + @Test + fun `upsert output legal entities, no input persisted`() { + val legalEntities = listOf( + RequestValues.legalEntityGateInputRequest1, + RequestValues.legalEntityGateInputRequest2, ) - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_LEGAL_ENTITIES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString(legalEntitiesPool) - ) - ) + try { + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + } catch (e: WebClientResponseException) { + Assertions.assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) + } + + } + + /** + * Given legal entities exists in the database + * When getting legal entities page via output route + * Then legal entities page should be returned + */ + @Test + fun `get legal entities output`() { + val legalEntities = listOf( + RequestValues.legalEntityGateInputRequest1, + RequestValues.legalEntityGateInputRequest2 ) - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_LEGAL_ADDRESSES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString(legalAddressesPool) - ) - ) + + val expectedLegalEntities = listOf( + ResponseValues.legalEntityGateInputResponse1, + ResponseValues.legalEntityGateInputResponse2, ) - val paginationValue = PaginationRequest(0, 10) + val page = 0 + val size = 10 + + val totalElements = 2L + val totalPages = 1 + val contentSize = 2 + + + val paginationValue = PaginationRequest(page, size) + + gateClient.legalEntities().upsertLegalEntities(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + val pageResponse = gateClient.legalEntities().getLegalEntitiesOutput(paginationValue, emptyList()) - val expectedResponse = PageOutputResponse( - total = total, - nextStartAfter = nextStartAfter, - content = expectedLegalEntities, - invalidEntries = expectedPending.size + expectedErrors.size, - pending = expectedPending, - errors = expectedErrors, - ) + val expectedPage = PageResponse( + totalElements, + totalPages, + page, + contentSize, + content = expectedLegalEntities + ) - testHelpers.assertRecursively(pageResponse).isEqualTo(expectedResponse) + assertThat(pageResponse).usingRecursiveComparison().ignoringCollectionOrder().ignoringAllOverriddenEquals() + .ignoringFieldsMatchingRegexes(".*processStartedAt*").isEqualTo(expectedPage) } /** - * Given legal entities exists in SaaS and bpdm pool + * Given legal entities exists in the database * When getting legal entities page via output route filtering by external ids * Then legal entities page should be returned */ @Test fun `get legal entities, filter by external ids`() { - val expectedLegalEntities = listOf( - ResponseValues.legalEntityGateOutput1, - ResponseValues.legalEntityGateOutput2 + val legalEntities = listOf( + RequestValues.legalEntityGateInputRequest1, + RequestValues.legalEntityGateInputRequest2 ) - val legalEntitiesSaas = listOf( - SaasValues.legalEntityAugmented1, - SaasValues.legalEntityAugmented2 + val expectedLegalEntities = listOf( + ResponseValues.legalEntityGateInputResponse1, + ResponseValues.legalEntityGateInputResponse2, ) - val legalEntitiesPool = listOf( - ResponseValues.legalEntityResponsePool1, - ResponseValues.legalEntityResponsePool2 - ) - val legalAddressesPool = listOf( - ResponseValues.logisticAddress1, - ResponseValues.logisticAddress2 - ) + val page = 0 + val size = 10 - val limit = 2 - val startAfter = "Aaa111" - val nextStartAfter = "Aaa222" - val total = 10 - - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH)) - .withQueryParam("externalIds", equalTo(listOf(CommonValues.externalId1, CommonValues.externalId2).joinToString(","))) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - nextStartAfter = nextStartAfter, - total = total, - values = legalEntitiesSaas.map { AugmentedBusinessPartnerResponseSaas(it) } - ) - ) - ) - ) - ) + val totalElements = 2L + val totalPages = 1 + val contentSize = 2 - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - startAfter = startAfter, - nextStartAfter = nextStartAfter, - total = total, - values = legalEntitiesSaas - ) - ) - ) - ) - ) - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_LEGAL_ENTITIES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString(legalEntitiesPool) - ) - ) - ) - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_LEGAL_ADDRESSES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString(legalAddressesPool) - ) - ) - ) + val paginationValue = PaginationRequest(page, size) + + gateClient.legalEntities().upsertLegalEntities(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) - val paginationValue = PaginationRequest(0, 10) val pageResponse = gateClient.legalEntities().getLegalEntitiesOutput(paginationValue, listOf(CommonValues.externalId1, CommonValues.externalId2)) - val expectedResponse = PageOutputResponse( - total = total, - nextStartAfter = nextStartAfter, - content = expectedLegalEntities, - invalidEntries = 0, - pending = listOf(), - errors = listOf(), + + val expectedPage = PageResponse( + totalElements, + totalPages, + page, + contentSize, + content = expectedLegalEntities ) - testHelpers.assertRecursively(pageResponse).isEqualTo(expectedResponse) + + assertThat(pageResponse).usingRecursiveComparison().ignoringCollectionOrder().ignoringAllOverriddenEquals() + .ignoringFieldsMatchingRegexes(".*processStartedAt*").isEqualTo(expectedPage) } } \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt index d057f3621..864298a5c 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt @@ -19,39 +19,36 @@ package org.eclipse.tractusx.bpdm.gate.controller -import com.fasterxml.jackson.databind.ObjectMapper import com.github.tomakehurst.wiremock.client.WireMock.* import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.common.dto.saas.AugmentedBusinessPartnerResponseSaas -import org.eclipse.tractusx.bpdm.common.dto.saas.PagedResponseSaas +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError -import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo -import org.eclipse.tractusx.bpdm.gate.api.model.response.PageOutputResponse +import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository import org.eclipse.tractusx.bpdm.gate.util.* -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_SITES_MAIN_ADDRESSES_SEARCH_PATH -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.POOL_API_MOCK_SITES_SEARCH_PATH -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH -import org.eclipse.tractusx.bpdm.gate.util.EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.RegisterExtension import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.HttpStatus import org.springframework.test.context.ActiveProfiles import org.springframework.test.context.ContextConfiguration import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource +import org.springframework.web.reactive.function.client.WebClientResponseException @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) internal class SiteControllerOutputIT @Autowired constructor( - private val objectMapper: ObjectMapper, - val gateClient: GateClient + val gateClient: GateClient, + private val gateSiteRepository: SiteRepository, + val testHelpers: DbTestHelpers ) { companion object { @RegisterExtension @@ -72,240 +69,165 @@ internal class SiteControllerOutputIT @Autowired constructor( } } + @BeforeEach + fun beforeEach() { + testHelpers.truncateDbTables() + } + /** - * Given sites exists in SaaS and bpdm pool - * When getting sites page via output route - * Then sites page should be returned + * If there is an Input Sites persisted, + * upsert the Output with same external id */ @Test - fun `get sites`() { - val expectedSites = listOf( - ResponseValues.siteGateOutput1, - ResponseValues.siteGateOutput2 - ) - val expectedErrors = listOf( - ErrorInfo(BusinessPartnerSharingError.BpnNotInPool, "BPNS0000000003X9 not found in pool", SaasValues.siteNotInPoolResponse.externalId), - ErrorInfo( - BusinessPartnerSharingError.SharingProcessError, - "SaaS sharing process error: Error message", - SaasValues.siteSharingErrorResponse.externalId - ), - ) - val expectedPending = listOf(SaasValues.sitePendingResponse.externalId!!) - - val sitesSaas = listOf( - SaasValues.siteBusinessPartner1, - SaasValues.siteBusinessPartner2, - SaasValues.siteNotInPoolResponse, - SaasValues.siteSharingErrorResponse, - SaasValues.sitePendingResponse, + fun `upsert sites output`() { + val sites = listOf( + RequestValues.siteGateInputRequest1, + RequestValues.siteGateInputRequest2 ) - val sitesPool = listOf( - ResponseValues.siteResponse1, - ResponseValues.siteResponse2 + val legalEntities = listOf( + RequestValues.legalEntityGateInputRequest1, + RequestValues.legalEntityGateInputRequest2 ) - val mainAddressesPool = listOf( - ResponseValues.logisticAddress1, - ResponseValues.logisticAddress2 + + try { + gateClient.legalEntities().upsertLegalEntities(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.sites().upsertSites(sites) + gateClient.sites().upsertSitesOutput(sites) + } catch (e: WebClientResponseException) { + Assertions.assertEquals(HttpStatus.OK, e.statusCode) + } + + //Check if persisted site data + val siteExternal1 = gateSiteRepository.findByExternalIdAndDataType("site-external-1", OutputInputEnum.Output) + Assertions.assertNotEquals(siteExternal1, null) + + val siteExternal2 = gateSiteRepository.findByExternalIdAndDataType("site-external-2", OutputInputEnum.Output) + Assertions.assertNotEquals(siteExternal2, null) + + } + + /** + * If there isn't an Input Sites persisted, + * when upserting an output Sites, it should show an 400 + */ + @Test + fun `upsert sites output, no input persisted`() { + val sites = listOf( + RequestValues.siteGateInputRequest1, + RequestValues.siteGateInputRequest2 ) - val limit = 2 - val startAfter = "Aaa111" - val nextStartAfter = "Aaa222" - val total = 10 - - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - nextStartAfter = nextStartAfter, - total = total, - values = sitesSaas.map { AugmentedBusinessPartnerResponseSaas(it) } - ) - ) - ) - ) + val legalEntities = listOf( + RequestValues.legalEntityGateInputRequest1, + RequestValues.legalEntityGateInputRequest2 ) - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - startAfter = startAfter, - nextStartAfter = nextStartAfter, - total = total, - values = sitesSaas - ) - ) - ) - ) + try { + gateClient.legalEntities().upsertLegalEntities(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.sites().upsertSitesOutput(sites) + } catch (e: WebClientResponseException) { + Assertions.assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) + } + + } + + /** + * Given sites exists in the database + * When getting sites page via output route + * Then sites page should be returned + */ + @Test + fun `get sites`() { + val expectedSites = listOf( + ResponseValues.persistencesiteGateInputResponse1, + ResponseValues.persistenceSiteGateInputResponse2 ) - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_SITES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PageResponse( - totalElements = sitesPool.size.toLong(), - totalPages = 1, - page = 0, - contentSize = sitesPool.size, - content = sitesPool - ) - - ) - ) - ) + val page = 0 + val size = 10 + + val totalElements = 2L + val totalPages = 1 + val pageValue = 0 + val contentSize = 2 + + val legalEntities = listOf( + RequestValues.legalEntityGateInputRequest1, + RequestValues.legalEntityGateInputRequest2 ) - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_SITES_MAIN_ADDRESSES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString(mainAddressesPool) - ) - ) + + val sites = listOf( + RequestValues.siteGateInputRequest1, + RequestValues.siteGateInputRequest2 ) - val paginationValue = PaginationRequest(0, 10) - val pageResponseValue = gateClient.sites().getSitesOutput(paginationValue, emptyList()) - - assertThat(pageResponseValue).isEqualTo( - PageOutputResponse( - total = total, - nextStartAfter = nextStartAfter, - content = expectedSites, - invalidEntries = expectedPending.size + expectedErrors.size, - pending = expectedPending, - errors = expectedErrors, + gateClient.legalEntities().upsertLegalEntities(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.sites().upsertSites(sites) + gateClient.sites().upsertSitesOutput(sites) + + val paginationValue = PaginationRequest(page, size) + val pageResponse = gateClient.sites().getSitesOutput(paginationValue, emptyList()) + + assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*", ".*processStartedAt*").isEqualTo( + PageResponse( + totalElements = totalElements, + totalPages = totalPages, + page = pageValue, + contentSize = contentSize, + content = expectedSites ) ) } /** - * Given sites exists in SaaS and bpdm pool + * Given sites exists in the database * When getting sites page via output route filtering by external ids * Then sites page should be returned */ @Test fun `get sites, filter by external ids`() { val expectedSites = listOf( - ResponseValues.siteGateOutput1, - ResponseValues.siteGateOutput2 + ResponseValues.persistencesiteGateInputResponse1, + ResponseValues.persistenceSiteGateInputResponse2 ) - val sitesSaas = listOf( - SaasValues.siteBusinessPartner1, - SaasValues.siteBusinessPartner2 - ) + val page = 0 + val size = 10 - val sitesPool = listOf( - ResponseValues.siteResponse1, - ResponseValues.siteResponse2 - ) - val mainAddressesPool = listOf( - ResponseValues.logisticAddress1, - ResponseValues.logisticAddress2 - ) + val totalElements = 2L + val totalPages = 1 + val pageValue = 0 + val contentSize = 2 - val limit = 2 - val startAfter = "Aaa111" - val nextStartAfter = "Aaa222" - val total = 10 - - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_AUGMENTED_BUSINESS_PARTNER_PATH)) - .withQueryParam("externalIds", equalTo(listOf(CommonValues.externalIdSite1, CommonValues.externalIdSite2).joinToString(","))) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - nextStartAfter = nextStartAfter, - total = total, - values = sitesSaas.map { AugmentedBusinessPartnerResponseSaas(it) } - ) - ) - ) - ) + val legalEntities = listOf( + RequestValues.legalEntityGateInputRequest1, + RequestValues.legalEntityGateInputRequest2 ) - wireMockServerSaas.stubFor( - get(urlPathMatching(SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PagedResponseSaas( - limit = limit, - startAfter = startAfter, - nextStartAfter = nextStartAfter, - total = total, - values = sitesSaas - ) - ) - ) - ) + val sites = listOf( + RequestValues.siteGateInputRequest1, + RequestValues.siteGateInputRequest2 ) - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_SITES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - PageResponse( - totalElements = sitesPool.size.toLong(), - totalPages = 1, - page = 0, - contentSize = sitesPool.size, - content = sitesPool - ) - ) - ) - ) - ) - wireMockServerBpdmPool.stubFor( - post(urlPathMatching(POOL_API_MOCK_SITES_MAIN_ADDRESSES_SEARCH_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString(mainAddressesPool) - ) - ) - ) + gateClient.legalEntities().upsertLegalEntities(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.sites().upsertSites(sites) + gateClient.sites().upsertSitesOutput(sites) + + val paginationValue = PaginationRequest(page, size) + val pageResponse = gateClient.sites().getSitesOutput(paginationValue, listOf(CommonValues.externalIdSite1, CommonValues.externalIdSite2)) - val paginationValue = PaginationRequest(0, 10) - val pageResponseValue = gateClient.sites().getSitesOutput(paginationValue, listOf(CommonValues.externalIdSite1, CommonValues.externalIdSite2)) - - assertThat(pageResponseValue).isEqualTo( - PageOutputResponse( - total = total, - nextStartAfter = nextStartAfter, - content = expectedSites, - invalidEntries = 0, - pending = listOf(), - errors = listOf(), + assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*", ".*processStartedAt*").isEqualTo( + PageResponse( + totalElements = totalElements, + totalPages = totalPages, + page = pageValue, + contentSize = contentSize, + content = expectedSites ) ) } From cea0ce863774d34539fd121c4f2af0cbef9b0005 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Wed, 7 Jun 2023 11:51:15 +0100 Subject: [PATCH 41/83] feat(gate): Removed ProcessStartedAt field, changed Response from input to output data class, fixed persistence accordingly --- .../tractusx/bpdm/gate/api/GateAddressApi.kt | 3 +- .../bpdm/gate/api/GateLegalEntityApi.kt | 3 +- .../tractusx/bpdm/gate/api/GateSiteApi.kt | 3 +- .../api/model/AddressGateOutputRequest.kt | 47 ++++++++++++ .../api/model/AddressGateOutputResponse.kt | 1 - .../api/model/LegalEntityGateOutputRequest.kt | 63 +++++++++++++++ .../model/LegalEntityGateOutputResponse.kt | 5 +- .../gate/api/model/SiteGateOutputRequest.kt | 43 +++++++++++ .../gate/api/model/SiteGateOutputResponse.kt | 7 +- .../bpdm/gate/controller/AddressController.kt | 3 +- .../gate/controller/LegalEntityController.kt | 3 +- .../bpdm/gate/controller/SiteController.kt | 3 +- .../gate/service/AddressPersistenceService.kt | 44 ++++++++++- .../bpdm/gate/service/AddressService.kt | 5 +- .../service/LegalEntityPersistenceService.kt | 52 +++++++++++-- .../bpdm/gate/service/LegalEntityService.kt | 5 +- .../bpdm/gate/service/ResponseMappings.kt | 76 +++++++++++++++++-- .../gate/service/SitePersistenceService.kt | 75 ++++++++++++------ .../tractusx/bpdm/gate/service/SiteService.kt | 5 +- .../V0_1_6_0__add_input_or_output_collumn.sql | 6 +- .../controller/AddressControllerOutputIT.kt | 25 ++++-- .../LegalEntityControllerOutputIT.kt | 34 ++++++--- .../gate/controller/SiteControllerOutputIT.kt | 70 ++++++++++++----- .../tractusx/bpdm/gate/util/RequestValues.kt | 56 ++++++++++++++ 24 files changed, 546 insertions(+), 91 deletions(-) create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputRequest.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt index 273b08c5e..96fd22ddb 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateAddressApi.kt @@ -29,6 +29,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType @@ -142,6 +143,6 @@ interface GateAddressApi { ) @PutMapping("/output/addresses") @PutExchange("/output/addresses") - fun putAddressesOutput(@RequestBody addresses: Collection): ResponseEntity + fun putAddressesOutput(@RequestBody addresses: Collection): ResponseEntity } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt index 04f614496..1acc0e5d9 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateLegalEntityApi.kt @@ -29,6 +29,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType @@ -137,6 +138,6 @@ interface GateLegalEntityApi { ) @PutMapping("/output/legal-entities") @PutExchange("/output/legal-entities") - fun upsertLegalEntitiesOutput(@RequestBody legalEntities: Collection): ResponseEntity + fun upsertLegalEntitiesOutput(@RequestBody legalEntities: Collection): ResponseEntity } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt index f10627acb..68c396ead 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSiteApi.kt @@ -29,6 +29,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType @@ -137,6 +138,6 @@ interface GateSiteApi { ) @PutMapping("/output/sites") @PutExchange("/output/sites") - fun upsertSitesOutput(@RequestBody sites: Collection): ResponseEntity + fun upsertSitesOutput(@RequestBody sites: Collection): ResponseEntity } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputRequest.kt new file mode 100644 index 000000000..6232e94c0 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputRequest.kt @@ -0,0 +1,47 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema( + name = "AddressGateOutputRequest", description = "Address with legal entity or site references. " + + "Only one of either legal entity or site external id can be set for an address." +) +data class AddressGateOutputRequest( + @field:JsonUnwrapped + val address: LogisticAddressGateDto, + + @Schema(description = "ID the record has in the external system where the record originates from") + val externalId: String, + + @Schema(description = "External id of the related legal entity") + val legalEntityExternalId: String? = null, + + @Schema(description = "External id of the related site") + val siteExternalId: String? = null, + + @Schema(description = "Business Partner Number") + val bpn: String? = null +) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt index ba71d965c..74ee67b8a 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.LogisticAddressDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt new file mode 100644 index 000000000..aed85e5fa --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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 + ******************************************************************************/ + +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema(name = "LegalEntityGateOutputRequest", description = "Legal entity with external id") +data class LegalEntityGateOutputRequest( + + val legalNameParts: Array = emptyArray(), + + @Schema(description = "legal Enity") + val legalEntity: LegalEntityDto, + + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressGateDto, + + @Schema(description = "ID the record has in the external system where the record originates from", required = true) + val externalId: String, + + @Schema(description = "Business Partner Number") + val bpn: String?, +) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt index 912284111..fd804bcd6 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt @@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer -import java.time.LocalDateTime @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema(name = "LegalEntityGateOutputResponse", description = "Legal entity with external id") @@ -36,8 +35,6 @@ data class LegalEntityGateOutputResponse( val externalId: String, @Schema(description = "Business Partner Number") - val bpn: String?, + val bpn: String? - @Schema(description = "Time the sharing process was started according to SaaS") - val processStartedAt: LocalDateTime? = null, ) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt new file mode 100644 index 000000000..a9782d1d6 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt @@ -0,0 +1,43 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema( + name = "SiteGateOutputRequest", description = "Site with legal entity reference" +) +data class SiteGateOutputRequest( + @field:JsonUnwrapped + val site: SiteGateDto, + + @Schema(description = "ID the record has in the external system where the record originates from") + val externalId: String, + + @Schema(description = "External id of the related legal entity") + val legalEntityExternalId: String, + + @Schema(description = "Business Partner Number") + val bpn: String?, +) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt index b27ae86d5..ed552e43f 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt @@ -22,9 +22,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.SiteDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer -import java.time.LocalDateTime @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema( @@ -41,8 +39,5 @@ data class SiteGateOutputResponse( val legalEntityExternalId: String, @Schema(description = "Business Partner Number") - val bpn: String?, - - @Schema(description = "Time the sharing process was started according to SaaS") - val processStartedAt: LocalDateTime? = null, + val bpn: String? ) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt index 8a8a72561..ab2111418 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateAddressApi import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates @@ -73,7 +74,7 @@ class AddressController( return addressService.getAddressesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } - override fun putAddressesOutput(addresses: Collection): ResponseEntity { + override fun putAddressesOutput(addresses: Collection): ResponseEntity { if (addresses.size > apiConfigProperties.upsertLimit || addresses.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt index aa2e25658..dbc2818ac 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateLegalEntityApi import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates @@ -68,7 +69,7 @@ class LegalEntityController( return legalEntityService.getLegalEntitiesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } - override fun upsertLegalEntitiesOutput(legalEntities: Collection): ResponseEntity { + override fun upsertLegalEntitiesOutput(legalEntities: Collection): ResponseEntity { if (legalEntities.size > apiConfigProperties.upsertLimit || legalEntities.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt index a08d4f7fd..6aba848c5 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateSiteApi import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates @@ -65,7 +66,7 @@ class SiteController( return siteService.getSitesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } - override fun upsertSitesOutput(sites: Collection): ResponseEntity { + override fun upsertSitesOutput(sites: Collection): ResponseEntity { if (sites.size > apiConfigProperties.upsertLimit || sites.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index 9c859de5c..ca07f849b 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -23,6 +23,7 @@ import jakarta.transaction.Transactional import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputRequest import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity import org.eclipse.tractusx.bpdm.gate.entity.LogisticAddress import org.eclipse.tractusx.bpdm.gate.entity.Site @@ -59,7 +60,45 @@ class AddressPersistenceService( updateAddress(existingAddress, address, legalEntityRecord, siteRecord) gateAddressRepository.save(existingAddress) } ?: run { - if (fullAddress.dataType == OutputInputEnum.Output && addressRecord.find { it.externalId == fullAddress.externalId && it.dataType == OutputInputEnum.Input } == null) { + gateAddressRepository.save(fullAddress) + } + } + } + + private fun updateAddress(address: LogisticAddress, changeAddress: AddressGateInputRequest, legalEntityRecord: LegalEntity?, siteRecord: Site?) { + + address.name = changeAddress.address.name + address.externalId = changeAddress.externalId + address.legalEntity = legalEntityRecord + address.site = siteRecord + address.siteExternalId = changeAddress.siteExternalId.toString() + address.physicalPostalAddress = changeAddress.address.physicalPostalAddress.toPhysicalPostalAddressEntity() + address.alternativePostalAddress = changeAddress.address.alternativePostalAddress?.toAlternativePostalAddressEntity() + + address.identifiers.replace(changeAddress.address.identifiers.map { toEntityIdentifier(it, address) }) + address.states.replace(changeAddress.address.states.map { toEntityAddress(it, address) }) + + } + + @Transactional + fun persistOutputAddressBP(addresses: Collection, dataType: OutputInputEnum) { + val externalIdColl: MutableCollection = mutableListOf() + addresses.forEach { externalIdColl.add(it.externalId) } + + val addressRecord = gateAddressRepository.findByExternalIdIn(externalIdColl) + + addresses.forEach { address -> + + val legalEntityRecord = address.legalEntityExternalId?.let { legalEntityRepository.findByExternalIdAndDataType(it, dataType) } + val siteRecord = address.siteExternalId?.let { siteEntityRepository.findByExternalIdAndDataType(it, dataType) } + + val fullAddress = address.toAddressGateOutput(legalEntityRecord, siteRecord, dataType) + + addressRecord.find { it.externalId == address.externalId && it.dataType == dataType }?.let { existingAddress -> + updateAddressOutput(existingAddress, address, legalEntityRecord, siteRecord) + gateAddressRepository.save(existingAddress) + } ?: run { + if (addressRecord.find { it.externalId == fullAddress.externalId && it.dataType == OutputInputEnum.Input } == null) { throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Logistic Address doesn't exist") } else { gateAddressRepository.save(fullAddress) @@ -68,9 +107,10 @@ class AddressPersistenceService( } } - private fun updateAddress(address: LogisticAddress, changeAddress: AddressGateInputRequest, legalEntityRecord: LegalEntity?, siteRecord: Site?) { + private fun updateAddressOutput(address: LogisticAddress, changeAddress: AddressGateOutputRequest, legalEntityRecord: LegalEntity?, siteRecord: Site?) { address.name = changeAddress.address.name + address.bpn = changeAddress.bpn address.externalId = changeAddress.externalId address.legalEntity = legalEntityRecord address.site = siteRecord diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index bac140c62..81e82783d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -26,6 +26,7 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties @@ -125,9 +126,9 @@ class AddressService( /** * Upsert addresses output to the database **/ - fun upsertOutputAddresses(addresses: Collection) { + fun upsertOutputAddresses(addresses: Collection) { - addressPersistenceService.persistAddressBP(addresses, OutputInputEnum.Output) + addressPersistenceService.persistOutputAddressBP(addresses, OutputInputEnum.Output) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 5b09c58c6..043ff7fac 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest import org.eclipse.tractusx.bpdm.gate.entity.* import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository @@ -58,11 +59,7 @@ class LegalEntityPersistenceService( gateLegalEntityRepository.save(existingLegalEntity) } ?: run { - if (fullLegalEntity.dataType == OutputInputEnum.Output && legalEntityRecord.find { it.externalId == fullLegalEntity.externalId && it.dataType == OutputInputEnum.Input } == null) { - throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Legal Entity doesn't exist") - } else { - gateLegalEntityRepository.save(fullLegalEntity) - } + gateLegalEntityRepository.save(fullLegalEntity) } } } @@ -105,4 +102,49 @@ class LegalEntityPersistenceService( return AddressIdentifier(dto.value, dto.type, address) } + @Transactional + fun persistLegalEntitiesOutputBP(legalEntities: Collection, datatype: OutputInputEnum) { + //finds Legal Entity by External ID + val legalEntityRecord = gateLegalEntityRepository.findDistinctByExternalIdIn(legalEntities.map { it.externalId }) + + //Business Partner persist + legalEntities.forEach { legalEntity -> + val fullLegalEntity = legalEntity.toLegalEntity(datatype) + legalEntityRecord.find { it.externalId == legalEntity.externalId && it.dataType == datatype }?.let { existingLegalEntity -> + + val logisticAddressRecord = + gateAddressRepository.findByExternalIdAndDataType(getMainAddressForLegalEntityExternalId(existingLegalEntity.externalId), datatype) + ?: throw BpdmNotFoundException("Business Partner", "Error") + + updateAddress(logisticAddressRecord, fullLegalEntity.legalAddress) + updateLegalEntityOutput(existingLegalEntity, legalEntity, logisticAddressRecord) + + gateLegalEntityRepository.save(existingLegalEntity) + } ?: run { + if (legalEntityRecord.find { it.externalId == fullLegalEntity.externalId && it.dataType == OutputInputEnum.Input } == null) { + throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Legal Entity doesn't exist") + } else { + gateLegalEntityRepository.save(fullLegalEntity) + } + } + } + } + + private fun updateLegalEntityOutput( + legalEntity: LegalEntity, + legalEntityRequest: LegalEntityGateOutputRequest, + logisticAddressRecord: LogisticAddress + ): LegalEntity { + legalEntity.bpn = legalEntityRequest.bpn + legalEntity.externalId = legalEntityRequest.externalId + legalEntity.legalForm = legalEntityRequest.legalEntity.legalForm + legalEntity.legalName = Name(value = legalEntityRequest.legalNameParts[0], shortName = legalEntityRequest.legalEntity.legalShortName) + legalEntity.identifiers.replace(legalEntityRequest.legalEntity.identifiers.map { toEntityIdentifier(it, legalEntity) }) + legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) + legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) + legalEntity.legalAddress = logisticAddressRecord + legalEntity.legalAddress.legalEntity = legalEntity + return legalEntity + } + } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 3d197fc44..de8ab8cf9 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -25,6 +25,7 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry @@ -58,9 +59,9 @@ class LegalEntityService( /** * Upsert legal entities output to the database **/ - fun upsertLegalEntitiesOutput(legalEntities: Collection) { + fun upsertLegalEntitiesOutput(legalEntities: Collection) { - legalEntityPersistenceService.persistLegalEntitiesBP(legalEntities, OutputInputEnum.Output) + legalEntityPersistenceService.persistLegalEntitiesOutputBP(legalEntities, OutputInputEnum.Output) } fun getLegalEntityByExternalId(externalId: String): LegalEntityGateInputResponse { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index b379ec446..36fe45642 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -48,6 +48,26 @@ fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site? return logisticAddress } +fun AddressGateOutputRequest.toAddressGateOutput(legalEntity: LegalEntity?, site: Site?, datatype: OutputInputEnum): LogisticAddress { + + val logisticAddress = LogisticAddress( + bpn = bpn, + externalId = externalId, + siteExternalId = siteExternalId.toString(), + name = address.name, + physicalPostalAddress = address.physicalPostalAddress.toPhysicalPostalAddressEntity(), + alternativePostalAddress = address.alternativePostalAddress?.toAlternativePostalAddressEntity(), + legalEntity = legalEntity, + site = site, + dataType = datatype + ) + + logisticAddress.identifiers.addAll(this.address.identifiers.map { toEntityIdentifier(it, logisticAddress) }.toSet()) + logisticAddress.states.addAll(this.address.states.map { toEntityAddress(it, logisticAddress) }.toSet()) + + return logisticAddress +} + fun toEntityAddress(dto: AddressStateDto, address: LogisticAddress): AddressState { return AddressState(dto.description, dto.validFrom, dto.validTo, dto.type, address) } @@ -130,6 +150,28 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputIn return site } +fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputInputEnum): Site { + + val addressInputRequest = AddressGateInputRequest( + address = site.mainAddress, + externalId = getMainAddressForSiteExternalId(externalId), + legalEntityExternalId = externalId + ) + + val site = Site( + bpn = bpn, + name = site.name, + externalId = externalId, + legalEntity = legalEntity, + dataType = datatype + ) + + site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) + site.mainAddress = addressInputRequest.toAddressGate(legalEntity, site, datatype) + + return site +} + fun toEntityAddress(dto: SiteStateDto, site: Site): SiteState { return SiteState(dto.description, dto.validFrom, dto.validTo, dto.type, site) } @@ -168,6 +210,33 @@ fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalE } +fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): LegalEntity { + + val addressInputRequest = AddressGateInputRequest( + address = legalAddress, + externalId = getMainAddressForLegalEntityExternalId(externalId), + legalEntityExternalId = externalId + ) + + val legalEntity = LegalEntity( + bpn = bpn, + externalId = externalId, + currentness = createCurrentnessTimestamp(), + legalForm = legalEntity.legalForm, + legalName = Name(legalNameParts[0], legalEntity.legalShortName), + dataType = datatype + ) + + legalEntity.identifiers.addAll(this.legalEntity.identifiers.map { toEntityIdentifier(it, legalEntity) }) + legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) + legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) + + legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, datatype) + + return legalEntity + +} + fun toEntityIdentifier(dto: LegalEntityIdentifierDto, legalEntity: LegalEntity): LegalEntityIdentifier { return LegalEntityIdentifier(dto.value, dto.type, dto.issuingBody, legalEntity) } @@ -375,10 +444,8 @@ fun Site.toSiteGateOutputResponse(sitePage: Site): SiteGateOutputResponse { site = sitePage.toSiteDto(), externalId = externalId, legalEntityExternalId = legalEntity.externalId, - bpn = bpn, - processStartedAt = null //TODO Remove this? + bpn = bpn ) - } //LegalEntity mapping to LegalEntityGateOutputResponse @@ -387,8 +454,7 @@ fun LegalEntity.toLegalEntityGateOutputResponse(legalEntity: LegalEntity): Legal return LegalEntityGateOutputResponse( legalEntity = legalEntity.toLegalEntityDto(), externalId = legalEntity.externalId, - bpn = legalEntity.bpn, - processStartedAt = null //TODO Remove this? + bpn = legalEntity.bpn ) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 8aefe380a..24ac1b644 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -23,6 +23,7 @@ import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.entity.* import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository @@ -43,45 +44,37 @@ class SitePersistenceService( fun persistSitesBP(sites: Collection, datatype: OutputInputEnum) { //Finds Site in DB - val externalIdColl: MutableCollection = mutableListOf() - sites.forEach { externalIdColl.add(it.externalId) } - val siteRecord = siteRepository.findByExternalIdIn(externalIdColl) + val siteRecord = siteRepository.findByExternalIdIn(sites.map { it.externalId }) sites.forEach { site -> - val legalEntityRecord = - site.legalEntityExternalId.let { - legalEntityRepository.findByExternalIdAndDataType(site.legalEntityExternalId, datatype) ?: throw BpdmNotFoundException( - "Business Partner", - it - ) - } + val legalEntityRecord = getLegalEntityRecord(site.legalEntityExternalId, datatype) val fullSite = site.toSiteGate(legalEntityRecord, datatype) siteRecord.find { it.externalId == site.externalId && it.dataType == datatype }?.let { existingSite -> - val logisticAddressRecord = - addressRepository.findByExternalIdAndDataType(getMainAddressForSiteExternalId(site.externalId), datatype) ?: throw BpdmNotFoundException( - "Business Partner", - "Error" - ) + val logisticAddressRecord = getAddressRecord(getMainAddressForSiteExternalId(site.externalId), datatype) updateAddress(logisticAddressRecord, fullSite.mainAddress) - updateSite(existingSite, site, legalEntityRecord) - siteRepository.save(existingSite) } ?: run { - if (fullSite.dataType == OutputInputEnum.Output && siteRecord.find { it.externalId == fullSite.externalId && it.dataType == OutputInputEnum.Input } == null) { - throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Site doesn't exist") - } else { - siteRepository.save(fullSite) - } + siteRepository.save(fullSite) } } } + private fun getAddressRecord(externalId: String, datatype: OutputInputEnum): LogisticAddress { + return addressRepository.findByExternalIdAndDataType(externalId, datatype) + ?: throw BpdmNotFoundException("Business Partner", "Error") + } + + private fun getLegalEntityRecord(externalId: String, datatype: OutputInputEnum): LegalEntity { + return legalEntityRepository.findByExternalIdAndDataType(externalId, datatype) + ?: throw BpdmNotFoundException("Business Partner", externalId) + } + private fun updateSite(site: Site, updatedSite: SiteGateInputRequest, legalEntityRecord: LegalEntity) { site.name = updatedSite.site.name @@ -113,4 +106,42 @@ class SitePersistenceService( return AddressIdentifier(dto.value, dto.type, address) } + @Transactional + fun persistSitesOutputBP(sites: Collection, datatype: OutputInputEnum) { + + //Finds Site in DB + val siteRecord = siteRepository.findByExternalIdIn(sites.map { it.externalId }) + + sites.forEach { site -> + + val legalEntityRecord = getLegalEntityRecord(site.legalEntityExternalId, datatype) + + val fullSite = site.toSiteGate(legalEntityRecord, datatype) + + siteRecord.find { it.externalId == site.externalId && it.dataType == datatype }?.let { existingSite -> + + val logisticAddressRecord = getAddressRecord(getMainAddressForSiteExternalId(site.externalId), datatype) + + updateAddress(logisticAddressRecord, fullSite.mainAddress) + updateSiteOutput(existingSite, site, legalEntityRecord) + siteRepository.save(existingSite) + } ?: run { + if (siteRecord.find { it.externalId == fullSite.externalId && it.dataType == OutputInputEnum.Input } == null) { + throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Site doesn't exist") + } else { + siteRepository.save(fullSite) + } + } + } + } + + private fun updateSiteOutput(site: Site, updatedSite: SiteGateOutputRequest, legalEntityRecord: LegalEntity) { + + site.bpn = updatedSite.bpn + site.name = updatedSite.site.name + site.externalId = updatedSite.externalId + site.legalEntity = legalEntityRecord + site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) + + } } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index 3c8e7bf02..4d0622a9f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -27,6 +27,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry @@ -120,9 +121,9 @@ class SiteService( /** * Upsert sites output to the database **/ - fun upsertSitesOutput(sites: Collection) { + fun upsertSitesOutput(sites: Collection) { - sitePersistenceService.persistSitesBP(sites, OutputInputEnum.Output) + sitePersistenceService.persistSitesOutputBP(sites, OutputInputEnum.Output) } /** diff --git a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql index 224f529ce..1640d5bda 100644 --- a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql +++ b/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql @@ -4,7 +4,7 @@ DROP CONSTRAINT IF EXISTS uk_7xolefhhm30nlfrp5fc25a3i2; -- Add the composite unique constraint on external_id and data_type (Addresses) ALTER TABLE logistic_addresses -ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'input', +ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'Input', ADD CONSTRAINT uk_external_id_data_type UNIQUE (external_id, data_type); -- Remove the existing unique constraint on external_id (Site) @@ -13,7 +13,7 @@ DROP CONSTRAINT IF EXISTS UK_1vrdeiex4x7p93r5svtvb5b4x; -- Add the composite unique constraint on external_id and data_type (Site) ALTER TABLE sites -ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'input', +ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'Input', ADD CONSTRAINT uk_external_id_data_type_site UNIQUE (external_id, data_type); -- Remove the existing unique constraint on external_id (Site) @@ -22,5 +22,5 @@ DROP CONSTRAINT IF EXISTS uk_fn3cbtgn4mcc8qprvf6nc33rb; -- Add the composite unique constraint on external_id and data_type (Site) ALTER TABLE legal_entities -ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'input', +ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'Input', ADD CONSTRAINT uk_external_id_data_type_legalentity UNIQUE (external_id, data_type); \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt index 67748f1a9..7254af144 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt @@ -104,9 +104,14 @@ internal class AddressControllerOutputIT @Autowired constructor( RequestValues.addressGateInputRequest2 ) + val addressesOutput = listOf( + RequestValues.addressGateOutputRequest1, + RequestValues.addressGateOutputRequest2 + ) + try { gateClient.addresses().upsertAddresses(addresses) - gateClient.addresses().putAddressesOutput(addresses) + gateClient.addresses().putAddressesOutput(addressesOutput) } catch (e: WebClientResponseException) { Assertions.assertEquals(HttpStatus.OK, e.statusCode) } @@ -127,8 +132,8 @@ internal class AddressControllerOutputIT @Autowired constructor( @Test fun `upsert output addresses, no input persisted`() { val addresses = listOf( - RequestValues.addressGateInputRequest1, - RequestValues.addressGateInputRequest2 + RequestValues.addressGateOutputRequest1, + RequestValues.addressGateOutputRequest2 ) try { @@ -151,6 +156,11 @@ internal class AddressControllerOutputIT @Autowired constructor( RequestValues.addressGateInputRequest2 ) + val addressesOutput = listOf( + RequestValues.addressGateOutputRequest1, + RequestValues.addressGateOutputRequest2 + ) + val expectedAddresses = listOf( ResponseValues.logisticAddressGateInputResponse1, ResponseValues.logisticAddressGateInputResponse2, @@ -165,7 +175,7 @@ internal class AddressControllerOutputIT @Autowired constructor( val contentSize = 2 gateClient.addresses().upsertAddresses(addresses) - gateClient.addresses().putAddressesOutput(addresses) + gateClient.addresses().putAddressesOutput(addressesOutput) val paginationValue = PaginationRequest(page, size) @@ -194,6 +204,11 @@ internal class AddressControllerOutputIT @Autowired constructor( RequestValues.addressGateInputRequest2 ) + val addressesOutput = listOf( + RequestValues.addressGateOutputRequest1, + RequestValues.addressGateOutputRequest2 + ) + val expectedAddresses = listOf( ResponseValues.logisticAddressGateInputResponse1, ResponseValues.logisticAddressGateInputResponse2, @@ -208,7 +223,7 @@ internal class AddressControllerOutputIT @Autowired constructor( val contentSize = 2 gateClient.addresses().upsertAddresses(addresses) - gateClient.addresses().putAddressesOutput(addresses) + gateClient.addresses().putAddressesOutput(addressesOutput) val paginationValue = PaginationRequest(page, size) val pageResponse = gateClient.addresses().getAddressesOutput(paginationValue, listOf(CommonValues.externalIdAddress1, CommonValues.externalIdAddress2)) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt index 07d8afa0e..37081f2f1 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt @@ -86,9 +86,14 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( RequestValues.legalEntityGateInputRequest2, ) + val legalEntitiesOutput = listOf( + RequestValues.legalEntityGateOutputRequest1, + RequestValues.legalEntityGateOutputRequest2, + ) + try { gateClient.legalEntities().upsertLegalEntities(legalEntities) - gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntitiesOutput) } catch (e: WebClientResponseException) { Assertions.assertEquals(HttpStatus.OK, e.statusCode) } @@ -108,13 +113,14 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( */ @Test fun `upsert output legal entities, no input persisted`() { - val legalEntities = listOf( - RequestValues.legalEntityGateInputRequest1, - RequestValues.legalEntityGateInputRequest2, + + val legalEntitiesOutput = listOf( + RequestValues.legalEntityGateOutputRequest1, + RequestValues.legalEntityGateOutputRequest2, ) try { - gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntitiesOutput) } catch (e: WebClientResponseException) { Assertions.assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } @@ -130,7 +136,12 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( fun `get legal entities output`() { val legalEntities = listOf( RequestValues.legalEntityGateInputRequest1, - RequestValues.legalEntityGateInputRequest2 + RequestValues.legalEntityGateInputRequest2, + ) + + val legalEntitiesOutput = listOf( + RequestValues.legalEntityGateOutputRequest1, + RequestValues.legalEntityGateOutputRequest2, ) val expectedLegalEntities = listOf( @@ -149,7 +160,7 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( val paginationValue = PaginationRequest(page, size) gateClient.legalEntities().upsertLegalEntities(legalEntities) - gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntitiesOutput) val pageResponse = gateClient.legalEntities().getLegalEntitiesOutput(paginationValue, emptyList()) @@ -174,7 +185,12 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( fun `get legal entities, filter by external ids`() { val legalEntities = listOf( RequestValues.legalEntityGateInputRequest1, - RequestValues.legalEntityGateInputRequest2 + RequestValues.legalEntityGateInputRequest2, + ) + + val legalEntitiesOutput = listOf( + RequestValues.legalEntityGateOutputRequest1, + RequestValues.legalEntityGateOutputRequest2, ) val expectedLegalEntities = listOf( @@ -193,7 +209,7 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( val paginationValue = PaginationRequest(page, size) gateClient.legalEntities().upsertLegalEntities(legalEntities) - gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntitiesOutput) val pageResponse = gateClient.legalEntities().getLegalEntitiesOutput(paginationValue, listOf(CommonValues.externalId1, CommonValues.externalId2)) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt index 864298a5c..5a11ce979 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt @@ -85,16 +85,26 @@ internal class SiteControllerOutputIT @Autowired constructor( RequestValues.siteGateInputRequest2 ) + val sitesOutput = listOf( + RequestValues.siteGateOutputRequest1, + RequestValues.siteGateOutputRequest2 + ) + val legalEntities = listOf( RequestValues.legalEntityGateInputRequest1, RequestValues.legalEntityGateInputRequest2 ) + val legalEntitiesOutput = listOf( + RequestValues.legalEntityGateOutputRequest1, + RequestValues.legalEntityGateOutputRequest2, + ) + try { gateClient.legalEntities().upsertLegalEntities(legalEntities) - gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntitiesOutput) gateClient.sites().upsertSites(sites) - gateClient.sites().upsertSitesOutput(sites) + gateClient.sites().upsertSitesOutput(sitesOutput) } catch (e: WebClientResponseException) { Assertions.assertEquals(HttpStatus.OK, e.statusCode) } @@ -114,9 +124,10 @@ internal class SiteControllerOutputIT @Autowired constructor( */ @Test fun `upsert sites output, no input persisted`() { - val sites = listOf( - RequestValues.siteGateInputRequest1, - RequestValues.siteGateInputRequest2 + + val sitesOutput = listOf( + RequestValues.siteGateOutputRequest1, + RequestValues.siteGateOutputRequest2 ) val legalEntities = listOf( @@ -124,10 +135,15 @@ internal class SiteControllerOutputIT @Autowired constructor( RequestValues.legalEntityGateInputRequest2 ) + val legalEntitiesOutput = listOf( + RequestValues.legalEntityGateOutputRequest1, + RequestValues.legalEntityGateOutputRequest2, + ) + try { gateClient.legalEntities().upsertLegalEntities(legalEntities) - gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) - gateClient.sites().upsertSitesOutput(sites) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntitiesOutput) + gateClient.sites().upsertSitesOutput(sitesOutput) } catch (e: WebClientResponseException) { Assertions.assertEquals(HttpStatus.BAD_REQUEST, e.statusCode) } @@ -154,20 +170,30 @@ internal class SiteControllerOutputIT @Autowired constructor( val pageValue = 0 val contentSize = 2 + val sites = listOf( + RequestValues.siteGateInputRequest1, + RequestValues.siteGateInputRequest2 + ) + + val sitesOutput = listOf( + RequestValues.siteGateOutputRequest1, + RequestValues.siteGateOutputRequest2 + ) + val legalEntities = listOf( RequestValues.legalEntityGateInputRequest1, RequestValues.legalEntityGateInputRequest2 ) - val sites = listOf( - RequestValues.siteGateInputRequest1, - RequestValues.siteGateInputRequest2 + val legalEntitiesOutput = listOf( + RequestValues.legalEntityGateOutputRequest1, + RequestValues.legalEntityGateOutputRequest2, ) gateClient.legalEntities().upsertLegalEntities(legalEntities) - gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntitiesOutput) gateClient.sites().upsertSites(sites) - gateClient.sites().upsertSitesOutput(sites) + gateClient.sites().upsertSitesOutput(sitesOutput) val paginationValue = PaginationRequest(page, size) val pageResponse = gateClient.sites().getSitesOutput(paginationValue, emptyList()) @@ -203,20 +229,30 @@ internal class SiteControllerOutputIT @Autowired constructor( val pageValue = 0 val contentSize = 2 + val sites = listOf( + RequestValues.siteGateInputRequest1, + RequestValues.siteGateInputRequest2 + ) + + val sitesOutput = listOf( + RequestValues.siteGateOutputRequest1, + RequestValues.siteGateOutputRequest2 + ) + val legalEntities = listOf( RequestValues.legalEntityGateInputRequest1, RequestValues.legalEntityGateInputRequest2 ) - val sites = listOf( - RequestValues.siteGateInputRequest1, - RequestValues.siteGateInputRequest2 + val legalEntitiesOutput = listOf( + RequestValues.legalEntityGateOutputRequest1, + RequestValues.legalEntityGateOutputRequest2, ) gateClient.legalEntities().upsertLegalEntities(legalEntities) - gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntities) + gateClient.legalEntities().upsertLegalEntitiesOutput(legalEntitiesOutput) gateClient.sites().upsertSites(sites) - gateClient.sites().upsertSitesOutput(sites) + gateClient.sites().upsertSitesOutput(sitesOutput) val paginationValue = PaginationRequest(page, size) val pageResponse = gateClient.sites().getSitesOutput(paginationValue, listOf(CommonValues.externalIdSite1, CommonValues.externalIdSite2)) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index 27472342b..b32062742 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -312,6 +312,21 @@ object RequestValues { ) + //Output values for sites + val siteGateOutputRequest1 = SiteGateOutputRequest( + site = site1, + externalId = CommonValues.externalIdSite1, + legalEntityExternalId = CommonValues.externalId1, + bpn = CommonValues.bpnSite1 + ) + + val siteGateOutputRequest2 = SiteGateOutputRequest( + site = site2, + externalId = CommonValues.externalIdSite2, + legalEntityExternalId = CommonValues.externalId2, + bpn = CommonValues.bpnSite2 + ) + val addressGateInputRequest1 = AddressGateInputRequest( address = address1.copy( name = CommonValues.name1, @@ -336,4 +351,45 @@ object RequestValues { ) + //Output Endpoint Values + val addressGateOutputRequest1 = AddressGateOutputRequest( + address = address1.copy( + name = CommonValues.name1, + identifiers = listOf( + AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) + ) + ), + externalId = CommonValues.externalIdAddress1, + legalEntityExternalId = CommonValues.externalId1, + bpn = CommonValues.bpnAddress1 + ) + + val addressGateOutputRequest2 = AddressGateOutputRequest( + address = address2.copy( + name = CommonValues.name2, + identifiers = listOf( + AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) + ) + ), + externalId = CommonValues.externalIdAddress2, + siteExternalId = CommonValues.externalIdSite1, + bpn = CommonValues.bpnAddress2 + ) + + //Output Values + val legalEntityGateOutputRequest1 = LegalEntityGateOutputRequest( + legalEntity = legalEntity1, + legalAddress = address1, + legalNameParts = arrayOf(CommonValues.name1), + externalId = CommonValues.externalId1, + bpn = CommonValues.bpn1 + ) + + val legalEntityGateOutputRequest2 = LegalEntityGateOutputRequest( + legalEntity = legalEntity2, + legalAddress = address2, + legalNameParts = arrayOf(CommonValues.name3), + externalId = CommonValues.externalId2, + bpn = CommonValues.bpn2 + ) } \ No newline at end of file From 67fe305d6cf067789fdb00342334b4a4c461dab5 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Wed, 7 Jun 2023 14:00:01 +0100 Subject: [PATCH 42/83] feat(gate): Unit tests fix according to the removal of BPNs, fix migration file --- ...V0_1_7_0__add_input_or_output_collumn.sql} | 0 .../controller/AddressControllerOutputIT.kt | 8 +-- .../LegalEntityControllerOutputIT.kt | 8 +-- .../gate/controller/SiteControllerOutputIT.kt | 8 +-- .../tractusx/bpdm/gate/util/ResponseValues.kt | 51 +++++++++++++++++++ 5 files changed, 63 insertions(+), 12 deletions(-) rename bpdm-gate/src/main/resources/db/migration/{V0_1_6_0__add_input_or_output_collumn.sql => V0_1_7_0__add_input_or_output_collumn.sql} (100%) diff --git a/bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql b/bpdm-gate/src/main/resources/db/migration/V0_1_7_0__add_input_or_output_collumn.sql similarity index 100% rename from bpdm-gate/src/main/resources/db/migration/V0_1_6_0__add_input_or_output_collumn.sql rename to bpdm-gate/src/main/resources/db/migration/V0_1_7_0__add_input_or_output_collumn.sql diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt index 7254af144..b4ff69251 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressControllerOutputIT.kt @@ -162,8 +162,8 @@ internal class AddressControllerOutputIT @Autowired constructor( ) val expectedAddresses = listOf( - ResponseValues.logisticAddressGateInputResponse1, - ResponseValues.logisticAddressGateInputResponse2, + ResponseValues.logisticAddressGateOutputResponse1, + ResponseValues.logisticAddressGateOutputResponse2, ) val page = 0 @@ -210,8 +210,8 @@ internal class AddressControllerOutputIT @Autowired constructor( ) val expectedAddresses = listOf( - ResponseValues.logisticAddressGateInputResponse1, - ResponseValues.logisticAddressGateInputResponse2, + ResponseValues.logisticAddressGateOutputResponse1, + ResponseValues.logisticAddressGateOutputResponse2, ) val page = 0 diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt index 37081f2f1..cdf05ce3c 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt @@ -145,8 +145,8 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( ) val expectedLegalEntities = listOf( - ResponseValues.legalEntityGateInputResponse1, - ResponseValues.legalEntityGateInputResponse2, + ResponseValues.legalEntityGateOutputResponse1, + ResponseValues.legalEntityGateOutputResponse2, ) val page = 0 @@ -194,8 +194,8 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( ) val expectedLegalEntities = listOf( - ResponseValues.legalEntityGateInputResponse1, - ResponseValues.legalEntityGateInputResponse2, + ResponseValues.legalEntityGateOutputResponse1, + ResponseValues.legalEntityGateOutputResponse2, ) val page = 0 diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt index 5a11ce979..cdb9c4e13 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerOutputIT.kt @@ -158,8 +158,8 @@ internal class SiteControllerOutputIT @Autowired constructor( @Test fun `get sites`() { val expectedSites = listOf( - ResponseValues.persistencesiteGateInputResponse1, - ResponseValues.persistenceSiteGateInputResponse2 + ResponseValues.persistencesiteGateOutputResponse1, + ResponseValues.persistencesiteGateOutputResponse2 ) val page = 0 @@ -217,8 +217,8 @@ internal class SiteControllerOutputIT @Autowired constructor( @Test fun `get sites, filter by external ids`() { val expectedSites = listOf( - ResponseValues.persistencesiteGateInputResponse1, - ResponseValues.persistenceSiteGateInputResponse2 + ResponseValues.persistencesiteGateOutputResponse1, + ResponseValues.persistencesiteGateOutputResponse2 ) val page = 0 diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 26734d755..fa4a795ff 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -298,6 +298,19 @@ object ResponseValues { processStartedAt = null, ) + //Gate Output Legal Entities Response + val legalEntityGateOutputResponse1 = LegalEntityGateOutputResponse( + legalEntity = RequestValues.legalEntity1, + externalId = CommonValues.externalId1, + bpn = CommonValues.bpn1, + ) + + val legalEntityGateOutputResponse2 = LegalEntityGateOutputResponse( + legalEntity = RequestValues.legalEntity2, + externalId = CommonValues.externalId2, + bpn = CommonValues.bpn2, + ) + //Values without processStartedAt value val newLegalEntityGateInputResponse1 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity1, @@ -372,6 +385,19 @@ object ResponseValues { processStartedAt = null, ) + val persistencesiteGateOutputResponse1 = SiteGateOutputResponse( + site = RequestValues.site1, + externalId = CommonValues.externalIdSite1, + legalEntityExternalId = CommonValues.externalId1, + bpn = CommonValues.bpnSite1, + ) + + val persistencesiteGateOutputResponse2 = SiteGateOutputResponse( + site = RequestValues.site2, + externalId = CommonValues.externalIdSite2, + legalEntityExternalId = CommonValues.externalId2, + bpn = CommonValues.bpnSite2, + ) val siteGateOutput1 = SiteGateOutput( site = siteResponse1, @@ -444,4 +470,29 @@ object ResponseValues { siteExternalId = null, processStartedAt = null, ) + + //Output Response Values + val logisticAddressGateOutputResponse1 = AddressGateOutputResponse( + address = RequestValues.logisticAddress1.copy( + name = CommonValues.name1, + identifiers = listOf( + AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) + ) + ), + externalId = CommonValues.externalIdAddress1, + legalEntityExternalId = null, + bpn = CommonValues.bpnAddress1 + ) + + val logisticAddressGateOutputResponse2 = AddressGateOutputResponse( + address = RequestValues.logisticAddress2.copy( + name = CommonValues.name2, + identifiers = listOf( + AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) + ) + ), + externalId = CommonValues.externalIdAddress2, + siteExternalId = null, + bpn = CommonValues.bpnAddress2 + ) } \ No newline at end of file From 2e3336c7182122b43e453ea29cb4825f539f25ce Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 13:58:28 +0200 Subject: [PATCH 43/83] fix(Gate): business partner output response DTOs - remove BPNs to be nullable in the output DTOs - add legal address to legal entity output response - unwrap legal entity data in the legal entity request DTOs - ignore admin area level 1 in test assertions for now --- .../bpdm/gate/api/model/AddressGateOutputRequest.kt | 2 +- .../bpdm/gate/api/model/AddressGateOutputResponse.kt | 2 +- .../bpdm/gate/api/model/LegalEntityGateInputRequest.kt | 4 +++- .../bpdm/gate/api/model/LegalEntityGateOutputRequest.kt | 4 +++- .../bpdm/gate/api/model/LegalEntityGateOutputResponse.kt | 5 ++++- .../tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt | 2 +- .../tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt | 2 +- .../eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt | 7 ++++--- .../bpdm/gate/controller/LegalEntityControllerOutputIT.kt | 6 ++++-- .../org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt | 2 ++ 10 files changed, 24 insertions(+), 12 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputRequest.kt index 6232e94c0..835152d12 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputRequest.kt @@ -43,5 +43,5 @@ data class AddressGateOutputRequest( val siteExternalId: String? = null, @Schema(description = "Business Partner Number") - val bpn: String? = null + val bpn: String ) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt index 74ee67b8a..8f0362406 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputResponse.kt @@ -43,6 +43,6 @@ data class AddressGateOutputResponse( val siteExternalId: String? = null, @Schema(description = "Business Partner Number") - val bpn: String? = null, + val bpn: String ) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt index a82785af0..9b6a83b2d 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model +import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto @@ -30,7 +31,8 @@ data class LegalEntityGateInputRequest( val legalNameParts: Array = emptyArray(), - @Schema(description = "legal Enity") + @Schema(description = "legal Entity") + @field:JsonUnwrapped val legalEntity: LegalEntityDto, @get:Schema(description = "Address of the official seat of this legal entity") diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt index aed85e5fa..7fccb1ebf 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt @@ -38,6 +38,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model +import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto @@ -50,6 +51,7 @@ data class LegalEntityGateOutputRequest( val legalNameParts: Array = emptyArray(), @Schema(description = "legal Enity") + @field:JsonUnwrapped val legalEntity: LegalEntityDto, @get:Schema(description = "Address of the official seat of this legal entity") @@ -59,5 +61,5 @@ data class LegalEntityGateOutputRequest( val externalId: String, @Schema(description = "Business Partner Number") - val bpn: String?, + val bpn: String ) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt index fd804bcd6..7e3a448ee 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt @@ -31,10 +31,13 @@ data class LegalEntityGateOutputResponse( @field:JsonUnwrapped val legalEntity: LegalEntityDto, + @get:Schema(description = "Address of the official seat of this legal entity") + val legalAddress: LogisticAddressGateDto, + @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, @Schema(description = "Business Partner Number") - val bpn: String? + val bpn: String ) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt index a9782d1d6..563c6c680 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt @@ -39,5 +39,5 @@ data class SiteGateOutputRequest( val legalEntityExternalId: String, @Schema(description = "Business Partner Number") - val bpn: String?, + val bpn: String ) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt index ed552e43f..7eab20a02 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt @@ -39,5 +39,5 @@ data class SiteGateOutputResponse( val legalEntityExternalId: String, @Schema(description = "Business Partner Number") - val bpn: String? + val bpn: String ) \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 36fe45642..3c9e6ff65 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -431,7 +431,7 @@ fun LogisticAddress.toAddressGateOutputResponse(logisticAddressPage: LogisticAdd externalId = externalId, legalEntityExternalId = legalEntity?.externalId, siteExternalId = site?.externalId, - bpn = bpn, + bpn = bpn!!, ) return addressGateOutputResponse @@ -444,7 +444,7 @@ fun Site.toSiteGateOutputResponse(sitePage: Site): SiteGateOutputResponse { site = sitePage.toSiteDto(), externalId = externalId, legalEntityExternalId = legalEntity.externalId, - bpn = bpn + bpn = bpn!! ) } @@ -454,7 +454,8 @@ fun LegalEntity.toLegalEntityGateOutputResponse(legalEntity: LegalEntity): Legal return LegalEntityGateOutputResponse( legalEntity = legalEntity.toLegalEntityDto(), externalId = legalEntity.externalId, - bpn = legalEntity.bpn + bpn = legalEntity.bpn!!, + legalAddress = legalEntity.legalAddress.toLogisticAddressDto() ) } diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt index cdf05ce3c..609e2debb 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerOutputIT.kt @@ -173,7 +173,8 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( ) assertThat(pageResponse).usingRecursiveComparison().ignoringCollectionOrder().ignoringAllOverriddenEquals() - .ignoringFieldsMatchingRegexes(".*processStartedAt*").isEqualTo(expectedPage) + .ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*.") + .isEqualTo(expectedPage) } /** @@ -222,6 +223,7 @@ internal class LegalEntityControllerOutputIT @Autowired constructor( ) assertThat(pageResponse).usingRecursiveComparison().ignoringCollectionOrder().ignoringAllOverriddenEquals() - .ignoringFieldsMatchingRegexes(".*processStartedAt*").isEqualTo(expectedPage) + .ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*.") + .isEqualTo(expectedPage) } } \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index fa4a795ff..557674616 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -303,12 +303,14 @@ object ResponseValues { legalEntity = RequestValues.legalEntity1, externalId = CommonValues.externalId1, bpn = CommonValues.bpn1, + legalAddress = RequestValues.address1 ) val legalEntityGateOutputResponse2 = LegalEntityGateOutputResponse( legalEntity = RequestValues.legalEntity2, externalId = CommonValues.externalId2, bpn = CommonValues.bpn2, + legalAddress = RequestValues.address2 ) //Values without processStartedAt value From d0c36f96f536288780c1f5c73f18b53cee5f20ac Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Wed, 7 Jun 2023 09:37:06 +0200 Subject: [PATCH 44/83] fix(api): #237 Remove Field ProcessStartedAt --- .../gate/api/model/AddressGateInputResponse.kt | 4 +--- .../api/model/LegalEntityGateInputResponse.kt | 4 +--- .../bpdm/gate/api/model/SiteGateInputResponse.kt | 5 +---- .../bpdm/gate/service/ResponseMappings.kt | 3 --- .../controller/LegalEntityControllerInputIT.kt | 6 +++--- .../bpdm/gate/controller/SiteControllerInputIT.kt | 6 +++--- .../tractusx/bpdm/gate/util/ResponseValues.kt | 15 +-------------- 7 files changed, 10 insertions(+), 33 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt index c5b15f6b0..5225e9b78 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateInputResponse.kt @@ -44,6 +44,4 @@ data class AddressGateInputResponse( @Schema(description = "External id of the related site") val siteExternalId: String? = null, - @Schema(description = "Time the sharing process was started according to SaaS") - val processStartedAt: LocalDateTime? = null, -) + ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt index fd8667a02..8e4c55093 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt @@ -41,8 +41,6 @@ data class LegalEntityGateInputResponse( @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, - @Schema(description = "Time the sharing process was started according to SaaS") - val processStartedAt: LocalDateTime? = null, -) + ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt index 16e5cd6fa..0e6c6ecf9 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt @@ -23,7 +23,6 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer -import java.time.LocalDateTime @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema( @@ -39,7 +38,5 @@ data class SiteGateInputResponse( @Schema(description = "External id of the related legal entity") val legalEntityExternalId: String, - @Schema(description = "Time the sharing process was started according to SaaS") - val processStartedAt: LocalDateTime? = null, -) + ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 3c9e6ff65..84770184b 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -269,7 +269,6 @@ fun LogisticAddress.toAddressGateInputResponse(logisticAddressPage: LogisticAddr externalId = externalId, legalEntityExternalId = legalEntity?.externalId, siteExternalId = site?.externalId, - processStartedAt = null //TODO Remove ? ) return addressGateInputResponse @@ -393,7 +392,6 @@ fun LegalEntity.LegalEntityGateInputResponse(legalEntity: LegalEntity): LegalEnt legalEntity = legalEntity.toLegalEntityDto(), legalAddress = legalAddress.toLogisticAddressDto(), externalId = legalEntity.externalId, - processStartedAt = null ) } @@ -418,7 +416,6 @@ fun Site.toSiteGateInputResponse(sitePage: Site): SiteGateInputResponse { site = sitePage.toSiteDto(), externalId = externalId, legalEntityExternalId = legalEntity.externalId, - processStartedAt = null //TODO Remove this? ) } diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt index 492b648c3..dc0daab0a 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt @@ -180,7 +180,7 @@ internal class LegalEntityControllerInputIT @Autowired constructor( val legalEntity = gateClient.legalEntities().getLegalEntityByExternalId(CommonValues.externalId3) assertThat(legalEntity).usingRecursiveComparison().ignoringCollectionOrder().ignoringAllOverriddenEquals() - .ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*").isEqualTo(expectedLegalEntity) + .ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*").isEqualTo(expectedLegalEntity) } @@ -240,7 +240,7 @@ internal class LegalEntityControllerInputIT @Autowired constructor( // TODO check administrativeAreaLevel1 assertThat(pageResponse).usingRecursiveComparison().ignoringCollectionOrder().ignoringAllOverriddenEquals() - .ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*").isEqualTo( + .ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*").isEqualTo( expectedPage ) } @@ -284,7 +284,7 @@ internal class LegalEntityControllerInputIT @Autowired constructor( ) assertThat(pageResponse).usingRecursiveComparison().ignoringCollectionOrder().ignoringAllOverriddenEquals() - .ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*").isEqualTo( + .ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*").isEqualTo( expectedPage ) } diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt index 851e8cbb6..f9f46da2b 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteControllerInputIT.kt @@ -94,7 +94,7 @@ internal class SiteControllerInputIT @Autowired constructor( val site = gateClient.sites().getSiteByExternalId(CommonValues.externalIdSite1) - assertThat(site).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*").isEqualTo(expectedSite) + assertThat(site).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*").isEqualTo(expectedSite) } /** @@ -205,7 +205,7 @@ internal class SiteControllerInputIT @Autowired constructor( val paginationValue = PaginationRequest(page, size) val pageResponse = gateClient.sites().getSites(paginationValue) - assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*").isEqualTo( + assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*").isEqualTo( PageResponse( totalElements = totalElements, totalPages = totalPages, @@ -255,7 +255,7 @@ internal class SiteControllerInputIT @Autowired constructor( val paginationValue = PaginationRequest(page, size) val pageResponse = gateClient.sites().getSitesByExternalIds(paginationValue, externalIds) - assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*").isEqualTo( + assertThat(pageResponse).usingRecursiveComparison().ignoringFieldsMatchingRegexes(".*administrativeAreaLevel1*").isEqualTo( PageResponse( totalElements = totalElements, totalPages = totalPages, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 557674616..039dde6b2 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -281,23 +281,21 @@ object ResponseValues { legalEntity = RequestValues.legalEntity1, legalAddress = RequestValues.address1, externalId = CommonValues.externalId1, - processStartedAt = SaasValues.modificationTime1, ) val legalEntityGateInputResponse2 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity2, legalAddress = RequestValues.address2, externalId = CommonValues.externalId2, - processStartedAt = SaasValues.modificationTime2, ) val legalEntityGateInputResponse3 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity3, legalAddress = RequestValues.address3, externalId = CommonValues.externalId3, - processStartedAt = null, ) + //Gate Output Legal Entities Response val legalEntityGateOutputResponse1 = LegalEntityGateOutputResponse( legalEntity = RequestValues.legalEntity1, @@ -318,13 +316,11 @@ object ResponseValues { legalEntity = RequestValues.legalEntity1, legalAddress = RequestValues.address1, externalId = CommonValues.externalId1, - processStartedAt = null ) val newLegalEntityGateInputResponse2 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity2, legalAddress = RequestValues.address2, externalId = CommonValues.externalId2, - processStartedAt = null, ) val legalEntityGateOutput1 = LegalEntityGateOutput( @@ -362,29 +358,24 @@ object ResponseValues { site = RequestValues.site1, externalId = CommonValues.externalIdSite1, legalEntityExternalId = CommonValues.externalId1, - processStartedAt = SaasValues.modificationTime1, ) val siteGateInputResponse2 = SiteGateInputResponse( site = RequestValues.site2, externalId = CommonValues.externalIdSite2, legalEntityExternalId = CommonValues.externalId2, - processStartedAt = SaasValues.modificationTime2, ) - //New Site Response values without processStartedAt value val persistencesiteGateInputResponse1 = SiteGateInputResponse( site = RequestValues.site1, externalId = CommonValues.externalIdSite1, legalEntityExternalId = CommonValues.externalId1, - processStartedAt = null, ) val persistenceSiteGateInputResponse2 = SiteGateInputResponse( site = RequestValues.site2, externalId = CommonValues.externalIdSite2, legalEntityExternalId = CommonValues.externalId2, - processStartedAt = null, ) val persistencesiteGateOutputResponse1 = SiteGateOutputResponse( @@ -423,7 +414,6 @@ object ResponseValues { ), externalId = CommonValues.externalIdAddress1, legalEntityExternalId = CommonValues.externalId1, - processStartedAt = SaasValues.modificationTime1, ) val addressGateInputResponse2 = AddressGateInputResponse( @@ -437,7 +427,6 @@ object ResponseValues { ), externalId = CommonValues.externalIdAddress2, siteExternalId = CommonValues.externalIdSite1, - processStartedAt = SaasValues.modificationTime2, ) val addressGateOutput1 = AddressGateOutput( @@ -458,7 +447,6 @@ object ResponseValues { ), externalId = CommonValues.externalIdAddress1, legalEntityExternalId = null, - processStartedAt = null, ) val logisticAddressGateInputResponse2 = AddressGateInputResponse( @@ -470,7 +458,6 @@ object ResponseValues { ), externalId = CommonValues.externalIdAddress2, siteExternalId = null, - processStartedAt = null, ) //Output Response Values From 65354d2912b1db5eb91078175f53ad0172b562b6 Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Mon, 5 Jun 2023 17:24:05 +0200 Subject: [PATCH 45/83] feat(Gate): merge changelog query endpoints - rename endpoint to input path - merged endpoint now contains filters fromTime, external-ids and lsa-types - possible to search for multiple lsa types at once - put search request parameters in body - make LSA type enumeration uppercase to match it with the Pool API fixes issue ##241 --- .../bridge/dummy/service/GateQueryService.kt | 22 +++--- .../bridge/dummy/service/GateUpdateService.kt | 24 +++--- .../bridge/dummy/service/PoolUpdateService.kt | 6 +- .../bpdm/bridge/dummy/service/SyncService.kt | 6 +- .../bpdm/gate/api/GateChangelogApi.kt | 37 ++------- .../tractusx/bpdm/gate/api/model/LsaType.kt | 6 +- .../model/request/ChangeLogSearchRequest.kt | 33 ++++++++ .../gate/controller/ChangelogController.kt | 17 +---- .../gate/repository/ChangelogRepository.kt | 24 +++--- .../bpdm/gate/service/AddressService.kt | 2 +- .../bpdm/gate/service/ChangelogService.kt | 32 ++------ .../bpdm/gate/service/LegalEntityService.kt | 2 +- .../tractusx/bpdm/gate/service/SiteService.kt | 2 +- .../V4_0_0_0__uppercase_lsa_types.sql | 23 ++++++ .../gate/controller/ChangeLogControllerIT.kt | 76 ++++++------------- .../controller/SharingStateControllerIT.kt | 52 ++++++------- .../tractusx/bpdm/gate/util/CommonValues.kt | 4 +- 17 files changed, 175 insertions(+), 193 deletions(-) create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangeLogSearchRequest.kt create mode 100644 bpdm-gate/src/main/resources/db/migration/V4_0_0_0__uppercase_lsa_types.sql diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt index 4438ed334..6271b15e2 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt @@ -26,6 +26,11 @@ import com.catenax.bpdm.bridge.dummy.dto.GateSiteInfo import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.gate.api.client.GateClient +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto +import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.springframework.stereotype.Service @@ -45,9 +50,8 @@ class GateQueryService( val content = mutableListOf() do { - val pageResponse = gateClient.changelog().getChangelogEntriesLsaType( - lsaType = null, - fromTime = modifiedAfter, + val pageResponse = gateClient.changelog().getChangelogEntries( + searchRequest = ChangeLogSearchRequest(fromTime = modifiedAfter), paginationRequest = PaginationRequest(page, bridgeConfigProperties.queryPageSize) ) page++ @@ -61,16 +65,16 @@ class GateQueryService( .also { logger.info { "Changed entries in Gate since last sync: " + - "${it[LsaType.LegalEntity]?.size ?: 0} legal entities, " + - "${it[LsaType.Site]?.size ?: 0} sites, " + - "${it[LsaType.Address]?.size ?: 0} addresses" + "${it[LsaType.LEGAL_ENTITY]?.size ?: 0} legal entities, " + + "${it[LsaType.SITE]?.size ?: 0} sites, " + + "${it[LsaType.ADDRESS]?.size ?: 0} addresses" } } } fun getLegalEntityInfos(externalIds: Set): Collection { val entries = getLegalEntitiesInput(externalIds) - val bpnByExternalId = getBpnByExternalId(LsaType.LegalEntity, externalIds) + val bpnByExternalId = getBpnByExternalId(LsaType.LEGAL_ENTITY, externalIds) return entries.map { GateLegalEntityInfo( @@ -84,7 +88,7 @@ class GateQueryService( fun getSiteInfos(externalIds: Set): Collection { val entries = getSitesInput(externalIds) - val bpnByExternalId = getBpnByExternalId(LsaType.Site, externalIds) + val bpnByExternalId = getBpnByExternalId(LsaType.SITE, externalIds) return entries.map { GateSiteInfo( @@ -98,7 +102,7 @@ class GateQueryService( fun getAddressInfos(externalIds: Set): Collection { val entries = getAddressesInput(externalIds) - val bpnByExternalId = getBpnByExternalId(LsaType.Address, externalIds) + val bpnByExternalId = getBpnByExternalId(LsaType.ADDRESS, externalIds) return entries.map { GateAddressInfo( diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt index 5f6086282..97699f917 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt @@ -41,12 +41,12 @@ class GateUpdateService( ) { for (entity in responseWrapper.entities) { val externalId = entity.index - buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, entity.legalEntity.bpnl, true) + buildSuccessSharingStateDto(LsaType.LEGAL_ENTITY, externalId, entity.legalEntity.bpnl, true) ?.let { gateClient.sharingState().upsertSharingState(it) } } for (errorInfo in responseWrapper.errors) { val externalId = errorInfo.entityKey - buildErrorSharingStateDto(LsaType.LegalEntity, externalId, null, errorInfo, true) + buildErrorSharingStateDto(LsaType.LEGAL_ENTITY, externalId, null, errorInfo, true) ?.let { gateClient.sharingState().upsertSharingState(it) } } logger.info { "Sharing states for ${responseWrapper.entityCount} valid and ${responseWrapper.errorCount} invalid new legal entities were updated in the Gate" } @@ -59,13 +59,13 @@ class GateUpdateService( for (entity in responseWrapper.entities) { val bpn = entity.legalEntity.bpnl val externalId = externalIdByBpn[bpn] - buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, bpn, false) + buildSuccessSharingStateDto(LsaType.LEGAL_ENTITY, externalId, bpn, false) ?.let { gateClient.sharingState().upsertSharingState(it) } } for (errorInfo in responseWrapper.errors) { val bpn = errorInfo.entityKey val externalId = externalIdByBpn[bpn] - buildErrorSharingStateDto(LsaType.LegalEntity, externalId, bpn, errorInfo, false) + buildErrorSharingStateDto(LsaType.LEGAL_ENTITY, externalId, bpn, errorInfo, false) ?.let { gateClient.sharingState().upsertSharingState(it) } } logger.info { "Sharing states for ${responseWrapper.entityCount} valid and ${responseWrapper.errorCount} invalid modified legal entities were updated in the Gate" } @@ -76,12 +76,12 @@ class GateUpdateService( ) { for (entity in responseWrapper.entities) { val externalId = entity.index - buildSuccessSharingStateDto(LsaType.Site, externalId, entity.site.bpns, true) + buildSuccessSharingStateDto(LsaType.SITE, externalId, entity.site.bpns, true) ?.let { gateClient.sharingState().upsertSharingState(it) } } for (errorInfo in responseWrapper.errors) { val externalId = errorInfo.entityKey - buildErrorSharingStateDto(LsaType.Site, externalId, null, errorInfo, true) + buildErrorSharingStateDto(LsaType.SITE, externalId, null, errorInfo, true) ?.let { gateClient.sharingState().upsertSharingState(it) } } logger.info { "Sharing states for ${responseWrapper.entityCount} valid and ${responseWrapper.errorCount} invalid new sites were updated in the Gate" } @@ -94,13 +94,13 @@ class GateUpdateService( for (entity in responseWrapper.entities) { val bpn = entity.site.bpns val externalId = externalIdByBpn[bpn] - buildSuccessSharingStateDto(LsaType.Site, externalId, bpn, false) + buildSuccessSharingStateDto(LsaType.SITE, externalId, bpn, false) ?.let { gateClient.sharingState().upsertSharingState(it) } } for (errorInfo in responseWrapper.errors) { val bpn = errorInfo.entityKey val externalId = externalIdByBpn[bpn] - buildErrorSharingStateDto(LsaType.Site, externalId, bpn, errorInfo, false) + buildErrorSharingStateDto(LsaType.SITE, externalId, bpn, errorInfo, false) ?.let { gateClient.sharingState().upsertSharingState(it) } } logger.info { "Sharing states for ${responseWrapper.entityCount} valid and ${responseWrapper.errorCount} invalid modified sites were updated in the Gate" } @@ -111,12 +111,12 @@ class GateUpdateService( ) { for (entity in responseWrapper.entities) { val externalId = entity.index - buildSuccessSharingStateDto(LsaType.Address, externalId, entity.address.bpna, true) + buildSuccessSharingStateDto(LsaType.ADDRESS, externalId, entity.address.bpna, true) ?.let { gateClient.sharingState().upsertSharingState(it) } } for (errorInfo in responseWrapper.errors) { val externalId = errorInfo.entityKey - buildErrorSharingStateDto(LsaType.Address, externalId, null, errorInfo, true) + buildErrorSharingStateDto(LsaType.ADDRESS, externalId, null, errorInfo, true) ?.let { gateClient.sharingState().upsertSharingState(it) } } logger.info { "Sharing states for ${responseWrapper.entityCount} valid and ${responseWrapper.errorCount} invalid new addresses were updated in the Gate" } @@ -129,13 +129,13 @@ class GateUpdateService( for (entity in responseWrapper.entities) { val bpn = entity.bpna val externalId = externalIdByBpn[bpn] - buildSuccessSharingStateDto(LsaType.Address, externalId, bpn, false) + buildSuccessSharingStateDto(LsaType.ADDRESS, externalId, bpn, false) ?.let { gateClient.sharingState().upsertSharingState(it) } } for (errorInfo in responseWrapper.errors) { val bpn = errorInfo.entityKey val externalId = externalIdByBpn[bpn] - buildErrorSharingStateDto(LsaType.Address, externalId, bpn, errorInfo, false) + buildErrorSharingStateDto(LsaType.ADDRESS, externalId, bpn, errorInfo, false) ?.let { gateClient.sharingState().upsertSharingState(it) } } logger.info { "Sharing states for ${responseWrapper.entityCount} valid and ${responseWrapper.errorCount} invalid modified addresses were updated in the Gate" } diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index 138eb67b6..faf2aff36 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -101,7 +101,7 @@ class PoolUpdateService( fun createSitesInPool(entriesToCreate: Collection): SitePartnerCreateResponseWrapper { val leParentBpnByExternalId = entriesToCreate .map { it.legalEntityExternalId } - .let { gateQueryService.getBpnByExternalId(LsaType.LegalEntity, it.toSet()) } + .let { gateQueryService.getBpnByExternalId(LsaType.LEGAL_ENTITY, it.toSet()) } val createRequests = entriesToCreate.mapNotNull { entry -> leParentBpnByExternalId[entry.legalEntityExternalId] ?.let { leParentBpn -> @@ -146,7 +146,7 @@ class PoolUpdateService( fun createAddressesInPool(entriesToCreate: Collection): AddressPartnerCreateResponseWrapper { val leParentBpnByExternalId = entriesToCreate .mapNotNull { it.legalEntityExternalId } - .let { gateQueryService.getBpnByExternalId(LsaType.LegalEntity, it.toSet()) } + .let { gateQueryService.getBpnByExternalId(LsaType.LEGAL_ENTITY, it.toSet()) } val leParentsCreateRequests = entriesToCreate.mapNotNull { entry -> leParentBpnByExternalId[entry.legalEntityExternalId] ?.let { leParentBpn -> @@ -160,7 +160,7 @@ class PoolUpdateService( val siteParentBpnByExternalId = entriesToCreate .mapNotNull { it.siteExternalId } - .let { gateQueryService.getBpnByExternalId(LsaType.Site, it.toSet()) } + .let { gateQueryService.getBpnByExternalId(LsaType.SITE, it.toSet()) } val siteParentsCreateRequests = entriesToCreate.mapNotNull { entry -> siteParentBpnByExternalId[entry.siteExternalId] ?.let { siteParentBpn -> diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/SyncService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/SyncService.kt index 66977f99f..883b01bad 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/SyncService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/SyncService.kt @@ -55,9 +55,9 @@ class SyncService( // Check changelog entries from Gate (after last sync time) val externalIdsByType = gateQueryService.getChangedExternalIdsByLsaType(modifiedAfter) - externalIdsByType[LsaType.LegalEntity]?.let { syncLegalEntities(it) } - externalIdsByType[LsaType.Site]?.let { syncSites(it) } - externalIdsByType[LsaType.Address]?.let { syncAddresses(it) } + externalIdsByType[LsaType.LEGAL_ENTITY]?.let { syncLegalEntities(it) } + externalIdsByType[LsaType.SITE]?.let { syncSites(it) } + externalIdsByType[LsaType.ADDRESS]?.let { syncAddresses(it) } } private fun syncLegalEntities(externalIdsRequested: Set) { diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt index 330b11540..b7fae38eb 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt @@ -20,15 +20,12 @@ package org.eclipse.tractusx.bpdm.gate.api import io.swagger.v3.oas.annotations.Operation -import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import jakarta.validation.Valid -import jakarta.validation.constraints.NotEmpty import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.gate.api.model.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse import org.springdoc.core.annotations.ParameterObject @@ -36,16 +33,15 @@ import org.springframework.http.MediaType import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange -import java.time.Instant -@RequestMapping("/api/catena/business-partners/changelog", produces = [MediaType.APPLICATION_JSON_VALUE]) -@HttpExchange("/api/catena/business-partners/changelog") +@RequestMapping("/api/catena/input/business-partners/changelog", produces = [MediaType.APPLICATION_JSON_VALUE]) +@HttpExchange("/api/catena/input/business-partners/changelog") interface GateChangelogApi { @Operation( - summary = "Get business partner changelog entries by list external id, from timestamp", - description = "Get business partner changelog entries by list external id, from timestamp" + summary = "Get business partner changelog entries by list external id, from timestamp and/or lsa type", + description = "Get business partner changelog entries by list external id, from timestamp and/or lsa type" ) @ApiResponses( value = [ @@ -55,28 +51,9 @@ interface GateChangelogApi { ) @PostMapping("/search") @PostExchange("/search") - fun getChangelogEntriesExternalId( + fun getChangelogEntries( @ParameterObject @Valid paginationRequest: PaginationRequest, - @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam(required = false) fromTime: Instant?, - @RequestBody(required = true) @NotEmpty(message = "Input externalIds list cannot be empty.") externalIds: Set + @RequestBody searchRequest: ChangeLogSearchRequest ): PageChangeLogResponse - @Operation( - summary = "Get business partner changelog entries by timestamp or LSA type", - description = "Get business partner changelog entries by from timestamp or LSA type" - ) - @ApiResponses( - value = [ - ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), - ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), - ] - ) - @PostMapping("/filter") - @PostExchange("/filter") - fun getChangelogEntriesLsaType( - @ParameterObject @Valid paginationRequest: PaginationRequest, - @Parameter(description = "From Time", example = "2023-03-20T10:23:28.194Z") @RequestParam(required = false) fromTime: Instant?, - @Parameter(description = "LSA Type") @RequestParam(required = false) lsaType: LsaType? - ): PageResponse - } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LsaType.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LsaType.kt index edc676704..0fcd358aa 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LsaType.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LsaType.kt @@ -20,7 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model enum class LsaType { - LegalEntity, - Site, - Address + LEGAL_ENTITY, + SITE, + ADDRESS } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangeLogSearchRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangeLogSearchRequest.kt new file mode 100644 index 000000000..b08dc42ec --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangeLogSearchRequest.kt @@ -0,0 +1,33 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model.request + +import io.swagger.v3.oas.annotations.Parameter +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType +import java.time.Instant + +data class ChangeLogSearchRequest( + @field:Parameter(description = "From when to search changelog entries", example = "2023-03-20T10:23:28.194Z", required = false) + val fromTime: Instant? = null, + @field:Parameter(description = "External-IDs of business partners for which to search changelog entries. Ignored if empty", required = false) + val externalIds: Set = emptySet(), + @field:Parameter(description = "Lsa-Types of business partners for which to search changelog entries. Ignored if empty", required = false) + val lsaTypes: Set = emptySet() + ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 2018c0cc3..1a290e529 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -20,15 +20,13 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateChangelogApi -import org.eclipse.tractusx.bpdm.gate.api.model.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse import org.eclipse.tractusx.bpdm.gate.service.ChangelogService import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.RestController -import java.time.Instant @RestController @Validated @@ -36,17 +34,10 @@ class ChangelogController( private val changelogService: ChangelogService ) : GateChangelogApi { - override fun getChangelogEntriesExternalId( - paginationRequest: PaginationRequest, fromTime: Instant?, externalIds: Set + override fun getChangelogEntries( + paginationRequest: PaginationRequest, searchRequest: ChangeLogSearchRequest ): PageChangeLogResponse { - return changelogService.getChangeLogByExternalId(externalIds, fromTime, paginationRequest.page, paginationRequest.size) + return changelogService.getChangeLogEntries(searchRequest.externalIds, searchRequest.lsaTypes, searchRequest.fromTime, paginationRequest.page, paginationRequest.size) } - override fun getChangelogEntriesLsaType( - paginationRequest: PaginationRequest, fromTime: Instant?, lsaType: LsaType? - ): PageResponse { - return changelogService.getChangeLogByLsaType(lsaType, fromTime, paginationRequest.page, paginationRequest.size) - } - - } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index c25bdda2f..c27bd60c4 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -33,15 +33,16 @@ interface ChangelogRepository : JpaRepository, JpaSpecific object Specs { /** - * Restrict to entries with any one of the given ExternalIds; ignore if null + * Restrict to entries with any one of the given ExternalIds; ignore if empty */ - fun byExternalIdsIn(externalIds: Collection) = + fun byExternalIdsIn(externalIds: Collection?) = Specification { root, _, _ -> - - externalIds.let { - root.get(ChangelogEntry::externalId.name).`in`(externalIds.map { externalId -> externalId }) + externalIds?.let { + if(externalIds.isNotEmpty()) + root.get(ChangelogEntry::externalId.name).`in`(externalIds.map { externalId -> externalId }) + else + null } - } /** @@ -55,12 +56,15 @@ interface ChangelogRepository : JpaRepository, JpaSpecific } /** - * Restrict to entries for the LsaType; ignore if null + * Restrict to entries for the LsaType; ignore if empty */ - fun byLsaType(lsaType: LsaType?) = + fun byLsaTypes(lsaTypes: Set?) = Specification { root, _, builder -> - lsaType?.let { - builder.equal(root.get(ChangelogEntry::businessPartnerType.name), lsaType) + lsaTypes?.let { + if(lsaTypes.isNotEmpty()) + root.get(ChangelogEntry::businessPartnerType.name).`in`(lsaTypes.map { lsaType -> lsaType }) + else + null } } } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index 81e82783d..7302b640f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -117,7 +117,7 @@ class AddressService( // create changelog entry if all goes well from saasClient addresses.forEach { address -> - changelogRepository.save(ChangelogEntry(address.externalId, LsaType.Address)) + changelogRepository.save(ChangelogEntry(address.externalId, LsaType.ADDRESS)) } addressPersistenceService.persistAddressBP(addresses, OutputInputEnum.Input) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index 12bbe40b2..edab530f7 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.service -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse @@ -28,7 +27,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byCreatedAtGreaterThan import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byExternalIdsIn -import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byLsaType +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byLsaTypes import org.springframework.data.domain.PageRequest import org.springframework.data.jpa.domain.Specification import org.springframework.stereotype.Service @@ -37,19 +36,21 @@ import java.time.Instant @Service class ChangelogService(private val changelogRepository: ChangelogRepository) { - fun getChangeLogByExternalId(externalIds: Set, createdAt: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { + fun getChangeLogEntries(externalIds: Set?, lsaTypes: Set?, createdAt: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { - val spec = Specification.allOf(byExternalIdsIn(externalIds = externalIds), byCreatedAtGreaterThan(createdAt = createdAt)) + val nonNullExternalIds = externalIds ?: emptySet() + + val spec = Specification.allOf(byExternalIdsIn(externalIds = nonNullExternalIds), byCreatedAtGreaterThan(createdAt = createdAt), byLsaTypes(lsaTypes)) val pageable = PageRequest.of(page, pageSize) val pageResponse = changelogRepository.findAll(spec, pageable) - val setDistinctList = changelogRepository.findExternalIdsInListDistinct(externalIds) + val setDistinctList = changelogRepository.findExternalIdsInListDistinct(nonNullExternalIds) val pageDto = pageResponse.map { it.toGateDto() } - val errorList = (externalIds - setDistinctList).map { + val errorList = (nonNullExternalIds - setDistinctList).map { ErrorInfo( ChangeLogOutputError.ExternalIdNotFound, "$it not found", @@ -68,23 +69,4 @@ class ChangelogService(private val changelogRepository: ChangelogRepository) { ) } - fun getChangeLogByLsaType(lsaType: LsaType?, createdAt: Instant?, page: Int, pageSize: Int): PageResponse { - - val spec = Specification.allOf(byCreatedAtGreaterThan(createdAt = createdAt), byLsaType(lsaType)) - val pageable = PageRequest.of(page, pageSize) - val pageResponse = changelogRepository.findAll(spec, pageable) - - val pageDto = pageResponse.map { - it.toGateDto() - } - - return PageResponse( - page = page, - totalElements = pageDto.totalElements, - totalPages = pageDto.totalPages, - contentSize = pageDto.content.size, - content = pageDto.content, - ) - } - } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index de8ab8cf9..a5e3e9be4 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -51,7 +51,7 @@ class LegalEntityService( fun upsertLegalEntities(legalEntities: Collection) { legalEntities.forEach { legalEntity -> - changelogRepository.save(ChangelogEntry(legalEntity.externalId, LsaType.LegalEntity)) + changelogRepository.save(ChangelogEntry(legalEntity.externalId, LsaType.LEGAL_ENTITY)) } legalEntityPersistenceService.persistLegalEntitiesBP(legalEntities, OutputInputEnum.Input) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index 4d0622a9f..0fed808c6 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -112,7 +112,7 @@ class SiteService( fun upsertSites(sites: Collection) { sites.forEach { site -> - changelogRepository.save(ChangelogEntry(site.externalId, LsaType.Site)) + changelogRepository.save(ChangelogEntry(site.externalId, LsaType.SITE)) } sitePersistenceService.persistSitesBP(sites, OutputInputEnum.Input) diff --git a/bpdm-gate/src/main/resources/db/migration/V4_0_0_0__uppercase_lsa_types.sql b/bpdm-gate/src/main/resources/db/migration/V4_0_0_0__uppercase_lsa_types.sql new file mode 100644 index 000000000..fff02eef2 --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V4_0_0_0__uppercase_lsa_types.sql @@ -0,0 +1,23 @@ +UPDATE changelog_entries +SET business_partner_type = 'LEGAL_ENTITY' +WHERE business_partner_type = 'LegalEntity'; + +UPDATE changelog_entries +SET business_partner_type = 'SITE' +WHERE business_partner_type = 'Site'; + +UPDATE changelog_entries +SET business_partner_type = 'ADDRESS' +WHERE business_partner_type = 'Address'; + +UPDATE sharing_states +SET lsa_type = 'LEGAL_ENTITY' +WHERE lsa_type = 'LegalEntity'; + +UPDATE sharing_states +SET lsa_type = 'SITE' +WHERE lsa_type = 'Site'; + +UPDATE sharing_states +SET lsa_type = 'ADDRESS' +WHERE lsa_type = 'Address'; \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt index 9b7888a4b..5613912f6 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt @@ -48,6 +48,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.config.SaasConfigProperties @@ -107,7 +108,9 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by external id`() { - val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), null, setOf(CommonValues.externalIdAddress1)) + val searchRequest = ChangeLogSearchRequest(externalIds = setOf(CommonValues.externalIdAddress1)) + + val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) assertRecursively(searchResult.content) .ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") @@ -123,7 +126,9 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by external id not found`() { - val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), null, setOf("NONEXIST")) + val searchRequest = ChangeLogSearchRequest(externalIds = setOf("NONEXIST")) + + val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) assertThat(searchResult.content) .usingRecursiveComparison() @@ -156,7 +161,9 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by external id and timeStamp`() { - val searchResult = gateClient.changelog().getChangelogEntriesExternalId(PaginationRequest(), instant, setOf(CommonValues.externalIdAddress1)) + val searchRequest = ChangeLogSearchRequest(externalIds = setOf(CommonValues.externalIdAddress1), fromTime = instant) + + val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") @@ -171,7 +178,9 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by lsaType`() { - val searchResult = gateClient.changelog().getChangelogEntriesLsaType(PaginationRequest(), null, lsaTypeParam) + val searchRequest = ChangeLogSearchRequest(lsaTypes = setOf(lsaTypeParam)) + + val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) @@ -185,7 +194,9 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by lsaType not found`() { - val searchResult = gateClient.changelog().getChangelogEntriesLsaType(PaginationRequest(), null, lsaTypeParamNotFound) + val searchRequest = ChangeLogSearchRequest(lsaTypes = setOf(lsaTypeParamNotFound)) + + val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) assertRecursively(searchResult.content) .isEqualTo(emptyList()) @@ -198,8 +209,9 @@ internal class ChangeLogControllerIT @Autowired constructor( */ @Test fun `get changeLog by lsaType and timeStamp`() { + val searchRequest = ChangeLogSearchRequest(lsaTypes = setOf(lsaTypeParam), fromTime = instant) - val searchResult = gateClient.changelog().getChangelogEntriesLsaType(PaginationRequest(), instant, lsaTypeParam) + val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) @@ -213,7 +225,9 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog from timeStamp`() { - val searchResult = gateClient.changelog().getChangelogEntriesLsaType(paginationRequest = PaginationRequest(), fromTime = instant, lsaType = null) + val searchRequest = ChangeLogSearchRequest(lsaTypes = emptySet(), fromTime = instant) + + val searchResult = gateClient.changelog().getChangelogEntries(paginationRequest = PaginationRequest(), searchRequest) assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) @@ -271,23 +285,7 @@ internal class ChangeLogControllerIT @Autowired constructor( ) ) ) - val stubMappingUpsertAddresses = wireMockServer.stubFor( - put(urlPathMatching(EndpointValues.SAAS_MOCK_BUSINESS_PARTNER_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - UpsertResponse( - emptyList(), - emptyList(), - 2, - 0 - ) - ) - ) - ) - ) + // mock "get addresses with relations" // this simulates the case that the address already had some relations wireMockServer.stubFor( @@ -312,36 +310,6 @@ internal class ChangeLogControllerIT @Autowired constructor( ) ) ) - val stubMappingDeleteRelations = wireMockServer.stubFor( - post(urlPathMatching(EndpointValues.SAAS_MOCK_DELETE_RELATIONS_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - DeleteRelationsResponseSaas(2) - ) - ) - ) - ) - val stubMappingUpsertRelations = wireMockServer.stubFor( - put(urlPathMatching(EndpointValues.SAAS_MOCK_RELATIONS_PATH)) - .willReturn( - aResponse() - .withHeader("Content-Type", "application/json") - .withBody( - objectMapper.writeValueAsString( - UpsertRelationsResponseSaas( - failures = emptyList(), - numberOfFailed = 0, - numberOfInserts = 2, - numberOfProvidedRelations = 2, - numberOfUpdates = 0 - ) - ) - ) - ) - ) } diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateControllerIT.kt index d52ccefe5..0ab3dc63e 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateControllerIT.kt @@ -54,36 +54,36 @@ class SharingStateControllerIT @Autowired constructor( @Test fun `insert and get sharing states `() { - val stateAddress = insertSharingStateSuccess(LsaType.Address, externalId = "exIdAddress") - val stateSite = insertSharingStateSuccess(LsaType.Site, externalId = "exIdSite") - val stateLegalEntity1 = insertSharingStateSuccess(LsaType.LegalEntity, externalId = "exIdEntity1") - val stateLegalEntity2 = insertSharingStateSuccess(LsaType.LegalEntity, externalId = "exIdEntity2") - insertSharingStateSuccess(LsaType.Address, externalId = "exIdMultiple") - insertSharingStateSuccess(LsaType.Site, externalId = "exIdMultiple") - insertSharingStateSuccess(LsaType.LegalEntity, externalId = "exIdMultiple") - - val searchAddressById = readSharingStates(LsaType.Address, "exIdAddress") + val stateAddress = insertSharingStateSuccess(LsaType.ADDRESS, externalId = "exIdAddress") + val stateSite = insertSharingStateSuccess(LsaType.SITE, externalId = "exIdSite") + val stateLegalEntity1 = insertSharingStateSuccess(LsaType.LEGAL_ENTITY, externalId = "exIdEntity1") + val stateLegalEntity2 = insertSharingStateSuccess(LsaType.LEGAL_ENTITY, externalId = "exIdEntity2") + insertSharingStateSuccess(LsaType.ADDRESS, externalId = "exIdMultiple") + insertSharingStateSuccess(LsaType.SITE, externalId = "exIdMultiple") + insertSharingStateSuccess(LsaType.LEGAL_ENTITY, externalId = "exIdMultiple") + + val searchAddressById = readSharingStates(LsaType.ADDRESS, "exIdAddress") assertThat(searchAddressById).hasSize(1) assertThat(searchAddressById.first()).isEqualTo(stateAddress) - val searchSitesById = readSharingStates(LsaType.Site, "exIdSite") + val searchSitesById = readSharingStates(LsaType.SITE, "exIdSite") assertThat(searchSitesById).hasSize(1) assertThat(searchSitesById.first()).isEqualTo(stateSite) - val searchAddressWrongId = readSharingStates(LsaType.Address, "exIdEntity") + val searchAddressWrongId = readSharingStates(LsaType.ADDRESS, "exIdEntity") assertThat(searchAddressWrongId).hasSize(0) - val searchEntityMultiple = readSharingStates(LsaType.LegalEntity, "exIdEntity1", "exIdEntity2") + val searchEntityMultiple = readSharingStates(LsaType.LEGAL_ENTITY, "exIdEntity1", "exIdEntity2") assertThat(searchEntityMultiple).hasSize(2) - val searchEntitySingle = readSharingStates(LsaType.LegalEntity, "exIdEntity2") + val searchEntitySingle = readSharingStates(LsaType.LEGAL_ENTITY, "exIdEntity2") assertThat(searchEntitySingle).hasSize(1) assertThat(searchEntitySingle.first()).isEqualTo(stateLegalEntity2) val searchAll = readSharingStates(null) assertThat(searchAll).hasSize(7) - val searchEntityAllLegalEntities = readSharingStates(LsaType.LegalEntity) + val searchEntityAllLegalEntities = readSharingStates(LsaType.LEGAL_ENTITY) assertThat(searchEntityAllLegalEntities).hasSize(3) assertThat(searchEntityAllLegalEntities).extracting(SharingStateDto::externalId.name) .contains(stateLegalEntity1.externalId, stateLegalEntity2.externalId, "exIdMultiple") @@ -98,11 +98,11 @@ class SharingStateControllerIT @Autowired constructor( @Test fun `insert and get sharing states with error code`() { - val stateAddress1 = insertSharingStateError(LsaType.Address, externalId = "exIdAddress1", errorCode = SharingTimeout) - insertSharingStateError(LsaType.Address, externalId = "exIdAddress2", errorCode = SharingProcessError) - insertSharingStateError(LsaType.Address, externalId = "exIdAddress3", errorCode = BpnNotInPool) + val stateAddress1 = insertSharingStateError(LsaType.ADDRESS, externalId = "exIdAddress1", errorCode = SharingTimeout) + insertSharingStateError(LsaType.ADDRESS, externalId = "exIdAddress2", errorCode = SharingProcessError) + insertSharingStateError(LsaType.ADDRESS, externalId = "exIdAddress3", errorCode = BpnNotInPool) - val searchAddress = readSharingStates(LsaType.Address, "exIdAddress1") + val searchAddress = readSharingStates(LsaType.ADDRESS, "exIdAddress1") assertThat(searchAddress).hasSize(1) assertThat(searchAddress.first()).isEqualTo(stateAddress1) } @@ -110,11 +110,11 @@ class SharingStateControllerIT @Autowired constructor( @Test fun `insert and update states`() { - val stateAddress1 = insertSharingStateError(LsaType.Address, externalId = "exIdAddress1", errorCode = SharingTimeout) - insertSharingStateError(LsaType.Address, externalId = "exIdAddress2", errorCode = SharingProcessError) - insertSharingStateError(LsaType.Address, externalId = "exIdAddress3", errorCode = BpnNotInPool) + val stateAddress1 = insertSharingStateError(LsaType.ADDRESS, externalId = "exIdAddress1", errorCode = SharingTimeout) + insertSharingStateError(LsaType.ADDRESS, externalId = "exIdAddress2", errorCode = SharingProcessError) + insertSharingStateError(LsaType.ADDRESS, externalId = "exIdAddress3", errorCode = BpnNotInPool) - val searchAddress = readSharingStates(LsaType.Address, "exIdAddress1") + val searchAddress = readSharingStates(LsaType.ADDRESS, "exIdAddress1") assertThat(searchAddress).hasSize(1) assertThat(searchAddress.first()).isEqualTo(stateAddress1) @@ -128,7 +128,7 @@ class SharingStateControllerIT @Autowired constructor( gateClient.sharingState().upsertSharingState(updatedAddress1) - val readUpdatedAddress = readSharingStates(LsaType.Address, "exIdAddress1") + val readUpdatedAddress = readSharingStates(LsaType.ADDRESS, "exIdAddress1") assertThat(readUpdatedAddress).hasSize(1) assertThat(readUpdatedAddress.first()).isEqualTo(updatedAddress1) } @@ -138,11 +138,11 @@ class SharingStateControllerIT @Autowired constructor( val startTime = LocalDateTime.now().withNano(0) val stateAddress1 = insertSharingStateSuccess( - lsaType = LsaType.Address, externalId = "exIdAddress1", + lsaType = LsaType.ADDRESS, externalId = "exIdAddress1", sharingProcessStarted = startTime ) - val readInsertedAddress = readSharingStates(LsaType.Address, "exIdAddress1") + val readInsertedAddress = readSharingStates(LsaType.ADDRESS, "exIdAddress1") assertThat(readInsertedAddress.first().sharingProcessStarted).isEqualTo(startTime) val updatedWithEmpyStarted = stateAddress1.copy( @@ -152,7 +152,7 @@ class SharingStateControllerIT @Autowired constructor( ) gateClient.sharingState().upsertSharingState(updatedWithEmpyStarted) - val readUpdatedAddress = readSharingStates(LsaType.Address, "exIdAddress1") + val readUpdatedAddress = readSharingStates(LsaType.ADDRESS, "exIdAddress1") assertThat(readUpdatedAddress.first().sharingStateType).isEqualTo(SharingStateType.Error) assertThat(readUpdatedAddress.first().sharingProcessStarted).isEqualTo(startTime).describedAs("Update with null - sharingProcessStarted not changed ") assertThat(readUpdatedAddress.first().sharingErrorMessage).isEqualTo("Changed") diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt index dd3d3f6cf..aab13a3e3 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/CommonValues.kt @@ -44,8 +44,8 @@ object CommonValues { const val externalId4 = "external-4" const val externalId5 = "external-5" - val lsaTypeParam = LsaType.Address - val lsaTypeParamNotFound = LsaType.Site + val lsaTypeParam = LsaType.ADDRESS + val lsaTypeParamNotFound = LsaType.SITE val lsaNone = OptionalLsaType.None const val externalIdSite1 = "site-external-1" From 406a50ad8801ea184d2f836b7e0f1e64b4f63beb Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 14:40:50 +0200 Subject: [PATCH 46/83] feat(Gate-API): add endpoint for output changelogs - endpoint only for API, logic not implemented yet --- .../bridge/dummy/service/GateQueryService.kt | 2 +- .../bpdm/gate/api/GateChangelogApi.kt | 31 ++++++++++++++----- .../gate/controller/ChangelogController.kt | 8 ++++- .../gate/controller/ChangeLogControllerIT.kt | 14 ++++----- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt index 6271b15e2..cb49086d4 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt @@ -50,7 +50,7 @@ class GateQueryService( val content = mutableListOf() do { - val pageResponse = gateClient.changelog().getChangelogEntries( + val pageResponse = gateClient.changelog().getInputChangelog( searchRequest = ChangeLogSearchRequest(fromTime = modifiedAfter), paginationRequest = PaginationRequest(page, bridgeConfigProperties.queryPageSize) ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt index b7fae38eb..6287e5e8e 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt @@ -34,14 +34,14 @@ import org.springframework.web.bind.annotation.* import org.springframework.web.service.annotation.HttpExchange import org.springframework.web.service.annotation.PostExchange -@RequestMapping("/api/catena/input/business-partners/changelog", produces = [MediaType.APPLICATION_JSON_VALUE]) -@HttpExchange("/api/catena/input/business-partners/changelog") +@RequestMapping("/api/catena", produces = [MediaType.APPLICATION_JSON_VALUE]) +@HttpExchange("/api/catena") interface GateChangelogApi { @Operation( - summary = "Get business partner changelog entries by list external id, from timestamp and/or lsa type", - description = "Get business partner changelog entries by list external id, from timestamp and/or lsa type" + summary = "Get business partner changelog entries for changes to the business partner input data", + description = "Get business partner changelog entries for changes to the business partner input data. Filter by list external id, from timestamp and/or lsa type" ) @ApiResponses( value = [ @@ -49,11 +49,28 @@ interface GateChangelogApi { ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), ] ) - @PostMapping("/search") - @PostExchange("/search") - fun getChangelogEntries( + @PostMapping("/input/changelog/search") + @PostExchange("/input/changelog/search") + fun getInputChangelog( @ParameterObject @Valid paginationRequest: PaginationRequest, @RequestBody searchRequest: ChangeLogSearchRequest ): PageChangeLogResponse + + @Operation( + summary = "Get business partner changelog entries for changes to the business partner output data", + description = "Get business partner changelog entries for changes to the business partner output data. Filter by list external id, from timestamp and/or lsa type" + ) + @ApiResponses( + value = [ + ApiResponse(responseCode = "200", description = "The changelog entries for the specified parameters"), + ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), + ] + ) + @PostMapping("/output/changelog/search") + @PostExchange("/output/changelog/search") + fun getOutputChangelog( + @ParameterObject @Valid paginationRequest: PaginationRequest, + @RequestBody searchRequest: ChangeLogSearchRequest + ): PageChangeLogResponse } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 1a290e529..30383e275 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -34,10 +34,16 @@ class ChangelogController( private val changelogService: ChangelogService ) : GateChangelogApi { - override fun getChangelogEntries( + override fun getInputChangelog( paginationRequest: PaginationRequest, searchRequest: ChangeLogSearchRequest ): PageChangeLogResponse { return changelogService.getChangeLogEntries(searchRequest.externalIds, searchRequest.lsaTypes, searchRequest.fromTime, paginationRequest.page, paginationRequest.size) } + override fun getOutputChangelog(paginationRequest: PaginationRequest, + searchRequest: ChangeLogSearchRequest): PageChangeLogResponse { + throw NotImplementedError() + TODO("Not yet implemented") + } + } \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt index 5613912f6..50a780a16 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt @@ -110,7 +110,7 @@ internal class ChangeLogControllerIT @Autowired constructor( val searchRequest = ChangeLogSearchRequest(externalIds = setOf(CommonValues.externalIdAddress1)) - val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) + val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) assertRecursively(searchResult.content) .ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") @@ -128,7 +128,7 @@ internal class ChangeLogControllerIT @Autowired constructor( val searchRequest = ChangeLogSearchRequest(externalIds = setOf("NONEXIST")) - val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) + val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) assertThat(searchResult.content) .usingRecursiveComparison() @@ -163,7 +163,7 @@ internal class ChangeLogControllerIT @Autowired constructor( val searchRequest = ChangeLogSearchRequest(externalIds = setOf(CommonValues.externalIdAddress1), fromTime = instant) - val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) + val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") @@ -180,7 +180,7 @@ internal class ChangeLogControllerIT @Autowired constructor( val searchRequest = ChangeLogSearchRequest(lsaTypes = setOf(lsaTypeParam)) - val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) + val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) @@ -196,7 +196,7 @@ internal class ChangeLogControllerIT @Autowired constructor( fun `get changeLog by lsaType not found`() { val searchRequest = ChangeLogSearchRequest(lsaTypes = setOf(lsaTypeParamNotFound)) - val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) + val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) assertRecursively(searchResult.content) .isEqualTo(emptyList()) @@ -211,7 +211,7 @@ internal class ChangeLogControllerIT @Autowired constructor( fun `get changeLog by lsaType and timeStamp`() { val searchRequest = ChangeLogSearchRequest(lsaTypes = setOf(lsaTypeParam), fromTime = instant) - val searchResult = gateClient.changelog().getChangelogEntries(PaginationRequest(), searchRequest) + val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) @@ -227,7 +227,7 @@ internal class ChangeLogControllerIT @Autowired constructor( val searchRequest = ChangeLogSearchRequest(lsaTypes = emptySet(), fromTime = instant) - val searchResult = gateClient.changelog().getChangelogEntries(paginationRequest = PaginationRequest(), searchRequest) + val searchResult = gateClient.changelog().getInputChangelog(paginationRequest = PaginationRequest(), searchRequest) assertRecursively(searchResult.content).ignoringFieldsMatchingRegexes(".*${ChangelogResponse::modifiedAt.name}") .isEqualTo(listOf(ChangelogResponse(CommonValues.externalIdAddress1, lsaTypeParam, instant))) From d28cdda7f9d8b92e97a50a966ff7cfd3cacc154a Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Tue, 6 Jun 2023 14:13:59 +0200 Subject: [PATCH 47/83] feat(Pool): add LSA type filter to changelog endpoint - add LSA type to changelog entry response - make changelog endpoint http POST with search request body - create API integration level tests for changelog fixes issue #240 --- ...inessPartnerApi.kt => PoolChangelogApi.kt} | 28 +- .../bpdm/pool/api/client/PoolApiClient.kt | 2 +- .../bpdm/pool/api/client/PoolClientImpl.kt | 4 +- .../tractusx/bpdm/pool/api/model/LsaType.kt | 25 + .../model/request/ChangelogSearchRequest.kt | 35 ++ .../model/response/ChangelogEntryResponse.kt | 5 +- .../impl/service/OpenSearchSyncPageService.kt | 2 +- ...erController.kt => ChangelogController.kt} | 31 +- .../bpdm/pool/dto/ChangelogEntryDto.kt | 2 +- .../bpdm/pool/entity/PartnerChangelogEntry.kt | 6 +- .../PartnerChangelogEntryRepository.kt | 28 +- .../service/BusinessPartnerBuildService.kt | 1 + .../pool/service/PartnerChangelogService.kt | 20 +- .../bpdm/pool/service/ResponseMappings.kt | 2 +- .../pool/controller/ChangelogControllerIT.kt | 458 ++++++++++++++++++ .../bpdm/pool/service/PartnerChangelogIT.kt | 259 ---------- 16 files changed, 586 insertions(+), 322 deletions(-) rename bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/{PoolBusinessPartnerApi.kt => PoolChangelogApi.kt} (70%) create mode 100644 bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LsaType.kt create mode 100644 bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/ChangelogSearchRequest.kt rename bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/{BusinessPartnerController.kt => ChangelogController.kt} (68%) create mode 100644 bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogControllerIT.kt delete mode 100644 bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolChangelogApi.kt similarity index 70% rename from bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt rename to bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolChangelogApi.kt index da540a523..e4347a15d 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolBusinessPartnerApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolChangelogApi.kt @@ -21,42 +21,40 @@ package org.eclipse.tractusx.bpdm.pool.api import io.swagger.v3.oas.annotations.Operation -import io.swagger.v3.oas.annotations.Parameter import io.swagger.v3.oas.annotations.media.Content import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.pool.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse import org.springdoc.core.annotations.ParameterObject import org.springframework.http.MediaType -import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.service.annotation.GetExchange import org.springframework.web.service.annotation.HttpExchange -import java.time.Instant +import org.springframework.web.service.annotation.PostExchange -@RequestMapping("/api/catena/business-partners", produces = [MediaType.APPLICATION_JSON_VALUE]) -@HttpExchange("/api/catena/business-partners") -interface PoolBusinessPartnerApi { +@RequestMapping("/api/catena/business-partners/changelog", produces = [MediaType.APPLICATION_JSON_VALUE]) +@HttpExchange("/api/catena/business-partners/changelog") +interface PoolChangelogApi { @Operation( - summary = "Get business partner changelog entries by bpn", - description = "Get business partner changelog entries by bpn ignoring case." + summary = "Get business partner changelog entries from time, by BPN and/or LSA type", + description = "Get business partner changelog entries from time, by BPN and/or LSA type" ) @ApiResponses( value = [ - ApiResponse(responseCode = "200", description = "The changelog entries for the specified bpn"), + ApiResponse(responseCode = "200", description = "The specified changelog entries"), ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) ] ) - @GetMapping("/changelog") - @GetExchange("/changelog") + @PostMapping("/search") + @PostExchange("/search") fun getChangelogEntries( - @Parameter(description = "BPN values") @RequestParam(required = false) bpn: Array?, - @Parameter(description = "Modified after") @RequestParam(required = false) modifiedAfter: Instant?, + @RequestBody changelogSearchRequest: ChangelogSearchRequest, @ParameterObject paginationRequest: PaginationRequest ): PageResponse } \ No newline at end of file diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolApiClient.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolApiClient.kt index 288afef22..0123ac4f3 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolApiClient.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolApiClient.kt @@ -27,7 +27,7 @@ interface PoolApiClient { fun bpns(): PoolBpnApi - fun businessPartners(): PoolBusinessPartnerApi + fun changelogs(): PoolChangelogApi fun legalEntities(): PoolLegalEntityApi diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolClientImpl.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolClientImpl.kt index ec1547e88..ccfd99d83 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolClientImpl.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/client/PoolClientImpl.kt @@ -40,7 +40,7 @@ class PoolClientImpl( private val poolClientAddress by lazy { httpServiceProxyFactory.createClient(PoolAddressApi::class.java) } private val poolClientBpn by lazy { httpServiceProxyFactory.createClient(PoolBpnApi::class.java) } - private val poolClientBusinessPartner by lazy { httpServiceProxyFactory.createClient(PoolBusinessPartnerApi::class.java) } + private val poolClientChangelog by lazy { httpServiceProxyFactory.createClient(PoolChangelogApi::class.java) } private val poolClientLegalEntity by lazy { httpServiceProxyFactory.createClient(PoolLegalEntityApi::class.java) } private val poolClientMetadata by lazy { httpServiceProxyFactory.createClient(PoolMetadataApi::class.java) } private val poolClientSite by lazy { httpServiceProxyFactory.createClient(PoolSiteApi::class.java) } @@ -51,7 +51,7 @@ class PoolClientImpl( override fun bpns() = poolClientBpn - override fun businessPartners() = poolClientBusinessPartner + override fun changelogs() = poolClientChangelog override fun legalEntities() = poolClientLegalEntity diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LsaType.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LsaType.kt new file mode 100644 index 000000000..004d72939 --- /dev/null +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/LsaType.kt @@ -0,0 +1,25 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.pool.api.model +enum class ChangelogSubject { + LEGAL_ENTITY, + ADDRESS, + SITE +} \ No newline at end of file diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/ChangelogSearchRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/ChangelogSearchRequest.kt new file mode 100644 index 000000000..fdabfb0e0 --- /dev/null +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/ChangelogSearchRequest.kt @@ -0,0 +1,35 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.pool.api.model.request + +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject +import java.time.Instant + + +@Schema(name = "ChangeLogSearchRequest", description = "Request for searching and filtering the business partner changelog") +data class ChangelogSearchRequest( + @Schema(description = "Changelog entries should be created after this time", example = "2023-03-20T10:23:28.194Z") + val fromTime: Instant? = null, + @Schema(description = "Only show changelog entries for business partners with the given BPNs. Empty means no restriction.") + val bpns: Set? = null, + @Schema(description = "Only show changelog entries for business partners with the given LSA types. Empty means no restriction.") + val lsaTypes: Set? = null +) diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ChangelogEntryResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ChangelogEntryResponse.kt index 5aace12b6..de453ceaa 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ChangelogEntryResponse.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/ChangelogEntryResponse.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.pool.api.model.response import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject import java.time.Instant @Schema(name = "ChangelogEntryResponse", description = "Changelog entry for a business partner") @@ -29,5 +30,7 @@ data class ChangelogEntryResponse( @Schema(description = "The type of the change") val changelogType: org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType, @Schema(description = "The timestamp of the change") - val timestamp: Instant + val timestamp: Instant, + @Schema(description = "The type of the business partner this change refers to") + val lsaType: ChangelogSubject ) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/OpenSearchSyncPageService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/OpenSearchSyncPageService.kt index 93d9b1e27..6758da36e 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/OpenSearchSyncPageService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/OpenSearchSyncPageService.kt @@ -20,10 +20,10 @@ package org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.service import mu.KotlinLogging +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.doc.AddressPartnerDoc import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.AddressPartnerDocRepository import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.LegalEntityDocRepository -import org.eclipse.tractusx.bpdm.pool.entity.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.entity.PartnerChangelogEntry import org.eclipse.tractusx.bpdm.pool.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.pool.repository.LogisticAddressRepository diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogController.kt similarity index 68% rename from bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt rename to bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogController.kt index ae84fc502..68319561c 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogController.kt @@ -21,30 +21,35 @@ package org.eclipse.tractusx.bpdm.pool.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.pool.api.PoolBusinessPartnerApi +import org.eclipse.tractusx.bpdm.pool.api.PoolChangelogApi +import org.eclipse.tractusx.bpdm.pool.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse import org.eclipse.tractusx.bpdm.pool.config.ControllerConfigProperties import org.eclipse.tractusx.bpdm.pool.exception.BpdmRequestSizeException import org.eclipse.tractusx.bpdm.pool.service.PartnerChangelogService -import org.springdoc.core.annotations.ParameterObject -import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController -import java.time.Instant @RestController -@RequestMapping("/api/catena/business-partners") -class BusinessPartnerController( +class ChangelogController( private val partnerChangelogService: PartnerChangelogService, private val controllerConfigProperties: ControllerConfigProperties -): PoolBusinessPartnerApi { +): PoolChangelogApi { override fun getChangelogEntries( - bpn: Array?, - modifiedAfter: Instant?, - @ParameterObject paginationRequest: PaginationRequest + changelogSearchRequest: ChangelogSearchRequest, + paginationRequest: PaginationRequest ): PageResponse { - if (bpn != null && bpn.size > controllerConfigProperties.searchRequestLimit) { - throw BpdmRequestSizeException(bpn.size, controllerConfigProperties.searchRequestLimit) + + changelogSearchRequest.bpns?.let { bpns -> + if (bpns.size > controllerConfigProperties.searchRequestLimit) { + throw BpdmRequestSizeException(bpns.size, controllerConfigProperties.searchRequestLimit) + } } - return partnerChangelogService.getChangelogEntriesByBpn(bpn, modifiedAfter, paginationRequest.page, paginationRequest.size) + + return partnerChangelogService.getChangeLogEntries( + changelogSearchRequest.bpns, + changelogSearchRequest.lsaTypes, + changelogSearchRequest.fromTime, + paginationRequest.page, + paginationRequest.size) } } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryDto.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryDto.kt index 18da2104f..8034b62ab 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryDto.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/dto/ChangelogEntryDto.kt @@ -19,8 +19,8 @@ package org.eclipse.tractusx.bpdm.pool.dto +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType -import org.eclipse.tractusx.bpdm.pool.entity.ChangelogSubject data class ChangelogEntryDto( val bpn: String, diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PartnerChangelogEntry.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PartnerChangelogEntry.kt index b2e734025..3503f9228 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PartnerChangelogEntry.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/PartnerChangelogEntry.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.entity import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.BaseEntity +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType @Entity @@ -38,8 +39,3 @@ class PartnerChangelogEntry( -enum class ChangelogSubject { - LEGAL_ENTITY, - ADDRESS, - SITE -} \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/PartnerChangelogEntryRepository.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/PartnerChangelogEntryRepository.kt index 3d66cb437..c913ddc77 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/PartnerChangelogEntryRepository.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/repository/PartnerChangelogEntryRepository.kt @@ -19,7 +19,7 @@ package org.eclipse.tractusx.bpdm.pool.repository -import org.eclipse.tractusx.bpdm.pool.entity.ChangelogSubject +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.entity.PartnerChangelogEntry import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable @@ -31,12 +31,15 @@ import java.time.Instant interface PartnerChangelogEntryRepository : JpaRepository, JpaSpecificationExecutor { object Specs { /** - * Restrict to entries with any one of the given BPNs; ignore if null + * Restrict to entries with any one of the given BPNs; ignore if empty */ - fun byBpnsIn(bpns: Array?) = + fun byBpnsIn(bpns: Set?) = Specification { root, _, _ -> - bpns?.let { - root.get(PartnerChangelogEntry::bpn.name).`in`(bpns.map { bpn -> bpn.uppercase() }) + bpns?.let{ + if(bpns.isNotEmpty()) + root.get(PartnerChangelogEntry::bpn.name).`in`(bpns.map { bpn -> bpn.uppercase() }) + else + null } } @@ -49,9 +52,20 @@ interface PartnerChangelogEntryRepository : JpaRepository + /** + * Restrict to entries with any one of the given LSA types; ignore if empty + */ + fun byLsaTypesIn(lsaTypes: Set?) = + Specification { root, _, _ -> + lsaTypes?.let { + if(lsaTypes.isNotEmpty()) + root.get(PartnerChangelogEntry::changelogSubject.name).`in`(lsaTypes.map { type -> type }) + else + null + } + } + } fun findByCreatedAtAfterAndChangelogSubjectIn( createdAt: Instant, diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index 0e15b082e..c8f88f3ec 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.* import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType import org.eclipse.tractusx.bpdm.pool.api.model.request.* import org.eclipse.tractusx.bpdm.pool.api.model.response.* diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt index 25dc7ff07..4aab1212d 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogService.kt @@ -21,12 +21,13 @@ package org.eclipse.tractusx.bpdm.pool.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse import org.eclipse.tractusx.bpdm.pool.dto.ChangelogEntryDto -import org.eclipse.tractusx.bpdm.pool.entity.ChangelogSubject import org.eclipse.tractusx.bpdm.pool.entity.PartnerChangelogEntry import org.eclipse.tractusx.bpdm.pool.repository.PartnerChangelogEntryRepository import org.eclipse.tractusx.bpdm.pool.repository.PartnerChangelogEntryRepository.Specs.byBpnsIn +import org.eclipse.tractusx.bpdm.pool.repository.PartnerChangelogEntryRepository.Specs.byLsaTypesIn import org.eclipse.tractusx.bpdm.pool.repository.PartnerChangelogEntryRepository.Specs.byUpdatedGreaterThan import org.springframework.data.domain.Page import org.springframework.data.domain.PageRequest @@ -48,12 +49,6 @@ class PartnerChangelogService( ) { private val logger = KotlinLogging.logger { } - @Transactional - fun createChangelogEntry(changelogEntry: ChangelogEntryDto): PartnerChangelogEntry { - logger.debug { "Create new change log entry for BPN ${changelogEntry.bpn}" } - return createChangelogEntries(listOf(changelogEntry)).single() - } - @Transactional fun createChangelogEntries(changelogEntries: Collection): List { logger.debug { "Create ${changelogEntries.size} new change log entries" } @@ -74,15 +69,8 @@ class PartnerChangelogService( ) } - fun getChangelogEntriesStartingAfterId(startId: Long = -1, pageIndex: Int, pageSize: Int): Page { - return partnerChangelogEntryRepository.findAllByIdGreaterThan( - startId, - PageRequest.of(pageIndex, pageSize, Sort.by(PartnerChangelogEntry::id.name).ascending()) - ) - } - - fun getChangelogEntriesByBpn(bpns: Array?, modifiedAfter: Instant?, pageIndex: Int, pageSize: Int): PageResponse { - val spec = Specification.allOf(byBpnsIn(bpns), byUpdatedGreaterThan(modifiedAfter)) + fun getChangeLogEntries(bpns: Set?, lsaTypes: Set?, fromTime: Instant?, pageIndex: Int, pageSize: Int): PageResponse { + val spec = Specification.allOf(byBpnsIn(bpns), byLsaTypesIn(lsaTypes), byUpdatedGreaterThan(fromTime)) val pageRequest = PageRequest.of(pageIndex, pageSize, Sort.by(PartnerChangelogEntry::updatedAt.name).ascending()) val page = partnerChangelogEntryRepository.findAll(spec, pageRequest) return page.toDto(page.content.map { it.toDto() }) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 96d962ab7..8943dda97 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -288,5 +288,5 @@ fun SyncRecord.toDto(): SyncResponse { } fun PartnerChangelogEntry.toDto(): ChangelogEntryResponse { - return ChangelogEntryResponse(bpn, changelogType, createdAt) + return ChangelogEntryResponse(bpn, changelogType, createdAt, changelogSubject) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogControllerIT.kt new file mode 100644 index 000000000..06b78d207 --- /dev/null +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/ChangelogControllerIT.kt @@ -0,0 +1,458 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.pool.controller + +import org.assertj.core.api.Assertions +import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse +import org.eclipse.tractusx.bpdm.pool.Application +import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogSubject +import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType +import org.eclipse.tractusx.bpdm.pool.api.model.request.ChangelogSearchRequest +import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse +import org.eclipse.tractusx.bpdm.pool.util.* +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.ContextConfiguration +import java.time.Instant +import java.util.* + +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [Application::class, TestHelpers::class], + properties = ["bpdm.controller.search-request-limit=2"] +) +@ActiveProfiles("test") +@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) +class ChangelogControllerIT @Autowired constructor( + val testHelpers: TestHelpers, + val poolClient: PoolClientImpl +) { + + @BeforeEach + fun beforeEach() { + testHelpers.truncateDbTables() + testHelpers.createTestMetadata() + } + + /** + * Given no legal entities in database + * When creating and updating legal entities and requesting changelog + * Then changelog entries for these legal entities + */ + @Test + fun `changelog for created and updated legal entities`() { + + val timeBeforeInsert = Instant.now() + + val createdStructures = testHelpers.createBusinessPartnerStructure( + listOf( + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate1), + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate2) + ) + ) + val bpnL1 = createdStructures[0].legalEntity.legalEntity.bpnl + val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpnl + + val bpnA1 = createdStructures[0].legalEntity.legalAddress.bpna + val bpnA2 = createdStructures[1].legalEntity.legalAddress.bpna + + + poolClient.legalEntities().updateBusinessPartners(listOf( + RequestValues.legalEntityUpdate1.copy(bpnl = bpnL1), + RequestValues.legalEntityUpdate2.copy(bpnl = bpnL2) + ) + ) + + val timeAfterUpdate = Instant.now() + + //Log entry for the created legal entities and their legal addresses should be there + val expectedChangelogEntries = listOf( + ChangelogEntryResponse(bpnL1, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY), + ChangelogEntryResponse(bpnL2, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY), + ChangelogEntryResponse(bpnA1, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnA2, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnL1, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY), + ChangelogEntryResponse(bpnL2, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY), + ChangelogEntryResponse(bpnA1, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnA2, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.ADDRESS) + ) + + val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + + val actualChangelog = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(), + PaginationRequest() + ) + + validateChangelogResponse(actualChangelog, expectedChangelog, timeBeforeInsert, timeAfterUpdate) + } + + /** + * Given no sites in database + * When creating and updating sites and requesting changelog + * Then changelog entries for these sites + */ + @Test + fun `changelog for created and updated sites`() { + + val timeBeforeInsert = Instant.now() + + val createdStructures = testHelpers.createBusinessPartnerStructure( + listOf( + LegalEntityStructureRequest( + legalEntity = RequestValues.legalEntityCreate1, + siteStructures = listOf( + SiteStructureRequest(site = RequestValues.siteCreate1), + SiteStructureRequest(site = RequestValues.siteCreate2), + )) + ) + ) + val bpnL = createdStructures[0].legalEntity.legalEntity.bpnl + val bpnS1 = createdStructures[0].siteStructures[0].site.site.bpns + val bpnS2 = createdStructures[0].siteStructures[1].site.site.bpns + val bpnLegalAddress = createdStructures[0].legalEntity.legalAddress.bpna + val bpnMainAddress1 = createdStructures[0].siteStructures[0].site.mainAddress.bpna + val bpnMainAddress2 = createdStructures[0].siteStructures[1].site.mainAddress.bpna + + poolClient.sites().updateSite(listOf( + RequestValues.siteUpdate1.copy(bpns = bpnS1), + RequestValues.siteUpdate2.copy(bpns = bpnS2) + )) + + val timeAfterUpdate = Instant.now() + + //Log entry for the created sites and their main address should be there + val expectedChangelogEntries = listOf( + ChangelogEntryResponse(bpnL, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY), + ChangelogEntryResponse(bpnS1, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.SITE), + ChangelogEntryResponse(bpnS2, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.SITE), + ChangelogEntryResponse(bpnLegalAddress, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnMainAddress1, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnMainAddress2, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnS1, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.SITE), + ChangelogEntryResponse(bpnS2, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.SITE), + ChangelogEntryResponse(bpnMainAddress1, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnMainAddress2, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.ADDRESS) + ) + + val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + + val actualChangelog = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(), + PaginationRequest() + ) + + validateChangelogResponse(actualChangelog, expectedChangelog, timeBeforeInsert, timeAfterUpdate) + } + + /** + * Given no addresses in database + * When creating and updating addresses and requesting changelog + * Then changelog entries for these addresses + */ + @Test + fun `changelog for created and updated addresses`() { + + val timeBeforeInsert = Instant.now() + + val createdStructures = testHelpers.createBusinessPartnerStructure( + listOf( + LegalEntityStructureRequest( + legalEntity = RequestValues.legalEntityCreate1, + addresses = listOf(RequestValues.addressPartnerCreate1), + siteStructures = listOf(SiteStructureRequest(site = RequestValues.siteCreate1, addresses = listOf(RequestValues.addressPartnerCreate2))) + ) + ) + ) + val bpnL = createdStructures[0].legalEntity.legalEntity.bpnl + val bpnS1 = createdStructures[0].siteStructures[0].site.site.bpns + val bpnLegalAddress = createdStructures[0].legalEntity.legalAddress.bpna + val bpnMainAddress = createdStructures[0].siteStructures[0].site.mainAddress.bpna + val bpnA1 = createdStructures[0].addresses[0].address.bpna + val bpnA2 = createdStructures[0].siteStructures[0].addresses[0].address.bpna + + poolClient.addresses().updateAddresses(listOf( + RequestValues.addressPartnerUpdate1.copy(bpna = bpnA1), + RequestValues.addressPartnerUpdate2.copy(bpna = bpnA2) + )) + + val timeAfterUpdate = Instant.now() + + //Log entry for the created addresses including legal and main address + val expectedChangelogEntries = listOf( + ChangelogEntryResponse(bpnL, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY), + ChangelogEntryResponse(bpnS1, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.SITE), + ChangelogEntryResponse(bpnLegalAddress, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnMainAddress, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnA1, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnA2, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnA1, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnA2, ChangelogType.UPDATE, timeAfterUpdate, ChangelogSubject.ADDRESS) + ) + + + val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + + + val actualChangelog = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(), + PaginationRequest() + ) + + validateChangelogResponse(actualChangelog, expectedChangelog, timeBeforeInsert, timeAfterUpdate) + } + + /** + * Given changelogs in database + * When paginating through changelogs + * Then page after page of changelogs returned + */ + @Test + fun `paginating changelogs`() { + + val timeBeforeInsert = Instant.now() + + val createdStructures = testHelpers.createBusinessPartnerStructure( + listOf( + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate1), + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate2), + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate3), + ) + ) + val bpnL1 = createdStructures[0].legalEntity.legalEntity.bpnl + val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpnl + val bpnL3 = createdStructures[2].legalEntity.legalEntity.bpnl + + + val timeAfterUpdate = Instant.now() + + val expectedEntriesFirstPage = listOf( + ChangelogEntryResponse(bpnL1, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY), + ChangelogEntryResponse(bpnL2, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY) + ) + + val expectedEntriesSecondPage = listOf( + ChangelogEntryResponse(bpnL3, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY) + ) + + val expectedFirstPage = PageResponse(3, 2, 0, expectedEntriesFirstPage.size, expectedEntriesFirstPage) + val expectedSecondPage = PageResponse(3, 2, 1, expectedEntriesSecondPage.size, expectedEntriesSecondPage) + + + val actualFirstPage = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(lsaTypes = setOf(ChangelogSubject.LEGAL_ENTITY)), + PaginationRequest(page = 0, size = 2) + ) + + val actualSecondPage = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(lsaTypes = setOf(ChangelogSubject.LEGAL_ENTITY)), + PaginationRequest(page = 1, size = 2) + ) + + validateChangelogResponse(actualFirstPage, expectedFirstPage, timeBeforeInsert, timeAfterUpdate) + validateChangelogResponse(actualSecondPage, expectedSecondPage, timeBeforeInsert, timeAfterUpdate) + } + + /** + * Given changelogs in database + * When filtering by LSA type + * Then only get changelog entries of that type + */ + @Test + fun `filter by LSA type`() { + + val timeBeforeInsert = Instant.now() + + val createdStructures = testHelpers.createBusinessPartnerStructure( + listOf( + LegalEntityStructureRequest( + legalEntity = RequestValues.legalEntityCreate1, + siteStructures = listOf(SiteStructureRequest(site = RequestValues.siteCreate1)) + ) + ) + ) + val bpnL = createdStructures[0].legalEntity.legalEntity.bpnl + val bpnS = createdStructures[0].siteStructures[0].site.site.bpns + val bpnLegalAddress = createdStructures[0].legalEntity.legalAddress.bpna + val bpnMainAddress = createdStructures[0].siteStructures[0].site.mainAddress.bpna + + + val timeAfterUpdate = Instant.now() + + val expectedLegalEntityEntries = listOf( + ChangelogEntryResponse(bpnL, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY) + ) + + val expectedSiteEntries = listOf( + ChangelogEntryResponse(bpnS, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.SITE) + ) + + val expectedAddressEntries = listOf( + ChangelogEntryResponse(bpnLegalAddress, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS), + ChangelogEntryResponse(bpnMainAddress, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.ADDRESS) + ) + + val expectedLegalEntitiesPage = PageResponse(expectedLegalEntityEntries.size.toLong(), 1, 0, expectedLegalEntityEntries.size, expectedLegalEntityEntries) + val expectedSitesPage = PageResponse(expectedSiteEntries.size.toLong(), 1, 0, expectedSiteEntries.size, expectedSiteEntries) + val expectedAddressesPage = PageResponse(expectedAddressEntries.size.toLong(), 1, 0, expectedAddressEntries.size, expectedAddressEntries) + + + val actualLegalEntityPage = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(lsaTypes = setOf(ChangelogSubject.LEGAL_ENTITY)), + PaginationRequest() + ) + val actualSitePage = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(lsaTypes = setOf(ChangelogSubject.SITE)), + PaginationRequest() + ) + val actualAddressPage = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(lsaTypes = setOf(ChangelogSubject.ADDRESS)), + PaginationRequest() + ) + + validateChangelogResponse(actualLegalEntityPage, expectedLegalEntitiesPage, timeBeforeInsert, timeAfterUpdate) + validateChangelogResponse(actualSitePage, expectedSitesPage, timeBeforeInsert, timeAfterUpdate) + validateChangelogResponse(actualAddressPage, expectedAddressesPage, timeBeforeInsert, timeAfterUpdate) + } + + /** + * Given changelogs + * When filtering changelogs by BPN + * Then only get changelogs with these BPNs + */ + @Test + fun `filter by BPNs`() { + + val timeBeforeInsert = Instant.now() + + val createdStructures = testHelpers.createBusinessPartnerStructure( + listOf( + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate1), + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate2), + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate3) + ) + ) + val bpnL1 = createdStructures[0].legalEntity.legalEntity.bpnl + val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpnl + + + val timeAfterUpdate = Instant.now() + + //Log entry for the created legal entities and their legal addresses should be there + val expectedChangelogEntries = listOf( + ChangelogEntryResponse(bpnL1, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY), + ChangelogEntryResponse(bpnL2, ChangelogType.CREATE, timeAfterUpdate, ChangelogSubject.LEGAL_ENTITY) + ) + + val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + + val actualChangelog = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(bpns = setOf(bpnL1, bpnL2)), + PaginationRequest() + ) + + validateChangelogResponse(actualChangelog, expectedChangelog, timeBeforeInsert, timeAfterUpdate) + } + + /** + * Given changelogs + * When filtering changelogs by timestamp + * Then only get changelogs having timestamps the given time + */ + @Test + fun `filter by timestamp`() { + + testHelpers.createBusinessPartnerStructure( + listOf( + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate1) + ) + ) + + val timeAfterFirstInsert = Instant.now() + + + val createdStructures = testHelpers.createBusinessPartnerStructure( + listOf( + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate2), + LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate3) + ) + ) + + val bpnL1 = createdStructures[0].legalEntity.legalEntity.bpnl + val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpnl + + val timeAfterSecondInsert = Instant.now() + + //Log entry for the created legal entities and their legal addresses should be there + val expectedChangelogEntries = listOf( + ChangelogEntryResponse(bpnL1, ChangelogType.CREATE, timeAfterSecondInsert, ChangelogSubject.LEGAL_ENTITY), + ChangelogEntryResponse(bpnL2, ChangelogType.CREATE, timeAfterSecondInsert, ChangelogSubject.LEGAL_ENTITY) + ) + + val expectedChangelog = PageResponse(expectedChangelogEntries.size.toLong(), 1, 0, expectedChangelogEntries.size, expectedChangelogEntries) + + val actualChangelog = poolClient.changelogs().getChangelogEntries( + ChangelogSearchRequest(fromTime = timeAfterFirstInsert, lsaTypes = setOf(ChangelogSubject.LEGAL_ENTITY)), + PaginationRequest() + ) + + validateChangelogResponse(actualChangelog, expectedChangelog, timeAfterFirstInsert, timeAfterSecondInsert) + } + + + private fun checkTimestampAscending() = + { changelogEntries: Collection -> + var lastTimestamp = Instant.MIN + for (changelogEntry in changelogEntries) { + Assertions.assertThat(changelogEntry.timestamp).isAfterOrEqualTo(lastTimestamp) + lastTimestamp = changelogEntry.timestamp + } + } + + private fun checkTimestampsInBetween(after: Instant, before: Instant) = + { changelogEntries: Collection -> + changelogEntries.forEach { entry -> + Assertions.assertThat(entry.timestamp).isBetween(after, before) + } + } + + private fun checkEqual(expected: PageResponse) = + { actualResponse: PageResponse -> + testHelpers.assertRecursively(actualResponse).isEqualTo(expected) + Unit + } + + private fun validateChangelogResponse(actual: PageResponse, + expected: PageResponse, + timeBeforeInsert: Instant, + timeAfterInsert: Instant + ){ + actual.also (checkEqual(expected)) + .content + .also (checkTimestampAscending()) + .also (checkTimestampsInBetween(timeBeforeInsert, timeAfterInsert) ) + } + + +} \ No newline at end of file diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt deleted file mode 100644 index b913dfd33..000000000 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt +++ /dev/null @@ -1,259 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.service - -import com.github.tomakehurst.wiremock.core.WireMockConfiguration -import com.github.tomakehurst.wiremock.junit5.WireMockExtension -import org.assertj.core.api.Assertions.assertThat -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.pool.Application -import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType -import org.eclipse.tractusx.bpdm.pool.api.model.response.ChangelogEntryResponse -import org.eclipse.tractusx.bpdm.pool.config.ControllerConfigProperties -import org.eclipse.tractusx.bpdm.pool.dto.ChangelogEntryDto -import org.eclipse.tractusx.bpdm.pool.entity.ChangelogSubject -import org.eclipse.tractusx.bpdm.pool.util.* -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.RegisterExtension -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.test.context.ActiveProfiles -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.DynamicPropertyRegistry -import org.springframework.test.context.DynamicPropertySource -import org.springframework.test.web.reactive.server.WebTestClient -import org.springframework.test.web.reactive.server.returnResult -import java.time.Instant -import java.util.* - -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [Application::class, TestHelpers::class], - properties = ["bpdm.controller.search-request-limit=2"] -) -@ActiveProfiles("test") -@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) -class PartnerChangelogIT @Autowired constructor( - val partnerChangelogService: PartnerChangelogService, - val testHelpers: TestHelpers, - val webTestClient: WebTestClient, - val controllerConfigProperties: ControllerConfigProperties, -) { - - companion object { - @RegisterExtension - var wireMockServer: WireMockExtension = WireMockExtension.newInstance() - .options(WireMockConfiguration.wireMockConfig().dynamicPort()) - .build() - - @JvmStatic - @DynamicPropertySource - fun configureProperties(registry: DynamicPropertyRegistry) { - registry.add("bpdm.saas.host") { wireMockServer.baseUrl() } - } - } - - @BeforeEach - fun beforeEach() { - testHelpers.truncateDbTables() - testHelpers.createTestMetadata() - } - - /** - * Given no partners in db - * When importing partners and then updating partners - * Then create and update changelog entries are created - */ - @Test - fun `create changelog entries`() { - val createdStructures = testHelpers.createBusinessPartnerStructure( - listOf( - LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate1), - LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate2), - LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate3) - ) - ) - val bpnL1 = createdStructures[0].legalEntity.legalEntity.bpnl - val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpnl - - // prepare modified partner to import - val modifiedPartnersToImport = listOf( - RequestValues.legalEntityUpdate3.copy(bpnl = bpnL1) - ) - - val timestampBetweenCreateAndUpdate = Instant.now() - - // update partner with modified values - webTestClient.invokePutWithoutResponse(EndpointValues.CATENA_LEGAL_ENTITY_PATH, modifiedPartnersToImport) - - - // For every LE we create, we get one changelog entry for the LE itself and one for the corresponding legal address. - // Altogether 3 LEs were created initially and 1 updated. So we get 6 create entries and 2 update entries. - - // no restrictions for BPNs and timestamp (BPNLs and BPNAs) - retrieveChangelog(null, null).content - .also(checkNumberCreatedAndUpdated(6, 2)) - .also(checkTimestampAscending()) - - // no restrictions for timestamp, but limited to multiple BPNs - retrieveChangelog(null, listOf(bpnL1, bpnL2)).content - .let(checkNumberCreatedAndUpdated(2, 1)) - - // check changelog entries were created - // first business partner was created and updated - retrieveChangelog(null, listOf(bpnL1)).content - .let(checkNumberCreatedAndUpdated(1, 1)) - - // second business partner was only created - retrieveChangelog(null, listOf(bpnL2)).content - .let(checkNumberCreatedAndUpdated(1, 0)) - - // filter out CREATED changelogs, only return two UPDATED changelog for BPNL1 and corresponding BPNA - retrieveChangelog(timestampBetweenCreateAndUpdate, null).content - .let(checkNumberCreatedAndUpdated(0, 2)) - - // filter out all changelogs - retrieveChangelog(Instant.now(), null).content - .let(checkNumberCreatedAndUpdated(0, 0)) - - // filter out CREATED changelogs, restrict to BPNL1 - retrieveChangelog(timestampBetweenCreateAndUpdate, listOf(bpnL1)).content - .let(checkNumberCreatedAndUpdated(0, 1)) - - // filter out CREATED changelogs, restrict to BPNL2, resulting in no entries - retrieveChangelog(timestampBetweenCreateAndUpdate, listOf(bpnL2)).content - .let(checkNumberCreatedAndUpdated(0, 0)) - } - - /** - * Given some business partners imported - * When trying to retrieve changelog entries using a nonexistent bpn - * Then an empty response is sent - */ - @Test - fun `get changelog entries by nonexistent bpn`() { - // import partners - webTestClient.invokePostEndpointWithoutResponse( - EndpointValues.CATENA_LEGAL_ENTITY_PATH, - listOf(RequestValues.legalEntityCreate1, RequestValues.legalEntityCreate2) - ) - - val bpn = "NONEXISTENT_BPN" - assertThat(retrieveChangelog(null, listOf(bpn)).contentSize).isEqualTo(0) - } - - /** - * Given some business partners imported - * When trying to retrieve changelog entries using an invalid timestamp - * Then a "bad request" response is sent - */ - @Test - fun `get changelog entries by invalid timestamp`() { - // import partners - webTestClient.invokePostEndpointWithoutResponse( - EndpointValues.CATENA_LEGAL_ENTITY_PATH, - listOf(RequestValues.legalEntityCreate1, RequestValues.legalEntityCreate2) - ) - - getChangelogResponse("NO_VALID_TIME", null) - .expectStatus().isBadRequest - - getChangelogResponse("2023-15-99T08:22:54.986733Z", null) - .expectStatus().isBadRequest - } - - /** - * Given some business partners imported - * When trying to retrieve changelog entries and using too many BPNs in the request - * Then a "bad request" response is sent - */ - @Test - fun `get changelog entries using too many search params`() { - // import partners - webTestClient.invokePostEndpointWithoutResponse( - EndpointValues.CATENA_LEGAL_ENTITY_PATH, - listOf(RequestValues.legalEntityCreate1, RequestValues.legalEntityCreate2) - ) - - val limit = controllerConfigProperties.searchRequestLimit - val bpnsOk = (0..limit - 1).map { it -> "bpn${it}" } // limit entries - getChangelogResponse(null, bpnsOk) - .expectStatus().isOk - - val bpnsTooMany = (0..limit).map { it -> "bpn${it}" } // limit+1 entries - getChangelogResponse(null, bpnsTooMany) - .expectStatus().isBadRequest - } - - /** - * Given some changelog entries in db - * When changelog entries retrieved paginated - * Then correct changelog page retrieved - */ - @Test - fun `get changelog entries starting after id via service`() { - val startId = partnerChangelogService.createChangelogEntry(ChangelogEntryDto("testBpn1", ChangelogType.CREATE, ChangelogSubject.LEGAL_ENTITY)).id - partnerChangelogService.createChangelogEntry(ChangelogEntryDto("testBpn1", ChangelogType.UPDATE, ChangelogSubject.LEGAL_ENTITY)) - partnerChangelogService.createChangelogEntry(ChangelogEntryDto("testBpn2", ChangelogType.CREATE, ChangelogSubject.LEGAL_ENTITY)) - - val changelogEntryPage = partnerChangelogService.getChangelogEntriesStartingAfterId(startId = startId, pageIndex = 1, pageSize = 1) - assertThat(changelogEntryPage.totalElements).isEqualTo(2) - assertThat(changelogEntryPage.content.size).isEqualTo(1) - assertThat(changelogEntryPage.content[0].bpn).isEqualTo("testBpn2") - } - - private fun checkNumberCreatedAndUpdated(created: Int, updated: Int) = - { changelogEntries: Collection -> - assertThat(changelogEntries) - .filteredOn { it.changelogType == ChangelogType.CREATE } - .hasSize(created) - assertThat(changelogEntries) - .filteredOn { it.changelogType == ChangelogType.UPDATE } - .hasSize(updated) - Unit - } - - private fun checkTimestampAscending() = - { changelogEntries: Collection -> - var lastTimestamp = Instant.MIN - for (changelogEntry in changelogEntries) { - assertThat(changelogEntry.timestamp).isAfterOrEqualTo(lastTimestamp) - lastTimestamp = changelogEntry.timestamp - } - } - - private fun retrieveChangelog(modifiedAfter: Instant?, bpn: Collection?): PageResponse = - getChangelogResponse(modifiedAfter, bpn) - .expectStatus().isOk - .returnResult>() - .responseBody - .blockFirst()!! - - private fun getChangelogResponse(modifiedAfter: Any?, bpn: Collection?) = - webTestClient - .get() - .uri { - it.path(EndpointValues.CATENA_BUSINESS_PARTNERS_PATH + EndpointValues.CATENA_CHANGELOG_PATH_POSTFIX) - .queryParamIfPresent("modifiedAfter", Optional.ofNullable(modifiedAfter)) - .queryParamIfPresent("bpn", Optional.ofNullable(bpn)) - .build() - } - .exchange() -} \ No newline at end of file From c2dff90fc59edbc072ebaac2fbd5e95bae005cdc Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Wed, 7 Jun 2023 16:34:09 +0200 Subject: [PATCH 48/83] feat(Pool): remove business partner legacy endpoints and logic fixes issue #248 --- .../response/BusinessPartnerMatchResponse.kt | 32 ---- .../model/response/BusinessPartnerResponse.kt | 47 ----- .../component/opensearch/SearchService.kt | 6 - .../impl/service/SearchServiceImpl.kt | 15 -- .../mock/service/SearchServiceMock.kt | 14 -- .../BusinessPartnerLegacyController.kt | 110 ------------ .../service/BusinessPartnerFetchService.kt | 11 -- .../bpdm/pool/service/ResponseMappings.kt | 15 -- .../BusinessPartnerLegacyControllerIT.kt | 161 ------------------ 9 files changed, 411 deletions(-) delete mode 100644 bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerMatchResponse.kt delete mode 100644 bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt delete mode 100644 bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt delete mode 100644 bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerMatchResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerMatchResponse.kt deleted file mode 100644 index ae52f6eb4..000000000 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerMatchResponse.kt +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.api.model.response - -import io.swagger.v3.oas.annotations.media.Schema - -@Schema( - name = "BusinessPartnerMatchResponse", - description = "Match with score for a business partner of type legal entity in legacy format", - deprecated = true -) -data class BusinessPartnerMatchResponse( - val score: Float, - val businessPartner: BusinessPartnerResponse -) diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt deleted file mode 100644 index e26f2a288..000000000 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/response/BusinessPartnerResponse.kt +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.api.model.response - -import com.fasterxml.jackson.annotation.JsonUnwrapped -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityResponse -import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse -import org.eclipse.tractusx.bpdm.common.dto.response.SiteResponse -import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer - -@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) -@Schema(name = "BusinessPartnerResponse", description = "Business Partner of type legal entity in deprecated response format", deprecated = true) -data class BusinessPartnerResponse( - val uuid: String, - - @get:Schema(description = "Legal name the partner goes by") - val legalName: String, - - @field:JsonUnwrapped - val legalEntity: LegalEntityResponse, - - @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressResponse, - - val addresses: Collection, - - val sites: Collection, -) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt index 2c6e8b9d7..21773a578 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/SearchService.kt @@ -24,7 +24,6 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse /** @@ -48,9 +47,4 @@ interface SearchService { paginationRequest: PaginationRequest ): PageResponse - fun searchBusinessPartners( - searchRequest: BusinessPartnerSearchRequest, - paginationRequest: PaginationRequest - ): PageResponse - } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt index 59bf985da..371cc8b57 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/SearchServiceImpl.kt @@ -25,7 +25,6 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService import org.eclipse.tractusx.bpdm.pool.component.opensearch.impl.repository.AddressDocSearchRepository @@ -95,20 +94,6 @@ class SearchServiceImpl( } } - override fun searchBusinessPartners( - searchRequest: BusinessPartnerSearchRequest, - paginationRequest: PaginationRequest - ): PageResponse { - - val legalEntityPage = searchAndPreparePage(searchRequest, paginationRequest) - businessPartnerFetchService.fetchDependenciesWithLegalAddress(legalEntityPage.content.map { (_, legalEntity) -> legalEntity }.toSet()) - - return with(legalEntityPage) { - PageResponse(totalElements, totalPages, page, contentSize, - content.map { (score, legalEntity) -> legalEntity.toBusinessPartnerMatchDto(score) }) - } - } - private fun searchAndPreparePage( searchRequest: BusinessPartnerSearchRequest, paginationRequest: PaginationRequest diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt index 616e01b61..0424415a1 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/mock/service/SearchServiceMock.kt @@ -25,12 +25,10 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchResponse import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService import org.eclipse.tractusx.bpdm.pool.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.pool.repository.LogisticAddressRepository -import org.eclipse.tractusx.bpdm.pool.service.toBusinessPartnerMatchDto import org.eclipse.tractusx.bpdm.pool.service.toDto import org.eclipse.tractusx.bpdm.pool.service.toMatchDto import org.springframework.data.domain.PageRequest @@ -75,16 +73,4 @@ class SearchServiceMock( return resultPage.toDto(resultPage.content.map { it.toMatchDto(1f) }) } - override fun searchBusinessPartners( - searchRequest: BusinessPartnerSearchRequest, - paginationRequest: PaginationRequest - ): PageResponse { - val resultPage = - legalEntityRepository.findAll(PageRequest.of(paginationRequest.page, paginationRequest.size)) - - logger.info { "Mock search: Returning ${resultPage.size} business partners from database" } - - return resultPage.toDto(resultPage.content.map { it.toBusinessPartnerMatchDto(1f) }) - } - } \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt deleted file mode 100644 index efd804116..000000000 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyController.kt +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.controller - -import io.swagger.v3.oas.annotations.Operation -import io.swagger.v3.oas.annotations.Parameter -import io.swagger.v3.oas.annotations.media.Content -import io.swagger.v3.oas.annotations.media.Schema -import io.swagger.v3.oas.annotations.responses.ApiResponse -import io.swagger.v3.oas.annotations.responses.ApiResponses -import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.BusinessPartnerSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.request.SitePropertiesSearchRequest -import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerResponse -import org.eclipse.tractusx.bpdm.pool.component.opensearch.SearchService -import org.eclipse.tractusx.bpdm.pool.config.BpnConfigProperties -import org.eclipse.tractusx.bpdm.pool.service.BusinessPartnerFetchService -import org.springdoc.core.annotations.ParameterObject -import org.springframework.web.bind.annotation.* - -@RestController -@RequestMapping("/api/catena/business-partner") -@Schema(deprecated = true) -class BusinessPartnerLegacyController( - private val searchService: SearchService, - private val bpnConfigProperties: BpnConfigProperties, - private val businessPartnerFetchService: BusinessPartnerFetchService -) { - - - @Operation( - summary = "Get page of business partners matching the search criteria", - description = "This endpoint tries to find matches among all existing business partners, " + - "filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. " + - "The match of a partner is better the higher its relevancy score." + - "Note that when using search parameters the max page is \${bpdm.opensearch.max-page}.", - deprecated = true - ) - @ApiResponses( - value = [ - ApiResponse(responseCode = "200", description = "Page of business partners matching the search criteria, may be empty"), - ApiResponse(responseCode = "400", description = "On malformed search or pagination request", content = [Content()]) - ] - ) - @GetMapping - fun searchBusinessPartners( - @ParameterObject bpSearchRequest: LegalEntityPropertiesSearchRequest, - @ParameterObject addressSearchRequest: AddressPropertiesSearchRequest, - @ParameterObject siteSearchRequest: SitePropertiesSearchRequest, - @ParameterObject paginationRequest: PaginationRequest - ): PageResponse { - return searchService.searchBusinessPartners( - BusinessPartnerSearchRequest(bpSearchRequest), - paginationRequest - ) - } - - @Operation( - summary = "Get business partner by identifier", - description = "This endpoint tries to find a business partner by the specified identifier. " + - "The identifier value is case insensitively compared but needs to be given exactly. " + - "By default the value given is interpreted as a BPN. " + - "By specifying the technical key of another identifier type" + - "the value is matched against the identifiers of that given type.", - deprecated = true - ) - @ApiResponses( - value = [ - ApiResponse(responseCode = "200", description = "Found business partner with specified identifier"), - ApiResponse(responseCode = "400", description = "On malformed request parameters", content = [Content()]), - ApiResponse( - responseCode = "404", - description = "No business partner found under specified identifier or specified identifier type not found", - content = [Content()] - ) - ] - ) - @GetMapping("/{idValue}") - fun getLegalEntity( - @Parameter(description = "Identifier value") @PathVariable idValue: String, - @Parameter(description = "Type of identifier to use, defaults to BPN when omitted", schema = Schema(defaultValue = "BPN")) - @RequestParam - idType: String? - ): BusinessPartnerResponse { - val actualType = idType ?: bpnConfigProperties.id - return if (actualType == bpnConfigProperties.id) businessPartnerFetchService.findBusinessPartnerIgnoreCase(idValue) - else businessPartnerFetchService.findBusinessPartnerIgnoreCase(actualType, idValue) - } -} \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt index 2bad56676..a70f954fe 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerFetchService.kt @@ -23,7 +23,6 @@ import org.eclipse.tractusx.bpdm.common.dto.IdentifierLsaType import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.pool.api.model.response.BpnIdentifierMappingResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerResponse import org.eclipse.tractusx.bpdm.pool.entity.IdentifierType import org.eclipse.tractusx.bpdm.pool.entity.LegalEntity import org.eclipse.tractusx.bpdm.pool.entity.LegalEntityIdentifier @@ -53,10 +52,6 @@ class BusinessPartnerFetchService( return findLegalEntityOrThrow(bpn).toPoolLegalEntity() } - fun findBusinessPartnerIgnoreCase(bpn: String): BusinessPartnerResponse { - return findLegalEntityOrThrow(bpn).toBusinessPartnerDto() - } - /** * Fetch a business partner by [identifierValue] (ignoring case) of [identifierType] and return as [PoolLegalEntityResponse] @@ -66,12 +61,6 @@ class BusinessPartnerFetchService( return findLegalEntityOrThrow(identifierType, identifierValue).toPoolLegalEntity() } - - @Transactional - fun findBusinessPartnerIgnoreCase(identifierType: String, identifierValue: String): BusinessPartnerResponse { - return findLegalEntityOrThrow(identifierType, identifierValue).toBusinessPartnerDto() - } - /** * Fetch business partners by BPN in [bpns] */ diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 8943dda97..23869d29f 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -41,10 +41,6 @@ fun LegalEntity.toMatchDto(score: Float): LegalEntityMatchResponse { ) } -fun LegalEntity.toBusinessPartnerMatchDto(score: Float): BusinessPartnerMatchResponse { - return BusinessPartnerMatchResponse(score, this.toBusinessPartnerDto()) -} - fun LegalEntity.toUpsertDto(entryId: String?): LegalEntityPartnerCreateResponse { return LegalEntityPartnerCreateResponse( legalEntity = toDto(), @@ -88,17 +84,6 @@ fun LegalEntity.toDto(): LegalEntityResponse { ) } -fun LegalEntity.toBusinessPartnerDto(): BusinessPartnerResponse { - return BusinessPartnerResponse( - uuid = "", - legalEntity = toDto(), - addresses = listOf(legalAddress.toDto()), - legalAddress = legalAddress.toDto(), - sites = emptyList(), - legalName = legalName.value, - ) -} - fun LegalEntityIdentifier.toDto(): LegalEntityIdentifierResponse { return LegalEntityIdentifierResponse(value, type.toTypeKeyNameDto(), issuingBody) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt deleted file mode 100644 index 42c7dfda7..000000000 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt +++ /dev/null @@ -1,161 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.pool.controller - -import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse -import org.eclipse.tractusx.bpdm.pool.Application -import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerMatchResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.BusinessPartnerResponse -import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityPartnerCreateResponse -import org.eclipse.tractusx.bpdm.pool.util.* -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.test.context.ActiveProfiles -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.web.reactive.server.WebTestClient - -@SpringBootTest( - webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [Application::class, TestHelpers::class] -) -@ActiveProfiles(value = ["test"]) -@ContextConfiguration(initializers = [PostgreSQLContextInitializer::class, OpenSearchContextInitializer::class]) -class BusinessPartnerLegacyControllerIT @Autowired constructor( - val webTestClient: WebTestClient, - val testHelpers: TestHelpers -) { - - lateinit var givenPartner1: LegalEntityPartnerCreateResponse - lateinit var givenPartner2: LegalEntityPartnerCreateResponse - lateinit var givenPartner3: LegalEntityPartnerCreateResponse - - val uniqueName = "XXXXXX_UNIQUE_XXXXXX" - - val partnerStructures = listOf( - LegalEntityStructureRequest(legalEntity = with(RequestValues.legalEntityCreate1) { - copy( - legalName = uniqueName - ) - }), - LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate2), - LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate3), - ) - - @BeforeEach - fun beforeEach() { - testHelpers.truncateDbTables() - webTestClient.invokeDeleteEndpointWithoutResponse(EndpointValues.OPENSEARCH_SYNC_PATH) - - testHelpers.createTestMetadata() - val givenStructure = testHelpers.createBusinessPartnerStructure(partnerStructures) - givenPartner1 = givenStructure[0].legalEntity - givenPartner2 = givenStructure[1].legalEntity - givenPartner3 = givenStructure[2].legalEntity - - - testHelpers.startSyncAndAwaitSuccess(webTestClient, EndpointValues.OPENSEARCH_SYNC_PATH) - } - - - /** - * Given legal entities - * When querying business partners - * Then return arbitrary list of business partner matches - */ - @Test - fun `get existing business partners`() { - - val expected = getExpectedPage(listOf(givenPartner1, givenPartner2, givenPartner3)) - - val respone = webTestClient.invokeGetEndpoint>(EndpointValues.CATENA_BUSINESS_PARTNER_LEGACY_PATH) - - - testHelpers.assertRecursively(respone).ignoringFieldsMatchingRegexes(".*uuid", ".*score").isEqualTo(expected) - } - - - /** - * Given legal entities - * When searching business partners by name - * Then return business partner matches - */ - @Test - fun `search business partners by name`() { - - val expected = getExpectedPage(listOf(givenPartner1)) - - val response = webTestClient.invokeGetEndpoint>( - EndpointValues.CATENA_BUSINESS_PARTNER_LEGACY_PATH, - Pair("legalName", uniqueName) - ) - - testHelpers.assertRecursively(response).ignoringFieldsMatchingRegexes(".*uuid", ".*score").isEqualTo(expected) - } - - /** - * Given legal entities - * When query business partner by BPN - * Then return business partner - */ - @Test - fun `find by BPN`() { - val expected = convertCreateResponse(givenPartner1) - - val bpn = givenPartner1.legalEntity.bpnl - val respone = webTestClient.invokeGetEndpoint("${EndpointValues.CATENA_BUSINESS_PARTNER_LEGACY_PATH}/${bpn}") - - testHelpers.assertRecursively(respone).ignoringFieldsMatchingRegexes(".*uuid").isEqualTo(expected) - } - - /** - * Given legal entities - * When query business partner by additional identifier - * Then return business partner - */ - @Test - fun `find by other identifier`() { - val expected = convertCreateResponse(givenPartner1) - - val additionalIdentifier = givenPartner1.legalEntity.identifiers.first() - val idValue = additionalIdentifier.value - val idType = additionalIdentifier.type.technicalKey - val respone = - webTestClient.invokeGetEndpoint("${EndpointValues.CATENA_BUSINESS_PARTNER_LEGACY_PATH}/$idValue", Pair("idType", idType)) - - testHelpers.assertRecursively(respone).ignoringFieldsMatchingRegexes(".*uuid").isEqualTo(expected) - } - - private fun getExpectedPage(givenPartners: Collection): PageResponse { - return PageResponse(givenPartners.size.toLong(), 1, 0, givenPartners.size, - givenPartners.map { BusinessPartnerMatchResponse(0f, convertCreateResponse(it)) }) - } - - private fun convertCreateResponse(toConvert: LegalEntityPartnerCreateResponse): BusinessPartnerResponse { - return BusinessPartnerResponse( - uuid = "", - legalName = toConvert.legalName, - legalEntity = toConvert.legalEntity, - legalAddress = toConvert.legalAddress, - addresses = listOf(toConvert.legalAddress), - sites = emptyList() - ) - } -} \ No newline at end of file From f31ccd79cbf962854443e6dcc9e5826d51678c3b Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 15:03:41 +0200 Subject: [PATCH 49/83] feat(Gate): replace name with name parts collection in logistic address --- .../bpdm/bridge/dummy/service/PoolUpdateService.kt | 6 +++--- .../bpdm/gate/api/model/LogisticAddressGateDto.kt | 2 +- .../bpdm/gate/service/AddressPersistenceService.kt | 4 ++-- .../tractusx/bpdm/gate/service/ResponseMappings.kt | 6 +++--- .../bpdm/gate/service/SaasRequestMappingService.kt | 2 +- .../eclipse/tractusx/bpdm/gate/util/RequestValues.kt | 8 ++++---- .../tractusx/bpdm/gate/util/ResponseValues.kt | 12 ++++++------ 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index faf2aff36..9bfe26ba9 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -61,7 +61,7 @@ class PoolUpdateService( fun gateToPoolLogisticAddress(gateDto: LogisticAddressGateDto): LogisticAddressDto { return LogisticAddressDto( - name = gateDto.name, + name = gateDto.nameParts.firstOrNull(), states = gateDto.states, identifiers = gateDto.identifiers, physicalPostalAddress = gateToPoolPhysicalAddress(gateDto.physicalPostalAddress), @@ -166,7 +166,7 @@ class PoolUpdateService( ?.let { siteParentBpn -> AddressPartnerCreateRequest( address = LogisticAddressDto( - name = entry.address.name, + name = entry.address.nameParts.firstOrNull(), states = entry.address.states, identifiers = entry.address.identifiers, physicalPostalAddress = gateToPoolPhysicalAddress(entry.address.physicalPostalAddress), @@ -193,7 +193,7 @@ class PoolUpdateService( val updateRequests = entriesToUpdate.map { AddressPartnerUpdateRequest( address = LogisticAddressDto( - name = it.address.name, + name = it.address.nameParts.firstOrNull(), states = it.address.states, identifiers = it.address.identifiers, physicalPostalAddress = gateToPoolPhysicalAddress(it.address.physicalPostalAddress), diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt index 8d78e88d5..159ba85f6 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt @@ -32,7 +32,7 @@ data class LogisticAddressGateDto( description = "Name of the logistic address of the business partner. This is not according to official\n" + "registers but according to the name the uploading sharing member chooses." ) - val name: String? = null, + val nameParts: Collection = emptyList(), @ArraySchema(arraySchema = Schema(description = "Indicates if the LogisticAddress is \"Active\" or \"Inactive\".")) val states: Collection = emptyList(), diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index ca07f849b..3af030c25 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -67,7 +67,7 @@ class AddressPersistenceService( private fun updateAddress(address: LogisticAddress, changeAddress: AddressGateInputRequest, legalEntityRecord: LegalEntity?, siteRecord: Site?) { - address.name = changeAddress.address.name + address.name = changeAddress.address.nameParts.firstOrNull() address.externalId = changeAddress.externalId address.legalEntity = legalEntityRecord address.site = siteRecord @@ -109,7 +109,7 @@ class AddressPersistenceService( private fun updateAddressOutput(address: LogisticAddress, changeAddress: AddressGateOutputRequest, legalEntityRecord: LegalEntity?, siteRecord: Site?) { - address.name = changeAddress.address.name + address.name = changeAddress.address.nameParts.firstOrNull() address.bpn = changeAddress.bpn address.externalId = changeAddress.externalId address.legalEntity = legalEntityRecord diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 84770184b..0ef169973 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -34,7 +34,7 @@ fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site? val logisticAddress = LogisticAddress( externalId = externalId, siteExternalId = siteExternalId.toString(), - name = address.name, + name = address.nameParts.firstOrNull(), physicalPostalAddress = address.physicalPostalAddress.toPhysicalPostalAddressEntity(), alternativePostalAddress = address.alternativePostalAddress?.toAlternativePostalAddressEntity(), legalEntity = legalEntity, @@ -54,7 +54,7 @@ fun AddressGateOutputRequest.toAddressGateOutput(legalEntity: LegalEntity?, site bpn = bpn, externalId = externalId, siteExternalId = siteExternalId.toString(), - name = address.name, + name = address.nameParts.firstOrNull(), physicalPostalAddress = address.physicalPostalAddress.toPhysicalPostalAddressEntity(), alternativePostalAddress = address.alternativePostalAddress?.toAlternativePostalAddressEntity(), legalEntity = legalEntity, @@ -278,7 +278,7 @@ fun LogisticAddress.toAddressGateInputResponse(logisticAddressPage: LogisticAddr fun LogisticAddress.toLogisticAddressDto(): LogisticAddressGateDto { val logisticAddress = LogisticAddressGateDto( - name = name, + nameParts = name?.let { listOf(name!!) }?: emptyList(), states = mapToDtoStates(states), identifiers = mapToDtoIdentifiers(identifiers), physicalPostalAddress = physicalPostalAddress.toPhysicalPostalAddress(), diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt index 7d3b8c93c..4ec11ebc4 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt @@ -73,7 +73,7 @@ class SaasRequestMappingService( dataSource = saasConfigProperties.datasource, types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.BP_ADDRESS.name)), identifiers = toAddressIdentifiersSaas(address.identifiers, ""), - names = toNamesSaas(address.name), + names = toNamesSaas(address.nameParts.firstOrNull()?: ""), status = address.states.map { it.toSaasModel() }.firstOrNull(), addresses = toAddressesSaasModel(address) ) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index b32062742..d7d4dcb9b 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -329,7 +329,7 @@ object RequestValues { val addressGateInputRequest1 = AddressGateInputRequest( address = address1.copy( - name = CommonValues.name1, + nameParts = listOf(CommonValues.name1), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) ) @@ -341,7 +341,7 @@ object RequestValues { val addressGateInputRequest2 = AddressGateInputRequest( address = address2.copy( - name = CommonValues.name2, + nameParts = listOf(CommonValues.name2), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) ) @@ -354,7 +354,7 @@ object RequestValues { //Output Endpoint Values val addressGateOutputRequest1 = AddressGateOutputRequest( address = address1.copy( - name = CommonValues.name1, + nameParts = listOf(CommonValues.name1), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) ) @@ -366,7 +366,7 @@ object RequestValues { val addressGateOutputRequest2 = AddressGateOutputRequest( address = address2.copy( - name = CommonValues.name2, + nameParts = listOf(CommonValues.name2), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) ) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 039dde6b2..bfc9cdf9b 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -406,7 +406,7 @@ object ResponseValues { val addressGateInputResponse1 = AddressGateInputResponse( address = RequestValues.address1 .copy( - name = CommonValues.name1, + nameParts = listOf(CommonValues.name1), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!), AddressIdentifierDto(SaasValues.identifier2.value!!, SaasValues.identifier2.type?.technicalKey!!) @@ -419,7 +419,7 @@ object ResponseValues { val addressGateInputResponse2 = AddressGateInputResponse( address = RequestValues.address2 .copy( - name = CommonValues.nameSite1, + nameParts = listOf(CommonValues.nameSite1), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!), AddressIdentifierDto(SaasValues.identifier2.value!!, SaasValues.identifier2.type?.technicalKey!!) @@ -440,7 +440,7 @@ object ResponseValues { val logisticAddressGateInputResponse1 = AddressGateInputResponse( address = RequestValues.logisticAddress1.copy( - name = CommonValues.name1, + nameParts = listOf(CommonValues.name1), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) ) @@ -451,7 +451,7 @@ object ResponseValues { val logisticAddressGateInputResponse2 = AddressGateInputResponse( address = RequestValues.logisticAddress2.copy( - name = CommonValues.name2, + nameParts = listOf(CommonValues.name2), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) ) @@ -463,7 +463,7 @@ object ResponseValues { //Output Response Values val logisticAddressGateOutputResponse1 = AddressGateOutputResponse( address = RequestValues.logisticAddress1.copy( - name = CommonValues.name1, + nameParts = listOf(CommonValues.name1), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) ) @@ -475,7 +475,7 @@ object ResponseValues { val logisticAddressGateOutputResponse2 = AddressGateOutputResponse( address = RequestValues.logisticAddress2.copy( - name = CommonValues.name2, + nameParts = listOf(CommonValues.name2), identifiers = listOf( AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) ) From 031a645e6199a4df45367917997f524c1c6b262e Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 15:14:59 +0200 Subject: [PATCH 50/83] feat(Gate): replace name with name parts collection in site DTO --- .../catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt | 4 ++-- .../org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt | 4 ++-- .../eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt | 6 +++--- .../tractusx/bpdm/gate/service/SaasRequestMappingService.kt | 2 +- .../tractusx/bpdm/gate/service/SitePersistenceService.kt | 4 ++-- .../org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index 9bfe26ba9..e36ed21ee 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -107,7 +107,7 @@ class PoolUpdateService( ?.let { leParentBpn -> SitePartnerCreateRequest( site = SiteDto( - name = entry.site.name, + name = entry.site.nameParts.firstOrNull()?: "", states = entry.site.states, mainAddress = gateToPoolLogisticAddress(entry.site.mainAddress), ), @@ -131,7 +131,7 @@ class PoolUpdateService( val updateRequests = entriesToUpdate.map { SitePartnerUpdateRequest( site = SiteDto( - name = it.site.name, + name = it.site.nameParts.firstOrNull()?: "", states = it.site.states, mainAddress = gateToPoolLogisticAddress(it.site.mainAddress), ), diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt index 923c06e23..bf13404b8 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt @@ -25,8 +25,8 @@ import org.eclipse.tractusx.bpdm.common.dto.SiteStateDto @Schema(name = "Site", description = "Site record") data class SiteGateDto( - @get:Schema(description = "Site name") - val name: String, + @get:Schema(description = "Parts that make up the name of that site") + val nameParts: Collection = emptyList(), @ArraySchema(arraySchema = Schema(description = "Business status")) val states: Collection = emptyList(), diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 0ef169973..612bb1511 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -138,7 +138,7 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputIn ) val site = Site( - name = site.name, + name = site.nameParts.firstOrNull()?: "", externalId = externalId, legalEntity = legalEntity, dataType = datatype @@ -160,7 +160,7 @@ fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputI val site = Site( bpn = bpn, - name = site.name, + name = site.nameParts.firstOrNull()?: "", externalId = externalId, legalEntity = legalEntity, dataType = datatype @@ -399,7 +399,7 @@ fun LegalEntity.LegalEntityGateInputResponse(legalEntity: LegalEntity): LegalEnt fun Site.toSiteDto(): SiteGateDto { return SiteGateDto( - name = name, + nameParts = if(name.isEmpty()) emptyList() else listOf(name), states = mapToDtoSitesStates(states), mainAddress = mainAddress.toLogisticAddressDto() ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt index 4ec11ebc4..0f7e00275 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt @@ -58,7 +58,7 @@ class SaasRequestMappingService( dataSource = saasConfigProperties.datasource, types = listOf(TypeKeyNameUrlSaas(BusinessPartnerTypeSaas.ORGANIZATIONAL_UNIT.name)), identifiers = toIdentifiersSaas(""), - names = toNamesSaas(site.name), + names = toNamesSaas(site.nameParts.firstOrNull()), status = site.states.map { it.toSaasModel() }.firstOrNull(), // TODO Known issue: Name, state, BPN-A and identifiers of the main address are not transferred to SaaS yet!! addresses = toAddressesSaasModel(site.mainAddress) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 24ac1b644..9cb3895c6 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -77,7 +77,7 @@ class SitePersistenceService( private fun updateSite(site: Site, updatedSite: SiteGateInputRequest, legalEntityRecord: LegalEntity) { - site.name = updatedSite.site.name + site.name = updatedSite.site.nameParts.firstOrNull() ?: "" site.externalId = updatedSite.externalId site.legalEntity = legalEntityRecord site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) @@ -138,7 +138,7 @@ class SitePersistenceService( private fun updateSiteOutput(site: Site, updatedSite: SiteGateOutputRequest, legalEntityRecord: LegalEntity) { site.bpn = updatedSite.bpn - site.name = updatedSite.site.name + site.name = updatedSite.site.nameParts.firstOrNull() ?: "" site.externalId = updatedSite.externalId site.legalEntity = legalEntityRecord site.states.replace(updatedSite.site.states.map { toEntityAddress(it, site) }) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index d7d4dcb9b..2c5fb5d1d 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -287,13 +287,13 @@ object RequestValues { ) val site1 = SiteGateDto( - name = CommonValues.nameSite1, + nameParts = listOf(CommonValues.nameSite1), states = listOf(siteBusinessStatus1), mainAddress = address1 ) val site2 = SiteGateDto( - name = CommonValues.nameSite2, + nameParts = listOf(CommonValues.nameSite2), states = listOf(siteBusinessStatus2), mainAddress = address2 ) From 3972c510f806fd0a8f084c2675ba67892745a8b5 Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 17:37:49 +0200 Subject: [PATCH 51/83] fix(Gate): response and request DTO information for legal/main address --- .../bridge/dummy/dto/GateLegalEntityInfo.kt | 4 +- .../bpdm/bridge/dummy/dto/GateSiteInfo.kt | 2 + .../bridge/dummy/service/GateQueryService.kt | 9 +- .../bridge/dummy/service/PoolUpdateService.kt | 8 +- .../model/AddressGateOutputChildRequest.kt | 38 +++ .../api/model/LegalEntityGateInputResponse.kt | 3 +- .../api/model/LegalEntityGateOutputRequest.kt | 2 +- .../model/LegalEntityGateOutputResponse.kt | 2 +- .../bpdm/gate/api/model/SiteGateDto.kt | 5 +- .../gate/api/model/SiteGateInputRequest.kt | 3 + .../gate/api/model/SiteGateInputResponse.kt | 3 + .../gate/api/model/SiteGateOutputRequest.kt | 3 + .../gate/api/model/SiteGateOutputResponse.kt | 3 + .../bpdm/gate/service/LegalEntityService.kt | 10 +- .../bpdm/gate/service/ResponseMappings.kt | 37 +-- .../gate/service/SaasRequestMappingService.kt | 2 +- .../LegalEntityControllerInputIT.kt | 6 +- .../tractusx/bpdm/gate/util/RequestValues.kt | 16 +- .../tractusx/bpdm/gate/util/ResponseValues.kt | 237 ++++++++---------- 19 files changed, 202 insertions(+), 191 deletions(-) create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputChildRequest.kt diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt index a0c2f1b86..b5be26524 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt @@ -20,12 +20,12 @@ package com.catenax.bpdm.bridge.dummy.dto import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto -import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto +import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse data class GateLegalEntityInfo( val legalNameParts: Array = emptyArray(), val legalEntity: LegalEntityDto, - val legalAddress: LogisticAddressGateDto, + val legalAddress: AddressGateInputResponse, val externalId: String, val bpn: String? ) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateSiteInfo.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateSiteInfo.kt index 10f9171ef..f6cdad2df 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateSiteInfo.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateSiteInfo.kt @@ -19,11 +19,13 @@ package com.catenax.bpdm.bridge.dummy.dto +import org.eclipse.tractusx.bpdm.gate.api.model.LogisticAddressGateDto import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateDto data class GateSiteInfo( val site: SiteGateDto, val externalId: String, val legalEntityExternalId: String, + val mainAddress: LogisticAddressGateDto, val bpn: String? ) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt index cb49086d4..4b5caf329 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt @@ -26,12 +26,8 @@ import com.catenax.bpdm.bridge.dummy.dto.GateSiteInfo import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.* +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.springframework.stereotype.Service import java.time.Instant @@ -95,7 +91,8 @@ class GateQueryService( site = it.site, externalId = it.externalId, legalEntityExternalId = it.legalEntityExternalId, - bpn = bpnByExternalId[it.externalId] + bpn = bpnByExternalId[it.externalId], + mainAddress = it.mainAddress.address ) } } diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index e36ed21ee..ce6ca9e45 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -74,7 +74,7 @@ class PoolUpdateService( val createRequests = entriesToCreate.map { LegalEntityPartnerCreateRequest( legalEntity = it.legalEntity, - legalAddress = gateToPoolLogisticAddress(it.legalAddress), + legalAddress = gateToPoolLogisticAddress(it.legalAddress.address), index = it.externalId, legalName = it.legalNameParts[0] ) @@ -88,7 +88,7 @@ class PoolUpdateService( val updateRequests = entriesToUpdate.map { LegalEntityPartnerUpdateRequest( legalEntity = it.legalEntity, - legalAddress = gateToPoolLogisticAddress(it.legalAddress), + legalAddress = gateToPoolLogisticAddress(it.legalAddress.address), bpnl = it.bpn!!, legalName = it.legalNameParts[0] ) @@ -109,7 +109,7 @@ class PoolUpdateService( site = SiteDto( name = entry.site.nameParts.firstOrNull()?: "", states = entry.site.states, - mainAddress = gateToPoolLogisticAddress(entry.site.mainAddress), + mainAddress = gateToPoolLogisticAddress(entry.mainAddress), ), index = entry.externalId, bpnlParent = leParentBpn @@ -133,7 +133,7 @@ class PoolUpdateService( site = SiteDto( name = it.site.nameParts.firstOrNull()?: "", states = it.site.states, - mainAddress = gateToPoolLogisticAddress(it.site.mainAddress), + mainAddress = gateToPoolLogisticAddress(it.mainAddress), ), bpns = it.bpn!! ) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputChildRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputChildRequest.kt new file mode 100644 index 000000000..826e3aa90 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AddressGateOutputChildRequest.kt @@ -0,0 +1,38 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +import com.fasterxml.jackson.annotation.JsonUnwrapped +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer + +@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) +@Schema( + name = "AddressGateOutputChildRequest", + description = "DTO for setting the output address data with BPN." +) +data class AddressGateOutputChildRequest( + @field:JsonUnwrapped + val address: LogisticAddressGateDto, + + @Schema(description = "Business Partner Number") + val bpn: String +) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt index 8e4c55093..1e9e44846 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt @@ -24,7 +24,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer -import java.time.LocalDateTime @JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class) @Schema(name = "LegalEntityGateInputResponse", description = "Legal entity with external id") @@ -36,7 +35,7 @@ data class LegalEntityGateInputResponse( val legalEntity: LegalEntityDto, @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressGateDto, + val legalAddress: AddressGateInputResponse, @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt index 7fccb1ebf..d6cd7493c 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt @@ -55,7 +55,7 @@ data class LegalEntityGateOutputRequest( val legalEntity: LegalEntityDto, @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressGateDto, + val legalAddress: AddressGateOutputChildRequest, @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt index 7e3a448ee..b41d45e0b 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt @@ -32,7 +32,7 @@ data class LegalEntityGateOutputResponse( val legalEntity: LegalEntityDto, @get:Schema(description = "Address of the official seat of this legal entity") - val legalAddress: LogisticAddressGateDto, + val legalAddress: AddressGateOutputResponse, @Schema(description = "ID the record has in the external system where the record originates from", required = true) val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt index bf13404b8..4a611aadb 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt @@ -29,8 +29,5 @@ data class SiteGateDto( val nameParts: Collection = emptyList(), @ArraySchema(arraySchema = Schema(description = "Business status")) - val states: Collection = emptyList(), - - @get:Schema(description = "Main address where this site resides") - val mainAddress: LogisticAddressGateDto + val states: Collection = emptyList() ) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt index 3701ab3cd..2a8b77fd2 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputRequest.kt @@ -32,6 +32,9 @@ data class SiteGateInputRequest( @field:JsonUnwrapped val site: SiteGateDto, + @get:Schema(description = "Main address where this site resides") + val mainAddress: LogisticAddressGateDto, + @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt index 0e6c6ecf9..42ed9a7a9 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateInputResponse.kt @@ -32,6 +32,9 @@ data class SiteGateInputResponse( @field:JsonUnwrapped val site: SiteGateDto, + @get:Schema(description = "Main address where this site resides") + val mainAddress: AddressGateInputResponse, + @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt index 563c6c680..719ee062c 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputRequest.kt @@ -32,6 +32,9 @@ data class SiteGateOutputRequest( @field:JsonUnwrapped val site: SiteGateDto, + @get:Schema(description = "Main address where this site resides") + val mainAddress: AddressGateOutputChildRequest, + @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt index 7eab20a02..84aa3c416 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateOutputResponse.kt @@ -32,6 +32,9 @@ data class SiteGateOutputResponse( @field:JsonUnwrapped val site: SiteGateDto, + @get:Schema(description = "Main address where this site resides") + val mainAddress: AddressGateOutputResponse, + @Schema(description = "ID the record has in the external system where the record originates from") val externalId: String, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index a5e3e9be4..01bf30517 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -23,11 +23,7 @@ import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.LsaType +import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository @@ -117,7 +113,7 @@ class LegalEntityService( private fun toValidLegalEntities(legalEntityPage: Page): List { return legalEntityPage.content.map { legalEntity -> - legalEntity.LegalEntityGateInputResponse(legalEntity) + legalEntity.toLegalEntityGateInputResponse(legalEntity) } } @@ -127,7 +123,7 @@ private fun toValidSingleLegalEntity(legalEntity: LegalEntity): LegalEntityGateI return LegalEntityGateInputResponse( legalEntity = legalEntity.toLegalEntityDto(), - legalAddress = legalEntity.legalAddress.toLogisticAddressDto(), + legalAddress = legalEntity.legalAddress.toAddressGateInputResponse(legalEntity.legalAddress), externalId = legalEntity.externalId ) } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 612bb1511..93f5c544a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -132,9 +132,9 @@ fun Page.toDto(dtoContent: Collection): PageResponse { fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputInputEnum): Site { val addressInputRequest = AddressGateInputRequest( - address = site.mainAddress, + address = mainAddress, externalId = getMainAddressForSiteExternalId(externalId), - legalEntityExternalId = externalId + siteExternalId = externalId ) val site = Site( @@ -145,17 +145,18 @@ fun SiteGateInputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputIn ) site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) - site.mainAddress = addressInputRequest.toAddressGate(legalEntity, site, datatype) + site.mainAddress = addressInputRequest.toAddressGate(null, site, datatype) return site } fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputInputEnum): Site { - val addressInputRequest = AddressGateInputRequest( - address = site.mainAddress, + val addressOutputRequest = AddressGateOutputRequest( + address = mainAddress.address, externalId = getMainAddressForSiteExternalId(externalId), - legalEntityExternalId = externalId + legalEntityExternalId = externalId, + bpn = mainAddress.bpn ) val site = Site( @@ -167,7 +168,7 @@ fun SiteGateOutputRequest.toSiteGate(legalEntity: LegalEntity, datatype: OutputI ) site.states.addAll(this.site.states.map { toEntityAddress(it, site) }.toSet()) - site.mainAddress = addressInputRequest.toAddressGate(legalEntity, site, datatype) + site.mainAddress = addressOutputRequest.toAddressGateOutput(null, site, datatype) return site } @@ -212,10 +213,11 @@ fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalE fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): LegalEntity { - val addressInputRequest = AddressGateInputRequest( - address = legalAddress, + val addressOutputRequest = AddressGateOutputRequest( + address = legalAddress.address, externalId = getMainAddressForLegalEntityExternalId(externalId), - legalEntityExternalId = externalId + legalEntityExternalId = externalId, + bpn = legalAddress.bpn ) val legalEntity = LegalEntity( @@ -231,7 +233,7 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) - legalEntity.legalAddress = addressInputRequest.toAddressGate(legalEntity, null, datatype) + legalEntity.legalAddress = addressOutputRequest.toAddressGateOutput(legalEntity, null, datatype) return legalEntity @@ -386,11 +388,11 @@ fun mapToLegalEntityClassificationsDto(classification: MutableSet Date: Fri, 9 Jun 2023 17:50:04 +0200 Subject: [PATCH 52/83] feat(Gate): add business partner roles to DTOs --- .../gate/api/model/BusinessPartnerRole.kt | 25 +++++++++++++++++++ .../api/model/LegalEntityGateInputRequest.kt | 3 +++ .../api/model/LegalEntityGateInputResponse.kt | 3 +++ .../api/model/LegalEntityGateOutputRequest.kt | 3 +++ .../model/LegalEntityGateOutputResponse.kt | 3 +++ .../gate/api/model/LogisticAddressGateDto.kt | 4 ++- .../bpdm/gate/api/model/SiteGateDto.kt | 5 +++- 7 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerRole.kt diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerRole.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerRole.kt new file mode 100644 index 000000000..8a6261939 --- /dev/null +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/BusinessPartnerRole.kt @@ -0,0 +1,25 @@ +/******************************************************************************* + * 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 org.eclipse.tractusx.bpdm.gate.api.model + +enum class BusinessPartnerRole { + SUPPLIER, + CUSTOMER +} \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt index 9b6a83b2d..1daa4deb2 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt @@ -35,6 +35,9 @@ data class LegalEntityGateInputRequest( @field:JsonUnwrapped val legalEntity: LegalEntityDto, + @Schema(description = "Which roles this business partner takes in relation to the sharing member") + val roles: Collection = emptyList(), + @get:Schema(description = "Address of the official seat of this legal entity") val legalAddress: LogisticAddressGateDto, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt index 1e9e44846..223bf5868 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt @@ -34,6 +34,9 @@ data class LegalEntityGateInputResponse( @field:JsonUnwrapped val legalEntity: LegalEntityDto, + @Schema(description = "Which roles this business partner takes in relation to the sharing member") + val roles: Collection = emptyList(), + @get:Schema(description = "Address of the official seat of this legal entity") val legalAddress: AddressGateInputResponse, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt index d6cd7493c..8c8a21a9f 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt @@ -54,6 +54,9 @@ data class LegalEntityGateOutputRequest( @field:JsonUnwrapped val legalEntity: LegalEntityDto, + @Schema(description = "Which roles this business partner takes in relation to the sharing member") + val roles: Collection = emptyList(), + @get:Schema(description = "Address of the official seat of this legal entity") val legalAddress: AddressGateOutputChildRequest, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt index b41d45e0b..24b6874a5 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt @@ -31,6 +31,9 @@ data class LegalEntityGateOutputResponse( @field:JsonUnwrapped val legalEntity: LegalEntityDto, + @Schema(description = "Which roles this business partner takes in relation to the sharing member") + val roles: Collection = emptyList(), + @get:Schema(description = "Address of the official seat of this legal entity") val legalAddress: AddressGateOutputResponse, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt index 159ba85f6..4a9d041ce 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LogisticAddressGateDto.kt @@ -44,5 +44,7 @@ data class LogisticAddressGateDto( val physicalPostalAddress: PhysicalPostalAddressGateDto, @get:Schema(description = "Alternative postal address") - val alternativePostalAddress: AlternativePostalAddressDto? = null + val alternativePostalAddress: AlternativePostalAddressDto? = null, + + val roles: Collection = emptyList() ) \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt index 4a611aadb..69b9890d4 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/SiteGateDto.kt @@ -29,5 +29,8 @@ data class SiteGateDto( val nameParts: Collection = emptyList(), @ArraySchema(arraySchema = Schema(description = "Business status")) - val states: Collection = emptyList() + val states: Collection = emptyList(), + + @Schema(description = "Which roles this business partner takes in relation to the sharing member") + val roles: Collection = emptyList(), ) \ No newline at end of file From 44268690fa575b1c6807f58a798b26e307784292 Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 18:11:45 +0200 Subject: [PATCH 53/83] cicd(Helm): increase the app version to 4.0.0-alpha.5 --- charts/bpdm/Chart.yaml | 14 +++++++------- charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml | 6 +++--- charts/bpdm/charts/bpdm-gate/Chart.yaml | 6 +++--- charts/bpdm/charts/bpdm-pool/Chart.yaml | 8 ++++---- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/charts/bpdm/Chart.yaml b/charts/bpdm/Chart.yaml index 428835b88..bc3a38dd9 100644 --- a/charts/bpdm/Chart.yaml +++ b/charts/bpdm/Chart.yaml @@ -22,32 +22,32 @@ apiVersion: v2 name: bpdm type: application description: A Helm chart for Kubernetes that deploys the gate and pool applications -version: 3.0.1 -appVersion: 1.0.0 +version: 3.0.2-alpha.1 +appVersion: "4.0.0-alpha.5" home: https://github.com/eclipse-tractusx/bpdm sources: - https://github.com/eclipse-tractusx/bpdm dependencies: - name: bpdm-gate - version: 4.0.0-alpha.5 + version: 4.0.0-alpha.6 alias: bpdm-gate condition: bpdm-gate.enabled - name: bpdm-pool - version: 5.0.0-alpha.4 + version: 5.0.0-alpha.5 alias: bpdm-pool condition: bpdm-pool.enabled - name: bpdm-bridge-dummy - version: 1.0.0 + version: 1.0.1-alpha.1 alias: bpdm-bridge-dummy condition: bpdm-bridge-dummy.enabled - name: opensearch - version: 2.*.* + version: 2.12.2 repository: https://opensearch-project.github.io/helm-charts/ alias: opensearch condition: opensearch.enabled - name: postgresql - version: 11.*.* + version: 11.9.13 repository: https://charts.bitnami.com/bitnami alias: postgres condition: postgres.enabled diff --git a/charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml b/charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml index 3589840db..542d4fedc 100644 --- a/charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml +++ b/charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml @@ -21,15 +21,15 @@ apiVersion: v2 type: application name: bpdm-bridge-dummy -appVersion: "4.0.0-alpha.4" -version: 1.0.0 +appVersion: "4.0.0-alpha.5" +version: 1.0.1-alpha.1 description: A Helm chart for deploying the BPDM bridge dummy service home: https://eclipse-tractusx.github.io/docs/kits/Business%20Partner%20Kit/Adoption%20View sources: - https://github.com/eclipse-tractusx/bpdm dependencies: - name: postgresql - version: 11.9.1 + version: 11.9.13 repository: https://charts.bitnami.com/bitnami alias: postgres condition: postgres.enabled diff --git a/charts/bpdm/charts/bpdm-gate/Chart.yaml b/charts/bpdm/charts/bpdm-gate/Chart.yaml index 7a0baf041..f4d9cb6f6 100644 --- a/charts/bpdm/charts/bpdm-gate/Chart.yaml +++ b/charts/bpdm/charts/bpdm-gate/Chart.yaml @@ -21,15 +21,15 @@ apiVersion: v2 type: application name: bpdm-gate -appVersion: "4.0.0-alpha.4" -version: 4.0.0-alpha.5 +appVersion: "4.0.0-alpha.5" +version: 4.0.0-alpha.6 description: A Helm chart for deploying the BPDM gate service home: https://eclipse-tractusx.github.io/docs/kits/Business%20Partner%20Kit/Adoption%20View sources: - https://github.com/eclipse-tractusx/bpdm dependencies: - name: postgresql - version: 11.9.1 + version: 11.9.13 repository: https://charts.bitnami.com/bitnami alias: postgres condition: postgres.enabled diff --git a/charts/bpdm/charts/bpdm-pool/Chart.yaml b/charts/bpdm/charts/bpdm-pool/Chart.yaml index 55e80c02b..836b1568c 100644 --- a/charts/bpdm/charts/bpdm-pool/Chart.yaml +++ b/charts/bpdm/charts/bpdm-pool/Chart.yaml @@ -21,20 +21,20 @@ apiVersion: v2 type: application name: bpdm-pool -appVersion: "4.0.0-alpha.4" -version: 5.0.0-alpha.4 +appVersion: "4.0.0-alpha.5" +version: 5.0.0-alpha.5 description: A Helm chart for deploying the BPDM pool service home: https://eclipse-tractusx.github.io/docs/kits/Business%20Partner%20Kit/Adoption%20View sources: - https://github.com/eclipse-tractusx/bpdm dependencies: - name: opensearch - version: 2.4.0 + version: 2.12.2 repository: https://opensearch-project.github.io/helm-charts/ alias: opensearch condition: opensearch.enabled - name: postgresql - version: 11.9.1 + version: 11.9.13 repository: https://charts.bitnami.com/bitnami alias: postgres condition: postgres.enabled From 3fee413f25eb2515d91c32ebd92cfd570f395839 Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 19:38:38 +0200 Subject: [PATCH 54/83] fix(Bridge): error on business partner sync with empty name parts --- .../catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt | 4 ++-- .../eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index ce6ca9e45..1083b1036 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -76,7 +76,7 @@ class PoolUpdateService( legalEntity = it.legalEntity, legalAddress = gateToPoolLogisticAddress(it.legalAddress.address), index = it.externalId, - legalName = it.legalNameParts[0] + legalName = it.legalNameParts.firstOrNull() ?: "" ) } @@ -90,7 +90,7 @@ class PoolUpdateService( legalEntity = it.legalEntity, legalAddress = gateToPoolLogisticAddress(it.legalAddress.address), bpnl = it.bpn!!, - legalName = it.legalNameParts[0] + legalName = it.legalNameParts.firstOrNull() ?: "" ) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 93f5c544a..2ce38a1ac 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -394,6 +394,7 @@ fun LegalEntity.toLegalEntityGateInputResponse(legalEntity: LegalEntity): LegalE legalEntity = legalEntity.toLegalEntityDto(), legalAddress = legalAddress.toAddressGateInputResponse(legalAddress), externalId = legalEntity.externalId, + legalNameParts = arrayOf(legalEntity.legalName.value) ) } From a710b5fd474f1af9f12be286e688dc93caa0c679 Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 20:11:24 +0200 Subject: [PATCH 55/83] fix(Gate): add missing legal name parts to DTOs and fix mapping logic --- .../bpdm/gate/api/model/LegalEntityGateOutputResponse.kt | 2 ++ .../eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt | 1 + .../eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt | 1 + .../org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt | 4 ++-- .../org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt | 4 ++++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt index 24b6874a5..8ed336f14 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputResponse.kt @@ -31,6 +31,8 @@ data class LegalEntityGateOutputResponse( @field:JsonUnwrapped val legalEntity: LegalEntityDto, + val legalNameParts: Collection, + @Schema(description = "Which roles this business partner takes in relation to the sharing member") val roles: Collection = emptyList(), diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 01bf30517..df6739017 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -123,6 +123,7 @@ private fun toValidSingleLegalEntity(legalEntity: LegalEntity): LegalEntityGateI return LegalEntityGateInputResponse( legalEntity = legalEntity.toLegalEntityDto(), + legalNameParts = arrayOf(legalEntity.legalName.value), legalAddress = legalEntity.legalAddress.toAddressGateInputResponse(legalEntity.legalAddress), externalId = legalEntity.externalId ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 2ce38a1ac..82d8eaaaf 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -454,6 +454,7 @@ fun LegalEntity.toLegalEntityGateOutputResponse(legalEntity: LegalEntity): Legal return LegalEntityGateOutputResponse( legalEntity = legalEntity.toLegalEntityDto(), + legalNameParts = listOf(legalName.value), externalId = legalEntity.externalId, bpn = legalEntity.bpn!!, legalAddress = legalAddress.toAddressGateOutputResponse(legalAddress) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index 0d1b153cd..d07f9e1c0 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -273,7 +273,7 @@ object RequestValues { val legalEntityGateInputRequest2 = LegalEntityGateInputRequest( legalEntity = legalEntity2, legalAddress = address2, - legalNameParts = arrayOf(CommonValues.name3), + legalNameParts = arrayOf(CommonValues.name2), externalId = CommonValues.externalId2, ) @@ -388,7 +388,7 @@ object RequestValues { val legalEntityGateOutputRequest2 = LegalEntityGateOutputRequest( legalEntity = legalEntity2, legalAddress = AddressGateOutputChildRequest(address2, CommonValues.bpnAddress2), - legalNameParts = arrayOf(CommonValues.name3), + legalNameParts = arrayOf(CommonValues.name2), externalId = CommonValues.externalId2, bpn = CommonValues.bpn2 ) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 6c9800ffa..30b530b9c 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -352,6 +352,7 @@ object ResponseValues { val legalEntityGateInputResponse1 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity1, + legalNameParts = arrayOf(CommonValues.name1), legalAddress = AddressGateInputResponse ( address = RequestValues.logisticAddress1, externalId = "${CommonValues.externalId1}_legalAddress", @@ -363,6 +364,7 @@ object ResponseValues { val legalEntityGateInputResponse2 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity2, + legalNameParts = arrayOf(CommonValues.name2), legalAddress = AddressGateInputResponse ( address = RequestValues.logisticAddress2, externalId = "${CommonValues.externalId2}_legalAddress", @@ -376,6 +378,7 @@ object ResponseValues { //Gate Output Legal Entities Response val legalEntityGateOutputResponse1 = LegalEntityGateOutputResponse( legalEntity = RequestValues.legalEntity1, + legalNameParts = listOf(CommonValues.name1), externalId = CommonValues.externalId1, bpn = CommonValues.bpn1, legalAddress = AddressGateOutputResponse( @@ -390,6 +393,7 @@ object ResponseValues { val legalEntityGateOutputResponse2 = LegalEntityGateOutputResponse( legalEntity = RequestValues.legalEntity2, externalId = CommonValues.externalId2, + legalNameParts = listOf(CommonValues.name2), bpn = CommonValues.bpn2, legalAddress = AddressGateOutputResponse( address = RequestValues.address2, From 55d058008fbaf738f9a3f3967917814ee9643fce Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Fri, 9 Jun 2023 20:26:15 +0200 Subject: [PATCH 56/83] cicd(Helm): increase app version to 4.0.0-alpha.6 --- charts/bpdm/Chart.yaml | 10 +++++----- charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml | 4 ++-- charts/bpdm/charts/bpdm-gate/Chart.yaml | 4 ++-- charts/bpdm/charts/bpdm-pool/Chart.yaml | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/charts/bpdm/Chart.yaml b/charts/bpdm/Chart.yaml index bc3a38dd9..85b4d59ab 100644 --- a/charts/bpdm/Chart.yaml +++ b/charts/bpdm/Chart.yaml @@ -22,23 +22,23 @@ apiVersion: v2 name: bpdm type: application description: A Helm chart for Kubernetes that deploys the gate and pool applications -version: 3.0.2-alpha.1 -appVersion: "4.0.0-alpha.5" +version: 3.0.2-alpha.2 +appVersion: "4.0.0-alpha.6" home: https://github.com/eclipse-tractusx/bpdm sources: - https://github.com/eclipse-tractusx/bpdm dependencies: - name: bpdm-gate - version: 4.0.0-alpha.6 + version: 4.0.0-alpha.7 alias: bpdm-gate condition: bpdm-gate.enabled - name: bpdm-pool - version: 5.0.0-alpha.5 + version: 5.0.0-alpha.6 alias: bpdm-pool condition: bpdm-pool.enabled - name: bpdm-bridge-dummy - version: 1.0.1-alpha.1 + version: 1.0.1-alpha.2 alias: bpdm-bridge-dummy condition: bpdm-bridge-dummy.enabled - name: opensearch diff --git a/charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml b/charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml index 542d4fedc..49a6ef1dc 100644 --- a/charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml +++ b/charts/bpdm/charts/bpdm-bridge-dummy/Chart.yaml @@ -21,8 +21,8 @@ apiVersion: v2 type: application name: bpdm-bridge-dummy -appVersion: "4.0.0-alpha.5" -version: 1.0.1-alpha.1 +appVersion: "4.0.0-alpha.6" +version: 1.0.1-alpha.2 description: A Helm chart for deploying the BPDM bridge dummy service home: https://eclipse-tractusx.github.io/docs/kits/Business%20Partner%20Kit/Adoption%20View sources: diff --git a/charts/bpdm/charts/bpdm-gate/Chart.yaml b/charts/bpdm/charts/bpdm-gate/Chart.yaml index f4d9cb6f6..2ed731b18 100644 --- a/charts/bpdm/charts/bpdm-gate/Chart.yaml +++ b/charts/bpdm/charts/bpdm-gate/Chart.yaml @@ -21,8 +21,8 @@ apiVersion: v2 type: application name: bpdm-gate -appVersion: "4.0.0-alpha.5" -version: 4.0.0-alpha.6 +appVersion: "4.0.0-alpha.6" +version: 4.0.0-alpha.7 description: A Helm chart for deploying the BPDM gate service home: https://eclipse-tractusx.github.io/docs/kits/Business%20Partner%20Kit/Adoption%20View sources: diff --git a/charts/bpdm/charts/bpdm-pool/Chart.yaml b/charts/bpdm/charts/bpdm-pool/Chart.yaml index 836b1568c..a15d59a61 100644 --- a/charts/bpdm/charts/bpdm-pool/Chart.yaml +++ b/charts/bpdm/charts/bpdm-pool/Chart.yaml @@ -21,8 +21,8 @@ apiVersion: v2 type: application name: bpdm-pool -appVersion: "4.0.0-alpha.5" -version: 5.0.0-alpha.5 +appVersion: "4.0.0-alpha.6" +version: 5.0.0-alpha.6 description: A Helm chart for deploying the BPDM pool service home: https://eclipse-tractusx.github.io/docs/kits/Business%20Partner%20Kit/Adoption%20View sources: From 19f59e4e4284fb17dde8276c915edc7c5329a227 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Wed, 14 Jun 2023 13:18:35 +0100 Subject: [PATCH 57/83] fix(gate): Added changelog to Logistic Address when Legal Entity or Site are Update/Created --- .../gate/service/LegalEntityPersistenceService.kt | 13 ++++++++++++- .../bpdm/gate/service/LegalEntityService.kt | 11 ++++------- .../bpdm/gate/service/SitePersistenceService.kt | 13 ++++++++++++- .../tractusx/bpdm/gate/service/SiteService.kt | 9 +-------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 043ff7fac..4abee05d2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -25,7 +25,9 @@ import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.entity.* +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.springframework.http.HttpStatus @@ -36,7 +38,8 @@ import org.springframework.web.server.ResponseStatusException @Service class LegalEntityPersistenceService( private val gateLegalEntityRepository: LegalEntityRepository, - private val gateAddressRepository: GateAddressRepository + private val gateAddressRepository: GateAddressRepository, + private val changelogRepository: ChangelogRepository ) { @Transactional @@ -58,12 +61,20 @@ class LegalEntityPersistenceService( updateLegalEntity(existingLegalEntity, legalEntity, logisticAddressRecord) gateLegalEntityRepository.save(existingLegalEntity) + saveChangelog(legalEntity) } ?: run { gateLegalEntityRepository.save(fullLegalEntity) + saveChangelog(legalEntity) } } } + //Creates Changelog For both Legal Entity and Logistic Address when they are created or updated + private fun saveChangelog(legalEntity: LegalEntityGateInputRequest) { + changelogRepository.save(ChangelogEntry(getMainAddressForLegalEntityExternalId(legalEntity.externalId), LsaType.ADDRESS)) + changelogRepository.save(ChangelogEntry(legalEntity.externalId, LsaType.LEGAL_ENTITY)) + } + private fun updateLegalEntity( legalEntity: LegalEntity, legalEntityRequest: LegalEntityGateInputRequest, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index df6739017..09d580da9 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -23,10 +23,11 @@ import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum -import org.eclipse.tractusx.bpdm.gate.api.model.* -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest +import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity -import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.springframework.data.domain.Page import org.springframework.data.domain.PageRequest @@ -34,7 +35,6 @@ import org.springframework.stereotype.Service @Service class LegalEntityService( - private val changelogRepository: ChangelogRepository, private val legalEntityPersistenceService: LegalEntityPersistenceService, private val legalEntityRepository: LegalEntityRepository ) { @@ -46,9 +46,6 @@ class LegalEntityService( **/ fun upsertLegalEntities(legalEntities: Collection) { - legalEntities.forEach { legalEntity -> - changelogRepository.save(ChangelogEntry(legalEntity.externalId, LsaType.LEGAL_ENTITY)) - } legalEntityPersistenceService.persistLegalEntitiesBP(legalEntities, OutputInputEnum.Input) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 9cb3895c6..7c689f718 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -22,9 +22,11 @@ package org.eclipse.tractusx.bpdm.gate.service import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.common.util.replace +import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.entity.* +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository @@ -37,7 +39,8 @@ import org.springframework.web.server.ResponseStatusException class SitePersistenceService( private val siteRepository: SiteRepository, private val legalEntityRepository: LegalEntityRepository, - private val addressRepository: GateAddressRepository + private val addressRepository: GateAddressRepository, + private val changelogRepository: ChangelogRepository ) { @Transactional @@ -59,12 +62,20 @@ class SitePersistenceService( updateAddress(logisticAddressRecord, fullSite.mainAddress) updateSite(existingSite, site, legalEntityRecord) siteRepository.save(existingSite) + saveChangelog(site) } ?: run { siteRepository.save(fullSite) + saveChangelog(site) } } } + //Creates Changelog For both Site and Logistic Address when they are created or updated + private fun saveChangelog(site: SiteGateInputRequest) { + changelogRepository.save(ChangelogEntry(getMainAddressForSiteExternalId(site.externalId), LsaType.ADDRESS)) + changelogRepository.save(ChangelogEntry(site.externalId, LsaType.SITE)) + } + private fun getAddressRecord(externalId: String, datatype: OutputInputEnum): LogisticAddress { return addressRepository.findByExternalIdAndDataType(externalId, datatype) ?: throw BpdmNotFoundException("Business Partner", "Error") diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index 0fed808c6..f2921001f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -23,17 +23,14 @@ import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException -import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties -import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.entity.Site import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException -import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository import org.springframework.data.domain.Page import org.springframework.data.domain.PageRequest @@ -44,7 +41,6 @@ class SiteService( private val saasRequestMappingService: SaasRequestMappingService, private val saasClient: SaasClient, private val bpnConfigProperties: BpnConfigProperties, - private val changelogRepository: ChangelogRepository, private val sitePersistenceService: SitePersistenceService, private val siteRepository: SiteRepository ) { @@ -111,11 +107,8 @@ class SiteService( **/ fun upsertSites(sites: Collection) { - sites.forEach { site -> - changelogRepository.save(ChangelogEntry(site.externalId, LsaType.SITE)) - } - sitePersistenceService.persistSitesBP(sites, OutputInputEnum.Input) + } /** From 70bef1c3b7a116e4a392bac7c49f4ff6c1d93235 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Wed, 14 Jun 2023 18:50:43 +0100 Subject: [PATCH 58/83] fix(Gate-Bridge): Replace Array with Collection Type #263 --- .../bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt | 2 +- .../bpdm/gate/api/model/LegalEntityGateInputRequest.kt | 2 +- .../gate/api/model/LegalEntityGateInputResponse.kt | 2 +- .../bpdm/gate/api/model/LegalEntityGateOutput.kt | 2 +- .../gate/api/model/LegalEntityGateOutputRequest.kt | 2 +- .../tractusx/bpdm/gate/service/LegalEntityService.kt | 2 +- .../tractusx/bpdm/gate/service/ResponseMappings.kt | 2 +- .../eclipse/tractusx/bpdm/gate/util/RequestValues.kt | 10 +++++----- .../eclipse/tractusx/bpdm/gate/util/ResponseValues.kt | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt index b5be26524..61c72afcc 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt @@ -23,7 +23,7 @@ import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse data class GateLegalEntityInfo( - val legalNameParts: Array = emptyArray(), + val legalNameParts: List = emptyList(), val legalEntity: LegalEntityDto, val legalAddress: AddressGateInputResponse, val externalId: String, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt index 1daa4deb2..f2952831d 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputRequest.kt @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ @Schema(name = "LegalEntityGateInputRequest", description = "Legal entity with external id") data class LegalEntityGateInputRequest( - val legalNameParts: Array = emptyArray(), + val legalNameParts: List = emptyList(), @Schema(description = "legal Entity") @field:JsonUnwrapped diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt index 223bf5868..5d2db58e0 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateInputResponse.kt @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ @Schema(name = "LegalEntityGateInputResponse", description = "Legal entity with external id") data class LegalEntityGateInputResponse( - val legalNameParts: Array = emptyArray(), + val legalNameParts: List = emptyList(), @field:JsonUnwrapped val legalEntity: LegalEntityDto, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt index fcf1db486..19aa75c83 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutput.kt @@ -31,7 +31,7 @@ import org.eclipse.tractusx.bpdm.gate.api.model.response.LogisticAddressGateResp @Schema(name = "LegalEntityGateOutput", description = "Legal entity with references") data class LegalEntityGateOutput( - val legalNameParts: Array = emptyArray(), + val legalNameParts: List = emptyList(), @field:JsonUnwrapped val legalEntity: LegalEntityResponse, diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt index 8c8a21a9f..d918ea291 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/LegalEntityGateOutputRequest.kt @@ -48,7 +48,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ @Schema(name = "LegalEntityGateOutputRequest", description = "Legal entity with external id") data class LegalEntityGateOutputRequest( - val legalNameParts: Array = emptyArray(), + val legalNameParts: List = emptyList(), @Schema(description = "legal Enity") @field:JsonUnwrapped diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 09d580da9..6a4d4b575 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -120,7 +120,7 @@ private fun toValidSingleLegalEntity(legalEntity: LegalEntity): LegalEntityGateI return LegalEntityGateInputResponse( legalEntity = legalEntity.toLegalEntityDto(), - legalNameParts = arrayOf(legalEntity.legalName.value), + legalNameParts = listOf(legalEntity.legalName.value), legalAddress = legalEntity.legalAddress.toAddressGateInputResponse(legalEntity.legalAddress), externalId = legalEntity.externalId ) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 82d8eaaaf..18745faac 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -394,7 +394,7 @@ fun LegalEntity.toLegalEntityGateInputResponse(legalEntity: LegalEntity): LegalE legalEntity = legalEntity.toLegalEntityDto(), legalAddress = legalAddress.toAddressGateInputResponse(legalAddress), externalId = legalEntity.externalId, - legalNameParts = arrayOf(legalEntity.legalName.value) + legalNameParts = listOf(legalEntity.legalName.value) ) } diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index d07f9e1c0..422b8db3a 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -265,7 +265,7 @@ object RequestValues { val legalEntityGateInputRequest1 = LegalEntityGateInputRequest( legalEntity = legalEntity1, legalAddress = address1, - legalNameParts = arrayOf(CommonValues.name1), + legalNameParts = listOf(CommonValues.name1), externalId = CommonValues.externalId1, ) @@ -273,7 +273,7 @@ object RequestValues { val legalEntityGateInputRequest2 = LegalEntityGateInputRequest( legalEntity = legalEntity2, legalAddress = address2, - legalNameParts = arrayOf(CommonValues.name2), + legalNameParts = listOf(CommonValues.name2), externalId = CommonValues.externalId2, ) @@ -281,7 +281,7 @@ object RequestValues { val legalEntityGateInputRequest3 = LegalEntityGateInputRequest( legalEntity = legalEntity3, legalAddress = address3, - legalNameParts = arrayOf(CommonValues.name1), + legalNameParts = listOf(CommonValues.name1), externalId = CommonValues.externalId3, ) @@ -380,7 +380,7 @@ object RequestValues { val legalEntityGateOutputRequest1 = LegalEntityGateOutputRequest( legalEntity = legalEntity1, legalAddress = AddressGateOutputChildRequest(address1, CommonValues.bpnAddress1), - legalNameParts = arrayOf(CommonValues.name1), + legalNameParts = listOf(CommonValues.name1), externalId = CommonValues.externalId1, bpn = CommonValues.bpn1 ) @@ -388,7 +388,7 @@ object RequestValues { val legalEntityGateOutputRequest2 = LegalEntityGateOutputRequest( legalEntity = legalEntity2, legalAddress = AddressGateOutputChildRequest(address2, CommonValues.bpnAddress2), - legalNameParts = arrayOf(CommonValues.name2), + legalNameParts = listOf(CommonValues.name2), externalId = CommonValues.externalId2, bpn = CommonValues.bpn2 ) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index 30b530b9c..fc0150f5e 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -352,7 +352,7 @@ object ResponseValues { val legalEntityGateInputResponse1 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity1, - legalNameParts = arrayOf(CommonValues.name1), + legalNameParts = listOf(CommonValues.name1), legalAddress = AddressGateInputResponse ( address = RequestValues.logisticAddress1, externalId = "${CommonValues.externalId1}_legalAddress", @@ -364,7 +364,7 @@ object ResponseValues { val legalEntityGateInputResponse2 = LegalEntityGateInputResponse( legalEntity = RequestValues.legalEntity2, - legalNameParts = arrayOf(CommonValues.name2), + legalNameParts = listOf(CommonValues.name2), legalAddress = AddressGateInputResponse ( address = RequestValues.logisticAddress2, externalId = "${CommonValues.externalId2}_legalAddress", From aa8cdfe0996467a3f06d73f44e47a7945af698bc Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 15 Jun 2023 11:24:02 +0100 Subject: [PATCH 59/83] Fix(Pool): Docs Update README to include Docker Compose setup instructions --- INSTALL.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index bc42eaca3..7ea4b7339 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -14,11 +14,16 @@ Then depending on which module you want to start go to the module subfolder you * Maven * JDK17 -* PostgreSQL 14.2 -* OpenSearch 2.1.0 +* Docker and Docker Compose * Keycloak 17.0.0 (with enabled `auth` profile) -When running, the project requires a Postgresql database and an Opensearch instance to be available to connect to. +When running, the project requires a PostgreSQL database and an OpenSearch instance to be available to connect to. You can set up these dependencies manually, or you can use the provided `docker-compose` file which will start the necessary dependencies for you. + +To use Docker Compose, navigate to the project directory and run the following command: +```bash +docker-compose up +``` + Per default configuration the application expects postgres to run on `localhost` on port `5432`. Opensearch needs to run on `localhost` on port `9200` on default. From 6d40d6713e91a4dc44f73282d4b0230aa1911ad6 Mon Sep 17 00:00:00 2001 From: cezaralexandremorais Date: Tue, 13 Jun 2023 09:47:37 +0100 Subject: [PATCH 60/83] feat: added maven wrapper for windows. --- mvnw.cmd | 205 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 mvnw.cmd diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 000000000..319c3586a --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,205 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Apache Maven Wrapper startup batch script, version 3.1.1 +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* +if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %WRAPPER_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% ^ + %JVM_CONFIG_MAVEN_PROPS% ^ + %MAVEN_OPTS% ^ + %MAVEN_DEBUG_OPTS% ^ + -classpath %WRAPPER_JAR% ^ + "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^ + %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" +if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%"=="on" pause + +if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% + +cmd /C exit /B %ERROR_CODE% From 14fcb28ea81c0b132c7654162b6ba0f363e0639f Mon Sep 17 00:00:00 2001 From: SujitMBRDI Date: Thu, 15 Jun 2023 15:55:35 +0530 Subject: [PATCH 61/83] Docs: Update yaml and json files for gate, pool and bridge dummy service #289 --- docs/api/bridge-dummy.json | 31 + docs/api/bridge-dummy.yaml | 19 + docs/api/gate.json | 4815 ++++++---------- docs/api/gate.yaml | 3876 ++++--------- docs/api/pool.json | 10354 +++++++++++------------------------ docs/api/pool.yaml | 6093 ++++++--------------- 6 files changed, 7617 insertions(+), 17571 deletions(-) create mode 100644 docs/api/bridge-dummy.json create mode 100644 docs/api/bridge-dummy.yaml diff --git a/docs/api/bridge-dummy.json b/docs/api/bridge-dummy.json new file mode 100644 index 000000000..62ea4e0b9 --- /dev/null +++ b/docs/api/bridge-dummy.json @@ -0,0 +1,31 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Business Partner Data Management Bridge Dummy", + "description": "Bridge between Gate and Pool as a simple replacement for a dedicated sharing service", + "version": "4.0.0-SNAPSHOT" + }, + "servers": [ + { + "url": "http://localhost:8083", + "description": "Generated server url" + } + ], + "paths": { + "/api/bridge/sync": { + "post": { + "tags": [ + "bridge-controller" + ], + "summary": "Start sync between Gate and Pool", + "operationId": "triggerSync", + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/docs/api/bridge-dummy.yaml b/docs/api/bridge-dummy.yaml new file mode 100644 index 000000000..57e1a09b1 --- /dev/null +++ b/docs/api/bridge-dummy.yaml @@ -0,0 +1,19 @@ +openapi: 3.0.1 +info: + title: Business Partner Data Management Bridge Dummy + description: Bridge between Gate and Pool as a simple replacement for a dedicated sharing service + version: 4.0.0-SNAPSHOT +servers: + - url: http://localhost:8083 + description: Generated server url +paths: + /api/bridge/sync: + post: + tags: + - bridge-controller + summary: Start sync between Gate and Pool + operationId: triggerSync + responses: + '200': + description: OK +components: {} diff --git a/docs/api/gate.json b/docs/api/gate.json index e94f33a2e..4f4936ef6 100644 --- a/docs/api/gate.json +++ b/docs/api/gate.json @@ -3,7 +3,7 @@ "info": { "title": "Business Partner Data Management Gate", "description": "A gate for a member to share business partner data with CatenaX", - "version": "4.0.0" + "version": "4.0.0-SNAPSHOT" }, "servers": [ { @@ -12,6 +12,217 @@ } ], "paths": { + "/api/catena/sharing-state": { + "get": { + "tags": [ + "sharing-state-controller" + ], + "summary": "Get sharing states (including error info and BPN) for business partners, optionally filtered by LSA type and external ID", + "operationId": "getSharingStates", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + }, + { + "name": "lsaType", + "in": "query", + "description": "LSA Type", + "required": false, + "schema": { + "type": "string", + "enum": [ + "LEGAL_ENTITY", + "SITE", + "ADDRESS" + ] + } + }, + { + "name": "externalIds", + "in": "query", + "description": "External identifiers", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "Page of sharing states", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageResponseSharingState" + } + } + } + } + } + }, + "put": { + "tags": [ + "sharing-state-controller" + ], + "summary": "Insert/update sharing state (including error info and BPN) for business partner with LSA type and external ID", + "operationId": "upsertSharingState", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SharingState" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "Operation completed successfully" + }, + "400": { + "description": "Invalid data (e.g. externalId)" + } + } + } + }, + "/api/catena/output/sites": { + "put": { + "tags": [ + "site-controller" + ], + "summary": "Create or update output sites.", + "description": "Create or update sites (Output). Updates instead of creating a new site if an already existing external id is used. The same external id may not occur more than once in a single request. For a single request, the maximum number of sites in the request is limited to 100 entries.", + "operationId": "upsertSitesOutput", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteGateOutputRequest" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Sites were successfully updated or created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Unit" + } + } + } + }, + "400": { + "description": "On malformed site request" + } + } + } + }, + "/api/catena/output/legal-entities": { + "put": { + "tags": [ + "legal-entity-controller" + ], + "summary": "Create or update output legal entities.", + "description": "Create or update legal entities (Output). Updates instead of creating a new legal entity if an already existing external id is used. The same external id may not occur more than once in a single request. For a single request, the maximum number of legal entities in the request is limited to 100 entries.", + "operationId": "upsertLegalEntitiesOutput", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LegalEntityGateOutputRequest" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "On malformed legal entity request" + }, + "200": { + "description": "Legal entities were successfully updated or created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Unit" + } + } + } + } + } + } + }, + "/api/catena/output/addresses": { + "put": { + "tags": [ + "address-controller" + ], + "summary": "Create or update output addresses.", + "description": "Create or update addresses (Output). Updates instead of creating a new address if an already existing external id is used. The same external id may not occur more than once in a single request. For a single request, the maximum number of addresses in the request is limited to 100 entries.", + "operationId": "putAddressesOutput", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressGateOutputRequest" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "On malformed address request" + }, + "200": { + "description": "Addresses were successfully updated or created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Unit" + } + } + } + } + } + } + }, "/api/catena/input/sites": { "get": { "tags": [ @@ -22,22 +233,24 @@ "operationId": "getSites", "parameters": [ { - "name": "startAfter", + "name": "page", "in": "query", - "description": "Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages.", + "description": "Number of page to get results from", "required": false, "schema": { - "type": "string" + "minimum": 0, + "type": "string", + "default": "0" } }, { - "name": "limit", + "name": "size", "in": "query", "description": "Size of each page", "required": false, "schema": { "maximum": 100, - "minimum": 1, + "minimum": 0, "type": "string", "default": "10" } @@ -47,9 +260,9 @@ "200": { "description": "The requested page of sites", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/PageStartAfterResponseSiteGateInputResponse" + "$ref": "#/components/schemas/PageResponseSiteGateInputResponse" } } } @@ -83,9 +296,9 @@ "200": { "description": "Sites were successfully updated or created", "content": { - "*/*": { + "application/json": { "schema": { - "type": "object" + "$ref": "#/components/schemas/Unit" } } } @@ -106,22 +319,24 @@ "operationId": "getLegalEntities", "parameters": [ { - "name": "startAfter", + "name": "page", "in": "query", - "description": "Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages.", + "description": "Number of page to get results from", "required": false, "schema": { - "type": "string" + "minimum": 0, + "type": "string", + "default": "0" } }, { - "name": "limit", + "name": "size", "in": "query", "description": "Size of each page", "required": false, "schema": { "maximum": 100, - "minimum": 1, + "minimum": 0, "type": "string", "default": "10" } @@ -131,9 +346,9 @@ "200": { "description": "The requested page of legal entities", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/PageStartAfterResponseLegalEntityGateInputResponse" + "$ref": "#/components/schemas/PageResponseLegalEntityGateInputResponse" } } } @@ -164,18 +379,18 @@ "required": true }, "responses": { + "400": { + "description": "On malformed legal entity request" + }, "200": { "description": "Legal entities were successfully updated or created", "content": { - "*/*": { + "application/json": { "schema": { - "type": "object" + "$ref": "#/components/schemas/Unit" } } } - }, - "400": { - "description": "On malformed legal entity request" } } } @@ -190,22 +405,24 @@ "operationId": "getAddresses", "parameters": [ { - "name": "startAfter", + "name": "page", "in": "query", - "description": "Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages.", + "description": "Number of page to get results from", "required": false, "schema": { - "type": "string" + "minimum": 0, + "type": "string", + "default": "0" } }, { - "name": "limit", + "name": "size", "in": "query", "description": "Size of each page", "required": false, "schema": { "maximum": 100, - "minimum": 1, + "minimum": 0, "type": "string", "default": "10" } @@ -215,9 +432,9 @@ "200": { "description": "The requested page of addresses", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/PageStartAfterResponseAddressGateInputResponse" + "$ref": "#/components/schemas/PageResponseAddressGateInputResponse" } } } @@ -248,18 +465,18 @@ "required": true }, "responses": { + "400": { + "description": "On malformed address request" + }, "200": { "description": "Addresses were successfully updated or created", "content": { - "*/*": { + "application/json": { "schema": { "$ref": "#/components/schemas/Unit" } } } - }, - "400": { - "description": "On malformed address request" } } } @@ -274,22 +491,24 @@ "operationId": "getSitesOutput", "parameters": [ { - "name": "startAfter", + "name": "page", "in": "query", - "description": "Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages.", + "description": "Number of page to get results from", "required": false, "schema": { - "type": "string" + "minimum": 0, + "type": "string", + "default": "0" } }, { - "name": "limit", + "name": "size", "in": "query", "description": "Size of each page", "required": false, "schema": { "maximum": 100, - "minimum": 1, + "minimum": 0, "type": "string", "default": "10" } @@ -311,9 +530,9 @@ "200": { "description": "The requested page of sites", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/PageOutputResponseSiteGateOutput" + "$ref": "#/components/schemas/PageResponseSiteGateOutputResponse" } } } @@ -334,22 +553,24 @@ "operationId": "getLegalEntitiesOutput", "parameters": [ { - "name": "startAfter", + "name": "page", "in": "query", - "description": "Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages.", + "description": "Number of page to get results from", "required": false, "schema": { - "type": "string" + "minimum": 0, + "type": "string", + "default": "0" } }, { - "name": "limit", + "name": "size", "in": "query", "description": "Size of each page", "required": false, "schema": { "maximum": 100, - "minimum": 1, + "minimum": 0, "type": "string", "default": "10" } @@ -371,9 +592,9 @@ "200": { "description": "The requested page of legal entities", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/PageOutputResponseLegalEntityGateOutput" + "$ref": "#/components/schemas/PageResponseLegalEntityGateOutputResponse" } } } @@ -384,32 +605,34 @@ } } }, - "/api/catena/output/addresses/search": { + "/api/catena/output/changelog/search": { "post": { "tags": [ - "address-controller" + "changelog-controller" ], - "summary": "Get page of addresses", - "description": "Get page of addresses. Can optionally be filtered by external ids.", - "operationId": "getAddressesOutput", + "summary": "Get business partner changelog entries for changes to the business partner output data", + "description": "Get business partner changelog entries for changes to the business partner output data. Filter by list external id, from timestamp and/or lsa type", + "operationId": "getOutputChangelog", "parameters": [ { - "name": "startAfter", + "name": "page", "in": "query", - "description": "Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages.", + "description": "Number of page to get results from", "required": false, "schema": { - "type": "string" + "minimum": 0, + "type": "string", + "default": "0" } }, { - "name": "limit", + "name": "size", "in": "query", "description": "Size of each page", "required": false, "schema": { "maximum": 100, - "minimum": 1, + "minimum": 0, "type": "string", "default": "10" } @@ -419,114 +642,195 @@ "content": { "application/json": { "schema": { - "type": "array", - "items": { - "type": "string" - } + "$ref": "#/components/schemas/ChangeLogSearchRequest" } } - } + }, + "required": true }, "responses": { + "400": { + "description": "On malformed pagination request" + }, "200": { - "description": "The requested page of addresses", + "description": "The changelog entries for the specified parameters", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/PageOutputResponseAddressGateOutput" + "$ref": "#/components/schemas/PageChangeLogResponseChangelogResponse" } } } - }, - "400": { - "description": "On malformed pagination request" } } } }, - "/api/catena/input/sites/validation": { + "/api/catena/output/addresses/search": { "post": { "tags": [ - "site-controller" + "address-controller" + ], + "summary": "Get page of addresses (Output)", + "description": "Get page of addresses (Output). Can optionally be filtered by external ids.", + "operationId": "getAddressesOutput", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } ], - "summary": "Validate a site", - "description": "Determines errors in a site record which keep it from entering the sharing process", - "operationId": "validateSite", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SiteGateInputRequest" + "type": "array", + "items": { + "type": "string" + } } } - }, - "required": true + } }, "responses": { "200": { - "description": "A validation response with possible errors", + "description": "The requested page of addresses", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/ValidationResponse" + "$ref": "#/components/schemas/PageResponseAddressGateInputResponse" } } } }, "400": { - "description": "On malformed site requests" + "description": "On malformed pagination request" } } } }, - "/api/catena/input/legal-entities/validation": { + "/api/catena/input/sites/search": { "post": { "tags": [ - "legal-entity-controller" + "site-controller" ], - "summary": "Validate a legal entity", - "description": "Determines errors in a legal entity record which keep it from entering the sharing process", - "operationId": "validateLegalEntity", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LegalEntityGateInputRequest" - } + "summary": "Get page of sites filtered by a collection of externalIds", + "description": "Get page of sites filtered by a collection of externalIds.", + "operationId": "getSitesByExternalIds", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" } }, - "required": true - }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "required": true + }, "responses": { "200": { - "description": "A validation response with possible errors", + "description": "The requested page of sites", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/ValidationResponse" + "$ref": "#/components/schemas/PageResponseSiteGateInputResponse" } } } }, "400": { - "description": "On malformed legal entity requests" + "description": "On malformed pagination request" } } } }, - "/api/catena/input/addresses/validation": { + "/api/catena/input/legal-entities/search": { "post": { "tags": [ - "address-controller" + "legal-entity-controller" + ], + "summary": "Get page of legal-entities filtered by a collection of externalIds", + "description": "Get page of legal-entities filtered by a collection of externalIds.", + "operationId": "getLegalEntitiesByExternalIds", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } ], - "summary": "Validate an address partner", - "description": "Determines errors in an address partner record which keep it from entering the sharing process", - "operationId": "validateSite_1", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AddressGateInputRequest" + "type": "array", + "items": { + "type": "string" + } } } }, @@ -534,34 +838,122 @@ }, "responses": { "200": { - "description": "A validation response with possible errors", + "description": "The requested page of legal-entities", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/ValidationResponse" + "$ref": "#/components/schemas/PageResponseLegalEntityGateInputResponse" } } } }, "400": { - "description": "On malformed address requests" + "description": "On malformed pagination request" + } + } + } + }, + "/api/catena/input/changelog/search": { + "post": { + "tags": [ + "changelog-controller" + ], + "summary": "Get business partner changelog entries for changes to the business partner input data", + "description": "Get business partner changelog entries for changes to the business partner input data. Filter by list external id, from timestamp and/or lsa type", + "operationId": "getInputChangelog", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChangeLogSearchRequest" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "On malformed pagination request" + }, + "200": { + "description": "The changelog entries for the specified parameters", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageChangeLogResponseChangelogResponse" + } + } + } } } } }, - "/api/catena/business-partners/type-match": { + "/api/catena/input/addresses/search": { "post": { "tags": [ - "business-partner-controller" + "address-controller" + ], + "summary": "Get page of addresses filtered by a collection of externalIds", + "description": "Get page of addresses filtered by a collection of externalIds.", + "operationId": "getAddressesByExternalIds", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } ], - "summary": "Determine the LSA type of a business partner candidate", - "description": "For one business partner candidate this request determines its likely type of either legal entity, site or address.It is possible that no type could be determined.The candidate needs to contain either a name or an identifier as a minimum requirement.", - "operationId": "determineLsaType", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BusinessPartnerCandidateDto" + "type": "array", + "items": { + "type": "string" + } } } }, @@ -569,17 +961,17 @@ }, "responses": { "200": { - "description": "Records were successfully processed.", + "description": "The requested page of addresses", "content": { - "*/*": { + "application/json": { "schema": { - "$ref": "#/components/schemas/TypeMatchResponse" + "$ref": "#/components/schemas/PageResponseAddressGateInputResponse" } } } }, "400": { - "description": "No name and no identifier given, or malformed request" + "description": "On malformed pagination request" } } } @@ -604,18 +996,18 @@ } ], "responses": { + "404": { + "description": "No site found under specified external identifier" + }, "200": { "description": "Found site with external identifier", "content": { - "*/*": { + "application/json": { "schema": { "$ref": "#/components/schemas/SiteGateInputResponse" } } } - }, - "404": { - "description": "No site found under specified external identifier" } } } @@ -640,18 +1032,18 @@ } ], "responses": { + "404": { + "description": "No legal entity found under specified external identifier" + }, "200": { "description": "Found legal entity with external identifier", "content": { - "*/*": { + "application/json": { "schema": { "$ref": "#/components/schemas/LegalEntityGateInputResponse" } } } - }, - "404": { - "description": "No legal entity found under specified external identifier" } } } @@ -676,18 +1068,18 @@ } ], "responses": { + "404": { + "description": "No address found under specified external identifier" + }, "200": { "description": "Found address with external identifier", "content": { - "*/*": { + "application/json": { "schema": { "$ref": "#/components/schemas/AddressGateInputResponse" } } } - }, - "404": { - "description": "No address found under specified external identifier" } } } @@ -695,97 +1087,335 @@ }, "components": { "schemas": { - "Address": { + "AddressGateInputRequest": { "type": "object", "properties": { - "version": { - "$ref": "#/components/schemas/AddressVersion" + "nameParts": { + "type": "array", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses.", + "items": { + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." + } + }, + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressState" + } + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressIdentifier" + } + }, + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddressGateDto" + }, + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } + }, + "externalId": { + "type": "string" }, - "careOf": { + "legalEntityExternalId": { "type": "string" }, - "contexts": { + "siteExternalId": { + "type": "string" + } + }, + "description": "Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address." + }, + "AddressGateInputResponse": { + "type": "object", + "properties": { + "nameParts": { "type": "array", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses.", "items": { - "type": "string" + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." } }, - "country": { - "type": "string", - "enum": [ - "UNDEFINED", - "AC", - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AN", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BU", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CP", - "CR", - "CS", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DG", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EA", - "EC", - "EE", - "EG", + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressState" + } + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressIdentifier" + } + }, + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddressGateDto" + }, + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } + }, + "externalId": { + "type": "string" + }, + "legalEntityExternalId": { + "type": "string" + }, + "siteExternalId": { + "type": "string" + }, + "bpn": { + "type": "string" + } + }, + "description": "Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address." + }, + "AddressGateOutputChildRequest": { + "type": "object", + "properties": { + "nameParts": { + "type": "array", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses.", + "items": { + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." + } + }, + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressState" + } + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressIdentifier" + } + }, + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddressGateDto" + }, + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } + }, + "bpn": { + "type": "string" + } + }, + "description": "DTO for setting the output address data with BPN." + }, + "AddressGateOutputRequest": { + "type": "object", + "properties": { + "nameParts": { + "type": "array", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses.", + "items": { + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." + } + }, + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressState" + } + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressIdentifier" + } + }, + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddressGateDto" + }, + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } + }, + "externalId": { + "type": "string" + }, + "legalEntityExternalId": { + "type": "string" + }, + "siteExternalId": { + "type": "string" + }, + "bpn": { + "type": "string" + } + }, + "description": "Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address." + }, + "AddressIdentifier": { + "type": "object", + "properties": { + "value": { + "type": "string", + "description": "Value of the identifier" + }, + "type": { + "type": "string", + "description": "Technical key of the type to which this identifier belongs to" + } + }, + "description": "Identifier record for a logistic address" + }, + "AddressState": { + "type": "object", + "properties": { + "description": { + "type": "string", + "description": "Description of the status" + }, + "validFrom": { + "type": "string", + "description": "Since when the status is/was valid", + "format": "date-time" + }, + "validTo": { + "type": "string", + "description": "Until the status was valid, if applicable", + "format": "date-time" + }, + "type": { + "type": "string", + "description": "The type of this specified status", + "enum": [ + "ACTIVE", + "INACTIVE" + ] + } + }, + "description": "Status record for a address" + }, + "AlternativePostalAddress": { + "type": "object", + "properties": { + "geographicCoordinates": { + "$ref": "#/components/schemas/GeoCoordinates" + }, + "country": { + "type": "string", + "description": "Describes the country", + "enum": [ + "UNDEFINED", + "AC", + "AD", + "AE", + "AF", + "AG", + "AI", + "AL", + "AM", + "AN", + "AO", + "AQ", + "AR", + "AS", + "AT", + "AU", + "AW", + "AX", + "AZ", + "BA", + "BB", + "BD", + "BE", + "BF", + "BG", + "BH", + "BI", + "BJ", + "BL", + "BM", + "BN", + "BO", + "BQ", + "BR", + "BS", + "BT", + "BU", + "BV", + "BW", + "BY", + "BZ", + "CA", + "CC", + "CD", + "CF", + "CG", + "CH", + "CI", + "CK", + "CL", + "CM", + "CN", + "CO", + "CP", + "CR", + "CS", + "CU", + "CV", + "CW", + "CX", + "CY", + "CZ", + "DE", + "DG", + "DJ", + "DK", + "DM", + "DO", + "DZ", + "EA", + "EC", + "EE", + "EG", "EH", "ER", "ES", @@ -987,2636 +1617,707 @@ "ZW" ] }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeArea" - } + "postalCode": { + "type": "string", + "description": "A postal code, also known as postcode, PIN or ZIP Code" }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Postcode" - } + "city": { + "type": "string", + "description": "The city of the address (Synonym: Town, village, municipality)" }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Locality" - } + "administrativeAreaLevel1": { + "type": "string", + "description": "Identifying code of the Region within the country (e.g. Bayern)" }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Thoroughfare" - } + "deliveryServiceNumber": { + "type": "string", + "description": "Describes the PO Box or private Bag number the delivery should be placed at." }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Premise" - } + "deliveryServiceType": { + "type": "string", + "description": "The type of this specified delivery", + "enum": [ + "PO_BOX", + "PRIVATE_BAG", + "BOITE_POSTALE" + ] + }, + "deliveryServiceQualifier": { + "type": "string", + "description": "Delivery Service Qualifier" + } + }, + "description": "Alternative Postal Address Part" + }, + "ChangeLogSearchRequest": { + "type": "object", + "properties": { + "fromTime": { + "type": "string", + "format": "date-time" }, - "postalDeliveryPoints": { + "externalIds": { + "uniqueItems": true, "type": "array", "items": { - "$ref": "#/components/schemas/PostalDeliveryPoint" + "type": "string" } }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" - }, - "types": { + "lsaTypes": { + "uniqueItems": true, "type": "array", "items": { "type": "string", "enum": [ - "BRANCH_OFFICE", - "CARE_OF", - "HEADQUARTER", - "LEGAL_ALTERNATIVE", - "PO_BOX", - "REGISTERED", - "REGISTERED_AGENT_MAIL", - "REGISTERED_AGENT_PHYSICAL", - "VAT_REGISTERED", - "UNSPECIFIC" + "LEGAL_ENTITY", + "SITE", + "ADDRESS" ] } } - }, - "description": "Localized address record for a business partner" + } }, - "AddressGateInputRequest": { - "type": "object", - "properties": { - "version": { - "$ref": "#/components/schemas/AddressVersion" - }, - "careOf": { - "type": "string" - }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } - }, - "country": { - "type": "string", - "enum": [ - "UNDEFINED", - "AC", - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AN", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BU", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CP", - "CR", - "CS", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DG", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EA", - "EC", - "EE", - "EG", - "EH", - "ER", - "ES", - "ET", - "EU", - "EZ", - "FI", - "FJ", - "FK", - "FM", - "FO", - "FR", - "FX", - "GA", - "GB", - "GD", - "GE", - "GF", - "GG", - "GH", - "GI", - "GL", - "GM", - "GN", - "GP", - "GQ", - "GR", - "GS", - "GT", - "GU", - "GW", - "GY", - "HK", - "HM", - "HN", - "HR", - "HT", - "HU", - "IC", - "ID", - "IE", - "IL", - "IM", - "IN", - "IO", - "IQ", - "IR", - "IS", - "IT", - "JE", - "JM", - "JO", - "JP", - "KE", - "KG", - "KH", - "KI", - "KM", - "KN", - "KP", - "KR", - "KW", - "KY", - "KZ", - "LA", - "LB", - "LC", - "LI", - "LK", - "LR", - "LS", - "LT", - "LU", - "LV", - "LY", - "MA", - "MC", - "MD", - "ME", - "MF", - "MG", - "MH", - "MK", - "ML", - "MM", - "MN", - "MO", - "MP", - "MQ", - "MR", - "MS", - "MT", - "MU", - "MV", - "MW", - "MX", - "MY", - "MZ", - "NA", - "NC", - "NE", - "NF", - "NG", - "NI", - "NL", - "NO", - "NP", - "NR", - "NT", - "NU", - "NZ", - "OM", - "PA", - "PE", - "PF", - "PG", - "PH", - "PK", - "PL", - "PM", - "PN", - "PR", - "PS", - "PT", - "PW", - "PY", - "QA", - "RE", - "RO", - "RS", - "RU", - "RW", - "SA", - "SB", - "SC", - "SD", - "SE", - "SF", - "SG", - "SH", - "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SU", - "SV", - "SX", - "SY", - "SZ", - "TA", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TP", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UK", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XI", - "XU", - "XK", - "YE", - "YT", - "YU", - "ZA", - "ZM", - "ZR", - "ZW" - ] - }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeArea" - } - }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Postcode" - } - }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Locality" - } - }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Thoroughfare" - } - }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Premise" - } - }, - "postalDeliveryPoints": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostalDeliveryPoint" - } - }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" - }, - "types": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "BRANCH_OFFICE", - "CARE_OF", - "HEADQUARTER", - "LEGAL_ALTERNATIVE", - "PO_BOX", - "REGISTERED", - "REGISTERED_AGENT_MAIL", - "REGISTERED_AGENT_PHYSICAL", - "VAT_REGISTERED", - "UNSPECIFIC" - ] - } - }, - "externalId": { - "type": "string" - }, - "legalEntityExternalId": { - "type": "string" - }, - "siteExternalId": { - "type": "string" - }, - "bpn": { - "type": "string" - } - }, - "description": "Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address." - }, - "AddressGateInputResponse": { - "type": "object", - "properties": { - "version": { - "$ref": "#/components/schemas/AddressVersion" - }, - "careOf": { - "type": "string" - }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } - }, - "country": { - "type": "string", - "enum": [ - "UNDEFINED", - "AC", - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AN", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BU", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CP", - "CR", - "CS", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DG", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EA", - "EC", - "EE", - "EG", - "EH", - "ER", - "ES", - "ET", - "EU", - "EZ", - "FI", - "FJ", - "FK", - "FM", - "FO", - "FR", - "FX", - "GA", - "GB", - "GD", - "GE", - "GF", - "GG", - "GH", - "GI", - "GL", - "GM", - "GN", - "GP", - "GQ", - "GR", - "GS", - "GT", - "GU", - "GW", - "GY", - "HK", - "HM", - "HN", - "HR", - "HT", - "HU", - "IC", - "ID", - "IE", - "IL", - "IM", - "IN", - "IO", - "IQ", - "IR", - "IS", - "IT", - "JE", - "JM", - "JO", - "JP", - "KE", - "KG", - "KH", - "KI", - "KM", - "KN", - "KP", - "KR", - "KW", - "KY", - "KZ", - "LA", - "LB", - "LC", - "LI", - "LK", - "LR", - "LS", - "LT", - "LU", - "LV", - "LY", - "MA", - "MC", - "MD", - "ME", - "MF", - "MG", - "MH", - "MK", - "ML", - "MM", - "MN", - "MO", - "MP", - "MQ", - "MR", - "MS", - "MT", - "MU", - "MV", - "MW", - "MX", - "MY", - "MZ", - "NA", - "NC", - "NE", - "NF", - "NG", - "NI", - "NL", - "NO", - "NP", - "NR", - "NT", - "NU", - "NZ", - "OM", - "PA", - "PE", - "PF", - "PG", - "PH", - "PK", - "PL", - "PM", - "PN", - "PR", - "PS", - "PT", - "PW", - "PY", - "QA", - "RE", - "RO", - "RS", - "RU", - "RW", - "SA", - "SB", - "SC", - "SD", - "SE", - "SF", - "SG", - "SH", - "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SU", - "SV", - "SX", - "SY", - "SZ", - "TA", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TP", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UK", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XI", - "XU", - "XK", - "YE", - "YT", - "YU", - "ZA", - "ZM", - "ZR", - "ZW" - ] - }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeArea" - } - }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Postcode" - } - }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Locality" - } - }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Thoroughfare" - } - }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Premise" - } - }, - "postalDeliveryPoints": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostalDeliveryPoint" - } - }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" - }, - "types": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "BRANCH_OFFICE", - "CARE_OF", - "HEADQUARTER", - "LEGAL_ALTERNATIVE", - "PO_BOX", - "REGISTERED", - "REGISTERED_AGENT_MAIL", - "REGISTERED_AGENT_PHYSICAL", - "VAT_REGISTERED", - "UNSPECIFIC" - ] - } - }, - "externalId": { - "type": "string" - }, - "legalEntityExternalId": { - "type": "string" - }, - "siteExternalId": { - "type": "string" - }, - "bpn": { - "type": "string" - }, - "processStartedAt": { - "type": "string", - "format": "date-time" - } - }, - "description": "Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address." - }, - "AddressGateOutput": { - "type": "object", - "properties": { - "bpn": { - "type": "string" - }, - "version": { - "$ref": "#/components/schemas/AddressVersionResponse" - }, - "careOf": { - "type": "string" - }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } - }, - "country": { - "$ref": "#/components/schemas/TypeKeyNameDtoCountryCode" - }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeAreaResponse" - } - }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostcodeResponse" - } - }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LocalityResponse" - } - }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ThoroughfareResponse" - } - }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PremiseResponse" - } - }, - "postalDeliveryPoints": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostalDeliveryPointResponse" - } - }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" - }, - "types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoAddressType" - } - }, - "externalId": { - "type": "string" - }, - "legalEntityBpn": { - "type": "string" - }, - "siteBpn": { - "type": "string" - } - }, - "description": "Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address." - }, - "AddressResponse": { - "type": "object", - "properties": { - "version": { - "$ref": "#/components/schemas/AddressVersionResponse" - }, - "careOf": { - "type": "string" - }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } - }, - "country": { - "$ref": "#/components/schemas/TypeKeyNameDtoCountryCode" - }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeAreaResponse" - } - }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostcodeResponse" - } - }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LocalityResponse" - } - }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ThoroughfareResponse" - } - }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PremiseResponse" - } - }, - "postalDeliveryPoints": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostalDeliveryPointResponse" - } - }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" - }, - "types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoAddressType" - } - } - }, - "description": "Localized address record of a business partner" - }, - "AddressVersion": { - "type": "object", - "properties": { - "characterSet": { - "type": "string", - "enum": [ - "ARABIC", - "CHINESE", - "CHINESE_TRADITIONAL", - "CYRILLIC", - "GREEK", - "HANGUL_KOREAN", - "HEBREW", - "HIRAGANA", - "KANJI", - "KATAKANA", - "LATIN", - "THAI", - "WESTERN_LATIN_STANDARD", - "UNDEFINED" - ] - }, - "language": { - "type": "string", - "enum": [ - "undefined", - "aa", - "ab", - "ae", - "af", - "ak", - "am", - "an", - "ar", - "as", - "av", - "ay", - "az", - "ba", - "be", - "bg", - "bh", - "bi", - "bm", - "bn", - "bo", - "br", - "bs", - "ca", - "ce", - "ch", - "co", - "cr", - "cs", - "cu", - "cv", - "cy", - "da", - "de", - "dv", - "dz", - "ee", - "el", - "en", - "eo", - "es", - "et", - "eu", - "fa", - "ff", - "fi", - "fj", - "fo", - "fr", - "fy", - "ga", - "gd", - "gl", - "gn", - "gu", - "gv", - "ha", - "he", - "hi", - "ho", - "hr", - "ht", - "hu", - "hy", - "hz", - "ia", - "id", - "ie", - "ig", - "ii", - "ik", - "io", - "is", - "it", - "iu", - "ja", - "jv", - "ka", - "kg", - "ki", - "kj", - "kk", - "kl", - "km", - "kn", - "ko", - "kr", - "ks", - "ku", - "kv", - "kw", - "ky", - "la", - "lb", - "lg", - "li", - "ln", - "lo", - "lt", - "lu", - "lv", - "mg", - "mh", - "mi", - "mk", - "ml", - "mn", - "mr", - "ms", - "mt", - "my", - "na", - "nb", - "nd", - "ne", - "ng", - "nl", - "nn", - "no", - "nr", - "nv", - "ny", - "oc", - "oj", - "om", - "or", - "os", - "pa", - "pi", - "pl", - "ps", - "pt", - "qu", - "rm", - "rn", - "ro", - "ru", - "rw", - "sa", - "sc", - "sd", - "se", - "sg", - "si", - "sk", - "sl", - "sm", - "sn", - "so", - "sq", - "sr", - "ss", - "st", - "su", - "sv", - "sw", - "ta", - "te", - "tg", - "th", - "ti", - "tk", - "tl", - "tn", - "to", - "tr", - "ts", - "tt", - "tw", - "ty", - "ug", - "uk", - "ur", - "uz", - "ve", - "vi", - "vo", - "wa", - "wo", - "xh", - "yi", - "yo", - "za", - "zh", - "zu" - ] - } - }, - "description": "Localization record for an address" - }, - "AddressVersionResponse": { - "type": "object", - "properties": { - "characterSet": { - "$ref": "#/components/schemas/TypeKeyNameDtoCharacterSet" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" - } - }, - "description": "Localization record of an address" - }, - "AdministrativeArea": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" - }, - "fipsCode": { - "type": "string" - }, - "type": { - "type": "string", - "enum": [ - "COUNTY", - "REGION", - "OTHER" - ] - } - }, - "description": "Areas such as country regions or counties" - }, - "AdministrativeAreaResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" - }, - "fipsCode": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoAdministrativeAreaType" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" - } - }, - "description": "Area of an address such as country region or county" - }, - "BankAccount": { - "type": "object", - "properties": { - "trustScores": { - "type": "array", - "items": { - "type": "number", - "format": "float" - } - }, - "currency": { - "type": "string", - "enum": [ - "UNDEFINED", - "AED", - "AFN", - "ALL", - "AMD", - "ANG", - "AOA", - "ARS", - "AUD", - "AWG", - "AZN", - "BAM", - "BBD", - "BDT", - "BGN", - "BHD", - "BIF", - "BMD", - "BND", - "BOB", - "BOV", - "BRL", - "BSD", - "BTN", - "BWP", - "BYN", - "BYR", - "BZD", - "CAD", - "CDF", - "CHE", - "CHF", - "CHW", - "CLF", - "CLP", - "CNY", - "COP", - "COU", - "CRC", - "CUC", - "CUP", - "CVE", - "CZK", - "DJF", - "DKK", - "DOP", - "DZD", - "EGP", - "ERN", - "ETB", - "EUR", - "FJD", - "FKP", - "GBP", - "GEL", - "GHS", - "GIP", - "GMD", - "GNF", - "GTQ", - "GYD", - "HKD", - "HNL", - "HRK", - "HTG", - "HUF", - "IDR", - "ILS", - "INR", - "IQD", - "IRR", - "ISK", - "JMD", - "JOD", - "JPY", - "KES", - "KGS", - "KHR", - "KMF", - "KPW", - "KRW", - "KWD", - "KYD", - "KZT", - "LAK", - "LBP", - "LKR", - "LRD", - "LSL", - "LTL", - "LYD", - "MAD", - "MDL", - "MGA", - "MKD", - "MMK", - "MNT", - "MOP", - "MRO", - "MRU", - "MUR", - "MVR", - "MWK", - "MXN", - "MXV", - "MYR", - "MZN", - "NAD", - "NGN", - "NIO", - "NOK", - "NPR", - "NZD", - "OMR", - "PAB", - "PEN", - "PGK", - "PHP", - "PKR", - "PLN", - "PYG", - "QAR", - "RON", - "RSD", - "RUB", - "RUR", - "RWF", - "SAR", - "SBD", - "SCR", - "SDG", - "SEK", - "SGD", - "SHP", - "SLL", - "SOS", - "SRD", - "SSP", - "STD", - "STN", - "SVC", - "SYP", - "SZL", - "THB", - "TJS", - "TMT", - "TND", - "TOP", - "TRY", - "TTD", - "TWD", - "TZS", - "UAH", - "UGX", - "USD", - "USN", - "USS", - "UYI", - "UYU", - "UZS", - "VEF", - "VES", - "VND", - "VUV", - "WST", - "XAF", - "XAG", - "XAU", - "XBA", - "XBB", - "XBC", - "XBD", - "XCD", - "XDR", - "XOF", - "XPD", - "XPF", - "XPT", - "XSU", - "XTS", - "XUA", - "XXX", - "YER", - "ZAR", - "ZMW", - "ZWL" - ] - }, - "internationalBankAccountIdentifier": { - "type": "string" - }, - "internationalBankIdentifier": { - "type": "string" - }, - "nationalBankAccountIdentifier": { - "type": "string" - }, - "nationalBankIdentifier": { - "type": "string" - } - }, - "description": "Bank account record of a business partner" - }, - "BankAccountResponse": { - "type": "object", - "properties": { - "trustScores": { - "type": "array", - "items": { - "type": "number", - "format": "float" - } - }, - "currency": { - "$ref": "#/components/schemas/TypeKeyNameDtoCurrencyCode" - }, - "internationalBankAccountIdentifier": { - "type": "string" - }, - "internationalBankIdentifier": { - "type": "string" - }, - "nationalBankAccountIdentifier": { - "type": "string" - }, - "nationalBankIdentifier": { - "type": "string" - } - }, - "description": "Bank account record for a business partner" - }, - "BusinessPartnerCandidateDto": { - "type": "object", - "properties": { - "identifiers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Identifier" - } - }, - "names": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Name" - } - }, - "legalForm": { - "type": "string" - }, - "status": { - "$ref": "#/components/schemas/BusinessStatus" - }, - "profileClassifications": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Classification" - } - }, - "bankAccounts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BankAccount" - } - }, - "address": { - "$ref": "#/components/schemas/Address" - } - } - }, - "BusinessStatus": { - "type": "object", - "properties": { - "officialDenotation": { - "type": "string" - }, - "validFrom": { - "type": "string", - "format": "date-time" - }, - "validUntil": { - "type": "string", - "format": "date-time" - }, - "type": { - "type": "string", - "enum": [ - "ACTIVE", - "DISSOLVED", - "IN_LIQUIDATION", - "INACTIVE", - "INSOLVENCY", - "UNKNOWN" - ] - } - }, - "description": "Status record for a business partner" - }, - "BusinessStatusResponse": { - "type": "object", - "properties": { - "officialDenotation": { - "type": "string" - }, - "validFrom": { - "type": "string", - "format": "date-time" - }, - "validUntil": { - "type": "string", - "format": "date-time" - }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoBusinessStatusType" - } - }, - "description": "Status of a business partner" - }, - "Classification": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "code": { - "type": "string" - }, - "type": { - "type": "string", - "enum": [ - "NACE", - "NAF", - "NAICS", - "SIC" - ] - } - }, - "description": "Classification record for a business partner" - }, - "ClassificationResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "code": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/NamedTypeWithLink" - } - }, - "description": "Classification record of a business partner" - }, - "ErrorInfoBusinessPartnerOutputError": { - "title": "ErrorInfo", - "type": "object", - "properties": { - "errorCode": { - "type": "string", - "description": "BusinessPartnerOutputError", - "enum": [ - "SharingProcessError", - "SharingTimeout", - "BpnNotInPool" - ] - }, - "message": { - "type": "string" - }, - "entityKey": { - "type": "string" - } - }, - "description": "Holds information about failures" - }, - "GeoCoordinates": { - "type": "object", - "properties": { - "longitude": { - "type": "number", - "format": "float" - }, - "latitude": { - "type": "number", - "format": "float" - }, - "altitude": { - "type": "number", - "format": "float" - } - }, - "description": "Geo coordinates record for an address" - }, - "Identifier": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "type": { - "type": "string" - }, - "issuingBody": { - "type": "string" - }, - "status": { - "type": "string" - } - }, - "description": "Identifier record for a business partner" - }, - "IdentifierResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" - }, - "issuingBody": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" - }, - "status": { - "$ref": "#/components/schemas/TypeKeyNameDtoString" - } - }, - "description": "Identifier record of a business partner" - }, - "LegalEntityGateInputRequest": { - "type": "object", - "properties": { - "identifiers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Identifier" - } - }, - "names": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Name" - } - }, - "legalForm": { - "type": "string" - }, - "status": { - "$ref": "#/components/schemas/BusinessStatus" - }, - "profileClassifications": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Classification" - } - }, - "types": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "BRAND", - "LEGAL_ENTITY", - "ORGANIZATIONAL_UNIT", - "SITE", - "UNKNOWN" - ] - } - }, - "bankAccounts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BankAccount" - } - }, - "legalAddress": { - "$ref": "#/components/schemas/Address" - }, - "externalId": { - "type": "string" - }, - "bpn": { - "type": "string" - } - }, - "description": "Legal entity with external id" - }, - "LegalEntityGateInputResponse": { - "type": "object", - "properties": { - "identifiers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Identifier" - } - }, - "names": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Name" - } - }, - "legalForm": { - "type": "string" - }, - "status": { - "$ref": "#/components/schemas/BusinessStatus" - }, - "profileClassifications": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Classification" - } - }, - "types": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "BRAND", - "LEGAL_ENTITY", - "ORGANIZATIONAL_UNIT", - "SITE", - "UNKNOWN" - ] - } - }, - "bankAccounts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BankAccount" - } - }, - "legalAddress": { - "$ref": "#/components/schemas/Address" - }, - "externalId": { - "type": "string" - }, - "bpn": { - "type": "string" - }, - "processStartedAt": { - "type": "string", - "format": "date-time" - } - }, - "description": "Legal entity with external id" - }, - "LegalEntityGateOutput": { - "type": "object", - "properties": { - "identifiers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/IdentifierResponse" - } - }, - "names": { - "type": "array", - "items": { - "$ref": "#/components/schemas/NameResponse" - } - }, - "legalForm": { - "$ref": "#/components/schemas/LegalFormResponse" - }, - "status": { - "$ref": "#/components/schemas/BusinessStatusResponse" - }, - "profileClassifications": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ClassificationResponse" - } - }, - "types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoBusinessPartnerType" - } - }, - "bankAccounts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BankAccountResponse" - } - }, - "roles": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameDtoString" - } - }, - "relations": { - "type": "array", - "items": { - "$ref": "#/components/schemas/RelationResponse" - } - }, - "legalAddress": { - "$ref": "#/components/schemas/AddressResponse" - }, - "bpn": { - "type": "string" - }, - "externalId": { - "type": "string" - } - }, - "description": "Legal entity with references" - }, - "LegalFormResponse": { - "type": "object", - "properties": { - "technicalKey": { - "type": "string" - }, - "name": { - "type": "string" - }, - "url": { - "type": "string" - }, - "mainAbbreviation": { - "type": "string" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" - }, - "categories": { - "type": "array", - "items": { - "$ref": "#/components/schemas/NamedTypeWithLink" - } - } - }, - "description": "Legal form a business partner can have" - }, - "Locality": { + "ChangelogResponse": { "type": "object", "properties": { - "value": { - "type": "string" - }, - "shortName": { + "externalId": { "type": "string" }, - "type": { + "businessPartnerType": { "type": "string", "enum": [ - "BLOCK", - "CITY", - "DISTRICT", - "OTHER", - "POST_OFFICE_CITY", - "QUARTER" + "LEGAL_ENTITY", + "SITE", + "ADDRESS" ] - } - }, - "description": "Locality record for an address such as city, block or district" - }, - "LocalityResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoLocalityType" }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" + "modifiedAt": { + "type": "string", + "format": "date-time" } }, - "description": "Locality record of an address such as city, block or district" + "description": "Changelog entry for a business partner" }, - "Name": { + "Classification": { "type": "object", "properties": { "value": { - "type": "string" - }, - "shortName": { - "type": "string" + "type": "string", + "description": "Name of the classification" }, - "type": { + "code": { "type": "string", - "enum": [ - "ACRONYM", - "DOING_BUSINESS_AS", - "ESTABLISHMENT", - "INTERNATIONAL", - "LOCAL", - "OTHER", - "REGISTERED", - "TRANSLITERATED", - "VAT_REGISTERED" - ] + "description": "Identifying code of the classification, if applicable" }, - "language": { + "type": { "type": "string", + "description": "Type of specified classification", "enum": [ - "undefined", - "aa", - "ab", - "ae", - "af", - "ak", - "am", - "an", - "ar", - "as", - "av", - "ay", - "az", - "ba", - "be", - "bg", - "bh", - "bi", - "bm", - "bn", - "bo", - "br", - "bs", - "ca", - "ce", - "ch", - "co", - "cr", - "cs", - "cu", - "cv", - "cy", - "da", - "de", - "dv", - "dz", - "ee", - "el", - "en", - "eo", - "es", - "et", - "eu", - "fa", - "ff", - "fi", - "fj", - "fo", - "fr", - "fy", - "ga", - "gd", - "gl", - "gn", - "gu", - "gv", - "ha", - "he", - "hi", - "ho", - "hr", - "ht", - "hu", - "hy", - "hz", - "ia", - "id", - "ie", - "ig", - "ii", - "ik", - "io", - "is", - "it", - "iu", - "ja", - "jv", - "ka", - "kg", - "ki", - "kj", - "kk", - "kl", - "km", - "kn", - "ko", - "kr", - "ks", - "ku", - "kv", - "kw", - "ky", - "la", - "lb", - "lg", - "li", - "ln", - "lo", - "lt", - "lu", - "lv", - "mg", - "mh", - "mi", - "mk", - "ml", - "mn", - "mr", - "ms", - "mt", - "my", - "na", - "nb", - "nd", - "ne", - "ng", - "nl", - "nn", - "no", - "nr", - "nv", - "ny", - "oc", - "oj", - "om", - "or", - "os", - "pa", - "pi", - "pl", - "ps", - "pt", - "qu", - "rm", - "rn", - "ro", - "ru", - "rw", - "sa", - "sc", - "sd", - "se", - "sg", - "si", - "sk", - "sl", - "sm", - "sn", - "so", - "sq", - "sr", - "ss", - "st", - "su", - "sv", - "sw", - "ta", - "te", - "tg", - "th", - "ti", - "tk", - "tl", - "tn", - "to", - "tr", - "ts", - "tt", - "tw", - "ty", - "ug", - "uk", - "ur", - "uz", - "ve", - "vi", - "vo", - "wa", - "wo", - "xh", - "yi", - "yo", - "za", - "zh", - "zu" + "NACE", + "NAF", + "NAICS", + "SIC" ] } }, - "description": "Name record for a business partner" + "description": "Classification record for a business partner" }, - "NameResponse": { + "ErrorInfoChangeLogOutputError": { + "title": "ErrorInfo", "type": "object", "properties": { - "value": { - "type": "string" + "errorCode": { + "type": "string", + "description": "ChangeLogOutputError", + "enum": [ + "ExternalIdNotFound" + ] }, - "shortName": { + "message": { "type": "string" }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoNameType" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" + "entityKey": { + "type": "string" } }, - "description": "Name record of a business partner" + "description": "Holds information about failures" }, - "NamedTypeWithLink": { + "GeoCoordinates": { "type": "object", "properties": { - "name": { - "type": "string" + "longitude": { + "type": "number", + "description": "Longitude coordinate", + "format": "float" }, - "url": { - "type": "string" + "latitude": { + "type": "number", + "description": "Latitude coordinate", + "format": "float" + }, + "altitude": { + "type": "number", + "description": "Altitude, if applicable", + "format": "float" } }, - "description": "General type with name and URL link for further information" + "description": "Geo coordinates record for an address" }, - "PageOutputResponseAddressGateOutput": { + "LegalEntityGateInputRequest": { "type": "object", "properties": { - "total": { - "type": "integer", - "format": "int32" - }, - "nextStartAfter": { - "type": "string" + "legalNameParts": { + "type": "array", + "items": { + "type": "string" + } }, - "content": { + "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/AddressGateOutput" + "$ref": "#/components/schemas/LegalEntityIdentifier" } }, - "invalidEntries": { - "type": "integer", - "format": "int32" + "legalShortName": { + "type": "string", + "description": "Abbreviated name or shorthand" + }, + "legalForm": { + "type": "string", + "description": "Technical key of the legal form" }, - "pending": { + "states": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/LegalEntityState" } }, - "errors": { + "classifications": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Classification" + } + }, + "roles": { "type": "array", "items": { - "$ref": "#/components/schemas/ErrorInfoBusinessPartnerOutputError" + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] } + }, + "legalAddress": { + "$ref": "#/components/schemas/LogisticAddressGateDto" + }, + "externalId": { + "type": "string" } }, - "description": "Paginated collection of results" + "description": "Legal entity with external id" }, - "PageOutputResponseLegalEntityGateOutput": { + "LegalEntityGateInputResponse": { "type": "object", "properties": { - "total": { - "type": "integer", - "format": "int32" - }, - "nextStartAfter": { - "type": "string" + "legalNameParts": { + "type": "array", + "items": { + "type": "string" + } }, - "content": { + "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/LegalEntityGateOutput" + "$ref": "#/components/schemas/LegalEntityIdentifier" } }, - "invalidEntries": { - "type": "integer", - "format": "int32" + "legalShortName": { + "type": "string", + "description": "Abbreviated name or shorthand" + }, + "legalForm": { + "type": "string", + "description": "Technical key of the legal form" }, - "pending": { + "states": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/LegalEntityState" } }, - "errors": { + "classifications": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Classification" + } + }, + "roles": { "type": "array", "items": { - "$ref": "#/components/schemas/ErrorInfoBusinessPartnerOutputError" + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] } + }, + "legalAddress": { + "$ref": "#/components/schemas/AddressGateInputResponse" + }, + "externalId": { + "type": "string" } }, - "description": "Paginated collection of results" + "description": "Legal entity with external id" }, - "PageOutputResponseSiteGateOutput": { + "LegalEntityGateOutputRequest": { "type": "object", "properties": { - "total": { - "type": "integer", - "format": "int32" - }, - "nextStartAfter": { - "type": "string" + "legalNameParts": { + "type": "array", + "items": { + "type": "string" + } }, - "content": { + "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/SiteGateOutput" + "$ref": "#/components/schemas/LegalEntityIdentifier" } }, - "invalidEntries": { - "type": "integer", - "format": "int32" + "legalShortName": { + "type": "string", + "description": "Abbreviated name or shorthand" }, - "pending": { + "legalForm": { + "type": "string", + "description": "Technical key of the legal form" + }, + "states": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/LegalEntityState" } }, - "errors": { + "classifications": { "type": "array", "items": { - "$ref": "#/components/schemas/ErrorInfoBusinessPartnerOutputError" + "$ref": "#/components/schemas/Classification" } - } - }, - "description": "Paginated collection of results" - }, - "PageStartAfterResponseAddressGateInputResponse": { - "type": "object", - "properties": { - "total": { - "type": "integer", - "format": "int32" - }, - "nextStartAfter": { - "type": "string" }, - "content": { + "roles": { "type": "array", "items": { - "$ref": "#/components/schemas/AddressGateInputResponse" + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] } }, - "invalidEntries": { - "type": "integer", - "format": "int32" + "legalAddress": { + "$ref": "#/components/schemas/AddressGateOutputChildRequest" + }, + "externalId": { + "type": "string" + }, + "bpn": { + "type": "string" } }, - "description": "Paginated collection of results" + "description": "Legal entity with external id" }, - "PageStartAfterResponseLegalEntityGateInputResponse": { + "LegalEntityGateOutputResponse": { "type": "object", "properties": { - "total": { - "type": "integer", - "format": "int32" - }, - "nextStartAfter": { - "type": "string" - }, - "content": { + "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/LegalEntityGateInputResponse" + "$ref": "#/components/schemas/LegalEntityIdentifier" } }, - "invalidEntries": { - "type": "integer", - "format": "int32" - } - }, - "description": "Paginated collection of results" - }, - "PageStartAfterResponseSiteGateInputResponse": { - "type": "object", - "properties": { - "total": { - "type": "integer", - "format": "int32" + "legalShortName": { + "type": "string", + "description": "Abbreviated name or shorthand" }, - "nextStartAfter": { - "type": "string" + "legalForm": { + "type": "string", + "description": "Technical key of the legal form" }, - "content": { + "states": { "type": "array", "items": { - "$ref": "#/components/schemas/SiteGateInputResponse" + "$ref": "#/components/schemas/LegalEntityState" } }, - "invalidEntries": { - "type": "integer", - "format": "int32" - } - }, - "description": "Paginated collection of results" - }, - "PostalDeliveryPoint": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" + "classifications": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Classification" + } }, - "number": { - "type": "string" + "legalNameParts": { + "type": "array", + "items": { + "type": "string" + } }, - "type": { - "type": "string", - "enum": [ - "INTERURBAN_DELIVERY_POINT", - "MAIL_STATION", - "MAILBOX", - "OTHER", - "POST_OFFICE_BOX" - ] - } - }, - "description": "Postal delivery point record for an address" - }, - "PostalDeliveryPointResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } }, - "shortName": { - "type": "string" + "legalAddress": { + "$ref": "#/components/schemas/AddressGateInputResponse" }, - "number": { + "externalId": { "type": "string" }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoPostalDeliveryPointType" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" + "bpn": { + "type": "string" } }, - "description": "Postal delivery point record of an address" + "description": "Legal entity with external id" }, - "Postcode": { + "LegalEntityIdentifier": { "type": "object", "properties": { "value": { - "type": "string" + "type": "string", + "description": "Value of the identifier" }, "type": { "type": "string", - "enum": [ - "CEDEX", - "LARGE_MAIL_USER", - "OTHER", - "POST_BOX", - "REGULAR" - ] - } - }, - "description": "Postcode record for an address" - }, - "PostcodeResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" + "description": "Technical key of the type to which this identifier belongs to" }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoPostCodeType" + "issuingBody": { + "type": "string", + "description": "Body which issued the identifier" } }, - "description": "Postcode record of an address" + "description": "Identifier record for a legal entity" }, - "Premise": { + "LegalEntityState": { "type": "object", "properties": { - "value": { - "type": "string" + "officialDenotation": { + "type": "string", + "description": "Exact, official denotation of the status" }, - "shortName": { - "type": "string" + "validFrom": { + "type": "string", + "description": "Since when the status is/was valid", + "format": "date-time" }, - "number": { - "type": "string" + "validTo": { + "type": "string", + "description": "Until the status was valid, if applicable", + "format": "date-time" }, "type": { "type": "string", + "description": "The type of this specified status", "enum": [ - "BUILDING", - "OTHER", - "LEVEL", - "HARBOUR", - "ROOM", - "SUITE", - "UNIT", - "WAREHOUSE" + "ACTIVE", + "INACTIVE" ] } }, - "description": "Premise record for an address such as building, room or floor" + "description": "Status record of a legal entity" }, - "PremiseResponse": { + "LogisticAddressGateDto": { "type": "object", "properties": { - "value": { - "type": "string" + "nameParts": { + "type": "array", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses.", + "items": { + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." + } }, - "shortName": { - "type": "string" + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressState" + } }, - "number": { - "type": "string" + "identifiers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressIdentifier" + } }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoPremiseType" + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddressGateDto" + }, + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } } }, - "description": "Premise record of an address such as building, room or floor" + "description": "Address record for a business partner" }, - "RelationResponse": { + "PageChangeLogResponseChangelogResponse": { "type": "object", "properties": { - "relationClass": { - "$ref": "#/components/schemas/TypeKeyNameDtoRelationClass" + "totalElements": { + "type": "integer", + "format": "int64" }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameDtoRelationType" + "totalPages": { + "type": "integer", + "format": "int32" }, - "startNode": { - "type": "string" + "page": { + "type": "integer", + "format": "int32" }, - "endNode": { - "type": "string" + "contentSize": { + "type": "integer", + "format": "int32" }, - "startedAt": { - "type": "string", - "format": "date-time" + "content": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ChangelogResponse" + } }, - "endedAt": { - "type": "string", - "format": "date-time" + "invalidEntries": { + "type": "integer", + "format": "int32" + }, + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ErrorInfoChangeLogOutputError" + } } }, - "description": "Directed relation between two business partners" + "description": "Paginated collection of results" }, - "SiteGateInputRequest": { + "PageResponseAddressGateInputResponse": { "type": "object", "properties": { - "name": { - "type": "string" + "totalElements": { + "type": "integer", + "description": "Total number of all results in all pages", + "format": "int64" }, - "mainAddress": { - "$ref": "#/components/schemas/Address" + "totalPages": { + "type": "integer", + "description": "Total number pages", + "format": "int32" }, - "externalId": { - "type": "string" + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" }, - "legalEntityExternalId": { - "type": "string" + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" }, - "bpn": { - "type": "string" + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/AddressGateInputResponse" + } } }, - "description": "Site with legal entity reference" + "description": "Paginated collection of results" }, - "SiteGateInputResponse": { + "PageResponseLegalEntityGateInputResponse": { "type": "object", "properties": { - "name": { - "type": "string" - }, - "mainAddress": { - "$ref": "#/components/schemas/Address" + "totalElements": { + "type": "integer", + "description": "Total number of all results in all pages", + "format": "int64" }, - "externalId": { - "type": "string" + "totalPages": { + "type": "integer", + "description": "Total number pages", + "format": "int32" }, - "legalEntityExternalId": { - "type": "string" + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" }, - "bpn": { - "type": "string" + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" }, - "processStartedAt": { - "type": "string", - "format": "date-time" + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/LegalEntityGateInputResponse" + } } }, - "description": "Site with legal entity reference" + "description": "Paginated collection of results" }, - "SiteGateOutput": { + "PageResponseLegalEntityGateOutputResponse": { "type": "object", "properties": { - "name": { - "type": "string" + "totalElements": { + "type": "integer", + "description": "Total number of all results in all pages", + "format": "int64" }, - "mainAddress": { - "$ref": "#/components/schemas/AddressResponse" + "totalPages": { + "type": "integer", + "description": "Total number pages", + "format": "int32" }, - "externalId": { - "type": "string" + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" }, - "bpn": { - "type": "string" + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" }, - "legalEntityBpn": { - "type": "string" + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/LegalEntityGateOutputResponse" + } } }, - "description": "Site with legal entity reference." + "description": "Paginated collection of results" }, - "Thoroughfare": { + "PageResponseSharingState": { "type": "object", "properties": { - "value": { - "type": "string" - }, - "name": { - "type": "string" + "totalElements": { + "type": "integer", + "description": "Total number of all results in all pages", + "format": "int64" }, - "shortName": { - "type": "string" + "totalPages": { + "type": "integer", + "description": "Total number pages", + "format": "int32" }, - "number": { - "type": "string" + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" }, - "direction": { - "type": "string" + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" }, - "type": { - "type": "string", - "enum": [ - "INDUSTRIAL_ZONE", - "OTHER", - "RIVER", - "SQUARE", - "STREET" - ] + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/SharingState" + } } }, - "description": "Thoroughfare record for an address such as street, square or industrial zone" + "description": "Paginated collection of results" }, - "ThoroughfareResponse": { + "PageResponseSiteGateInputResponse": { "type": "object", "properties": { - "value": { - "type": "string" - }, - "name": { - "type": "string" - }, - "shortName": { - "type": "string" + "totalElements": { + "type": "integer", + "description": "Total number of all results in all pages", + "format": "int64" }, - "number": { - "type": "string" + "totalPages": { + "type": "integer", + "description": "Total number pages", + "format": "int32" }, - "direction": { - "type": "string" + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoThoroughfareType" + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/SiteGateInputResponse" + } } }, - "description": "Thoroughfare record of an address such as street, square or industrial zone" + "description": "Paginated collection of results" }, - "TypeKeyNameDtoCharacterSet": { + "PageResponseSiteGateOutputResponse": { "type": "object", "properties": { - "technicalKey": { - "type": "string", - "enum": [ - "ARABIC", - "CHINESE", - "CHINESE_TRADITIONAL", - "CYRILLIC", - "GREEK", - "HANGUL_KOREAN", - "HEBREW", - "HIRAGANA", - "KANJI", - "KATAKANA", - "LATIN", - "THAI", - "WESTERN_LATIN_STANDARD", - "UNDEFINED" - ] + "totalElements": { + "type": "integer", + "description": "Total number of all results in all pages", + "format": "int64" }, - "name": { - "type": "string" + "totalPages": { + "type": "integer", + "description": "Total number pages", + "format": "int32" + }, + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" + }, + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" + }, + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/SiteGateOutputResponse" + } } }, - "description": "Named type uniquely identified by its technical key" + "description": "Paginated collection of results" }, - "TypeKeyNameDtoCountryCode": { + "PhysicalPostalAddressGateDto": { "type": "object", "properties": { - "technicalKey": { + "geographicCoordinates": { + "$ref": "#/components/schemas/GeoCoordinates" + }, + "country": { "type": "string", + "description": "Describes the country", "enum": [ "UNDEFINED", "AC", @@ -3892,751 +2593,335 @@ "ZW" ] }, - "name": { - "type": "string" - } - }, - "description": "Named type uniquely identified by its technical key" - }, - "TypeKeyNameDtoCurrencyCode": { - "type": "object", - "properties": { - "technicalKey": { + "postalCode": { "type": "string", - "enum": [ - "UNDEFINED", - "AED", - "AFN", - "ALL", - "AMD", - "ANG", - "AOA", - "ARS", - "AUD", - "AWG", - "AZN", - "BAM", - "BBD", - "BDT", - "BGN", - "BHD", - "BIF", - "BMD", - "BND", - "BOB", - "BOV", - "BRL", - "BSD", - "BTN", - "BWP", - "BYN", - "BYR", - "BZD", - "CAD", - "CDF", - "CHE", - "CHF", - "CHW", - "CLF", - "CLP", - "CNY", - "COP", - "COU", - "CRC", - "CUC", - "CUP", - "CVE", - "CZK", - "DJF", - "DKK", - "DOP", - "DZD", - "EGP", - "ERN", - "ETB", - "EUR", - "FJD", - "FKP", - "GBP", - "GEL", - "GHS", - "GIP", - "GMD", - "GNF", - "GTQ", - "GYD", - "HKD", - "HNL", - "HRK", - "HTG", - "HUF", - "IDR", - "ILS", - "INR", - "IQD", - "IRR", - "ISK", - "JMD", - "JOD", - "JPY", - "KES", - "KGS", - "KHR", - "KMF", - "KPW", - "KRW", - "KWD", - "KYD", - "KZT", - "LAK", - "LBP", - "LKR", - "LRD", - "LSL", - "LTL", - "LYD", - "MAD", - "MDL", - "MGA", - "MKD", - "MMK", - "MNT", - "MOP", - "MRO", - "MRU", - "MUR", - "MVR", - "MWK", - "MXN", - "MXV", - "MYR", - "MZN", - "NAD", - "NGN", - "NIO", - "NOK", - "NPR", - "NZD", - "OMR", - "PAB", - "PEN", - "PGK", - "PHP", - "PKR", - "PLN", - "PYG", - "QAR", - "RON", - "RSD", - "RUB", - "RUR", - "RWF", - "SAR", - "SBD", - "SCR", - "SDG", - "SEK", - "SGD", - "SHP", - "SLL", - "SOS", - "SRD", - "SSP", - "STD", - "STN", - "SVC", - "SYP", - "SZL", - "THB", - "TJS", - "TMT", - "TND", - "TOP", - "TRY", - "TTD", - "TWD", - "TZS", - "UAH", - "UGX", - "USD", - "USN", - "USS", - "UYI", - "UYU", - "UZS", - "VEF", - "VES", - "VND", - "VUV", - "WST", - "XAF", - "XAG", - "XAU", - "XBA", - "XBB", - "XBC", - "XBD", - "XCD", - "XDR", - "XOF", - "XPD", - "XPF", - "XPT", - "XSU", - "XTS", - "XUA", - "XXX", - "YER", - "ZAR", - "ZMW", - "ZWL" - ] + "description": "A postal code, also known as postcode, PIN or ZIP Code" }, - "name": { - "type": "string" - } - }, - "description": "Named type uniquely identified by its technical key" - }, - "TypeKeyNameDtoLanguageCode": { - "type": "object", - "properties": { - "technicalKey": { + "city": { + "type": "string", + "description": "The city of the address (Synonym: Town, village, municipality)" + }, + "street": { + "$ref": "#/components/schemas/StreetGate" + }, + "administrativeAreaLevel1": { "type": "string", - "enum": [ - "undefined", - "aa", - "ab", - "ae", - "af", - "ak", - "am", - "an", - "ar", - "as", - "av", - "ay", - "az", - "ba", - "be", - "bg", - "bh", - "bi", - "bm", - "bn", - "bo", - "br", - "bs", - "ca", - "ce", - "ch", - "co", - "cr", - "cs", - "cu", - "cv", - "cy", - "da", - "de", - "dv", - "dz", - "ee", - "el", - "en", - "eo", - "es", - "et", - "eu", - "fa", - "ff", - "fi", - "fj", - "fo", - "fr", - "fy", - "ga", - "gd", - "gl", - "gn", - "gu", - "gv", - "ha", - "he", - "hi", - "ho", - "hr", - "ht", - "hu", - "hy", - "hz", - "ia", - "id", - "ie", - "ig", - "ii", - "ik", - "io", - "is", - "it", - "iu", - "ja", - "jv", - "ka", - "kg", - "ki", - "kj", - "kk", - "kl", - "km", - "kn", - "ko", - "kr", - "ks", - "ku", - "kv", - "kw", - "ky", - "la", - "lb", - "lg", - "li", - "ln", - "lo", - "lt", - "lu", - "lv", - "mg", - "mh", - "mi", - "mk", - "ml", - "mn", - "mr", - "ms", - "mt", - "my", - "na", - "nb", - "nd", - "ne", - "ng", - "nl", - "nn", - "no", - "nr", - "nv", - "ny", - "oc", - "oj", - "om", - "or", - "os", - "pa", - "pi", - "pl", - "ps", - "pt", - "qu", - "rm", - "rn", - "ro", - "ru", - "rw", - "sa", - "sc", - "sd", - "se", - "sg", - "si", - "sk", - "sl", - "sm", - "sn", - "so", - "sq", - "sr", - "ss", - "st", - "su", - "sv", - "sw", - "ta", - "te", - "tg", - "th", - "ti", - "tk", - "tl", - "tn", - "to", - "tr", - "ts", - "tt", - "tw", - "ty", - "ug", - "uk", - "ur", - "uz", - "ve", - "vi", - "vo", - "wa", - "wo", - "xh", - "yi", - "yo", - "za", - "zh", - "zu" - ] + "description": "Identifying code of the Region within the country (e.g. Bayern)" }, - "name": { - "type": "string" - } - }, - "description": "Named type uniquely identified by its technical key" - }, - "TypeKeyNameDtoRelationClass": { - "type": "object", - "properties": { - "technicalKey": { + "administrativeAreaLevel2": { "type": "string", - "enum": [ - "SAAS_HIERARCHY", - "SAAS_TRANSITION", - "CX_HIERARCHY", - "DNB_HIERARCHY", - "LEI_HIERARCHY" - ] + "description": "Further possibility to describe the region/address(e.g. County/Landkreis)" }, - "name": { - "type": "string" - } - }, - "description": "Named type uniquely identified by its technical key" - }, - "TypeKeyNameDtoRelationType": { - "type": "object", - "properties": { - "technicalKey": { + "administrativeAreaLevel3": { "type": "string", - "enum": [ - "CX_LEGAL_SUCCESSOR_OF", - "CX_LEGAL_PREDECESSOR_OF", - "CX_ADDRESS_OF", - "CX_SITE_OF", - "CX_OWNED_BY", - "DIRECT_LEGAL_RELATION", - "COMMERCIAL_ULTIMATE", - "DOMESTIC_BRANCH_RELATION", - "INTERNATIONAL_BRANCH_RELATION", - "DOMESTIC_LEGAL_ULTIMATE_RELATION", - "GLOBAL_LEGAL_ULTIMATE_RELATION", - "LEGAL_PREDECESSOR", - "LEGAL_SUCCESSOR", - "DNB_PARENT", - "DNB_HEADQUARTER", - "DNB_DOMESTIC_ULTIMATE", - "DNB_GLOBAL_ULTIMATE", - "LEI_DIRECT_PARENT", - "LEI_INTERNATIONAL_BRANCH", - "LEI_ULTIMATE_PARENT" - ] + "description": "Further possibility to describe the region/address(e.g. Township/Gemeinde)" }, - "name": { - "type": "string" - } - }, - "description": "Named type uniquely identified by its technical key" - }, - "TypeKeyNameDtoString": { - "type": "object", - "properties": { - "technicalKey": { - "type": "string" + "district": { + "type": "string", + "description": "Divides the city in several smaller areas" }, - "name": { - "type": "string" - } - }, - "description": "Named type uniquely identified by its technical key" - }, - "TypeKeyNameUrlDtoAddressType": { - "type": "object", - "properties": { - "technicalKey": { + "companyPostalCode": { "type": "string", - "enum": [ - "BRANCH_OFFICE", - "CARE_OF", - "HEADQUARTER", - "LEGAL_ALTERNATIVE", - "PO_BOX", - "REGISTERED", - "REGISTERED_AGENT_MAIL", - "REGISTERED_AGENT_PHYSICAL", - "VAT_REGISTERED", - "UNSPECIFIC" - ] + "description": "A separate postal code for a company, also known as postcode, PIN or ZIP Code" }, - "name": { - "type": "string" + "industrialZone": { + "type": "string", + "description": "The practice of designating an area for industrial development" }, - "url": { - "type": "string" - } - } - }, - "TypeKeyNameUrlDtoAdministrativeAreaType": { - "type": "object", - "properties": { - "technicalKey": { + "building": { "type": "string", - "enum": [ - "COUNTY", - "REGION", - "OTHER" - ] + "description": "Describes a specific building within the address" }, - "name": { - "type": "string" + "floor": { + "type": "string", + "description": "Describes the floor/level the delivery shall take place" }, - "url": { - "type": "string" + "door": { + "type": "string", + "description": "Describes the door/room/suite on the respective floor the delivery shall take place" } - } + }, + "description": "Physical Postal Address Part" }, - "TypeKeyNameUrlDtoBusinessPartnerType": { + "SharingState": { "type": "object", "properties": { - "technicalKey": { + "lsaType": { "type": "string", + "description": "LSA Type", "enum": [ - "BRAND", "LEGAL_ENTITY", - "ORGANIZATIONAL_UNIT", "SITE", - "UNKNOWN" + "ADDRESS" ] }, - "name": { - "type": "string" + "externalId": { + "type": "string", + "description": "External identifier" }, - "url": { - "type": "string" - } - } - }, - "TypeKeyNameUrlDtoBusinessStatusType": { - "type": "object", - "properties": { - "technicalKey": { + "sharingStateType": { "type": "string", + "description": "Type of sharing state", "enum": [ - "ACTIVE", - "DISSOLVED", - "IN_LIQUIDATION", - "INACTIVE", - "INSOLVENCY", - "UNKNOWN" + "Pending", + "Success", + "Error" ] }, - "name": { - "type": "string" - }, - "url": { - "type": "string" - } - } - }, - "TypeKeyNameUrlDtoLocalityType": { - "type": "object", - "properties": { - "technicalKey": { + "sharingErrorCode": { "type": "string", + "description": "BusinessPartnerSharingError", "enum": [ - "BLOCK", - "CITY", - "DISTRICT", - "OTHER", - "POST_OFFICE_CITY", - "QUARTER" + "SharingProcessError", + "SharingTimeout", + "BpnNotInPool" ] }, - "name": { - "type": "string" + "sharingErrorMessage": { + "type": "string", + "description": "Sharing error message (for error)" }, - "url": { - "type": "string" + "bpn": { + "type": "string", + "description": "BPN (for success)" + }, + "sharingProcessStarted": { + "type": "string", + "description": "Sharing process started (not updated if null)", + "format": "date-time" } } }, - "TypeKeyNameUrlDtoNameType": { + "SiteGateInputRequest": { "type": "object", "properties": { - "technicalKey": { - "type": "string", - "enum": [ - "ACRONYM", - "DOING_BUSINESS_AS", - "ESTABLISHMENT", - "INTERNATIONAL", - "LOCAL", - "OTHER", - "REGISTERED", - "TRANSLITERATED", - "VAT_REGISTERED" - ] + "nameParts": { + "type": "array", + "description": "Parts that make up the name of that site", + "items": { + "type": "string", + "description": "Parts that make up the name of that site" + } }, - "name": { + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteState" + } + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } + }, + "mainAddress": { + "$ref": "#/components/schemas/LogisticAddressGateDto" + }, + "externalId": { "type": "string" }, - "url": { + "legalEntityExternalId": { "type": "string" } - } + }, + "description": "Site with legal entity reference" }, - "TypeKeyNameUrlDtoPostCodeType": { + "SiteGateInputResponse": { "type": "object", "properties": { - "technicalKey": { - "type": "string", - "enum": [ - "CEDEX", - "LARGE_MAIL_USER", - "OTHER", - "POST_BOX", - "REGULAR" - ] + "nameParts": { + "type": "array", + "description": "Parts that make up the name of that site", + "items": { + "type": "string", + "description": "Parts that make up the name of that site" + } }, - "name": { + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteState" + } + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } + }, + "mainAddress": { + "$ref": "#/components/schemas/AddressGateInputResponse" + }, + "externalId": { "type": "string" }, - "url": { + "legalEntityExternalId": { "type": "string" } - } + }, + "description": "Site with legal entity reference" }, - "TypeKeyNameUrlDtoPostalDeliveryPointType": { + "SiteGateOutputRequest": { "type": "object", "properties": { - "technicalKey": { - "type": "string", - "enum": [ - "INTERURBAN_DELIVERY_POINT", - "MAIL_STATION", - "MAILBOX", - "OTHER", - "POST_OFFICE_BOX" - ] + "nameParts": { + "type": "array", + "description": "Parts that make up the name of that site", + "items": { + "type": "string", + "description": "Parts that make up the name of that site" + } }, - "name": { - "type": "string" + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteState" + } + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } + }, + "mainAddress": { + "$ref": "#/components/schemas/AddressGateOutputChildRequest" }, - "url": { + "externalId": { "type": "string" - } - } - }, - "TypeKeyNameUrlDtoPremiseType": { - "type": "object", - "properties": { - "technicalKey": { - "type": "string", - "enum": [ - "BUILDING", - "OTHER", - "LEVEL", - "HARBOUR", - "ROOM", - "SUITE", - "UNIT", - "WAREHOUSE" - ] }, - "name": { + "legalEntityExternalId": { "type": "string" }, - "url": { + "bpn": { "type": "string" } - } + }, + "description": "Site with legal entity reference" }, - "TypeKeyNameUrlDtoString": { + "SiteGateOutputResponse": { "type": "object", "properties": { - "technicalKey": { + "nameParts": { + "type": "array", + "description": "Parts that make up the name of that site", + "items": { + "type": "string", + "description": "Parts that make up the name of that site" + } + }, + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteState" + } + }, + "roles": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "SUPPLIER", + "CUSTOMER" + ] + } + }, + "mainAddress": { + "$ref": "#/components/schemas/AddressGateInputResponse" + }, + "externalId": { "type": "string" }, - "name": { + "legalEntityExternalId": { "type": "string" }, - "url": { + "bpn": { "type": "string" } - } + }, + "description": "Site with legal entity reference" }, - "TypeKeyNameUrlDtoThoroughfareType": { + "SiteState": { "type": "object", "properties": { - "technicalKey": { + "description": { "type": "string", - "enum": [ - "INDUSTRIAL_ZONE", - "OTHER", - "RIVER", - "SQUARE", - "STREET" - ] + "description": "Description of the status" }, - "name": { - "type": "string" + "validFrom": { + "type": "string", + "description": "Since when the status is/was valid", + "format": "date-time" }, - "url": { - "type": "string" - } - } - }, - "TypeMatchResponse": { - "type": "object", - "properties": { - "score": { - "type": "number", - "format": "float" + "validTo": { + "type": "string", + "description": "Until the status was valid, if applicable", + "format": "date-time" }, "type": { "type": "string", + "description": "The type of this specified status", "enum": [ - "LegalEntity", - "Site", - "Address", - "None" + "ACTIVE", + "INACTIVE" ] } - } - }, - "Unit": { - "type": "object" + }, + "description": "Status record of a site" }, - "ValidationResponse": { + "StreetGate": { "type": "object", "properties": { - "status": { + "namePrefix": { "type": "string", - "enum": [ - "OK", - "ERROR" - ] + "description": "Describes the official name prefix of the Street." }, - "errors": { - "type": "array", - "items": { - "type": "string" - } + "additionalNamePrefix": { + "type": "string", + "description": "Describes the additional name prefix of the Street." + }, + "name": { + "type": "string", + "description": "Describes the Name of the Street." + }, + "additionalNameSuffix": { + "type": "string", + "description": "Describes the additional name suffix of the Street." + }, + "houseNumber": { + "type": "string", + "description": "Describes the House Number" + }, + "milestone": { + "type": "string", + "description": "The Milestone is relevant for long roads without specific house numbers." + }, + "direction": { + "type": "string", + "description": "Describes the direction" + }, + "nameSuffix": { + "type": "string", + "description": "Describes the name suffix of the Street." } }, - "description": "Contains overall result of a sharing process validation request" + "description": "A public road in a city, town, or village, typically with houses and buildings on one or both sides." + }, + "Unit": { + "type": "object" } } } diff --git a/docs/api/gate.yaml b/docs/api/gate.yaml index d0a755ed4..cc3acbaf8 100644 --- a/docs/api/gate.yaml +++ b/docs/api/gate.yaml @@ -2,11 +2,148 @@ openapi: 3.0.1 info: title: Business Partner Data Management Gate description: A gate for a member to share business partner data with CatenaX - version: 4.0.0 + version: 4.0.0-SNAPSHOT servers: - url: http://localhost:8081 description: Generated server url paths: + /api/catena/sharing-state: + get: + tags: + - sharing-state-controller + summary: Get sharing states (including error info and BPN) for business partners, optionally filtered by LSA type and external ID + operationId: getSharingStates + parameters: + - name: page + in: query + description: Number of page to get results from + required: false + schema: + minimum: 0 + type: string + default: '0' + - name: size + in: query + description: Size of each page + required: false + schema: + maximum: 100 + minimum: 0 + type: string + default: '10' + - name: lsaType + in: query + description: LSA Type + required: false + schema: + type: string + enum: + - LEGAL_ENTITY + - SITE + - ADDRESS + - name: externalIds + in: query + description: External identifiers + required: false + schema: + type: array + items: + type: string + responses: + '200': + description: Page of sharing states + content: + application/json: + schema: + $ref: '#/components/schemas/PageResponseSharingState' + put: + tags: + - sharing-state-controller + summary: Insert/update sharing state (including error info and BPN) for business partner with LSA type and external ID + operationId: upsertSharingState + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SharingState' + required: true + responses: + '204': + description: Operation completed successfully + '400': + description: Invalid data (e.g. externalId) + /api/catena/output/sites: + put: + tags: + - site-controller + summary: Create or update output sites. + description: Create or update sites (Output). Updates instead of creating a new site if an already existing external id is used. The same external id may not occur more than once in a single request. For a single request, the maximum number of sites in the request is limited to 100 entries. + operationId: upsertSitesOutput + requestBody: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/SiteGateOutputRequest' + required: true + responses: + '200': + description: Sites were successfully updated or created + content: + application/json: + schema: + $ref: '#/components/schemas/Unit' + '400': + description: On malformed site request + /api/catena/output/legal-entities: + put: + tags: + - legal-entity-controller + summary: Create or update output legal entities. + description: Create or update legal entities (Output). Updates instead of creating a new legal entity if an already existing external id is used. The same external id may not occur more than once in a single request. For a single request, the maximum number of legal entities in the request is limited to 100 entries. + operationId: upsertLegalEntitiesOutput + requestBody: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/LegalEntityGateOutputRequest' + required: true + responses: + '200': + description: Legal entities were successfully updated or created + content: + application/json: + schema: + $ref: '#/components/schemas/Unit' + '400': + description: On malformed legal entity request + /api/catena/output/addresses: + put: + tags: + - address-controller + summary: Create or update output addresses. + description: Create or update addresses (Output). Updates instead of creating a new address if an already existing external id is used. The same external id may not occur more than once in a single request. For a single request, the maximum number of addresses in the request is limited to 100 entries. + operationId: putAddressesOutput + requestBody: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/AddressGateOutputRequest' + required: true + responses: + '200': + description: Addresses were successfully updated or created + content: + application/json: + schema: + $ref: '#/components/schemas/Unit' + '400': + description: On malformed address request /api/catena/input/sites: get: tags: @@ -15,28 +152,30 @@ paths: description: Get page of sites. operationId: getSites parameters: - - name: startAfter + - name: page in: query - description: Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages. + description: Number of page to get results from required: false schema: + minimum: 0 type: string - - name: limit + default: '0' + - name: size in: query description: Size of each page required: false schema: maximum: 100 - minimum: 1 + minimum: 0 type: string default: '10' responses: '200': description: The requested page of sites content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/PageStartAfterResponseSiteGateInputResponse' + $ref: '#/components/schemas/PageResponseSiteGateInputResponse' '400': description: On malformed pagination request put: @@ -57,9 +196,9 @@ paths: '200': description: Sites were successfully updated or created content: - '*/*': + application/json: schema: - type: object + $ref: '#/components/schemas/Unit' '400': description: On malformed site request /api/catena/input/legal-entities: @@ -70,28 +209,30 @@ paths: description: Get page of legal entities. operationId: getLegalEntities parameters: - - name: startAfter + - name: page in: query - description: Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages. + description: Number of page to get results from required: false schema: + minimum: 0 type: string - - name: limit + default: '0' + - name: size in: query description: Size of each page required: false schema: maximum: 100 - minimum: 1 + minimum: 0 type: string default: '10' responses: '200': description: The requested page of legal entities content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/PageStartAfterResponseLegalEntityGateInputResponse' + $ref: '#/components/schemas/PageResponseLegalEntityGateInputResponse' '400': description: On malformed pagination request put: @@ -112,9 +253,9 @@ paths: '200': description: Legal entities were successfully updated or created content: - '*/*': + application/json: schema: - type: object + $ref: '#/components/schemas/Unit' '400': description: On malformed legal entity request /api/catena/input/addresses: @@ -125,28 +266,30 @@ paths: description: Get page of addresses. operationId: getAddresses parameters: - - name: startAfter + - name: page in: query - description: Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages. + description: Number of page to get results from required: false schema: + minimum: 0 type: string - - name: limit + default: '0' + - name: size in: query description: Size of each page required: false schema: maximum: 100 - minimum: 1 + minimum: 0 type: string default: '10' responses: '200': description: The requested page of addresses content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/PageStartAfterResponseAddressGateInputResponse' + $ref: '#/components/schemas/PageResponseAddressGateInputResponse' '400': description: On malformed pagination request put: @@ -167,7 +310,7 @@ paths: '200': description: Addresses were successfully updated or created content: - '*/*': + application/json: schema: $ref: '#/components/schemas/Unit' '400': @@ -180,19 +323,21 @@ paths: description: Get page of sites. Can optionally be filtered by external ids. operationId: getSitesOutput parameters: - - name: startAfter + - name: page in: query - description: Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages. + description: Number of page to get results from required: false schema: + minimum: 0 type: string - - name: limit + default: '0' + - name: size in: query description: Size of each page required: false schema: maximum: 100 - minimum: 1 + minimum: 0 type: string default: '10' requestBody: @@ -206,9 +351,9 @@ paths: '200': description: The requested page of sites content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/PageOutputResponseSiteGateOutput' + $ref: '#/components/schemas/PageResponseSiteGateOutputResponse' '400': description: On malformed pagination request /api/catena/output/legal-entities/search: @@ -219,19 +364,21 @@ paths: description: Get page of legal entities. Can optionally be filtered by external ids. operationId: getLegalEntitiesOutput parameters: - - name: startAfter + - name: page in: query - description: Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages. + description: Number of page to get results from required: false schema: + minimum: 0 type: string - - name: limit + default: '0' + - name: size in: query description: Size of each page required: false schema: maximum: 100 - minimum: 1 + minimum: 0 type: string default: '10' requestBody: @@ -245,32 +392,74 @@ paths: '200': description: The requested page of legal entities content: - '*/*': + application/json: + schema: + $ref: '#/components/schemas/PageResponseLegalEntityGateOutputResponse' + '400': + description: On malformed pagination request + /api/catena/output/changelog/search: + post: + tags: + - changelog-controller + summary: Get business partner changelog entries for changes to the business partner output data + description: Get business partner changelog entries for changes to the business partner output data. Filter by list external id, from timestamp and/or lsa type + operationId: getOutputChangelog + parameters: + - name: page + in: query + description: Number of page to get results from + required: false + schema: + minimum: 0 + type: string + default: '0' + - name: size + in: query + description: Size of each page + required: false + schema: + maximum: 100 + minimum: 0 + type: string + default: '10' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChangeLogSearchRequest' + required: true + responses: + '200': + description: The changelog entries for the specified parameters + content: + application/json: schema: - $ref: '#/components/schemas/PageOutputResponseLegalEntityGateOutput' + $ref: '#/components/schemas/PageChangeLogResponseChangelogResponse' '400': description: On malformed pagination request /api/catena/output/addresses/search: post: tags: - address-controller - summary: Get page of addresses - description: Get page of addresses. Can optionally be filtered by external ids. + summary: Get page of addresses (Output) + description: Get page of addresses (Output). Can optionally be filtered by external ids. operationId: getAddressesOutput parameters: - - name: startAfter + - name: page in: query - description: Value used to indicate which page to retrieve. When this value is not provided, the first page is returned.The nextStartAfter value from the response can then be used to request subsequent pages. + description: Number of page to get results from required: false schema: + minimum: 0 type: string - - name: limit + default: '0' + - name: size in: query description: Size of each page required: false schema: maximum: 100 - minimum: 1 + minimum: 0 type: string default: '10' requestBody: @@ -284,99 +473,177 @@ paths: '200': description: The requested page of addresses content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/PageOutputResponseAddressGateOutput' + $ref: '#/components/schemas/PageResponseAddressGateInputResponse' '400': description: On malformed pagination request - /api/catena/input/sites/validation: + /api/catena/input/sites/search: post: tags: - site-controller - summary: Validate a site - description: Determines errors in a site record which keep it from entering the sharing process - operationId: validateSite + summary: Get page of sites filtered by a collection of externalIds + description: Get page of sites filtered by a collection of externalIds. + operationId: getSitesByExternalIds + parameters: + - name: page + in: query + description: Number of page to get results from + required: false + schema: + minimum: 0 + type: string + default: '0' + - name: size + in: query + description: Size of each page + required: false + schema: + maximum: 100 + minimum: 0 + type: string + default: '10' requestBody: content: application/json: schema: - $ref: '#/components/schemas/SiteGateInputRequest' + type: array + items: + type: string required: true responses: '200': - description: A validation response with possible errors + description: The requested page of sites content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/ValidationResponse' + $ref: '#/components/schemas/PageResponseSiteGateInputResponse' '400': - description: On malformed site requests - /api/catena/input/legal-entities/validation: + description: On malformed pagination request + /api/catena/input/legal-entities/search: post: tags: - legal-entity-controller - summary: Validate a legal entity - description: Determines errors in a legal entity record which keep it from entering the sharing process - operationId: validateLegalEntity + summary: Get page of legal-entities filtered by a collection of externalIds + description: Get page of legal-entities filtered by a collection of externalIds. + operationId: getLegalEntitiesByExternalIds + parameters: + - name: page + in: query + description: Number of page to get results from + required: false + schema: + minimum: 0 + type: string + default: '0' + - name: size + in: query + description: Size of each page + required: false + schema: + maximum: 100 + minimum: 0 + type: string + default: '10' requestBody: content: application/json: schema: - $ref: '#/components/schemas/LegalEntityGateInputRequest' + type: array + items: + type: string required: true responses: '200': - description: A validation response with possible errors + description: The requested page of legal-entities content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/ValidationResponse' + $ref: '#/components/schemas/PageResponseLegalEntityGateInputResponse' '400': - description: On malformed legal entity requests - /api/catena/input/addresses/validation: + description: On malformed pagination request + /api/catena/input/changelog/search: post: tags: - - address-controller - summary: Validate an address partner - description: Determines errors in an address partner record which keep it from entering the sharing process - operationId: validateSite_1 + - changelog-controller + summary: Get business partner changelog entries for changes to the business partner input data + description: Get business partner changelog entries for changes to the business partner input data. Filter by list external id, from timestamp and/or lsa type + operationId: getInputChangelog + parameters: + - name: page + in: query + description: Number of page to get results from + required: false + schema: + minimum: 0 + type: string + default: '0' + - name: size + in: query + description: Size of each page + required: false + schema: + maximum: 100 + minimum: 0 + type: string + default: '10' requestBody: content: application/json: schema: - $ref: '#/components/schemas/AddressGateInputRequest' + $ref: '#/components/schemas/ChangeLogSearchRequest' required: true responses: '200': - description: A validation response with possible errors + description: The changelog entries for the specified parameters content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/ValidationResponse' + $ref: '#/components/schemas/PageChangeLogResponseChangelogResponse' '400': - description: On malformed address requests - /api/catena/business-partners/type-match: + description: On malformed pagination request + /api/catena/input/addresses/search: post: tags: - - business-partner-controller - summary: Determine the LSA type of a business partner candidate - description: For one business partner candidate this request determines its likely type of either legal entity, site or address.It is possible that no type could be determined.The candidate needs to contain either a name or an identifier as a minimum requirement. - operationId: determineLsaType + - address-controller + summary: Get page of addresses filtered by a collection of externalIds + description: Get page of addresses filtered by a collection of externalIds. + operationId: getAddressesByExternalIds + parameters: + - name: page + in: query + description: Number of page to get results from + required: false + schema: + minimum: 0 + type: string + default: '0' + - name: size + in: query + description: Size of each page + required: false + schema: + maximum: 100 + minimum: 0 + type: string + default: '10' requestBody: content: application/json: schema: - $ref: '#/components/schemas/BusinessPartnerCandidateDto' + type: array + items: + type: string required: true responses: '200': - description: Records were successfully processed. + description: The requested page of addresses content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/TypeMatchResponse' + $ref: '#/components/schemas/PageResponseAddressGateInputResponse' '400': - description: No name and no identifier given, or malformed request + description: On malformed pagination request /api/catena/input/sites/{externalId}: get: tags: @@ -395,7 +662,7 @@ paths: '200': description: Found site with external identifier content: - '*/*': + application/json: schema: $ref: '#/components/schemas/SiteGateInputResponse' '404': @@ -418,7 +685,7 @@ paths: '200': description: Found legal entity with external identifier content: - '*/*': + application/json: schema: $ref: '#/components/schemas/LegalEntityGateInputResponse' '404': @@ -441,63 +708,245 @@ paths: '200': description: Found address with external identifier content: - '*/*': + application/json: schema: $ref: '#/components/schemas/AddressGateInputResponse' '404': description: No address found under specified external identifier components: schemas: - Address: + AddressGateInputRequest: type: object properties: - version: - $ref: '#/components/schemas/AddressVersion' - careOf: + nameParts: + type: array + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + items: + type: string + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: + type: array + items: + $ref: '#/components/schemas/AddressState' + identifiers: + type: array + items: + $ref: '#/components/schemas/AddressIdentifier' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddressGateDto' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + roles: + type: array + items: + type: string + enum: + - SUPPLIER + - CUSTOMER + externalId: + type: string + legalEntityExternalId: + type: string + siteExternalId: type: string - contexts: + description: Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address. + AddressGateInputResponse: + type: object + properties: + nameParts: type: array + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. items: type: string - country: + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: + type: array + items: + $ref: '#/components/schemas/AddressState' + identifiers: + type: array + items: + $ref: '#/components/schemas/AddressIdentifier' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddressGateDto' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + roles: + type: array + items: + type: string + enum: + - SUPPLIER + - CUSTOMER + externalId: type: string - enum: - - UNDEFINED - - AC - - AD - - AE - - AF - - AG - - AI - - AL - - AM - - AN - - AO - - AQ - - AR - - AS - - AT - - AU - - AW - - AX - - AZ - - BA - - BB - - BD - - BE - - BF - - BG - - BH - - BI - - BJ - - BL - - BM - - BN - - BO - - BQ - - BR - - BS - - BT + legalEntityExternalId: + type: string + siteExternalId: + type: string + bpn: + type: string + description: Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address. + AddressGateOutputChildRequest: + type: object + properties: + nameParts: + type: array + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + items: + type: string + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: + type: array + items: + $ref: '#/components/schemas/AddressState' + identifiers: + type: array + items: + $ref: '#/components/schemas/AddressIdentifier' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddressGateDto' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + roles: + type: array + items: + type: string + enum: + - SUPPLIER + - CUSTOMER + bpn: + type: string + description: DTO for setting the output address data with BPN. + AddressGateOutputRequest: + type: object + properties: + nameParts: + type: array + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + items: + type: string + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: + type: array + items: + $ref: '#/components/schemas/AddressState' + identifiers: + type: array + items: + $ref: '#/components/schemas/AddressIdentifier' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddressGateDto' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + roles: + type: array + items: + type: string + enum: + - SUPPLIER + - CUSTOMER + externalId: + type: string + legalEntityExternalId: + type: string + siteExternalId: + type: string + bpn: + type: string + description: Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address. + AddressIdentifier: + type: object + properties: + value: + type: string + description: Value of the identifier + type: + type: string + description: Technical key of the type to which this identifier belongs to + description: Identifier record for a logistic address + AddressState: + type: object + properties: + description: + type: string + description: Description of the status + validFrom: + type: string + description: Since when the status is/was valid + format: date-time + validTo: + type: string + description: Until the status was valid, if applicable + format: date-time + type: + type: string + description: The type of this specified status + enum: + - ACTIVE + - INACTIVE + description: Status record for a address + AlternativePostalAddress: + type: object + properties: + geographicCoordinates: + $ref: '#/components/schemas/GeoCoordinates' + country: + type: string + description: Describes the country + enum: + - UNDEFINED + - AC + - AD + - AE + - AF + - AG + - AI + - AL + - AM + - AN + - AO + - AQ + - AR + - AS + - AT + - AU + - AW + - AX + - AZ + - BA + - BB + - BD + - BE + - BF + - BG + - BH + - BI + - BJ + - BL + - BM + - BN + - BO + - BQ + - BR + - BS + - BT - BU - BV - BW @@ -734,2169 +1183,516 @@ components: - ZM - ZR - ZW - administrativeAreas: + postalCode: + type: string + description: A postal code, also known as postcode, PIN or ZIP Code + city: + type: string + description: 'The city of the address (Synonym: Town, village, municipality)' + administrativeAreaLevel1: + type: string + description: Identifying code of the Region within the country (e.g. Bayern) + deliveryServiceNumber: + type: string + description: Describes the PO Box or private Bag number the delivery should be placed at. + deliveryServiceType: + type: string + description: The type of this specified delivery + enum: + - PO_BOX + - PRIVATE_BAG + - BOITE_POSTALE + deliveryServiceQualifier: + type: string + description: Delivery Service Qualifier + description: Alternative Postal Address Part + ChangeLogSearchRequest: + type: object + properties: + fromTime: + type: string + format: date-time + externalIds: + uniqueItems: true type: array items: - $ref: '#/components/schemas/AdministrativeArea' - postCodes: + type: string + lsaTypes: + uniqueItems: true type: array items: - $ref: '#/components/schemas/Postcode' - localities: + type: string + enum: + - LEGAL_ENTITY + - SITE + - ADDRESS + ChangelogResponse: + type: object + properties: + externalId: + type: string + businessPartnerType: + type: string + enum: + - LEGAL_ENTITY + - SITE + - ADDRESS + modifiedAt: + type: string + format: date-time + description: Changelog entry for a business partner + Classification: + type: object + properties: + value: + type: string + description: Name of the classification + code: + type: string + description: Identifying code of the classification, if applicable + type: + type: string + description: Type of specified classification + enum: + - NACE + - NAF + - NAICS + - SIC + description: Classification record for a business partner + ErrorInfoChangeLogOutputError: + title: ErrorInfo + type: object + properties: + errorCode: + type: string + description: ChangeLogOutputError + enum: + - ExternalIdNotFound + message: + type: string + entityKey: + type: string + description: Holds information about failures + GeoCoordinates: + type: object + properties: + longitude: + type: number + description: Longitude coordinate + format: float + latitude: + type: number + description: Latitude coordinate + format: float + altitude: + type: number + description: Altitude, if applicable + format: float + description: Geo coordinates record for an address + LegalEntityGateInputRequest: + type: object + properties: + legalNameParts: type: array items: - $ref: '#/components/schemas/Locality' - thoroughfares: + type: string + identifiers: type: array items: - $ref: '#/components/schemas/Thoroughfare' - premises: + $ref: '#/components/schemas/LegalEntityIdentifier' + legalShortName: + type: string + description: Abbreviated name or shorthand + legalForm: + type: string + description: Technical key of the legal form + states: type: array items: - $ref: '#/components/schemas/Premise' - postalDeliveryPoints: + $ref: '#/components/schemas/LegalEntityState' + classifications: type: array items: - $ref: '#/components/schemas/PostalDeliveryPoint' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: + $ref: '#/components/schemas/Classification' + roles: type: array items: type: string enum: - - BRANCH_OFFICE - - CARE_OF - - HEADQUARTER - - LEGAL_ALTERNATIVE - - PO_BOX - - REGISTERED - - REGISTERED_AGENT_MAIL - - REGISTERED_AGENT_PHYSICAL - - VAT_REGISTERED - - UNSPECIFIC - description: Localized address record for a business partner - AddressGateInputRequest: + - SUPPLIER + - CUSTOMER + legalAddress: + $ref: '#/components/schemas/LogisticAddressGateDto' + externalId: + type: string + description: Legal entity with external id + LegalEntityGateInputResponse: type: object properties: - version: - $ref: '#/components/schemas/AddressVersion' - careOf: + legalNameParts: + type: array + items: + type: string + identifiers: + type: array + items: + $ref: '#/components/schemas/LegalEntityIdentifier' + legalShortName: type: string - contexts: + description: Abbreviated name or shorthand + legalForm: + type: string + description: Technical key of the legal form + states: + type: array + items: + $ref: '#/components/schemas/LegalEntityState' + classifications: + type: array + items: + $ref: '#/components/schemas/Classification' + roles: type: array items: type: string - country: + enum: + - SUPPLIER + - CUSTOMER + legalAddress: + $ref: '#/components/schemas/AddressGateInputResponse' + externalId: type: string - enum: - - UNDEFINED - - AC - - AD - - AE - - AF - - AG - - AI - - AL - - AM - - AN - - AO - - AQ - - AR - - AS - - AT - - AU - - AW - - AX - - AZ - - BA - - BB - - BD - - BE - - BF - - BG - - BH - - BI - - BJ - - BL - - BM - - BN - - BO - - BQ - - BR - - BS - - BT - - BU - - BV - - BW - - BY - - BZ - - CA - - CC - - CD - - CF - - CG - - CH - - CI - - CK - - CL - - CM - - CN - - CO - - CP - - CR - - CS - - CU - - CV - - CW - - CX - - CY - - CZ - - DE - - DG - - DJ - - DK - - DM - - DO - - DZ - - EA - - EC - - EE - - EG - - EH - - ER - - ES - - ET - - EU - - EZ - - FI - - FJ - - FK - - FM - - FO - - FR - - FX - - GA - - GB - - GD - - GE - - GF - - GG - - GH - - GI - - GL - - GM - - GN - - GP - - GQ - - GR - - GS - - GT - - GU - - GW - - GY - - HK - - HM - - HN - - HR - - HT - - HU - - IC - - ID - - IE - - IL - - IM - - IN - - IO - - IQ - - IR - - IS - - IT - - JE - - JM - - JO - - JP - - KE - - KG - - KH - - KI - - KM - - KN - - KP - - KR - - KW - - KY - - KZ - - LA - - LB - - LC - - LI - - LK - - LR - - LS - - LT - - LU - - LV - - LY - - MA - - MC - - MD - - ME - - MF - - MG - - MH - - MK - - ML - - MM - - MN - - MO - - MP - - MQ - - MR - - MS - - MT - - MU - - MV - - MW - - MX - - MY - - MZ - - NA - - NC - - NE - - NF - - NG - - NI - - NL - - 'NO' - - NP - - NR - - NT - - NU - - NZ - - OM - - PA - - PE - - PF - - PG - - PH - - PK - - PL - - PM - - PN - - PR - - PS - - PT - - PW - - PY - - QA - - RE - - RO - - RS - - RU - - RW - - SA - - SB - - SC - - SD - - SE - - SF - - SG - - SH - - SI - - SJ - - SK - - SL - - SM - - SN - - SO - - SR - - SS - - ST - - SU - - SV - - SX - - SY - - SZ - - TA - - TC - - TD - - TF - - TG - - TH - - TJ - - TK - - TL - - TM - - TN - - TO - - TP - - TR - - TT - - TV - - TW - - TZ - - UA - - UG - - UK - - UM - - US - - UY - - UZ - - VA - - VC - - VE - - VG - - VI - - VN - - VU - - WF - - WS - - XI - - XU - - XK - - YE - - YT - - YU - - ZA - - ZM - - ZR - - ZW - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeArea' - postCodes: - type: array - items: - $ref: '#/components/schemas/Postcode' - localities: - type: array - items: - $ref: '#/components/schemas/Locality' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/Thoroughfare' - premises: - type: array - items: - $ref: '#/components/schemas/Premise' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPoint' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - type: string - enum: - - BRANCH_OFFICE - - CARE_OF - - HEADQUARTER - - LEGAL_ALTERNATIVE - - PO_BOX - - REGISTERED - - REGISTERED_AGENT_MAIL - - REGISTERED_AGENT_PHYSICAL - - VAT_REGISTERED - - UNSPECIFIC - externalId: - type: string - legalEntityExternalId: - type: string - siteExternalId: - type: string - bpn: - type: string - description: Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address. - AddressGateInputResponse: - type: object - properties: - version: - $ref: '#/components/schemas/AddressVersion' - careOf: - type: string - contexts: - type: array - items: - type: string - country: - type: string - enum: - - UNDEFINED - - AC - - AD - - AE - - AF - - AG - - AI - - AL - - AM - - AN - - AO - - AQ - - AR - - AS - - AT - - AU - - AW - - AX - - AZ - - BA - - BB - - BD - - BE - - BF - - BG - - BH - - BI - - BJ - - BL - - BM - - BN - - BO - - BQ - - BR - - BS - - BT - - BU - - BV - - BW - - BY - - BZ - - CA - - CC - - CD - - CF - - CG - - CH - - CI - - CK - - CL - - CM - - CN - - CO - - CP - - CR - - CS - - CU - - CV - - CW - - CX - - CY - - CZ - - DE - - DG - - DJ - - DK - - DM - - DO - - DZ - - EA - - EC - - EE - - EG - - EH - - ER - - ES - - ET - - EU - - EZ - - FI - - FJ - - FK - - FM - - FO - - FR - - FX - - GA - - GB - - GD - - GE - - GF - - GG - - GH - - GI - - GL - - GM - - GN - - GP - - GQ - - GR - - GS - - GT - - GU - - GW - - GY - - HK - - HM - - HN - - HR - - HT - - HU - - IC - - ID - - IE - - IL - - IM - - IN - - IO - - IQ - - IR - - IS - - IT - - JE - - JM - - JO - - JP - - KE - - KG - - KH - - KI - - KM - - KN - - KP - - KR - - KW - - KY - - KZ - - LA - - LB - - LC - - LI - - LK - - LR - - LS - - LT - - LU - - LV - - LY - - MA - - MC - - MD - - ME - - MF - - MG - - MH - - MK - - ML - - MM - - MN - - MO - - MP - - MQ - - MR - - MS - - MT - - MU - - MV - - MW - - MX - - MY - - MZ - - NA - - NC - - NE - - NF - - NG - - NI - - NL - - 'NO' - - NP - - NR - - NT - - NU - - NZ - - OM - - PA - - PE - - PF - - PG - - PH - - PK - - PL - - PM - - PN - - PR - - PS - - PT - - PW - - PY - - QA - - RE - - RO - - RS - - RU - - RW - - SA - - SB - - SC - - SD - - SE - - SF - - SG - - SH - - SI - - SJ - - SK - - SL - - SM - - SN - - SO - - SR - - SS - - ST - - SU - - SV - - SX - - SY - - SZ - - TA - - TC - - TD - - TF - - TG - - TH - - TJ - - TK - - TL - - TM - - TN - - TO - - TP - - TR - - TT - - TV - - TW - - TZ - - UA - - UG - - UK - - UM - - US - - UY - - UZ - - VA - - VC - - VE - - VG - - VI - - VN - - VU - - WF - - WS - - XI - - XU - - XK - - YE - - YT - - YU - - ZA - - ZM - - ZR - - ZW - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeArea' - postCodes: - type: array - items: - $ref: '#/components/schemas/Postcode' - localities: - type: array - items: - $ref: '#/components/schemas/Locality' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/Thoroughfare' - premises: - type: array - items: - $ref: '#/components/schemas/Premise' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPoint' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - type: string - enum: - - BRANCH_OFFICE - - CARE_OF - - HEADQUARTER - - LEGAL_ALTERNATIVE - - PO_BOX - - REGISTERED - - REGISTERED_AGENT_MAIL - - REGISTERED_AGENT_PHYSICAL - - VAT_REGISTERED - - UNSPECIFIC - externalId: - type: string - legalEntityExternalId: - type: string - siteExternalId: - type: string - bpn: - type: string - processStartedAt: - type: string - format: date-time - description: Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address. - AddressGateOutput: - type: object - properties: - bpn: - type: string - version: - $ref: '#/components/schemas/AddressVersionResponse' - careOf: - type: string - contexts: - type: array - items: - type: string - country: - $ref: '#/components/schemas/TypeKeyNameDtoCountryCode' - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeAreaResponse' - postCodes: - type: array - items: - $ref: '#/components/schemas/PostcodeResponse' - localities: - type: array - items: - $ref: '#/components/schemas/LocalityResponse' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/ThoroughfareResponse' - premises: - type: array - items: - $ref: '#/components/schemas/PremiseResponse' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPointResponse' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoAddressType' - externalId: - type: string - legalEntityBpn: - type: string - siteBpn: - type: string - description: Address with legal entity or site references. Only one of either legal entity or site external id can be set for an address. - AddressResponse: - type: object - properties: - version: - $ref: '#/components/schemas/AddressVersionResponse' - careOf: - type: string - contexts: - type: array - items: - type: string - country: - $ref: '#/components/schemas/TypeKeyNameDtoCountryCode' - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeAreaResponse' - postCodes: - type: array - items: - $ref: '#/components/schemas/PostcodeResponse' - localities: - type: array - items: - $ref: '#/components/schemas/LocalityResponse' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/ThoroughfareResponse' - premises: - type: array - items: - $ref: '#/components/schemas/PremiseResponse' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPointResponse' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoAddressType' - description: Localized address record of a business partner - AddressVersion: - type: object - properties: - characterSet: - type: string - enum: - - ARABIC - - CHINESE - - CHINESE_TRADITIONAL - - CYRILLIC - - GREEK - - HANGUL_KOREAN - - HEBREW - - HIRAGANA - - KANJI - - KATAKANA - - LATIN - - THAI - - WESTERN_LATIN_STANDARD - - UNDEFINED - language: - type: string - enum: - - undefined - - aa - - ab - - ae - - af - - ak - - am - - an - - ar - - as - - av - - ay - - az - - ba - - be - - bg - - bh - - bi - - bm - - bn - - bo - - br - - bs - - ca - - ce - - ch - - co - - cr - - cs - - cu - - cv - - cy - - da - - de - - dv - - dz - - ee - - el - - en - - eo - - es - - et - - eu - - fa - - ff - - fi - - fj - - fo - - fr - - fy - - ga - - gd - - gl - - gn - - gu - - gv - - ha - - he - - hi - - ho - - hr - - ht - - hu - - hy - - hz - - ia - - id - - ie - - ig - - ii - - ik - - io - - is - - it - - iu - - ja - - jv - - ka - - kg - - ki - - kj - - kk - - kl - - km - - kn - - ko - - kr - - ks - - ku - - kv - - kw - - ky - - la - - lb - - lg - - li - - ln - - lo - - lt - - lu - - lv - - mg - - mh - - mi - - mk - - ml - - mn - - mr - - ms - - mt - - my - - na - - nb - - nd - - ne - - ng - - nl - - nn - - 'no' - - nr - - nv - - ny - - oc - - oj - - om - - or - - os - - pa - - pi - - pl - - ps - - pt - - qu - - rm - - rn - - ro - - ru - - rw - - sa - - sc - - sd - - se - - sg - - si - - sk - - sl - - sm - - sn - - so - - sq - - sr - - ss - - st - - su - - sv - - sw - - ta - - te - - tg - - th - - ti - - tk - - tl - - tn - - to - - tr - - ts - - tt - - tw - - ty - - ug - - uk - - ur - - uz - - ve - - vi - - vo - - wa - - wo - - xh - - yi - - yo - - za - - zh - - zu - description: Localization record for an address - AddressVersionResponse: - type: object - properties: - characterSet: - $ref: '#/components/schemas/TypeKeyNameDtoCharacterSet' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Localization record of an address - AdministrativeArea: - type: object - properties: - value: - type: string - shortName: - type: string - fipsCode: - type: string - type: - type: string - enum: - - COUNTY - - REGION - - OTHER - description: Areas such as country regions or counties - AdministrativeAreaResponse: - type: object - properties: - value: - type: string - shortName: - type: string - fipsCode: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoAdministrativeAreaType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Area of an address such as country region or county - BankAccount: - type: object - properties: - trustScores: - type: array - items: - type: number - format: float - currency: - type: string - enum: - - UNDEFINED - - AED - - AFN - - ALL - - AMD - - ANG - - AOA - - ARS - - AUD - - AWG - - AZN - - BAM - - BBD - - BDT - - BGN - - BHD - - BIF - - BMD - - BND - - BOB - - BOV - - BRL - - BSD - - BTN - - BWP - - BYN - - BYR - - BZD - - CAD - - CDF - - CHE - - CHF - - CHW - - CLF - - CLP - - CNY - - COP - - COU - - CRC - - CUC - - CUP - - CVE - - CZK - - DJF - - DKK - - DOP - - DZD - - EGP - - ERN - - ETB - - EUR - - FJD - - FKP - - GBP - - GEL - - GHS - - GIP - - GMD - - GNF - - GTQ - - GYD - - HKD - - HNL - - HRK - - HTG - - HUF - - IDR - - ILS - - INR - - IQD - - IRR - - ISK - - JMD - - JOD - - JPY - - KES - - KGS - - KHR - - KMF - - KPW - - KRW - - KWD - - KYD - - KZT - - LAK - - LBP - - LKR - - LRD - - LSL - - LTL - - LYD - - MAD - - MDL - - MGA - - MKD - - MMK - - MNT - - MOP - - MRO - - MRU - - MUR - - MVR - - MWK - - MXN - - MXV - - MYR - - MZN - - NAD - - NGN - - NIO - - NOK - - NPR - - NZD - - OMR - - PAB - - PEN - - PGK - - PHP - - PKR - - PLN - - PYG - - QAR - - RON - - RSD - - RUB - - RUR - - RWF - - SAR - - SBD - - SCR - - SDG - - SEK - - SGD - - SHP - - SLL - - SOS - - SRD - - SSP - - STD - - STN - - SVC - - SYP - - SZL - - THB - - TJS - - TMT - - TND - - TOP - - TRY - - TTD - - TWD - - TZS - - UAH - - UGX - - USD - - USN - - USS - - UYI - - UYU - - UZS - - VEF - - VES - - VND - - VUV - - WST - - XAF - - XAG - - XAU - - XBA - - XBB - - XBC - - XBD - - XCD - - XDR - - XOF - - XPD - - XPF - - XPT - - XSU - - XTS - - XUA - - XXX - - YER - - ZAR - - ZMW - - ZWL - internationalBankAccountIdentifier: - type: string - internationalBankIdentifier: - type: string - nationalBankAccountIdentifier: - type: string - nationalBankIdentifier: - type: string - description: Bank account record of a business partner - BankAccountResponse: - type: object - properties: - trustScores: - type: array - items: - type: number - format: float - currency: - $ref: '#/components/schemas/TypeKeyNameDtoCurrencyCode' - internationalBankAccountIdentifier: - type: string - internationalBankIdentifier: - type: string - nationalBankAccountIdentifier: - type: string - nationalBankIdentifier: - type: string - description: Bank account record for a business partner - BusinessPartnerCandidateDto: - type: object - properties: - identifiers: - type: array - items: - $ref: '#/components/schemas/Identifier' - names: - type: array - items: - $ref: '#/components/schemas/Name' - legalForm: - type: string - status: - $ref: '#/components/schemas/BusinessStatus' - profileClassifications: - type: array - items: - $ref: '#/components/schemas/Classification' - bankAccounts: - type: array - items: - $ref: '#/components/schemas/BankAccount' - address: - $ref: '#/components/schemas/Address' - BusinessStatus: - type: object - properties: - officialDenotation: - type: string - validFrom: - type: string - format: date-time - validUntil: - type: string - format: date-time - type: - type: string - enum: - - ACTIVE - - DISSOLVED - - IN_LIQUIDATION - - INACTIVE - - INSOLVENCY - - UNKNOWN - description: Status record for a business partner - BusinessStatusResponse: - type: object - properties: - officialDenotation: - type: string - validFrom: - type: string - format: date-time - validUntil: - type: string - format: date-time - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoBusinessStatusType' - description: Status of a business partner - Classification: - type: object - properties: - value: - type: string - code: - type: string - type: - type: string - enum: - - NACE - - NAF - - NAICS - - SIC - description: Classification record for a business partner - ClassificationResponse: - type: object - properties: - value: - type: string - code: - type: string - type: - $ref: '#/components/schemas/NamedTypeWithLink' - description: Classification record of a business partner - ErrorInfoBusinessPartnerOutputError: - title: ErrorInfo - type: object - properties: - errorCode: - type: string - description: BusinessPartnerOutputError - enum: - - SharingProcessError - - SharingTimeout - - BpnNotInPool - message: - type: string - entityKey: - type: string - description: Holds information about failures - GeoCoordinates: - type: object - properties: - longitude: - type: number - format: float - latitude: - type: number - format: float - altitude: - type: number - format: float - description: Geo coordinates record for an address - Identifier: - type: object - properties: - value: - type: string - type: - type: string - issuingBody: - type: string - status: - type: string - description: Identifier record for a business partner - IdentifierResponse: - type: object - properties: - value: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' - issuingBody: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' - status: - $ref: '#/components/schemas/TypeKeyNameDtoString' - description: Identifier record of a business partner - LegalEntityGateInputRequest: + description: Legal entity with external id + LegalEntityGateOutputRequest: type: object properties: - identifiers: - type: array - items: - $ref: '#/components/schemas/Identifier' - names: - type: array - items: - $ref: '#/components/schemas/Name' - legalForm: - type: string - status: - $ref: '#/components/schemas/BusinessStatus' - profileClassifications: - type: array - items: - $ref: '#/components/schemas/Classification' - types: + legalNameParts: type: array items: type: string - enum: - - BRAND - - LEGAL_ENTITY - - ORGANIZATIONAL_UNIT - - SITE - - UNKNOWN - bankAccounts: + identifiers: type: array items: - $ref: '#/components/schemas/BankAccount' - legalAddress: - $ref: '#/components/schemas/Address' - externalId: + $ref: '#/components/schemas/LegalEntityIdentifier' + legalShortName: type: string - bpn: + description: Abbreviated name or shorthand + legalForm: type: string - description: Legal entity with external id - LegalEntityGateInputResponse: - type: object - properties: - identifiers: + description: Technical key of the legal form + states: type: array items: - $ref: '#/components/schemas/Identifier' - names: - type: array - items: - $ref: '#/components/schemas/Name' - legalForm: - type: string - status: - $ref: '#/components/schemas/BusinessStatus' - profileClassifications: + $ref: '#/components/schemas/LegalEntityState' + classifications: type: array items: $ref: '#/components/schemas/Classification' - types: + roles: type: array items: type: string enum: - - BRAND - - LEGAL_ENTITY - - ORGANIZATIONAL_UNIT - - SITE - - UNKNOWN - bankAccounts: - type: array - items: - $ref: '#/components/schemas/BankAccount' + - SUPPLIER + - CUSTOMER legalAddress: - $ref: '#/components/schemas/Address' + $ref: '#/components/schemas/AddressGateOutputChildRequest' externalId: type: string bpn: type: string - processStartedAt: - type: string - format: date-time description: Legal entity with external id - LegalEntityGateOutput: + LegalEntityGateOutputResponse: type: object properties: identifiers: type: array items: - $ref: '#/components/schemas/IdentifierResponse' - names: - type: array - items: - $ref: '#/components/schemas/NameResponse' + $ref: '#/components/schemas/LegalEntityIdentifier' + legalShortName: + type: string + description: Abbreviated name or shorthand legalForm: - $ref: '#/components/schemas/LegalFormResponse' - status: - $ref: '#/components/schemas/BusinessStatusResponse' - profileClassifications: + type: string + description: Technical key of the legal form + states: type: array items: - $ref: '#/components/schemas/ClassificationResponse' - types: + $ref: '#/components/schemas/LegalEntityState' + classifications: type: array items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoBusinessPartnerType' - bankAccounts: + $ref: '#/components/schemas/Classification' + legalNameParts: type: array items: - $ref: '#/components/schemas/BankAccountResponse' + type: string roles: type: array items: - $ref: '#/components/schemas/TypeKeyNameDtoString' - relations: - type: array - items: - $ref: '#/components/schemas/RelationResponse' + type: string + enum: + - SUPPLIER + - CUSTOMER legalAddress: - $ref: '#/components/schemas/AddressResponse' - bpn: - type: string + $ref: '#/components/schemas/AddressGateInputResponse' externalId: type: string - description: Legal entity with references - LegalFormResponse: - type: object - properties: - technicalKey: - type: string - name: - type: string - url: - type: string - mainAbbreviation: + bpn: type: string - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - categories: - type: array - items: - $ref: '#/components/schemas/NamedTypeWithLink' - description: Legal form a business partner can have - Locality: + description: Legal entity with external id + LegalEntityIdentifier: type: object properties: value: type: string - shortName: - type: string + description: Value of the identifier type: type: string - enum: - - BLOCK - - CITY - - DISTRICT - - OTHER - - POST_OFFICE_CITY - - QUARTER - description: Locality record for an address such as city, block or district - LocalityResponse: - type: object - properties: - value: - type: string - shortName: + description: Technical key of the type to which this identifier belongs to + issuingBody: type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoLocalityType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Locality record of an address such as city, block or district - Name: + description: Body which issued the identifier + description: Identifier record for a legal entity + LegalEntityState: type: object properties: - value: - type: string - shortName: - type: string - type: - type: string - enum: - - ACRONYM - - DOING_BUSINESS_AS - - ESTABLISHMENT - - INTERNATIONAL - - LOCAL - - OTHER - - REGISTERED - - TRANSLITERATED - - VAT_REGISTERED - language: + officialDenotation: type: string - enum: - - undefined - - aa - - ab - - ae - - af - - ak - - am - - an - - ar - - as - - av - - ay - - az - - ba - - be - - bg - - bh - - bi - - bm - - bn - - bo - - br - - bs - - ca - - ce - - ch - - co - - cr - - cs - - cu - - cv - - cy - - da - - de - - dv - - dz - - ee - - el - - en - - eo - - es - - et - - eu - - fa - - ff - - fi - - fj - - fo - - fr - - fy - - ga - - gd - - gl - - gn - - gu - - gv - - ha - - he - - hi - - ho - - hr - - ht - - hu - - hy - - hz - - ia - - id - - ie - - ig - - ii - - ik - - io - - is - - it - - iu - - ja - - jv - - ka - - kg - - ki - - kj - - kk - - kl - - km - - kn - - ko - - kr - - ks - - ku - - kv - - kw - - ky - - la - - lb - - lg - - li - - ln - - lo - - lt - - lu - - lv - - mg - - mh - - mi - - mk - - ml - - mn - - mr - - ms - - mt - - my - - na - - nb - - nd - - ne - - ng - - nl - - nn - - 'no' - - nr - - nv - - ny - - oc - - oj - - om - - or - - os - - pa - - pi - - pl - - ps - - pt - - qu - - rm - - rn - - ro - - ru - - rw - - sa - - sc - - sd - - se - - sg - - si - - sk - - sl - - sm - - sn - - so - - sq - - sr - - ss - - st - - su - - sv - - sw - - ta - - te - - tg - - th - - ti - - tk - - tl - - tn - - to - - tr - - ts - - tt - - tw - - ty - - ug - - uk - - ur - - uz - - ve - - vi - - vo - - wa - - wo - - xh - - yi - - yo - - za - - zh - - zu - description: Name record for a business partner - NameResponse: - type: object - properties: - value: + description: Exact, official denotation of the status + validFrom: type: string - shortName: + description: Since when the status is/was valid + format: date-time + validTo: type: string + description: Until the status was valid, if applicable + format: date-time type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoNameType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Name record of a business partner - NamedTypeWithLink: - type: object - properties: - name: type: string - url: - type: string - description: General type with name and URL link for further information - PageOutputResponseAddressGateOutput: + description: The type of this specified status + enum: + - ACTIVE + - INACTIVE + description: Status record of a legal entity + LogisticAddressGateDto: type: object properties: - total: - type: integer - format: int32 - nextStartAfter: - type: string - content: - type: array - items: - $ref: '#/components/schemas/AddressGateOutput' - invalidEntries: - type: integer - format: int32 - pending: + nameParts: type: array + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. items: type: string - errors: + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: type: array items: - $ref: '#/components/schemas/ErrorInfoBusinessPartnerOutputError' - description: Paginated collection of results - PageOutputResponseLegalEntityGateOutput: - type: object - properties: - total: - type: integer - format: int32 - nextStartAfter: - type: string - content: + $ref: '#/components/schemas/AddressState' + identifiers: type: array items: - $ref: '#/components/schemas/LegalEntityGateOutput' - invalidEntries: - type: integer - format: int32 - pending: + $ref: '#/components/schemas/AddressIdentifier' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddressGateDto' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + roles: type: array items: type: string - errors: - type: array - items: - $ref: '#/components/schemas/ErrorInfoBusinessPartnerOutputError' - description: Paginated collection of results - PageOutputResponseSiteGateOutput: + enum: + - SUPPLIER + - CUSTOMER + description: Address record for a business partner + PageChangeLogResponseChangelogResponse: type: object properties: - total: + totalElements: + type: integer + format: int64 + totalPages: type: integer format: int32 - nextStartAfter: - type: string - content: - type: array - items: - $ref: '#/components/schemas/SiteGateOutput' - invalidEntries: + page: type: integer format: int32 - pending: - type: array - items: - type: string - errors: - type: array - items: - $ref: '#/components/schemas/ErrorInfoBusinessPartnerOutputError' - description: Paginated collection of results - PageStartAfterResponseAddressGateInputResponse: - type: object - properties: - total: + contentSize: type: integer format: int32 - nextStartAfter: - type: string content: type: array items: - $ref: '#/components/schemas/AddressGateInputResponse' + $ref: '#/components/schemas/ChangelogResponse' invalidEntries: type: integer format: int32 + errors: + type: array + items: + $ref: '#/components/schemas/ErrorInfoChangeLogOutputError' description: Paginated collection of results - PageStartAfterResponseLegalEntityGateInputResponse: + PageResponseAddressGateInputResponse: type: object properties: - total: + totalElements: + type: integer + description: Total number of all results in all pages + format: int64 + totalPages: type: integer + description: Total number pages format: int32 - nextStartAfter: - type: string - content: - type: array - items: - $ref: '#/components/schemas/LegalEntityGateInputResponse' - invalidEntries: + page: type: integer + description: Current page number format: int32 - description: Paginated collection of results - PageStartAfterResponseSiteGateInputResponse: - type: object - properties: - total: + contentSize: type: integer + description: Number of results in the page format: int32 - nextStartAfter: - type: string content: type: array + description: Collection of results in the page items: - $ref: '#/components/schemas/SiteGateInputResponse' - invalidEntries: - type: integer - format: int32 - description: Paginated collection of results - PostalDeliveryPoint: - type: object - properties: - value: - type: string - shortName: - type: string - number: - type: string - type: - type: string - enum: - - INTERURBAN_DELIVERY_POINT - - MAIL_STATION - - MAILBOX - - OTHER - - POST_OFFICE_BOX - description: Postal delivery point record for an address - PostalDeliveryPointResponse: - type: object - properties: - value: - type: string - shortName: - type: string - number: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoPostalDeliveryPointType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Postal delivery point record of an address - Postcode: - type: object - properties: - value: - type: string - type: - type: string - enum: - - CEDEX - - LARGE_MAIL_USER - - OTHER - - POST_BOX - - REGULAR - description: Postcode record for an address - PostcodeResponse: - type: object - properties: - value: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoPostCodeType' - description: Postcode record of an address - Premise: - type: object - properties: - value: - type: string - shortName: - type: string - number: - type: string - type: - type: string - enum: - - BUILDING - - OTHER - - LEVEL - - HARBOUR - - ROOM - - SUITE - - UNIT - - WAREHOUSE - description: Premise record for an address such as building, room or floor - PremiseResponse: - type: object - properties: - value: - type: string - shortName: - type: string - number: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoPremiseType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Premise record of an address such as building, room or floor - RelationResponse: - type: object - properties: - relationClass: - $ref: '#/components/schemas/TypeKeyNameDtoRelationClass' - type: - $ref: '#/components/schemas/TypeKeyNameDtoRelationType' - startNode: - type: string - endNode: - type: string - startedAt: - type: string - format: date-time - endedAt: - type: string - format: date-time - description: Directed relation between two business partners - SiteGateInputRequest: - type: object - properties: - name: - type: string - mainAddress: - $ref: '#/components/schemas/Address' - externalId: - type: string - legalEntityExternalId: - type: string - bpn: - type: string - description: Site with legal entity reference - SiteGateInputResponse: + $ref: '#/components/schemas/AddressGateInputResponse' + description: Paginated collection of results + PageResponseLegalEntityGateInputResponse: type: object properties: - name: - type: string - mainAddress: - $ref: '#/components/schemas/Address' - externalId: - type: string - legalEntityExternalId: - type: string - bpn: - type: string - processStartedAt: - type: string - format: date-time - description: Site with legal entity reference - SiteGateOutput: + totalElements: + type: integer + description: Total number of all results in all pages + format: int64 + totalPages: + type: integer + description: Total number pages + format: int32 + page: + type: integer + description: Current page number + format: int32 + contentSize: + type: integer + description: Number of results in the page + format: int32 + content: + type: array + description: Collection of results in the page + items: + $ref: '#/components/schemas/LegalEntityGateInputResponse' + description: Paginated collection of results + PageResponseLegalEntityGateOutputResponse: type: object properties: - name: - type: string - mainAddress: - $ref: '#/components/schemas/AddressResponse' - externalId: - type: string - bpn: - type: string - legalEntityBpn: - type: string - description: Site with legal entity reference. - Thoroughfare: + totalElements: + type: integer + description: Total number of all results in all pages + format: int64 + totalPages: + type: integer + description: Total number pages + format: int32 + page: + type: integer + description: Current page number + format: int32 + contentSize: + type: integer + description: Number of results in the page + format: int32 + content: + type: array + description: Collection of results in the page + items: + $ref: '#/components/schemas/LegalEntityGateOutputResponse' + description: Paginated collection of results + PageResponseSharingState: type: object properties: - value: - type: string - name: - type: string - shortName: - type: string - number: - type: string - direction: - type: string - type: - type: string - enum: - - INDUSTRIAL_ZONE - - OTHER - - RIVER - - SQUARE - - STREET - description: Thoroughfare record for an address such as street, square or industrial zone - ThoroughfareResponse: + totalElements: + type: integer + description: Total number of all results in all pages + format: int64 + totalPages: + type: integer + description: Total number pages + format: int32 + page: + type: integer + description: Current page number + format: int32 + contentSize: + type: integer + description: Number of results in the page + format: int32 + content: + type: array + description: Collection of results in the page + items: + $ref: '#/components/schemas/SharingState' + description: Paginated collection of results + PageResponseSiteGateInputResponse: type: object properties: - value: - type: string - name: - type: string - shortName: - type: string - number: - type: string - direction: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoThoroughfareType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Thoroughfare record of an address such as street, square or industrial zone - TypeKeyNameDtoCharacterSet: + totalElements: + type: integer + description: Total number of all results in all pages + format: int64 + totalPages: + type: integer + description: Total number pages + format: int32 + page: + type: integer + description: Current page number + format: int32 + contentSize: + type: integer + description: Number of results in the page + format: int32 + content: + type: array + description: Collection of results in the page + items: + $ref: '#/components/schemas/SiteGateInputResponse' + description: Paginated collection of results + PageResponseSiteGateOutputResponse: type: object properties: - technicalKey: - type: string - enum: - - ARABIC - - CHINESE - - CHINESE_TRADITIONAL - - CYRILLIC - - GREEK - - HANGUL_KOREAN - - HEBREW - - HIRAGANA - - KANJI - - KATAKANA - - LATIN - - THAI - - WESTERN_LATIN_STANDARD - - UNDEFINED - name: - type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoCountryCode: + totalElements: + type: integer + description: Total number of all results in all pages + format: int64 + totalPages: + type: integer + description: Total number pages + format: int32 + page: + type: integer + description: Current page number + format: int32 + contentSize: + type: integer + description: Number of results in the page + format: int32 + content: + type: array + description: Collection of results in the page + items: + $ref: '#/components/schemas/SiteGateOutputResponse' + description: Paginated collection of results + PhysicalPostalAddressGateDto: type: object properties: - technicalKey: + geographicCoordinates: + $ref: '#/components/schemas/GeoCoordinates' + country: type: string + description: Describes the country enum: - UNDEFINED - AC @@ -3170,645 +1966,239 @@ components: - ZM - ZR - ZW - name: + postalCode: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoCurrencyCode: - type: object - properties: - technicalKey: + description: A postal code, also known as postcode, PIN or ZIP Code + city: type: string - enum: - - UNDEFINED - - AED - - AFN - - ALL - - AMD - - ANG - - AOA - - ARS - - AUD - - AWG - - AZN - - BAM - - BBD - - BDT - - BGN - - BHD - - BIF - - BMD - - BND - - BOB - - BOV - - BRL - - BSD - - BTN - - BWP - - BYN - - BYR - - BZD - - CAD - - CDF - - CHE - - CHF - - CHW - - CLF - - CLP - - CNY - - COP - - COU - - CRC - - CUC - - CUP - - CVE - - CZK - - DJF - - DKK - - DOP - - DZD - - EGP - - ERN - - ETB - - EUR - - FJD - - FKP - - GBP - - GEL - - GHS - - GIP - - GMD - - GNF - - GTQ - - GYD - - HKD - - HNL - - HRK - - HTG - - HUF - - IDR - - ILS - - INR - - IQD - - IRR - - ISK - - JMD - - JOD - - JPY - - KES - - KGS - - KHR - - KMF - - KPW - - KRW - - KWD - - KYD - - KZT - - LAK - - LBP - - LKR - - LRD - - LSL - - LTL - - LYD - - MAD - - MDL - - MGA - - MKD - - MMK - - MNT - - MOP - - MRO - - MRU - - MUR - - MVR - - MWK - - MXN - - MXV - - MYR - - MZN - - NAD - - NGN - - NIO - - NOK - - NPR - - NZD - - OMR - - PAB - - PEN - - PGK - - PHP - - PKR - - PLN - - PYG - - QAR - - RON - - RSD - - RUB - - RUR - - RWF - - SAR - - SBD - - SCR - - SDG - - SEK - - SGD - - SHP - - SLL - - SOS - - SRD - - SSP - - STD - - STN - - SVC - - SYP - - SZL - - THB - - TJS - - TMT - - TND - - TOP - - TRY - - TTD - - TWD - - TZS - - UAH - - UGX - - USD - - USN - - USS - - UYI - - UYU - - UZS - - VEF - - VES - - VND - - VUV - - WST - - XAF - - XAG - - XAU - - XBA - - XBB - - XBC - - XBD - - XCD - - XDR - - XOF - - XPD - - XPF - - XPT - - XSU - - XTS - - XUA - - XXX - - YER - - ZAR - - ZMW - - ZWL - name: + description: 'The city of the address (Synonym: Town, village, municipality)' + street: + $ref: '#/components/schemas/StreetGate' + administrativeAreaLevel1: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoLanguageCode: - type: object - properties: - technicalKey: + description: Identifying code of the Region within the country (e.g. Bayern) + administrativeAreaLevel2: type: string - enum: - - undefined - - aa - - ab - - ae - - af - - ak - - am - - an - - ar - - as - - av - - ay - - az - - ba - - be - - bg - - bh - - bi - - bm - - bn - - bo - - br - - bs - - ca - - ce - - ch - - co - - cr - - cs - - cu - - cv - - cy - - da - - de - - dv - - dz - - ee - - el - - en - - eo - - es - - et - - eu - - fa - - ff - - fi - - fj - - fo - - fr - - fy - - ga - - gd - - gl - - gn - - gu - - gv - - ha - - he - - hi - - ho - - hr - - ht - - hu - - hy - - hz - - ia - - id - - ie - - ig - - ii - - ik - - io - - is - - it - - iu - - ja - - jv - - ka - - kg - - ki - - kj - - kk - - kl - - km - - kn - - ko - - kr - - ks - - ku - - kv - - kw - - ky - - la - - lb - - lg - - li - - ln - - lo - - lt - - lu - - lv - - mg - - mh - - mi - - mk - - ml - - mn - - mr - - ms - - mt - - my - - na - - nb - - nd - - ne - - ng - - nl - - nn - - 'no' - - nr - - nv - - ny - - oc - - oj - - om - - or - - os - - pa - - pi - - pl - - ps - - pt - - qu - - rm - - rn - - ro - - ru - - rw - - sa - - sc - - sd - - se - - sg - - si - - sk - - sl - - sm - - sn - - so - - sq - - sr - - ss - - st - - su - - sv - - sw - - ta - - te - - tg - - th - - ti - - tk - - tl - - tn - - to - - tr - - ts - - tt - - tw - - ty - - ug - - uk - - ur - - uz - - ve - - vi - - vo - - wa - - wo - - xh - - yi - - yo - - za - - zh - - zu - name: + description: Further possibility to describe the region/address(e.g. County/Landkreis) + administrativeAreaLevel3: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoRelationClass: - type: object - properties: - technicalKey: + description: Further possibility to describe the region/address(e.g. Township/Gemeinde) + district: type: string - enum: - - SAAS_HIERARCHY - - SAAS_TRANSITION - - CX_HIERARCHY - - DNB_HIERARCHY - - LEI_HIERARCHY - name: + description: Divides the city in several smaller areas + companyPostalCode: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoRelationType: - type: object - properties: - technicalKey: + description: A separate postal code for a company, also known as postcode, PIN or ZIP Code + industrialZone: type: string - enum: - - CX_LEGAL_SUCCESSOR_OF - - CX_LEGAL_PREDECESSOR_OF - - CX_ADDRESS_OF - - CX_SITE_OF - - CX_OWNED_BY - - DIRECT_LEGAL_RELATION - - COMMERCIAL_ULTIMATE - - DOMESTIC_BRANCH_RELATION - - INTERNATIONAL_BRANCH_RELATION - - DOMESTIC_LEGAL_ULTIMATE_RELATION - - GLOBAL_LEGAL_ULTIMATE_RELATION - - LEGAL_PREDECESSOR - - LEGAL_SUCCESSOR - - DNB_PARENT - - DNB_HEADQUARTER - - DNB_DOMESTIC_ULTIMATE - - DNB_GLOBAL_ULTIMATE - - LEI_DIRECT_PARENT - - LEI_INTERNATIONAL_BRANCH - - LEI_ULTIMATE_PARENT - name: + description: The practice of designating an area for industrial development + building: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoString: - type: object - properties: - technicalKey: + description: Describes a specific building within the address + floor: type: string - name: + description: Describes the floor/level the delivery shall take place + door: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameUrlDtoAddressType: + description: Describes the door/room/suite on the respective floor the delivery shall take place + description: Physical Postal Address Part + SharingState: type: object properties: - technicalKey: + lsaType: type: string + description: LSA Type enum: - - BRANCH_OFFICE - - CARE_OF - - HEADQUARTER - - LEGAL_ALTERNATIVE - - PO_BOX - - REGISTERED - - REGISTERED_AGENT_MAIL - - REGISTERED_AGENT_PHYSICAL - - VAT_REGISTERED - - UNSPECIFIC - name: - type: string - url: + - LEGAL_ENTITY + - SITE + - ADDRESS + externalId: type: string - TypeKeyNameUrlDtoAdministrativeAreaType: - type: object - properties: - technicalKey: + description: External identifier + sharingStateType: type: string + description: Type of sharing state enum: - - COUNTY - - REGION - - OTHER - name: - type: string - url: - type: string - TypeKeyNameUrlDtoBusinessPartnerType: - type: object - properties: - technicalKey: + - Pending + - Success + - Error + sharingErrorCode: type: string + description: BusinessPartnerSharingError enum: - - BRAND - - LEGAL_ENTITY - - ORGANIZATIONAL_UNIT - - SITE - - UNKNOWN - name: + - SharingProcessError + - SharingTimeout + - BpnNotInPool + sharingErrorMessage: type: string - url: + description: Sharing error message (for error) + bpn: + type: string + description: BPN (for success) + sharingProcessStarted: type: string - TypeKeyNameUrlDtoBusinessStatusType: + description: Sharing process started (not updated if null) + format: date-time + SiteGateInputRequest: type: object properties: - technicalKey: - type: string - enum: - - ACTIVE - - DISSOLVED - - IN_LIQUIDATION - - INACTIVE - - INSOLVENCY - - UNKNOWN - name: + nameParts: + type: array + description: Parts that make up the name of that site + items: + type: string + description: Parts that make up the name of that site + states: + type: array + items: + $ref: '#/components/schemas/SiteState' + roles: + type: array + items: + type: string + enum: + - SUPPLIER + - CUSTOMER + mainAddress: + $ref: '#/components/schemas/LogisticAddressGateDto' + externalId: type: string - url: + legalEntityExternalId: type: string - TypeKeyNameUrlDtoLocalityType: + description: Site with legal entity reference + SiteGateInputResponse: type: object properties: - technicalKey: - type: string - enum: - - BLOCK - - CITY - - DISTRICT - - OTHER - - POST_OFFICE_CITY - - QUARTER - name: + nameParts: + type: array + description: Parts that make up the name of that site + items: + type: string + description: Parts that make up the name of that site + states: + type: array + items: + $ref: '#/components/schemas/SiteState' + roles: + type: array + items: + type: string + enum: + - SUPPLIER + - CUSTOMER + mainAddress: + $ref: '#/components/schemas/AddressGateInputResponse' + externalId: type: string - url: + legalEntityExternalId: type: string - TypeKeyNameUrlDtoNameType: + description: Site with legal entity reference + SiteGateOutputRequest: type: object properties: - technicalKey: + nameParts: + type: array + description: Parts that make up the name of that site + items: + type: string + description: Parts that make up the name of that site + states: + type: array + items: + $ref: '#/components/schemas/SiteState' + roles: + type: array + items: + type: string + enum: + - SUPPLIER + - CUSTOMER + mainAddress: + $ref: '#/components/schemas/AddressGateOutputChildRequest' + externalId: type: string - enum: - - ACRONYM - - DOING_BUSINESS_AS - - ESTABLISHMENT - - INTERNATIONAL - - LOCAL - - OTHER - - REGISTERED - - TRANSLITERATED - - VAT_REGISTERED - name: + legalEntityExternalId: type: string - url: + bpn: type: string - TypeKeyNameUrlDtoPostCodeType: + description: Site with legal entity reference + SiteGateOutputResponse: type: object properties: - technicalKey: + nameParts: + type: array + description: Parts that make up the name of that site + items: + type: string + description: Parts that make up the name of that site + states: + type: array + items: + $ref: '#/components/schemas/SiteState' + roles: + type: array + items: + type: string + enum: + - SUPPLIER + - CUSTOMER + mainAddress: + $ref: '#/components/schemas/AddressGateInputResponse' + externalId: type: string - enum: - - CEDEX - - LARGE_MAIL_USER - - OTHER - - POST_BOX - - REGULAR - name: + legalEntityExternalId: type: string - url: + bpn: type: string - TypeKeyNameUrlDtoPostalDeliveryPointType: + description: Site with legal entity reference + SiteState: type: object properties: - technicalKey: + description: type: string - enum: - - INTERURBAN_DELIVERY_POINT - - MAIL_STATION - - MAILBOX - - OTHER - - POST_OFFICE_BOX - name: + description: Description of the status + validFrom: type: string - url: + description: Since when the status is/was valid + format: date-time + validTo: type: string - TypeKeyNameUrlDtoPremiseType: - type: object - properties: - technicalKey: + description: Until the status was valid, if applicable + format: date-time + type: type: string + description: The type of this specified status enum: - - BUILDING - - OTHER - - LEVEL - - HARBOUR - - ROOM - - SUITE - - UNIT - - WAREHOUSE - name: - type: string - url: - type: string - TypeKeyNameUrlDtoString: + - ACTIVE + - INACTIVE + description: Status record of a site + StreetGate: type: object properties: - technicalKey: + namePrefix: type: string + description: Describes the official name prefix of the Street. + additionalNamePrefix: + type: string + description: Describes the additional name prefix of the Street. name: type: string - url: + description: Describes the Name of the Street. + additionalNameSuffix: type: string - TypeKeyNameUrlDtoThoroughfareType: - type: object - properties: - technicalKey: + description: Describes the additional name suffix of the Street. + houseNumber: type: string - enum: - - INDUSTRIAL_ZONE - - OTHER - - RIVER - - SQUARE - - STREET - name: + description: Describes the House Number + milestone: type: string - url: + description: The Milestone is relevant for long roads without specific house numbers. + direction: type: string - TypeMatchResponse: - type: object - properties: - score: - type: number - format: float - type: + description: Describes the direction + nameSuffix: type: string - enum: - - LegalEntity - - Site - - Address - - None + description: Describes the name suffix of the Street. + description: A public road in a city, town, or village, typically with houses and buildings on one or both sides. Unit: type: object - ValidationResponse: - type: object - properties: - status: - type: string - enum: - - OK - - ERROR - errors: - type: array - items: - type: string - description: Contains overall result of a sharing process validation request diff --git a/docs/api/pool.json b/docs/api/pool.json index 2181e21a3..9a868b4c8 100644 --- a/docs/api/pool.json +++ b/docs/api/pool.json @@ -3,7 +3,7 @@ "info": { "title": "Business Partner Data Management Pool", "description": "Service that manages and shares business partner data with other CatenaX services", - "version": "4.0.0" + "version": "4.0.0-SNAPSHOT" }, "servers": [ { @@ -34,21 +34,18 @@ "required": true }, "responses": { + "400": { + "description": "On malformed requests" + }, "200": { - "description": "The successfully updated records", + "description": "Update sites request was processed successfully, possible errors are returned", "content": { - "*/*": { + "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/SitePartnerCreateResponse" - } + "$ref": "#/components/schemas/SiteUpdateWrapper" } } } - }, - "400": { - "description": "On malformed requests" } } }, @@ -73,21 +70,18 @@ "required": true }, "responses": { + "400": { + "description": "On malformed requests" + }, "200": { - "description": "New business partner record successfully created", + "description": "New sites request was processed successfully, possible errors are returned", "content": { - "*/*": { + "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/SitePartnerCreateResponse" - } + "$ref": "#/components/schemas/SiteCreateWrapper" } } } - }, - "400": { - "description": "On malformed requests" } } } @@ -98,11 +92,11 @@ "legal-entity-controller" ], "summary": "Get page of legal entity business partners matching the search criteria", - "description": "This endpoint tries to find matches among all existing business partners of type legal entity, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score.", + "description": "This endpoint tries to find matches among all existing business partners of type legal entity, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. Note that when using search parameters the max page is 20.", "operationId": "getLegalEntities", "parameters": [ { - "name": "name", + "name": "legalName", "in": "query", "description": "Filter legal entities by name", "required": false, @@ -110,96 +104,6 @@ "type": "string" } }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, { "name": "page", "in": "query", @@ -228,7 +132,7 @@ "200": { "description": "Page of business partners matching the search criteria, may be empty", "content": { - "*/*": { + "application/json": { "schema": { "$ref": "#/components/schemas/PageResponseLegalEntityMatchResponse" } @@ -253,7 +157,7 @@ "schema": { "type": "array", "items": { - "$ref": "#/components/schemas/LegalEntityUpdateRequest" + "$ref": "#/components/schemas/LegalEntityPartnerUpdateRequest" } } } @@ -261,24 +165,18 @@ "required": true }, "responses": { + "400": { + "description": "On malformed requests" + }, "200": { - "description": "The successfully updated records", + "description": "Update legal entities request was processed successfully, possible errors are returned", "content": { - "*/*": { + "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LegalEntityPartnerCreateResponse" - } + "$ref": "#/components/schemas/LegalEntityUpdateWrapper" } } } - }, - "400": { - "description": "On malformed requests" - }, - "404": { - "description": "Metadata referenced by technical key not found" } } }, @@ -303,24 +201,18 @@ "required": true }, "responses": { + "400": { + "description": "On malformed requests" + }, "200": { - "description": "New business partner record successfully created", + "description": "New legal entities request was processed successfully, possible errors are returned", "content": { - "*/*": { + "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LegalEntityPartnerCreateResponse" - } + "$ref": "#/components/schemas/LegalEntityCreateWrapper" } } } - }, - "400": { - "description": "On malformed requests" - }, - "404": { - "description": "Metadata referenced by technical key not found" } } } @@ -331,4187 +223,1898 @@ "address-controller" ], "summary": "Get page of addresses matching the search criteria", - "description": "This endpoint tries to find matches among all existing business partners of type address, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score.", + "description": "This endpoint tries to find matches among all existing business partners of type address, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. Note that when using search parameters the max page is 20.", "operationId": "getAddresses_1", "parameters": [ { - "name": "administrativeArea", + "name": "name", "in": "query", - "description": "Filter business partners by administrative area name", + "description": "Filter business partners by name", "required": false, "schema": { "type": "string" } }, { - "name": "postCode", + "name": "page", "in": "query", - "description": "Filter business partners by postcode or postcodes", + "description": "Number of page to get results from", "required": false, "schema": { - "type": "string" + "minimum": 0, + "type": "string", + "default": "0" } }, { - "name": "locality", + "name": "size", "in": "query", - "description": "Filter business partners by locality full denotation", + "description": "Size of each page", "required": false, "schema": { - "type": "string" + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } + ], + "responses": { + "200": { + "description": "Page of addresses matching the search criteria, may be empty", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageResponseAddressMatchResponse" + } + } } }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" + "400": { + "description": "On malformed search or pagination request" + } + } + }, + "put": { + "tags": [ + "address-controller" + ], + "summary": "Update existing address business partners", + "description": "Update existing business partner records of type address referenced via BPNA. The endpoint expects to receive the full updated record, including values that didn't change.", + "operationId": "updateAddresses", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressPartnerUpdateRequest" + } + } } }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" + "required": true + }, + "responses": { + "400": { + "description": "On malformed requests" + }, + "200": { + "description": "The successfully updated records, possible errors are returned", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AddressUpdateWrapper" + } + } + } + } + } + }, + "post": { + "tags": [ + "address-controller" + ], + "summary": "Create new address business partners", + "description": "Create new business partners of type address by specifying the BPN of the parent each address belongs to. A parent can be either a site or legal entity business partner. If the parent cannot be found, the record is ignored.For matching purposes, on each record you can specify your own index value which will reappear in the corresponding record of the response.", + "operationId": "createAddresses", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressPartnerCreateRequest" + } + } } }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" + "required": true + }, + "responses": { + "400": { + "description": "On malformed requests" + }, + "200": { + "description": "New business partner record successfully created, possible errors are returned", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AddressCreateWrapper" + } + } + } + } + } + } + }, + "/api/opensearch/business-partner": { + "get": { + "tags": [ + "open-search-controller" + ], + "summary": "Fetch information about the latest OpenSearch export", + "description": "Fetch information about the latest export (either ongoing or already finished)", + "operationId": "getBusinessPartners", + "responses": { + "200": { + "description": "Export information found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SyncResponse" + } + } } }, - { - "name": "countryCode", - "in": "query", - "description": "Filter business partners by ISO 3166-1 alpha-2 country code", - "required": false, - "schema": { - "type": "string", - "enum": [ - "UNDEFINED", - "AC", - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AN", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BU", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CP", - "CR", - "CS", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DG", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EA", - "EC", - "EE", - "EG", - "EH", - "ER", - "ES", - "ET", - "EU", - "EZ", - "FI", - "FJ", - "FK", - "FM", - "FO", - "FR", - "FX", - "GA", - "GB", - "GD", - "GE", - "GF", - "GG", - "GH", - "GI", - "GL", - "GM", - "GN", - "GP", - "GQ", - "GR", - "GS", - "GT", - "GU", - "GW", - "GY", - "HK", - "HM", - "HN", - "HR", - "HT", - "HU", - "IC", - "ID", - "IE", - "IL", - "IM", - "IN", - "IO", - "IQ", - "IR", - "IS", - "IT", - "JE", - "JM", - "JO", - "JP", - "KE", - "KG", - "KH", - "KI", - "KM", - "KN", - "KP", - "KR", - "KW", - "KY", - "KZ", - "LA", - "LB", - "LC", - "LI", - "LK", - "LR", - "LS", - "LT", - "LU", - "LV", - "LY", - "MA", - "MC", - "MD", - "ME", - "MF", - "MG", - "MH", - "MK", - "ML", - "MM", - "MN", - "MO", - "MP", - "MQ", - "MR", - "MS", - "MT", - "MU", - "MV", - "MW", - "MX", - "MY", - "MZ", - "NA", - "NC", - "NE", - "NF", - "NG", - "NI", - "NL", - "NO", - "NP", - "NR", - "NT", - "NU", - "NZ", - "OM", - "PA", - "PE", - "PF", - "PG", - "PH", - "PK", - "PL", - "PM", - "PN", - "PR", - "PS", - "PT", - "PW", - "PY", - "QA", - "RE", - "RO", - "RS", - "RU", - "RW", - "SA", - "SB", - "SC", - "SD", - "SE", - "SF", - "SG", - "SH", - "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SU", - "SV", - "SX", - "SY", - "SZ", - "TA", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TP", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UK", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XI", - "XU", - "XK", - "YE", - "YT", - "YU", - "ZA", - "ZM", - "ZR", - "ZW" - ] - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Page of addresses matching the search criteria, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseAddressMatchResponse" - } - } - } - }, - "400": { - "description": "On malformed search or pagination request" - } - } - }, - "put": { - "tags": [ - "address-controller" - ], - "summary": "Update existing address business partners", - "description": "Update existing business partner records of type address referenced via BPNA. The endpoint expects to receive the full updated record, including values that didn't change.", - "operationId": "updateAddresses", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AddressPartnerUpdateRequest" - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "The successfully updated records", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AddressPartnerResponse" - } - } - } - } - }, - "400": { - "description": "On malformed requests" - } - } - }, - "post": { - "tags": [ - "address-controller" - ], - "summary": "Create new address business partners", - "description": "Create new business partners of type address by specifying the BPN of the parent each address belongs to. A parent can be either a site or legal entity business partner. If the parent cannot be found, the record is ignored.For matching purposes, on each record you can specify your own index value which will reappear in the corresponding record of the response.", - "operationId": "createAddresses", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AddressPartnerCreateRequest" - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "New business partner record successfully created", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AddressPartnerCreateResponse" - } - } - } - } - }, - "400": { - "description": "On malformed requests" - } - } - } - }, - "/api/saas/business-partner/sync": { - "get": { - "tags": [ - "saas-controller" - ], - "summary": "Fetch information about the SaaS synchronization", - "description": "Fetch information about the latest import (either ongoing or already finished)", - "operationId": "getSyncStatus", - "responses": { - "200": { - "description": "Import information found", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/SyncResponse" - } - } - } - }, - "500": { - "description": "Fetching failed (no connection to database)" - } - } - }, - "post": { - "tags": [ - "saas-controller" - ], - "summary": "Import new business partner records from SaaS", - "description": "Triggers an asynchronous import of new business partner records from SaaS. A SaaS record counts as new when it does not have a BPN and the BPDM service does not already have a record with the same SaaS ID. This import only regards records with a modifiedAfter timestamp since the last import.", - "operationId": "importBusinessPartners", - "responses": { - "200": { - "description": "Import successfully started", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/SyncResponse" - } - } - } - }, - "409": { - "description": "Import already running", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/SyncResponse" - } - } - } - }, - "500": { - "description": "Import couldn't start to unexpected error" - } - } - } - }, - "/api/opensearch/business-partner": { - "get": { - "tags": [ - "open-search-controller" - ], - "summary": "Fetch information about the latest OpenSearch export", - "description": "Fetch information about the latest export (either ongoing or already finished)", - "operationId": "getBusinessPartners", - "responses": { - "200": { - "description": "Export information found", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/SyncResponse" - } - } - } - }, - "500": { - "description": "Fetching failed (no connection to database)" - } - } - }, - "post": { - "tags": [ - "open-search-controller" - ], - "summary": "Index new business partner records on OpenSearch", - "description": "Triggers an asynchronous export of business partner records from BPDM to OpenSearch. Only exports records which have been updated since the last export. ", - "operationId": "export", - "responses": { - "200": { - "description": "Export of records successfully", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/SyncResponse" - } - } - } - }, - "500": { - "description": "Export failed (no connection to OpenSearch or database)" - } - } - }, - "delete": { - "tags": [ - "open-search-controller" - ], - "summary": "Clear business partner index on OpenSearch", - "description": "Deletes all business partner records in the OpenSearch index. Also resets the timestamp from the last export.", - "operationId": "clear", - "responses": { - "200": { - "description": "Index successfully cleared" - }, - "500": { - "description": "Clearing failed (no connection to OpenSearch or database)" - } - } - } - }, - "/api/catena/sites/search": { - "post": { - "tags": [ - "site-controller" - ], - "summary": "Search site partners by BPNs and/or parent BPNs", - "description": "Search business partners of type site by their BPNSs or by the BPNLs of their parent legal entities", - "operationId": "searchSites", - "parameters": [ - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SiteBpnSearchRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Found sites that belong to specified legal entites", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSitePartnerSearchResponse" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - } - } - } - }, - "/api/catena/sites/main-addresses/search": { - "post": { - "tags": [ - "site-controller" - ], - "summary": "Search Main Addresses", - "description": "Search main addresses of site business partners by BPNS", - "operationId": "searchMainAddresses", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "The found main addresses", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/MainAddressSearchResponse" - } - } - } - } - }, - "400": { - "description": "On malformed request parameters" - } - } - } - }, - "/api/catena/legal-forms": { - "get": { - "tags": [ - "metadata-controller" - ], - "summary": "Get page of legal forms", - "description": "Lists all currently known legal forms in a paginated result", - "operationId": "getLegalForms", - "parameters": [ - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Page of existing legal forms, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseLegalFormResponse" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - } - } - }, - "post": { - "tags": [ - "metadata-controller" - ], - "summary": "Create new legal form", - "description": "Create a new legal form which can be referenced by business partner records. The actual name of the legal form is free to choose and doesn't need to be unique. The technical key can be freely chosen but needs to be unique as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.", - "operationId": "createLegalForm", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LegalFormRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "New legal form successfully created", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/LegalFormResponse" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - }, - "409": { - "description": "Legal form with specified technical key already exists" - } - } - } - }, - "/api/catena/legal-entities/{bpn}/confirm-up-to-date": { - "post": { - "tags": [ - "legal-entity-controller" - ], - "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.", - "operationId": "setLegalEntityCurrentness", - "parameters": [ - { - "name": "bpn", - "in": "path", - "description": "Bpn value", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Business partner's \"currentness\" successfully updated" - }, - "400": { - "description": "On malformed request parameters" - }, - "404": { - "description": "No business partner found for specified bpn" - } - } - } - }, - "/api/catena/legal-entities/search": { - "post": { - "tags": [ - "legal-entity-controller" - ], - "summary": "Search legal entity partners by BPNLs", - "description": "Search legal entity partners by their BPNLs. The response can contain less results than the number of BPNLs that were requested, if some of the BPNLs did not exist. For a single request, the maximum number of BPNLs to search for is limited to 5000 entries.", - "operationId": "searchSites_1", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Found legal entites", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LegalEntityPartnerResponse" - } - } - } - } - }, - "400": { - "description": "On malformed request parameters or if number of requested bpns exceeds limit" - } - } - } - }, - "/api/catena/legal-entities/legal-addresses/search": { - "post": { - "tags": [ - "legal-entity-controller" - ], - "summary": "Search Legal Addresses", - "description": "Search legal addresses of legal entities by BPNL", - "operationId": "searchLegalAddresses", - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "The found legal addresses", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LegalAddressSearchResponse" - } - } - } - } - }, - "400": { - "description": "On malformed request parameters" - } - } - } - }, - "/api/catena/issuing-bodies": { - "get": { - "tags": [ - "metadata-controller" - ], - "summary": "Get page of issuing bodies", - "description": "Lists all currently known issuing bodies in a paginated result", - "operationId": "getIssuingBodies", - "parameters": [ - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Page of existing issuing bodies, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseTypeKeyNameUrlDtoString" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - } - } - }, - "post": { - "tags": [ - "metadata-controller" - ], - "summary": "Create new issuing body", - "description": "Create a new issuing body which can be referenced by business partner records. An issuing body should be an entity which the Catena organisation trusts to issue identifiers.The actual name of the issuing body is free to choose and doesn't need to be unique. The technical key can be freely chosen but needs to be unique as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.", - "operationId": "createIssuingBody", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "New issuing body successfully created", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - }, - "409": { - "description": "Issuing body with specified technical key already exists" - } - } - } - }, - "/api/catena/identifier-types": { - "get": { - "tags": [ - "metadata-controller" - ], - "summary": "Get page of identifier types", - "description": "Lists all currently known identifier types in a paginated result", - "operationId": "getIdentifierTypes", - "parameters": [ - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Page of existing identifier types, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseTypeKeyNameUrlDtoString" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - } - } - }, - "post": { - "tags": [ - "metadata-controller" - ], - "summary": "Create new identifier type", - "description": "Create a new identifier type which can be referenced by business partner records. Identifier types such as BPN or VAT determine with which kind of values a business partner can be identified with. The actual name of the identifier type is free to choose and doesn't need to be unique. The technical key can be freely chosen but needs to be unique as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.", - "operationId": "createIdentifierType", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "New identifier type successfully created", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - }, - "409": { - "description": "Identifier type with specified technical key already exists" - } - } - } - }, - "/api/catena/identifier-status": { - "get": { - "tags": [ - "metadata-controller" - ], - "summary": "Get page of identifier statuses", - "description": "Lists all currently known identifier statuses in a paginated result", - "operationId": "getIdentifierStati", - "parameters": [ - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Page of existing identifier statuses, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseTypeKeyNameDtoString" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - } - } - }, - "post": { - "tags": [ - "metadata-controller" - ], - "summary": "Create new identifier status", - "description": "Create a new identifier status which can be referenced by business partner records. A status further distinguishes an identifier by adding current status information such as active or revoked.The actual name of the identifier status is free to choose and doesn't need to be unique. The technical key can be freely chosen but needs to be unique as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.", - "operationId": "createIdentifierStatus", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TypeKeyNameDtoString" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "New identifier status successfully created", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/TypeKeyNameDtoString" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - }, - "409": { - "description": "Identifier status with specified technical key already exists" - } - } - } - }, - "/api/catena/bpn/search": { - "post": { - "tags": [ - "bpn-controller" - ], - "summary": "Find business partner numbers by identifiers", - "description": "Find business partner numbers by identifiers. The response can contain less results than the number of identifier values that were requested, if some of the identifiers did not exist. For a single request, the maximum number of identifier values to search for is limited to 5000 entries.", - "operationId": "findBpnsByIdentifiers", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IdentifiersSearchRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Found bpn to identifier value mappings", - "content": { - "*/*": { - "schema": { - "uniqueItems": true, - "type": "array", - "items": { - "$ref": "#/components/schemas/BpnIdentifierMappingResponse" - } - } - } - } - }, - "400": { - "description": "On malformed request parameters or if number of requested bpns exceeds limit" - }, - "404": { - "description": "Specified identifier type not found" - } - } - } - }, - "/api/catena/addresses/search": { - "post": { - "tags": [ - "address-controller" - ], - "summary": "Search address partners by BPNs and/or parent BPNs", - "description": "Search business partners of type address by their BPN or their parent partners BPN (BPNLs or BPNS).", - "operationId": "searchAddresses", - "parameters": [ - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AddressPartnerBpnSearchRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "Found sites for the specified sites and legal entities", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseAddressPartnerSearchResponse" - } - } - } - }, - "400": { - "description": "On malformed pagination request" - } - } - } - }, - "/api/catena/suggestions/sites/names": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in business partner sites", - "description": "Performs search on site names in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible site names in the search set.", - "operationId": "getSiteSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show site names best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/legal-entities/statuses": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in business statuses", - "description": "Performs search on business status denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible business status denotations in the search set.", - "operationId": "getStatusSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show business status denotations best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/legal-entities/names": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in business partner names", - "description": "Performs search on business partner names in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible names in the search set.", - "operationId": "getNameSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show names best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/legal-entities/legal-forms": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in business partner legal forms", - "description": "Performs search on legal form names in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible legal form names in the search set.", - "operationId": "getLegalFormSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show legal form names best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/legal-entities/classifications": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in business partner classifications", - "description": "Performs search on business partner classifications in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible business partner classifications in the search set.", - "operationId": "getClassificationSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show business partner classifications best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/addresses/thoroughfares": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in thoroughfares", - "description": "Performs search on thoroughfare denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible thoroughfare names in the search set.", - "operationId": "getThoroughfareSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show thoroughfare names best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/addresses/premises": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in premises", - "description": "Performs search on premise denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible premise names in the search set.", - "operationId": "getPremiseSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show premise names best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/addresses/postcodes": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in postcodes", - "description": "Performs search on postcode values in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible postcode values in the search set.", - "operationId": "getPostcodeSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show postcodes best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/addresses/postal-delivery-points": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in postal delivery points", - "description": "Performs search on postal delivery point denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible postal delivery point names in the search set.", - "operationId": "getPostalDeliverPointSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show postal delivery point names best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/addresses/localities": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in localities", - "description": "Performs search on locality denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible locality names in the search set.", - "operationId": "getLocalitySuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show locality names this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/suggestions/addresses/administrative-areas": { - "get": { - "tags": [ - "suggestion-controller" - ], - "summary": "Find best matches for given text in administrative areas", - "description": "Performs search on administrative area names in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible administrative area names in the search set.", - "operationId": "getAdminAreaSuggestion", - "parameters": [ - { - "name": "text", - "in": "query", - "description": "Show administrative area names best matching this text", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Best matches found, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSuggestionResponse" - } - } - } - } - } - } - }, - "/api/catena/sites/{bpn}": { - "get": { - "tags": [ - "site-controller" - ], - "summary": "Get site partners by bpn", - "description": "Get business partners of type site by bpn-s ignoring case.", - "operationId": "getSite", - "parameters": [ - { - "name": "bpn", - "in": "path", - "description": "Bpn value", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Found site with specified bpn", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/SitePartnerSearchResponse" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - }, - "404": { - "description": "No site found under specified bpn" - } - } - } - }, - "/api/catena/legal-entities/{idValue}": { - "get": { - "tags": [ - "legal-entity-controller" - ], - "summary": "Get legal entity business partner by identifier", - "description": "This endpoint tries to find a business partner by the specified identifier. The identifier value is case insensitively compared but needs to be given exactly. By default the value given is interpreted as a BPN. By specifying the technical key of another identifier typethe value is matched against the identifiers of that given type.", - "operationId": "getLegalEntity", - "parameters": [ - { - "name": "idValue", - "in": "path", - "description": "Identifier value", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "idType", - "in": "query", - "description": "Type of identifier to use, defaults to BPN when omitted", - "required": false, - "schema": { - "type": "string", - "default": "BPN" - } - } - ], - "responses": { - "200": { - "description": "Found business partner with specified identifier", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/LegalEntityPartnerResponse" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - }, - "404": { - "description": "No business partner found under specified identifier or specified identifier type not found" - } - } - } - }, - "/api/catena/legal-entities/{bpn}/sites": { - "get": { - "tags": [ - "legal-entity-controller" - ], - "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.", - "operationId": "getSites", - "parameters": [ - { - "name": "bpn", - "in": "path", - "description": "Bpn value", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "The sites for the specified bpn", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseSitePartnerResponse" - } - } - } - }, - "400": { - "description": "On malformed pagination request" - }, - "404": { - "description": "No business partner found for specified bpn" - } - } - } - }, - "/api/catena/legal-entities/{bpn}/addresses": { - "get": { - "tags": [ - "legal-entity-controller" - ], - "summary": "Get address partners of a legal entity", - "description": "Get business partners of type address belonging to a business partner of type legal entity, identified by the business partner's bpn ignoring case.", - "operationId": "getAddresses", - "parameters": [ - { - "name": "bpn", - "in": "path", - "description": "Bpn value", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "The addresses for the specified bpn", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseAddressPartnerResponse" - } - } - } - }, - "400": { - "description": "On malformed pagination request" - }, - "404": { - "description": "No business partner found for specified bpn" - } - } - } - }, - "/api/catena/identifier-types/for-country": { - "get": { - "tags": [ - "metadata-controller" - ], - "summary": "Get valid identifier types for a country", - "description": "Returns which identifier types are valid and which ones are mandatory for a country specified by its ISO 3166-1 alpha-2 country code.", - "operationId": "getValidIdentifierTypesForCountry", - "parameters": [ - { - "name": "country", - "in": "query", - "required": true, - "schema": { - "type": "string", - "enum": [ - "UNDEFINED", - "AC", - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AN", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BU", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CP", - "CR", - "CS", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DG", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EA", - "EC", - "EE", - "EG", - "EH", - "ER", - "ES", - "ET", - "EU", - "EZ", - "FI", - "FJ", - "FK", - "FM", - "FO", - "FR", - "FX", - "GA", - "GB", - "GD", - "GE", - "GF", - "GG", - "GH", - "GI", - "GL", - "GM", - "GN", - "GP", - "GQ", - "GR", - "GS", - "GT", - "GU", - "GW", - "GY", - "HK", - "HM", - "HN", - "HR", - "HT", - "HU", - "IC", - "ID", - "IE", - "IL", - "IM", - "IN", - "IO", - "IQ", - "IR", - "IS", - "IT", - "JE", - "JM", - "JO", - "JP", - "KE", - "KG", - "KH", - "KI", - "KM", - "KN", - "KP", - "KR", - "KW", - "KY", - "KZ", - "LA", - "LB", - "LC", - "LI", - "LK", - "LR", - "LS", - "LT", - "LU", - "LV", - "LY", - "MA", - "MC", - "MD", - "ME", - "MF", - "MG", - "MH", - "MK", - "ML", - "MM", - "MN", - "MO", - "MP", - "MQ", - "MR", - "MS", - "MT", - "MU", - "MV", - "MW", - "MX", - "MY", - "MZ", - "NA", - "NC", - "NE", - "NF", - "NG", - "NI", - "NL", - "NO", - "NP", - "NR", - "NT", - "NU", - "NZ", - "OM", - "PA", - "PE", - "PF", - "PG", - "PH", - "PK", - "PL", - "PM", - "PN", - "PR", - "PS", - "PT", - "PW", - "PY", - "QA", - "RE", - "RO", - "RS", - "RU", - "RW", - "SA", - "SB", - "SC", - "SD", - "SE", - "SF", - "SG", - "SH", - "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SU", - "SV", - "SX", - "SY", - "SZ", - "TA", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TP", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UK", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XI", - "XU", - "XK", - "YE", - "YT", - "YU", - "ZA", - "ZM", - "ZR", - "ZW" - ] - } - } - ], - "responses": { - "200": { - "description": "The identifier types", - "content": { - "*/*": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/CountryIdentifierTypeResponse" - } - } - } - } - }, - "400": { - "description": "On malformed request parameters" - } - } - } - }, - "/api/catena/business-partners/{bpn}/changelog": { - "get": { - "tags": [ - "business-partner-controller" - ], - "summary": "Get business partner changelog entries by bpn", - "description": "Get business partner changelog entries by bpn ignoring case.", - "operationId": "getChangelogEntries", - "parameters": [ - { - "name": "bpn", - "in": "path", - "description": "Bpn value", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "The changelog entries for the specified bpn", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseChangelogEntryResponse" - } - } - } - }, - "400": { - "description": "On malformed pagination request" - }, - "404": { - "description": "No business partner found for specified bpn" - } - } - } - }, - "/api/catena/business-partner": { - "get": { - "tags": [ - "business-partner-legacy-controller" - ], - "summary": "Get page of business partners matching the search criteria", - "description": "This endpoint tries to find matches among all existing business partners, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score.", - "operationId": "searchBusinessPartners", - "parameters": [ - { - "name": "name", - "in": "query", - "description": "Filter legal entities by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "legalForm", - "in": "query", - "description": "Filter legal entities by legal form name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "status", - "in": "query", - "description": "Filter legal entities by status official denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "classification", - "in": "query", - "description": "Filter legal entities by classification denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "administrativeArea", - "in": "query", - "description": "Filter business partners by administrative area name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postCode", - "in": "query", - "description": "Filter business partners by postcode or postcodes", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "locality", - "in": "query", - "description": "Filter business partners by locality full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "thoroughfare", - "in": "query", - "description": "Filter business partners by thoroughfare full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "premise", - "in": "query", - "description": "Filter business partners by premise full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "postalDeliveryPoint", - "in": "query", - "description": "Filter business partners by postal delivery point full denotation", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "siteName", - "in": "query", - "description": "Filter sites by name", - "required": false, - "schema": { - "type": "string" - } - }, - { - "name": "page", - "in": "query", - "description": "Number of page to get results from", - "required": false, - "schema": { - "minimum": 0, - "type": "string", - "default": "0" - } - }, - { - "name": "size", - "in": "query", - "description": "Size of each page", - "required": false, - "schema": { - "maximum": 100, - "minimum": 0, - "type": "string", - "default": "10" - } - } - ], - "responses": { - "200": { - "description": "Page of business partners matching the search criteria, may be empty", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/PageResponseBusinessPartnerMatchResponse" - } - } - } - }, - "400": { - "description": "On malformed search or pagination request" - } - }, - "deprecated": true - } - }, - "/api/catena/business-partner/{idValue}": { - "get": { - "tags": [ - "business-partner-legacy-controller" - ], - "summary": "Get business partner by identifier", - "description": "This endpoint tries to find a business partner by the specified identifier. The identifier value is case insensitively compared but needs to be given exactly. By default the value given is interpreted as a BPN. By specifying the technical key of another identifier typethe value is matched against the identifiers of that given type.", - "operationId": "getLegalEntity_1", - "parameters": [ - { - "name": "idValue", - "in": "path", - "description": "Identifier value", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "idType", - "in": "query", - "description": "Type of identifier to use, defaults to BPN when omitted", - "required": false, - "schema": { - "type": "string", - "default": "BPN" - } - } - ], - "responses": { - "200": { - "description": "Found business partner with specified identifier", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/BusinessPartnerResponse" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - }, - "404": { - "description": "No business partner found under specified identifier or specified identifier type not found" - } - }, - "deprecated": true - } - }, - "/api/catena/addresses/{bpn}": { - "get": { - "tags": [ - "address-controller" - ], - "summary": "Get address partners by bpn", - "description": "Get business partners of type address by bpn-a ignoring case.", - "operationId": "getAddress", - "parameters": [ - { - "name": "bpn", - "in": "path", - "description": "Bpn value", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Found address with specified bpn", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/AddressPartnerSearchResponse" - } - } - } - }, - "400": { - "description": "On malformed request parameters" - }, - "404": { - "description": "No address found under specified bpn" - } - } - } - } - }, - "components": { - "schemas": { - "Address": { - "type": "object", - "properties": { - "version": { - "$ref": "#/components/schemas/AddressVersion" - }, - "careOf": { - "type": "string" - }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } - }, - "country": { - "type": "string", - "enum": [ - "UNDEFINED", - "AC", - "AD", - "AE", - "AF", - "AG", - "AI", - "AL", - "AM", - "AN", - "AO", - "AQ", - "AR", - "AS", - "AT", - "AU", - "AW", - "AX", - "AZ", - "BA", - "BB", - "BD", - "BE", - "BF", - "BG", - "BH", - "BI", - "BJ", - "BL", - "BM", - "BN", - "BO", - "BQ", - "BR", - "BS", - "BT", - "BU", - "BV", - "BW", - "BY", - "BZ", - "CA", - "CC", - "CD", - "CF", - "CG", - "CH", - "CI", - "CK", - "CL", - "CM", - "CN", - "CO", - "CP", - "CR", - "CS", - "CU", - "CV", - "CW", - "CX", - "CY", - "CZ", - "DE", - "DG", - "DJ", - "DK", - "DM", - "DO", - "DZ", - "EA", - "EC", - "EE", - "EG", - "EH", - "ER", - "ES", - "ET", - "EU", - "EZ", - "FI", - "FJ", - "FK", - "FM", - "FO", - "FR", - "FX", - "GA", - "GB", - "GD", - "GE", - "GF", - "GG", - "GH", - "GI", - "GL", - "GM", - "GN", - "GP", - "GQ", - "GR", - "GS", - "GT", - "GU", - "GW", - "GY", - "HK", - "HM", - "HN", - "HR", - "HT", - "HU", - "IC", - "ID", - "IE", - "IL", - "IM", - "IN", - "IO", - "IQ", - "IR", - "IS", - "IT", - "JE", - "JM", - "JO", - "JP", - "KE", - "KG", - "KH", - "KI", - "KM", - "KN", - "KP", - "KR", - "KW", - "KY", - "KZ", - "LA", - "LB", - "LC", - "LI", - "LK", - "LR", - "LS", - "LT", - "LU", - "LV", - "LY", - "MA", - "MC", - "MD", - "ME", - "MF", - "MG", - "MH", - "MK", - "ML", - "MM", - "MN", - "MO", - "MP", - "MQ", - "MR", - "MS", - "MT", - "MU", - "MV", - "MW", - "MX", - "MY", - "MZ", - "NA", - "NC", - "NE", - "NF", - "NG", - "NI", - "NL", - "NO", - "NP", - "NR", - "NT", - "NU", - "NZ", - "OM", - "PA", - "PE", - "PF", - "PG", - "PH", - "PK", - "PL", - "PM", - "PN", - "PR", - "PS", - "PT", - "PW", - "PY", - "QA", - "RE", - "RO", - "RS", - "RU", - "RW", - "SA", - "SB", - "SC", - "SD", - "SE", - "SF", - "SG", - "SH", - "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SU", - "SV", - "SX", - "SY", - "SZ", - "TA", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TP", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UK", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XI", - "XU", - "XK", - "YE", - "YT", - "YU", - "ZA", - "ZM", - "ZR", - "ZW" - ] + "500": { + "description": "Fetching failed (no connection to database)" + } + } + }, + "post": { + "tags": [ + "open-search-controller" + ], + "summary": "Index new business partner records on OpenSearch", + "description": "Triggers an asynchronous export of business partner records from BPDM to OpenSearch. Only exports records which have been updated since the last export. ", + "operationId": "export", + "responses": { + "500": { + "description": "Export failed (no connection to OpenSearch or database)" + }, + "200": { + "description": "Export of records successfully", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SyncResponse" + } + } + } + } + } + }, + "delete": { + "tags": [ + "open-search-controller" + ], + "summary": "Clear business partner index on OpenSearch", + "description": "Deletes all business partner records in the OpenSearch index. Also resets the timestamp from the last export.", + "operationId": "clear", + "responses": { + "500": { + "description": "Clearing failed (no connection to OpenSearch or database)" + }, + "200": { + "description": "Index successfully cleared" + } + } + } + }, + "/api/catena/sites/search": { + "post": { + "tags": [ + "site-controller" + ], + "summary": "Search site partners by BPNs and/or parent BPNs", + "description": "Search business partners of type site by their BPNSs or by the BPNLs of their parent legal entities", + "operationId": "searchSites", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SiteBpnSearchRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Found sites that belong to specified legal entites", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageResponseSitePoolResponse" + } + } + } + }, + "400": { + "description": "On malformed request parameters" + } + } + } + }, + "/api/catena/sites/main-addresses/search": { + "post": { + "tags": [ + "site-controller" + ], + "summary": "Search Main Addresses", + "description": "Search main addresses of site business partners by BPNS", + "operationId": "searchMainAddresses", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "The found main addresses", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MainAddressResponse" + } + } + } + } + }, + "400": { + "description": "On malformed request parameters" + } + } + } + }, + "/api/catena/legal-forms": { + "get": { + "tags": [ + "metadata-controller" + ], + "summary": "Get page of legal forms", + "description": "Lists all currently known legal forms in a paginated result", + "operationId": "getLegalForms", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } + ], + "responses": { + "200": { + "description": "Page of existing legal forms, may be empty", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageResponseLegalFormResponse" + } + } + } + }, + "400": { + "description": "On malformed request parameters" + } + } + }, + "post": { + "tags": [ + "metadata-controller" + ], + "summary": "Create new legal form", + "description": "Create a new legal form which can be referenced by business partner records. The actual name of the legal form is free to choose and doesn't need to be unique. The technical key can be freely chosen but needs to be unique for the lsaType as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.", + "operationId": "createLegalForm", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LegalFormRequest" + } + } + }, + "required": true + }, + "responses": { + "409": { + "description": "Legal form with specified technical key already exists" + }, + "200": { + "description": "New legal form successfully created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LegalFormResponse" + } + } + } + }, + "400": { + "description": "On malformed request parameters" + } + } + } + }, + "/api/catena/legal-entities/{bpnl}/confirm-up-to-date": { + "post": { + "tags": [ + "legal-entity-controller" + ], + "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 bpnl.", + "operationId": "setLegalEntityCurrentness", + "parameters": [ + { + "name": "bpnl", + "in": "path", + "description": "Bpnl value", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Business partner's \"currentness\" successfully updated" + }, + "404": { + "description": "No business partner found for specified bpnl" + }, + "400": { + "description": "On malformed request parameters" + } + } + } + }, + "/api/catena/legal-entities/search": { + "post": { + "tags": [ + "legal-entity-controller" + ], + "summary": "Search legal entity partners by BPNLs", + "description": "Search legal entity partners by their BPNLs. The response can contain less results than the number of BPNLs that were requested, if some of the BPNLs did not exist. For a single request, the maximum number of BPNLs to search for is limited to ${bpdm.bpn.search-request-limit} entries.", + "operationId": "searchSites_1", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "On malformed request parameters or if number of requested bpns exceeds limit" + }, + "200": { + "description": "Found legal entites", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PoolLegalEntityResponse" + } + } + } + } + } + } + } + }, + "/api/catena/legal-entities/legal-addresses/search": { + "post": { + "tags": [ + "legal-entity-controller" + ], + "summary": "Search Legal Addresses", + "description": "Search legal addresses of legal entities by BPNL", + "operationId": "searchLegalAddresses", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "The found legal addresses", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LegalAddressResponse" + } + } + } + } + }, + "400": { + "description": "On malformed request parameters" + } + } + } + }, + "/api/catena/identifier-types": { + "get": { + "tags": [ + "metadata-controller" + ], + "summary": "Get page of identifier types filtered by lsaType and (optionally) country (specified by its ISO 3166-1 alpha-2 country code)", + "description": "Lists all matching identifier types including validity details in a paginated result", + "operationId": "getIdentifierTypes", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + }, + { + "name": "lsaType", + "in": "query", + "required": true, + "schema": { + "type": "string", + "description": "Specifies if an identifier type is valid for legal entities (L) or addresses (A). Sites (S) are not supported.", + "enum": [ + "LEGAL_ENTITY", + "ADDRESS" + ] + } + }, + { + "name": "country", + "in": "query", + "required": false, + "schema": { + "type": "string", + "enum": [ + "UNDEFINED", + "AC", + "AD", + "AE", + "AF", + "AG", + "AI", + "AL", + "AM", + "AN", + "AO", + "AQ", + "AR", + "AS", + "AT", + "AU", + "AW", + "AX", + "AZ", + "BA", + "BB", + "BD", + "BE", + "BF", + "BG", + "BH", + "BI", + "BJ", + "BL", + "BM", + "BN", + "BO", + "BQ", + "BR", + "BS", + "BT", + "BU", + "BV", + "BW", + "BY", + "BZ", + "CA", + "CC", + "CD", + "CF", + "CG", + "CH", + "CI", + "CK", + "CL", + "CM", + "CN", + "CO", + "CP", + "CR", + "CS", + "CU", + "CV", + "CW", + "CX", + "CY", + "CZ", + "DE", + "DG", + "DJ", + "DK", + "DM", + "DO", + "DZ", + "EA", + "EC", + "EE", + "EG", + "EH", + "ER", + "ES", + "ET", + "EU", + "EZ", + "FI", + "FJ", + "FK", + "FM", + "FO", + "FR", + "FX", + "GA", + "GB", + "GD", + "GE", + "GF", + "GG", + "GH", + "GI", + "GL", + "GM", + "GN", + "GP", + "GQ", + "GR", + "GS", + "GT", + "GU", + "GW", + "GY", + "HK", + "HM", + "HN", + "HR", + "HT", + "HU", + "IC", + "ID", + "IE", + "IL", + "IM", + "IN", + "IO", + "IQ", + "IR", + "IS", + "IT", + "JE", + "JM", + "JO", + "JP", + "KE", + "KG", + "KH", + "KI", + "KM", + "KN", + "KP", + "KR", + "KW", + "KY", + "KZ", + "LA", + "LB", + "LC", + "LI", + "LK", + "LR", + "LS", + "LT", + "LU", + "LV", + "LY", + "MA", + "MC", + "MD", + "ME", + "MF", + "MG", + "MH", + "MK", + "ML", + "MM", + "MN", + "MO", + "MP", + "MQ", + "MR", + "MS", + "MT", + "MU", + "MV", + "MW", + "MX", + "MY", + "MZ", + "NA", + "NC", + "NE", + "NF", + "NG", + "NI", + "NL", + "NO", + "NP", + "NR", + "NT", + "NU", + "NZ", + "OM", + "PA", + "PE", + "PF", + "PG", + "PH", + "PK", + "PL", + "PM", + "PN", + "PR", + "PS", + "PT", + "PW", + "PY", + "QA", + "RE", + "RO", + "RS", + "RU", + "RW", + "SA", + "SB", + "SC", + "SD", + "SE", + "SF", + "SG", + "SH", + "SI", + "SJ", + "SK", + "SL", + "SM", + "SN", + "SO", + "SR", + "SS", + "ST", + "SU", + "SV", + "SX", + "SY", + "SZ", + "TA", + "TC", + "TD", + "TF", + "TG", + "TH", + "TJ", + "TK", + "TL", + "TM", + "TN", + "TO", + "TP", + "TR", + "TT", + "TV", + "TW", + "TZ", + "UA", + "UG", + "UK", + "UM", + "US", + "UY", + "UZ", + "VA", + "VC", + "VE", + "VG", + "VI", + "VN", + "VU", + "WF", + "WS", + "XI", + "XU", + "XK", + "YE", + "YT", + "YU", + "ZA", + "ZM", + "ZR", + "ZW" + ] + } + } + ], + "responses": { + "200": { + "description": "Page of existing identifier types, may be empty", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageResponseIdentifierTypeDto" + } + } + } + }, + "400": { + "description": "On malformed request parameters" + } + } + }, + "post": { + "tags": [ + "metadata-controller" + ], + "summary": "Create new identifier type", + "description": "Create a new identifier type (including validity details) which can be referenced by business partner records. Identifier types such as BPN or VAT determine with which kind of values a business partner can be identified with. The actual name of the identifier type is free to choose and doesn't need to be unique. The technical key can be freely chosen but needs to be unique for the lsaType as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.", + "operationId": "createIdentifierType", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IdentifierTypeDto" + } + } + }, + "required": true + }, + "responses": { + "409": { + "description": "Identifier type with specified technical key already exists" + }, + "400": { + "description": "On malformed request parameters" + }, + "200": { + "description": "New identifier type successfully created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IdentifierTypeDto" + } + } + } + } + } + } + }, + "/api/catena/business-partners/changelog/search": { + "post": { + "tags": [ + "changelog-controller" + ], + "summary": "Get business partner changelog entries from time, by BPN and/or LSA type", + "description": "Get business partner changelog entries from time, by BPN and/or LSA type", + "operationId": "getChangelogEntries", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ChangeLogSearchRequest" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "On malformed pagination request" + }, + "404": { + "description": "No business partner found for specified bpn" + }, + "200": { + "description": "The specified changelog entries", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageResponseChangelogEntryResponse" + } + } + } + } + } + } + }, + "/api/catena/bpn/search": { + "post": { + "tags": [ + "bpn-controller" + ], + "summary": "Find business partner numbers by identifiers", + "description": "Find business partner numbers by identifiers. The response can contain less results than the number of identifier values that were requested, if some of the identifiers did not exist. For a single request, the maximum number of identifier values to search for is limited to ${bpdm.bpn.search-request-limit} entries.", + "operationId": "findBpnsByIdentifiers", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IdentifiersSearchRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Found bpn to identifier value mappings", + "content": { + "application/json": { + "schema": { + "uniqueItems": true, + "type": "array", + "items": { + "$ref": "#/components/schemas/BpnIdentifierMappingResponse" + } + } + } + } + }, + "404": { + "description": "Specified identifier type not found" + }, + "400": { + "description": "On malformed request parameters or if number of requested bpns exceeds limit" + } + } + } + }, + "/api/catena/addresses/search": { + "post": { + "tags": [ + "address-controller" + ], + "summary": "Search address partners by BPNs and/or parent BPNs", + "description": "Search business partners of type address by their BPN or their parent partners BPN (BPNLs or BPNS).", + "operationId": "searchAddresses", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AddressPartnerBpnSearchRequest" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "On malformed pagination request" + }, + "200": { + "description": "Found sites for the specified sites and legal entities", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageResponseLogisticAddressResponse" + } + } + } + } + } + } + }, + "/api/catena/sites/{bpn}": { + "get": { + "tags": [ + "site-controller" + ], + "summary": "Get site partners by bpn", + "description": "Get business partners of type site by bpn-s ignoring case.", + "operationId": "getSite", + "parameters": [ + { + "name": "bpn", + "in": "path", + "description": "Bpn value", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "No site found under specified bpn" + }, + "400": { + "description": "On malformed request parameters" + }, + "200": { + "description": "Found site with specified bpn", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SitePoolResponse" + } + } + } + } + } + } + }, + "/api/catena/legal-entities/{idValue}": { + "get": { + "tags": [ + "legal-entity-controller" + ], + "summary": "Get legal entity business partner by identifier", + "description": "This endpoint tries to find a business partner by the specified identifier. The identifier value is case insensitively compared but needs to be given exactly. By default the value given is interpreted as a BPN. By specifying the technical key of another identifier typethe value is matched against the identifiers of that given type.", + "operationId": "getLegalEntity", + "parameters": [ + { + "name": "idValue", + "in": "path", + "description": "Identifier value", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "idType", + "in": "query", + "description": "Type of identifier to use, defaults to BPN when omitted", + "required": false, + "schema": { + "type": "string", + "default": "BPN" + } + } + ], + "responses": { + "200": { + "description": "Found business partner with specified identifier", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PoolLegalEntityResponse" + } + } + } + }, + "400": { + "description": "On malformed request parameters" + }, + "404": { + "description": "No business partner found under specified identifier or specified identifier type not found" + } + } + } + }, + "/api/catena/legal-entities/{bpnl}/sites": { + "get": { + "tags": [ + "legal-entity-controller" + ], + "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 bpnl ignoring case.", + "operationId": "getSites", + "parameters": [ + { + "name": "bpnl", + "in": "path", + "description": "Bpnl value", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } + ], + "responses": { + "400": { + "description": "On malformed pagination request" + }, + "200": { + "description": "The sites for the specified bpnl", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageResponseSiteResponse" + } + } + } + }, + "404": { + "description": "No business partner found for specified bpnl" + } + } + } + }, + "/api/catena/legal-entities/{bpnl}/addresses": { + "get": { + "tags": [ + "legal-entity-controller" + ], + "summary": "Get address partners of a legal entity", + "description": "Get business partners of type address belonging to a business partner of type legal entity, identified by the business partner's bpn ignoring case.", + "operationId": "getAddresses", + "parameters": [ + { + "name": "bpnl", + "in": "path", + "description": "Bpn value", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "page", + "in": "query", + "description": "Number of page to get results from", + "required": false, + "schema": { + "minimum": 0, + "type": "string", + "default": "0" + } + }, + { + "name": "size", + "in": "query", + "description": "Size of each page", + "required": false, + "schema": { + "maximum": 100, + "minimum": 0, + "type": "string", + "default": "10" + } + } + ], + "responses": { + "400": { + "description": "On malformed pagination request" + }, + "200": { + "description": "The addresses for the specified bpn", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageResponseLogisticAddressResponse" + } + } + } + }, + "404": { + "description": "No business partner found for specified bpn" + } + } + } + }, + "/api/catena/field-quality-rules/": { + "get": { + "tags": [ + "metadata-controller" + ], + "summary": "Get all field quality rules filtered by country (specified by its ISO 3166-1 alpha-2 country code)", + "description": "List the country specific data rules for entity fields.All fields that are not in this list are considered to be forbidden.", + "operationId": "getFieldQualityRules", + "parameters": [ + { + "name": "country", + "in": "query", + "description": "ISO 3166-1 alpha-2 country code", + "required": true, + "schema": { + "type": "string", + "enum": [ + "UNDEFINED", + "AC", + "AD", + "AE", + "AF", + "AG", + "AI", + "AL", + "AM", + "AN", + "AO", + "AQ", + "AR", + "AS", + "AT", + "AU", + "AW", + "AX", + "AZ", + "BA", + "BB", + "BD", + "BE", + "BF", + "BG", + "BH", + "BI", + "BJ", + "BL", + "BM", + "BN", + "BO", + "BQ", + "BR", + "BS", + "BT", + "BU", + "BV", + "BW", + "BY", + "BZ", + "CA", + "CC", + "CD", + "CF", + "CG", + "CH", + "CI", + "CK", + "CL", + "CM", + "CN", + "CO", + "CP", + "CR", + "CS", + "CU", + "CV", + "CW", + "CX", + "CY", + "CZ", + "DE", + "DG", + "DJ", + "DK", + "DM", + "DO", + "DZ", + "EA", + "EC", + "EE", + "EG", + "EH", + "ER", + "ES", + "ET", + "EU", + "EZ", + "FI", + "FJ", + "FK", + "FM", + "FO", + "FR", + "FX", + "GA", + "GB", + "GD", + "GE", + "GF", + "GG", + "GH", + "GI", + "GL", + "GM", + "GN", + "GP", + "GQ", + "GR", + "GS", + "GT", + "GU", + "GW", + "GY", + "HK", + "HM", + "HN", + "HR", + "HT", + "HU", + "IC", + "ID", + "IE", + "IL", + "IM", + "IN", + "IO", + "IQ", + "IR", + "IS", + "IT", + "JE", + "JM", + "JO", + "JP", + "KE", + "KG", + "KH", + "KI", + "KM", + "KN", + "KP", + "KR", + "KW", + "KY", + "KZ", + "LA", + "LB", + "LC", + "LI", + "LK", + "LR", + "LS", + "LT", + "LU", + "LV", + "LY", + "MA", + "MC", + "MD", + "ME", + "MF", + "MG", + "MH", + "MK", + "ML", + "MM", + "MN", + "MO", + "MP", + "MQ", + "MR", + "MS", + "MT", + "MU", + "MV", + "MW", + "MX", + "MY", + "MZ", + "NA", + "NC", + "NE", + "NF", + "NG", + "NI", + "NL", + "NO", + "NP", + "NR", + "NT", + "NU", + "NZ", + "OM", + "PA", + "PE", + "PF", + "PG", + "PH", + "PK", + "PL", + "PM", + "PN", + "PR", + "PS", + "PT", + "PW", + "PY", + "QA", + "RE", + "RO", + "RS", + "RU", + "RW", + "SA", + "SB", + "SC", + "SD", + "SE", + "SF", + "SG", + "SH", + "SI", + "SJ", + "SK", + "SL", + "SM", + "SN", + "SO", + "SR", + "SS", + "ST", + "SU", + "SV", + "SX", + "SY", + "SZ", + "TA", + "TC", + "TD", + "TF", + "TG", + "TH", + "TJ", + "TK", + "TL", + "TM", + "TN", + "TO", + "TP", + "TR", + "TT", + "TV", + "TW", + "TZ", + "UA", + "UG", + "UK", + "UM", + "US", + "UY", + "UZ", + "VA", + "VC", + "VE", + "VG", + "VI", + "VN", + "VU", + "WF", + "WS", + "XI", + "XU", + "XK", + "YE", + "YT", + "YU", + "ZA", + "ZM", + "ZR", + "ZW" + ] + } + } + ], + "responses": { + "200": { + "description": "List of the existing rules for the given country", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FieldQualityRuleDto" + } + } + } + } + }, + "400": { + "description": "On malformed request parameters" + } + } + } + }, + "/api/catena/addresses/{bpna}": { + "get": { + "tags": [ + "address-controller" + ], + "summary": "Get address partners by bpna", + "description": "Get business partners of type address by bpn-a ignoring case.", + "operationId": "getAddress", + "parameters": [ + { + "name": "bpna", + "in": "path", + "description": "Bpn value", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Found address with specified bpna", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LogisticAddressResponse" + } + } + } + }, + "404": { + "description": "No address found under specified bpna" + }, + "400": { + "description": "On malformed request parameters" + } + } + } + } + }, + "components": { + "schemas": { + "AddressCreateWrapper": { + "type": "object", + "properties": { + "entities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressPartnerCreateResponse" + } + }, + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ErrorInfoAddressCreateError" + } + }, + "errorCount": { + "type": "integer", + "format": "int32" + }, + "entityCount": { + "type": "integer", + "format": "int32" + } + }, + "description": "Holds information about successfully and failed entities after the creating/updating of several objects" + }, + "AddressIdentifier": { + "type": "object", + "properties": { + "value": { + "type": "string", + "description": "Value of the identifier" + }, + "type": { + "type": "string", + "description": "Technical key of the type to which this identifier belongs to" + } + }, + "description": "Identifier record for a logistic address" + }, + "AddressMatchResponse": { + "type": "object", + "properties": { + "score": { + "type": "number", + "format": "float" + }, + "address": { + "$ref": "#/components/schemas/LogisticAddressResponse" + } + }, + "description": "Match with score for a business partner record of type address" + }, + "AddressPartnerBpnSearchRequest": { + "type": "object", + "properties": { + "legalEntities": { + "type": "array", + "items": { + "type": "string" + } }, - "administrativeAreas": { + "sites": { "type": "array", "items": { - "$ref": "#/components/schemas/AdministrativeArea" + "type": "string" } }, - "postCodes": { + "addresses": { "type": "array", "items": { - "$ref": "#/components/schemas/Postcode" + "type": "string" } + } + }, + "description": "Request for searching business partners of type address by parent BPNs" + }, + "AddressPartnerCreateRequest": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." }, - "localities": { + "states": { "type": "array", "items": { - "$ref": "#/components/schemas/Locality" + "$ref": "#/components/schemas/AddressState" } }, - "thoroughfares": { + "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/Thoroughfare" + "$ref": "#/components/schemas/AddressIdentifier" } }, - "premises": { + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddress" + }, + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" + }, + "bpnParent": { + "type": "string" + }, + "index": { + "type": "string" + } + }, + "description": "Request for creating new business partner record of type address" + }, + "AddressPartnerCreateResponse": { + "type": "object", + "properties": { + "bpna": { + "type": "string", + "description": "Business Partner Number of this address" + }, + "name": { + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." + }, + "states": { "type": "array", "items": { - "$ref": "#/components/schemas/Premise" + "$ref": "#/components/schemas/AddressStateResponse" } }, - "postalDeliveryPoints": { + "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/PostalDeliveryPoint" + "$ref": "#/components/schemas/IdentifierResponse" } }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddress" + }, + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" + }, + "bpnLegalEntity": { + "type": "string", + "description": "BPN of the related legal entity, if available" + }, + "bpnSite": { + "type": "string", + "description": "BPN of the related site, if available" + }, + "createdAt": { + "type": "string", + "description": "The timestamp the business partner data was created", + "format": "date-time" + }, + "updatedAt": { + "type": "string", + "description": "The timestamp the business partner data was last updated", + "format": "date-time" + }, + "isLegalAddress": { + "type": "boolean", + "description": "Flag if this is the legal address of its related legal entity" + }, + "isMainAddress": { + "type": "boolean", + "description": "Flag if this is the main address of its related site" + }, + "index": { + "type": "string" + } + }, + "description": "Created business partners of type address" + }, + "AddressPartnerUpdateRequest": { + "type": "object", + "properties": { + "bpna": { + "type": "string" + }, + "name": { + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." }, - "types": { + "states": { "type": "array", "items": { - "type": "string", - "enum": [ - "BRANCH_OFFICE", - "CARE_OF", - "HEADQUARTER", - "LEGAL_ALTERNATIVE", - "PO_BOX", - "REGISTERED", - "REGISTERED_AGENT_MAIL", - "REGISTERED_AGENT_PHYSICAL", - "VAT_REGISTERED", - "UNSPECIFIC" - ] + "$ref": "#/components/schemas/AddressState" + } + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AddressIdentifier" } + }, + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddress" + }, + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" } }, - "description": "Localized address record for a business partner" + "description": "Request for updating a business partner record of type address" }, - "AddressMatchResponse": { + "AddressState": { "type": "object", "properties": { - "score": { - "type": "number", - "format": "float" + "description": { + "type": "string", + "description": "Description of the status" }, - "address": { - "$ref": "#/components/schemas/AddressPartnerSearchResponse" + "validFrom": { + "type": "string", + "description": "Since when the status is/was valid", + "format": "date-time" + }, + "validTo": { + "type": "string", + "description": "Until the status was valid, if applicable", + "format": "date-time" + }, + "type": { + "type": "string", + "description": "The type of this specified status", + "enum": [ + "ACTIVE", + "INACTIVE" + ] } }, - "description": "Match with score for a business partner record of type address" + "description": "Status record for a address" }, - "AddressPartnerBpnSearchRequest": { + "AddressStateResponse": { "type": "object", "properties": { - "legalEntities": { - "type": "array", - "items": { - "type": "string" - } + "description": { + "type": "string", + "description": "Exact, official denotation of the status" }, - "sites": { + "validFrom": { + "type": "string", + "description": "Since when the status is/was valid", + "format": "date-time" + }, + "validTo": { + "type": "string", + "description": "Until the status was valid, if applicable", + "format": "date-time" + }, + "type": { + "$ref": "#/components/schemas/TypeKeyNameDtoBusinessStateType" + } + }, + "description": "Status record of a legal entity" + }, + "AddressUpdateWrapper": { + "type": "object", + "properties": { + "entities": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/LogisticAddressResponse" } }, - "addresses": { + "errors": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/ErrorInfoAddressUpdateError" } + }, + "errorCount": { + "type": "integer", + "format": "int32" + }, + "entityCount": { + "type": "integer", + "format": "int32" } }, - "description": "Request for searching business partners of type address by parent BPNs" + "description": "Holds information about successfully and failed entities after the creating/updating of several objects" }, - "AddressPartnerCreateRequest": { + "AlternativePostalAddress": { "type": "object", "properties": { - "version": { - "$ref": "#/components/schemas/AddressVersion" - }, - "careOf": { - "type": "string" - }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } + "geographicCoordinates": { + "$ref": "#/components/schemas/GeoCoordinates" }, "country": { "type": "string", + "description": "Describes the country", "enum": [ "UNDEFINED", "AC", @@ -4787,248 +2390,284 @@ "ZW" ] }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeArea" - } + "postalCode": { + "type": "string", + "description": "A postal code, also known as postcode, PIN or ZIP Code" }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Postcode" - } + "city": { + "type": "string", + "description": "The city of the address (Synonym: Town, village, municipality)" }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Locality" - } + "administrativeAreaLevel1": { + "type": "string", + "description": "Identifying code of the Region within the country (e.g. Bayern)" }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Thoroughfare" - } + "deliveryServiceNumber": { + "type": "string", + "description": "Describes the PO Box or private Bag number the delivery should be placed at." }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Premise" - } + "deliveryServiceType": { + "type": "string", + "description": "The type of this specified delivery", + "enum": [ + "PO_BOX", + "PRIVATE_BAG", + "BOITE_POSTALE" + ] + }, + "deliveryServiceQualifier": { + "type": "string", + "description": "Delivery Service Qualifier" + } + }, + "description": "Alternative Postal Address Part" + }, + "BpnIdentifierMappingResponse": { + "type": "object", + "properties": { + "idValue": { + "type": "string" + }, + "bpn": { + "type": "string" + } + }, + "description": "Mapping of Business Partner Number to identifier value" + }, + "ChangeLogSearchRequest": { + "type": "object", + "properties": { + "fromTime": { + "type": "string", + "format": "date-time" }, - "postalDeliveryPoints": { + "bpns": { + "uniqueItems": true, "type": "array", "items": { - "$ref": "#/components/schemas/PostalDeliveryPoint" + "type": "string" } }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" - }, - "types": { + "lsaTypes": { + "uniqueItems": true, "type": "array", "items": { "type": "string", "enum": [ - "BRANCH_OFFICE", - "CARE_OF", - "HEADQUARTER", - "LEGAL_ALTERNATIVE", - "PO_BOX", - "REGISTERED", - "REGISTERED_AGENT_MAIL", - "REGISTERED_AGENT_PHYSICAL", - "VAT_REGISTERED", - "UNSPECIFIC" + "LEGAL_ENTITY", + "ADDRESS", + "SITE" ] } - }, - "parent": { - "type": "string" - }, - "index": { - "type": "string" } }, - "description": "Request for creating new business partner record of type address" + "description": "Request for searching and filtering the business partner changelog" }, - "AddressPartnerCreateResponse": { + "ChangelogEntryResponse": { "type": "object", "properties": { "bpn": { "type": "string" }, - "version": { - "$ref": "#/components/schemas/AddressVersionResponse" - }, - "careOf": { - "type": "string" - }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } - }, - "country": { - "$ref": "#/components/schemas/TypeKeyNameDtoCountryCode" - }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeAreaResponse" - } + "changelogType": { + "type": "string", + "enum": [ + "CREATE", + "UPDATE" + ] }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostcodeResponse" - } + "timestamp": { + "type": "string", + "format": "date-time" }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LocalityResponse" - } + "lsaType": { + "type": "string", + "enum": [ + "LEGAL_ENTITY", + "ADDRESS", + "SITE" + ] + } + }, + "description": "Changelog entry for a business partner" + }, + "Classification": { + "type": "object", + "properties": { + "value": { + "type": "string", + "description": "Name of the classification" }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ThoroughfareResponse" - } + "code": { + "type": "string", + "description": "Identifying code of the classification, if applicable" }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PremiseResponse" - } + "type": { + "type": "string", + "description": "Type of specified classification", + "enum": [ + "NACE", + "NAF", + "NAICS", + "SIC" + ] + } + }, + "description": "Classification record for a business partner" + }, + "ClassificationResponse": { + "type": "object", + "properties": { + "value": { + "type": "string", + "description": "Name of the classification" }, - "postalDeliveryPoints": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostalDeliveryPointResponse" - } + "code": { + "type": "string", + "description": "Identifying code of the classification, if applicable" }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" + "type": { + "$ref": "#/components/schemas/TypeKeyNameDtoClassificationType" + } + }, + "description": "Classification record of a business partner" + }, + "ErrorInfoAddressCreateError": { + "title": "ErrorInfo", + "type": "object", + "properties": { + "errorCode": { + "type": "string", + "description": "AddressCreateError", + "enum": [ + "BpnNotValid", + "SiteNotFound", + "LegalEntityNotFound" + ] }, - "types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoAddressType" - } + "message": { + "type": "string" }, - "index": { + "entityKey": { "type": "string" } }, - "description": "Created business partners of type address" + "description": "Holds information about failures when creating or updating an entity" }, - "AddressPartnerResponse": { + "ErrorInfoAddressUpdateError": { + "title": "ErrorInfo", "type": "object", "properties": { - "bpn": { - "type": "string" - }, - "version": { - "$ref": "#/components/schemas/AddressVersionResponse" + "errorCode": { + "type": "string", + "description": "AddressUpdateError", + "enum": [ + "AddressNotFound" + ] }, - "careOf": { + "message": { "type": "string" }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } - }, - "country": { - "$ref": "#/components/schemas/TypeKeyNameDtoCountryCode" - }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeAreaResponse" - } - }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostcodeResponse" - } - }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LocalityResponse" - } - }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ThoroughfareResponse" - } + "entityKey": { + "type": "string" + } + }, + "description": "Holds information about failures when creating or updating an entity" + }, + "ErrorInfoLegalEntityCreateError": { + "title": "ErrorInfo", + "type": "object", + "properties": { + "errorCode": { + "type": "string", + "description": "LegalEntityCreateError", + "enum": [ + "LegalEntityDuplicateIdentifier" + ] }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PremiseResponse" - } + "message": { + "type": "string" }, - "postalDeliveryPoints": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostalDeliveryPointResponse" - } + "entityKey": { + "type": "string" + } + }, + "description": "Holds information about failures when creating or updating an entity" + }, + "ErrorInfoLegalEntityUpdateError": { + "title": "ErrorInfo", + "type": "object", + "properties": { + "errorCode": { + "type": "string", + "description": "LegalEntityUpdateError", + "enum": [ + "LegalEntityNotFound" + ] }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" + "message": { + "type": "string" }, - "types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoAddressType" - } + "entityKey": { + "type": "string" } }, - "description": "Business partner of type address" + "description": "Holds information about failures when creating or updating an entity" }, - "AddressPartnerSearchResponse": { + "ErrorInfoSiteCreateError": { + "title": "ErrorInfo", "type": "object", "properties": { - "address": { - "$ref": "#/components/schemas/AddressPartnerResponse" + "errorCode": { + "type": "string", + "description": "SiteCreateError", + "enum": [ + "LegalEntityNotFound" + ] }, - "bpnLegalEntity": { + "message": { "type": "string" }, - "bpnSite": { + "entityKey": { "type": "string" } }, - "description": "Business partner of type address with parent reference" + "description": "Holds information about failures when creating or updating an entity" }, - "AddressPartnerUpdateRequest": { + "ErrorInfoSiteUpdateError": { + "title": "ErrorInfo", "type": "object", "properties": { - "bpn": { - "type": "string" + "errorCode": { + "type": "string", + "description": "SiteUpdateError", + "enum": [ + "SiteNotFound" + ] }, - "version": { - "$ref": "#/components/schemas/AddressVersion" + "message": { + "type": "string" }, - "careOf": { + "entityKey": { "type": "string" + } + }, + "description": "Holds information about failures when creating or updating an entity" + }, + "FieldQualityRuleDto": { + "type": "object", + "properties": { + "fieldPath": { + "type": "string", + "description": "Path to the field" }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } + "schemaName": { + "type": "string", + "description": "Schema name of the entity the field belongs to" }, "country": { "type": "string", + "description": "Country for wich the rule is valid", "enum": [ "UNDEFINED", "AC", @@ -5244,1006 +2883,535 @@ "SG", "SH", "SI", - "SJ", - "SK", - "SL", - "SM", - "SN", - "SO", - "SR", - "SS", - "ST", - "SU", - "SV", - "SX", - "SY", - "SZ", - "TA", - "TC", - "TD", - "TF", - "TG", - "TH", - "TJ", - "TK", - "TL", - "TM", - "TN", - "TO", - "TP", - "TR", - "TT", - "TV", - "TW", - "TZ", - "UA", - "UG", - "UK", - "UM", - "US", - "UY", - "UZ", - "VA", - "VC", - "VE", - "VG", - "VI", - "VN", - "VU", - "WF", - "WS", - "XI", - "XU", - "XK", - "YE", - "YT", - "YU", - "ZA", - "ZM", - "ZR", - "ZW" - ] - }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeArea" - } - }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Postcode" - } - }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Locality" - } - }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Thoroughfare" - } - }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Premise" - } - }, - "postalDeliveryPoints": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostalDeliveryPoint" - } - }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" - }, - "types": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "BRANCH_OFFICE", - "CARE_OF", - "HEADQUARTER", - "LEGAL_ALTERNATIVE", - "PO_BOX", - "REGISTERED", - "REGISTERED_AGENT_MAIL", - "REGISTERED_AGENT_PHYSICAL", - "VAT_REGISTERED", - "UNSPECIFIC" - ] - } - } - }, - "description": "Request for updating a business partner record of type address" - }, - "AddressResponse": { - "type": "object", - "properties": { - "version": { - "$ref": "#/components/schemas/AddressVersionResponse" - }, - "careOf": { - "type": "string" - }, - "contexts": { - "type": "array", - "items": { - "type": "string" - } - }, - "country": { - "$ref": "#/components/schemas/TypeKeyNameDtoCountryCode" - }, - "administrativeAreas": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdministrativeAreaResponse" - } - }, - "postCodes": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostcodeResponse" - } - }, - "localities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LocalityResponse" - } - }, - "thoroughfares": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ThoroughfareResponse" - } - }, - "premises": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PremiseResponse" - } - }, - "postalDeliveryPoints": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PostalDeliveryPointResponse" - } - }, - "geographicCoordinates": { - "$ref": "#/components/schemas/GeoCoordinates" - }, - "types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoAddressType" - } - } - }, - "description": "Localized address record of a business partner" - }, - "AddressVersion": { - "type": "object", - "properties": { - "characterSet": { - "type": "string", - "enum": [ - "ARABIC", - "CHINESE", - "CHINESE_TRADITIONAL", - "CYRILLIC", - "GREEK", - "HANGUL_KOREAN", - "HEBREW", - "HIRAGANA", - "KANJI", - "KATAKANA", - "LATIN", - "THAI", - "WESTERN_LATIN_STANDARD", - "UNDEFINED" + "SJ", + "SK", + "SL", + "SM", + "SN", + "SO", + "SR", + "SS", + "ST", + "SU", + "SV", + "SX", + "SY", + "SZ", + "TA", + "TC", + "TD", + "TF", + "TG", + "TH", + "TJ", + "TK", + "TL", + "TM", + "TN", + "TO", + "TP", + "TR", + "TT", + "TV", + "TW", + "TZ", + "UA", + "UG", + "UK", + "UM", + "US", + "UY", + "UZ", + "VA", + "VC", + "VE", + "VG", + "VI", + "VN", + "VU", + "WF", + "WS", + "XI", + "XU", + "XK", + "YE", + "YT", + "YU", + "ZA", + "ZM", + "ZR", + "ZW" ] }, - "language": { + "qualityLevel": { "type": "string", + "description": "Defines the quality of an entity field.", "enum": [ - "undefined", - "aa", - "ab", - "ae", - "af", - "ak", - "am", - "an", - "ar", - "as", - "av", - "ay", - "az", - "ba", - "be", - "bg", - "bh", - "bi", - "bm", - "bn", - "bo", - "br", - "bs", - "ca", - "ce", - "ch", - "co", - "cr", - "cs", - "cu", - "cv", - "cy", - "da", - "de", - "dv", - "dz", - "ee", - "el", - "en", - "eo", - "es", - "et", - "eu", - "fa", - "ff", - "fi", - "fj", - "fo", - "fr", - "fy", - "ga", - "gd", - "gl", - "gn", - "gu", - "gv", - "ha", - "he", - "hi", - "ho", - "hr", - "ht", - "hu", - "hy", - "hz", - "ia", - "id", - "ie", - "ig", - "ii", - "ik", - "io", - "is", - "it", - "iu", - "ja", - "jv", - "ka", - "kg", - "ki", - "kj", - "kk", - "kl", - "km", - "kn", - "ko", - "kr", - "ks", - "ku", - "kv", - "kw", - "ky", - "la", - "lb", - "lg", - "li", - "ln", - "lo", - "lt", - "lu", - "lv", - "mg", - "mh", - "mi", - "mk", - "ml", - "mn", - "mr", - "ms", - "mt", - "my", - "na", - "nb", - "nd", - "ne", - "ng", - "nl", - "nn", - "no", - "nr", - "nv", - "ny", - "oc", - "oj", - "om", - "or", - "os", - "pa", - "pi", - "pl", - "ps", - "pt", - "qu", - "rm", - "rn", - "ro", - "ru", - "rw", - "sa", - "sc", - "sd", - "se", - "sg", - "si", - "sk", - "sl", - "sm", - "sn", - "so", - "sq", - "sr", - "ss", - "st", - "su", - "sv", - "sw", - "ta", - "te", - "tg", - "th", - "ti", - "tk", - "tl", - "tn", - "to", - "tr", - "ts", - "tt", - "tw", - "ty", - "ug", - "uk", - "ur", - "uz", - "ve", - "vi", - "vo", - "wa", - "wo", - "xh", - "yi", - "yo", - "za", - "zh", - "zu" + "MANDATORY", + "OPTIONAL", + "FORBIDDEN" ] } }, - "description": "Localization record for an address" - }, - "AddressVersionResponse": { - "type": "object", - "properties": { - "characterSet": { - "$ref": "#/components/schemas/TypeKeyNameDtoCharacterSet" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" - } - }, - "description": "Localization record of an address" + "description": "Rule for the quality level of an entity field " }, - "AdministrativeArea": { + "GeoCoordinates": { "type": "object", "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" + "longitude": { + "type": "number", + "description": "Longitude coordinate", + "format": "float" }, - "fipsCode": { - "type": "string" + "latitude": { + "type": "number", + "description": "Latitude coordinate", + "format": "float" }, - "type": { - "type": "string", - "enum": [ - "COUNTY", - "REGION", - "OTHER" - ] + "altitude": { + "type": "number", + "description": "Altitude, if applicable", + "format": "float" } }, - "description": "Areas such as country regions or counties" + "description": "Geo coordinates record for an address" }, - "AdministrativeAreaResponse": { + "IdentifierResponse": { "type": "object", "properties": { "value": { - "type": "string" - }, - "shortName": { - "type": "string" - }, - "fipsCode": { - "type": "string" + "type": "string", + "description": "Value of the identifier" }, "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoAdministrativeAreaType" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" + "$ref": "#/components/schemas/TypeKeyNameDtoString" } }, - "description": "Area of an address such as country region or county" + "description": "Identifier record of a logistic address" }, - "BankAccount": { + "IdentifierTypeDetailDto": { "type": "object", "properties": { - "trustScores": { - "type": "array", - "items": { - "type": "number", - "format": "float" - } - }, - "currency": { + "country": { "type": "string", + "description": "Country in which this identifier is valid, null for universal identifiers", "enum": [ "UNDEFINED", - "AED", - "AFN", - "ALL", - "AMD", - "ANG", - "AOA", - "ARS", - "AUD", - "AWG", - "AZN", - "BAM", - "BBD", - "BDT", - "BGN", - "BHD", - "BIF", - "BMD", - "BND", - "BOB", - "BOV", - "BRL", - "BSD", - "BTN", - "BWP", - "BYN", - "BYR", - "BZD", - "CAD", - "CDF", - "CHE", - "CHF", - "CHW", - "CLF", - "CLP", - "CNY", - "COP", - "COU", - "CRC", - "CUC", - "CUP", - "CVE", - "CZK", - "DJF", - "DKK", - "DOP", - "DZD", - "EGP", - "ERN", - "ETB", - "EUR", - "FJD", - "FKP", - "GBP", - "GEL", - "GHS", - "GIP", - "GMD", - "GNF", - "GTQ", - "GYD", - "HKD", - "HNL", - "HRK", - "HTG", - "HUF", - "IDR", - "ILS", - "INR", - "IQD", - "IRR", - "ISK", - "JMD", - "JOD", - "JPY", - "KES", - "KGS", - "KHR", - "KMF", - "KPW", - "KRW", - "KWD", - "KYD", - "KZT", - "LAK", - "LBP", - "LKR", - "LRD", - "LSL", - "LTL", - "LYD", - "MAD", - "MDL", - "MGA", - "MKD", - "MMK", - "MNT", - "MOP", - "MRO", - "MRU", - "MUR", - "MVR", - "MWK", - "MXN", - "MXV", - "MYR", - "MZN", - "NAD", - "NGN", - "NIO", - "NOK", - "NPR", - "NZD", - "OMR", - "PAB", - "PEN", - "PGK", - "PHP", - "PKR", - "PLN", - "PYG", - "QAR", - "RON", - "RSD", - "RUB", - "RUR", - "RWF", - "SAR", - "SBD", - "SCR", - "SDG", - "SEK", - "SGD", - "SHP", - "SLL", - "SOS", - "SRD", - "SSP", - "STD", - "STN", - "SVC", - "SYP", - "SZL", - "THB", - "TJS", - "TMT", - "TND", - "TOP", - "TRY", - "TTD", - "TWD", - "TZS", - "UAH", - "UGX", - "USD", - "USN", - "USS", - "UYI", - "UYU", - "UZS", - "VEF", - "VES", - "VND", - "VUV", - "WST", - "XAF", - "XAG", - "XAU", - "XBA", - "XBB", - "XBC", - "XBD", - "XCD", - "XDR", - "XOF", - "XPD", - "XPF", - "XPT", - "XSU", - "XTS", - "XUA", - "XXX", - "YER", - "ZAR", - "ZMW", - "ZWL" - ] - }, - "internationalBankAccountIdentifier": { - "type": "string" - }, - "internationalBankIdentifier": { - "type": "string" - }, - "nationalBankAccountIdentifier": { - "type": "string" - }, - "nationalBankIdentifier": { - "type": "string" - } - }, - "description": "Bank account record of a business partner" - }, - "BankAccountResponse": { - "type": "object", - "properties": { - "trustScores": { - "type": "array", - "items": { - "type": "number", - "format": "float" - } - }, - "currency": { - "$ref": "#/components/schemas/TypeKeyNameDtoCurrencyCode" - }, - "internationalBankAccountIdentifier": { - "type": "string" - }, - "internationalBankIdentifier": { - "type": "string" - }, - "nationalBankAccountIdentifier": { - "type": "string" - }, - "nationalBankIdentifier": { - "type": "string" - } - }, - "description": "Bank account record for a business partner" - }, - "BpnIdentifierMappingResponse": { - "type": "object", - "properties": { - "idValue": { - "type": "string" - }, - "bpn": { - "type": "string" - } - }, - "description": "Mapping of Business Partner Number to identifier value" - }, - "BusinessPartnerMatchResponse": { - "type": "object", - "properties": { - "score": { - "type": "number", - "format": "float" - }, - "businessPartner": { - "$ref": "#/components/schemas/BusinessPartnerResponse" - } - }, - "description": "Match with score for a business partner of type legal entity in legacy format", - "deprecated": true - }, - "BusinessPartnerResponse": { - "type": "object", - "properties": { - "uuid": { - "type": "string" - }, - "bpn": { - "type": "string" - }, - "identifiers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/IdentifierResponse" - } - }, - "names": { - "type": "array", - "items": { - "$ref": "#/components/schemas/NameResponse" - } - }, - "legalForm": { - "$ref": "#/components/schemas/LegalFormResponse" - }, - "status": { - "$ref": "#/components/schemas/BusinessStatusResponse" - }, - "profileClassifications": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ClassificationResponse" - } - }, - "types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoBusinessPartnerType" - } - }, - "bankAccounts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BankAccountResponse" - } - }, - "roles": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameDtoString" - } - }, - "relations": { - "type": "array", - "items": { - "$ref": "#/components/schemas/RelationResponse" - } - }, - "addresses": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AddressPartnerResponse" - } - }, - "sites": { - "type": "array", - "items": { - "$ref": "#/components/schemas/SitePartnerResponse" - } - }, - "currentness": { - "type": "string", - "format": "date-time" - } - }, - "description": "Business Partner of type legal entity in deprecated response format", - "deprecated": true - }, - "BusinessStatus": { - "type": "object", - "properties": { - "officialDenotation": { - "type": "string" - }, - "validFrom": { - "type": "string", - "format": "date-time" - }, - "validUntil": { - "type": "string", - "format": "date-time" - }, - "type": { - "type": "string", - "enum": [ - "ACTIVE", - "DISSOLVED", - "IN_LIQUIDATION", - "INACTIVE", - "INSOLVENCY", - "UNKNOWN" + "AC", + "AD", + "AE", + "AF", + "AG", + "AI", + "AL", + "AM", + "AN", + "AO", + "AQ", + "AR", + "AS", + "AT", + "AU", + "AW", + "AX", + "AZ", + "BA", + "BB", + "BD", + "BE", + "BF", + "BG", + "BH", + "BI", + "BJ", + "BL", + "BM", + "BN", + "BO", + "BQ", + "BR", + "BS", + "BT", + "BU", + "BV", + "BW", + "BY", + "BZ", + "CA", + "CC", + "CD", + "CF", + "CG", + "CH", + "CI", + "CK", + "CL", + "CM", + "CN", + "CO", + "CP", + "CR", + "CS", + "CU", + "CV", + "CW", + "CX", + "CY", + "CZ", + "DE", + "DG", + "DJ", + "DK", + "DM", + "DO", + "DZ", + "EA", + "EC", + "EE", + "EG", + "EH", + "ER", + "ES", + "ET", + "EU", + "EZ", + "FI", + "FJ", + "FK", + "FM", + "FO", + "FR", + "FX", + "GA", + "GB", + "GD", + "GE", + "GF", + "GG", + "GH", + "GI", + "GL", + "GM", + "GN", + "GP", + "GQ", + "GR", + "GS", + "GT", + "GU", + "GW", + "GY", + "HK", + "HM", + "HN", + "HR", + "HT", + "HU", + "IC", + "ID", + "IE", + "IL", + "IM", + "IN", + "IO", + "IQ", + "IR", + "IS", + "IT", + "JE", + "JM", + "JO", + "JP", + "KE", + "KG", + "KH", + "KI", + "KM", + "KN", + "KP", + "KR", + "KW", + "KY", + "KZ", + "LA", + "LB", + "LC", + "LI", + "LK", + "LR", + "LS", + "LT", + "LU", + "LV", + "LY", + "MA", + "MC", + "MD", + "ME", + "MF", + "MG", + "MH", + "MK", + "ML", + "MM", + "MN", + "MO", + "MP", + "MQ", + "MR", + "MS", + "MT", + "MU", + "MV", + "MW", + "MX", + "MY", + "MZ", + "NA", + "NC", + "NE", + "NF", + "NG", + "NI", + "NL", + "NO", + "NP", + "NR", + "NT", + "NU", + "NZ", + "OM", + "PA", + "PE", + "PF", + "PG", + "PH", + "PK", + "PL", + "PM", + "PN", + "PR", + "PS", + "PT", + "PW", + "PY", + "QA", + "RE", + "RO", + "RS", + "RU", + "RW", + "SA", + "SB", + "SC", + "SD", + "SE", + "SF", + "SG", + "SH", + "SI", + "SJ", + "SK", + "SL", + "SM", + "SN", + "SO", + "SR", + "SS", + "ST", + "SU", + "SV", + "SX", + "SY", + "SZ", + "TA", + "TC", + "TD", + "TF", + "TG", + "TH", + "TJ", + "TK", + "TL", + "TM", + "TN", + "TO", + "TP", + "TR", + "TT", + "TV", + "TW", + "TZ", + "UA", + "UG", + "UK", + "UM", + "US", + "UY", + "UZ", + "VA", + "VC", + "VE", + "VG", + "VI", + "VN", + "VU", + "WF", + "WS", + "XI", + "XU", + "XK", + "YE", + "YT", + "YU", + "ZA", + "ZM", + "ZR", + "ZW" ] - } - }, - "description": "Status record for a business partner" - }, - "BusinessStatusResponse": { - "type": "object", - "properties": { - "officialDenotation": { - "type": "string" - }, - "validFrom": { - "type": "string", - "format": "date-time" - }, - "validUntil": { - "type": "string", - "format": "date-time" }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoBusinessStatusType" + "mandatory": { + "type": "boolean", + "description": "True if identifier is mandatory in this country" } }, - "description": "Status of a business partner" + "description": "Identifier type validity details" }, - "ChangelogEntryResponse": { + "IdentifierTypeDto": { "type": "object", "properties": { - "bpn": { - "type": "string" + "technicalKey": { + "type": "string", + "description": "Unique key (in combination with lsaType) to be used as reference" }, - "changelogType": { + "lsaType": { "type": "string", + "description": "Specifies if an identifier type is valid for legal entities (L) or addresses (A). Sites (S) are not supported.", "enum": [ - "CREATE", - "UPDATE" + "LEGAL_ENTITY", + "ADDRESS" ] }, - "timestamp": { + "name": { "type": "string", - "format": "date-time" + "description": "Full name" + }, + "details": { + "type": "array", + "description": "Validity details", + "items": { + "$ref": "#/components/schemas/IdentifierTypeDetailDto" + } } }, - "description": "Changelog entry for a business partner" + "description": "Identifier type definition for legal entity or address" }, - "Classification": { + "IdentifiersSearchRequest": { "type": "object", "properties": { - "value": { - "type": "string" - }, - "code": { - "type": "string" - }, - "type": { + "lsaType": { "type": "string", + "description": "Specifies if an identifier type is valid for legal entities (L) or addresses (A). Sites (S) are not supported.", "enum": [ - "NACE", - "NAF", - "NAICS", - "SIC" + "LEGAL_ENTITY", + "ADDRESS" ] - } - }, - "description": "Classification record for a business partner" - }, - "ClassificationResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" }, - "code": { + "idType": { "type": "string" }, - "type": { - "$ref": "#/components/schemas/NamedTypeWithLink" + "idValues": { + "type": "array", + "items": { + "type": "string" + } } }, - "description": "Classification record of a business partner" + "description": "Contains identifiers to search legal entities by" }, - "CountryIdentifierTypeResponse": { + "LegalAddressResponse": { "type": "object", "properties": { - "identifierType": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddress" }, - "mandatory": { - "type": "boolean" - } - }, - "description": "Valid identifiers for a country" - }, - "GeoCoordinates": { - "type": "object", - "properties": { - "longitude": { - "type": "number", - "format": "float" + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" }, - "latitude": { - "type": "number", - "format": "float" + "bpnLegalEntity": { + "type": "string" }, - "altitude": { - "type": "number", - "format": "float" + "createdAt": { + "type": "string", + "format": "date-time" + }, + "updatedAt": { + "type": "string", + "format": "date-time" } }, - "description": "Geo coordinates record for an address" + "description": "Legal address for legal entity" }, - "Identifier": { + "LegalEntityCreateWrapper": { "type": "object", "properties": { - "value": { - "type": "string" + "entities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LegalEntityPartnerCreateResponse" + } }, - "type": { - "type": "string" + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ErrorInfoLegalEntityCreateError" + } }, - "issuingBody": { - "type": "string" + "errorCount": { + "type": "integer", + "format": "int32" }, - "status": { - "type": "string" + "entityCount": { + "type": "integer", + "format": "int32" } }, - "description": "Identifier record for a business partner" + "description": "Holds information about successfully and failed entities after the creating/updating of several objects" }, - "IdentifierResponse": { + "LegalEntityIdentifier": { "type": "object", "properties": { "value": { - "type": "string" + "type": "string", + "description": "Value of the identifier" }, "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" + "type": "string", + "description": "Technical key of the type to which this identifier belongs to" }, "issuingBody": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" - }, - "status": { - "$ref": "#/components/schemas/TypeKeyNameDtoString" + "type": "string", + "description": "Body which issued the identifier" } }, - "description": "Identifier record of a business partner" + "description": "Identifier record for a legal entity" }, - "IdentifiersSearchRequest": { + "LegalEntityIdentifierResponse": { "type": "object", "properties": { - "idType": { - "type": "string" + "value": { + "type": "string", + "description": "Value of the identifier" }, - "idValues": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "description": "Contains identifiers to search legal entities by" - }, - "LegalAddressSearchResponse": { - "type": "object", - "properties": { - "legalEntity": { - "type": "string" + "type": { + "$ref": "#/components/schemas/TypeKeyNameDtoString" }, - "legalAddress": { - "$ref": "#/components/schemas/AddressResponse" + "issuingBody": { + "type": "string", + "description": "Body which issued the identifier" } }, - "description": "Legal address record with parent BPN" + "description": "Identifier record of a legal entity" }, "LegalEntityMatchResponse": { "type": "object", @@ -6252,113 +3420,37 @@ "type": "number", "format": "float" }, - "legalEntity": { - "$ref": "#/components/schemas/LegalEntityPartnerResponse" - } - }, - "description": "Match with score for a business partner record of type legal entity" - }, - "LegalEntityPartnerCreateRequest": { - "type": "object", - "properties": { - "identifiers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Identifier" - } - }, - "names": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Name" - } - }, - "legalForm": { - "type": "string" - }, - "status": { - "$ref": "#/components/schemas/BusinessStatus" - }, - "profileClassifications": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Classification" - } - }, - "types": { - "type": "array", - "items": { - "type": "string", - "enum": [ - "BRAND", - "LEGAL_ENTITY", - "ORGANIZATIONAL_UNIT", - "SITE", - "UNKNOWN" - ] - } - }, - "bankAccounts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BankAccount" - } - }, - "legalAddress": { - "$ref": "#/components/schemas/Address" + "legalName": { + "type": "string", + "description": "Legal name the partner goes by" }, - "index": { - "type": "string" - } - }, - "description": "Request for creating new business partner record of type legal entity" - }, - "LegalEntityPartnerCreateResponse": { - "type": "object", - "properties": { - "bpn": { - "type": "string" + "bpnl": { + "type": "string", + "description": "Business Partner Number of this legal entity" }, "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/IdentifierResponse" + "$ref": "#/components/schemas/LegalEntityIdentifierResponse" } }, - "names": { - "type": "array", - "items": { - "$ref": "#/components/schemas/NameResponse" - } + "legalShortName": { + "type": "string", + "description": "Abbreviated name or shorthand" }, "legalForm": { "$ref": "#/components/schemas/LegalFormResponse" }, - "status": { - "$ref": "#/components/schemas/BusinessStatusResponse" - }, - "profileClassifications": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ClassificationResponse" - } - }, - "types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoBusinessPartnerType" - } - }, - "bankAccounts": { + "states": { "type": "array", "items": { - "$ref": "#/components/schemas/BankAccountResponse" + "$ref": "#/components/schemas/LegalEntityStateResponse" } }, - "roles": { + "classifications": { "type": "array", "items": { - "$ref": "#/components/schemas/TypeKeyNameDtoString" + "$ref": "#/components/schemas/ClassificationResponse" } }, "relations": { @@ -6369,1397 +3461,667 @@ }, "currentness": { "type": "string", + "description": "The timestamp the business partner data was last indicated to be still current", "format": "date-time" }, - "legalAddress": { - "$ref": "#/components/schemas/AddressResponse" + "createdAt": { + "type": "string", + "description": "The timestamp the business partner data was created", + "format": "date-time" }, - "index": { - "type": "string" + "updatedAt": { + "type": "string", + "description": "The timestamp the business partner data was last updated", + "format": "date-time" + }, + "legalAddress": { + "$ref": "#/components/schemas/LogisticAddressResponse" } }, - "description": "Created business partner of type legal entity" + "description": "Match with score for a business partner record of type legal entity" }, - "LegalEntityPartnerResponse": { + "LegalEntityPartnerCreateRequest": { "type": "object", "properties": { - "bpn": { - "type": "string" + "legalName": { + "type": "string", + "description": "Legal name the partner goes by" }, "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/IdentifierResponse" + "$ref": "#/components/schemas/LegalEntityIdentifier" } }, - "names": { - "type": "array", - "items": { - "$ref": "#/components/schemas/NameResponse" - } + "legalShortName": { + "type": "string", + "description": "Abbreviated name or shorthand" }, "legalForm": { - "$ref": "#/components/schemas/LegalFormResponse" - }, - "status": { - "$ref": "#/components/schemas/BusinessStatusResponse" - }, - "profileClassifications": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ClassificationResponse" - } - }, - "types": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoBusinessPartnerType" - } + "type": "string", + "description": "Technical key of the legal form" }, - "bankAccounts": { + "states": { "type": "array", "items": { - "$ref": "#/components/schemas/BankAccountResponse" + "$ref": "#/components/schemas/LegalEntityState" } }, - "roles": { + "classifications": { "type": "array", "items": { - "$ref": "#/components/schemas/TypeKeyNameDtoString" + "$ref": "#/components/schemas/Classification" } }, - "relations": { - "type": "array", - "items": { - "$ref": "#/components/schemas/RelationResponse" - } + "legalAddress": { + "$ref": "#/components/schemas/LogisticAddressDto" }, - "currentness": { - "type": "string", - "format": "date-time" + "index": { + "type": "string" } }, - "description": "Business partner of type legal entity with currentness" + "description": "Request for creating new business partner record of type legal entity" }, - "LegalEntityUpdateRequest": { + "LegalEntityPartnerCreateResponse": { "type": "object", "properties": { - "bpn": { - "type": "string" + "legalName": { + "type": "string", + "description": "Legal name the partner goes by" + }, + "bpnl": { + "type": "string", + "description": "Business Partner Number of this legal entity" }, "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/Identifier" + "$ref": "#/components/schemas/LegalEntityIdentifierResponse" } }, - "names": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Name" - } + "legalShortName": { + "type": "string", + "description": "Abbreviated name or shorthand" }, "legalForm": { - "type": "string" - }, - "status": { - "$ref": "#/components/schemas/BusinessStatus" + "$ref": "#/components/schemas/LegalFormResponse" }, - "profileClassifications": { + "states": { "type": "array", "items": { - "$ref": "#/components/schemas/Classification" + "$ref": "#/components/schemas/LegalEntityStateResponse" } }, - "types": { + "classifications": { "type": "array", "items": { - "type": "string", - "enum": [ - "BRAND", - "LEGAL_ENTITY", - "ORGANIZATIONAL_UNIT", - "SITE", - "UNKNOWN" - ] + "$ref": "#/components/schemas/ClassificationResponse" } }, - "bankAccounts": { + "relations": { "type": "array", "items": { - "$ref": "#/components/schemas/BankAccount" + "$ref": "#/components/schemas/RelationResponse" } }, + "currentness": { + "type": "string", + "description": "The timestamp the business partner data was last indicated to be still current", + "format": "date-time" + }, + "createdAt": { + "type": "string", + "description": "The timestamp the business partner data was created", + "format": "date-time" + }, + "updatedAt": { + "type": "string", + "description": "The timestamp the business partner data was last updated", + "format": "date-time" + }, "legalAddress": { - "$ref": "#/components/schemas/Address" + "$ref": "#/components/schemas/LogisticAddressResponse" + }, + "index": { + "type": "string" } }, - "description": "Request for updating a business partner record of type legal entity" + "description": "Created business partner of type legal entity" }, - "LegalFormRequest": { + "LegalEntityPartnerUpdateRequest": { "type": "object", "properties": { - "technicalKey": { - "type": "string" - }, - "name": { - "type": "string" - }, - "url": { - "type": "string" - }, - "mainAbbreviation": { + "bpnl": { "type": "string" }, - "language": { + "legalName": { "type": "string", - "enum": [ - "undefined", - "aa", - "ab", - "ae", - "af", - "ak", - "am", - "an", - "ar", - "as", - "av", - "ay", - "az", - "ba", - "be", - "bg", - "bh", - "bi", - "bm", - "bn", - "bo", - "br", - "bs", - "ca", - "ce", - "ch", - "co", - "cr", - "cs", - "cu", - "cv", - "cy", - "da", - "de", - "dv", - "dz", - "ee", - "el", - "en", - "eo", - "es", - "et", - "eu", - "fa", - "ff", - "fi", - "fj", - "fo", - "fr", - "fy", - "ga", - "gd", - "gl", - "gn", - "gu", - "gv", - "ha", - "he", - "hi", - "ho", - "hr", - "ht", - "hu", - "hy", - "hz", - "ia", - "id", - "ie", - "ig", - "ii", - "ik", - "io", - "is", - "it", - "iu", - "ja", - "jv", - "ka", - "kg", - "ki", - "kj", - "kk", - "kl", - "km", - "kn", - "ko", - "kr", - "ks", - "ku", - "kv", - "kw", - "ky", - "la", - "lb", - "lg", - "li", - "ln", - "lo", - "lt", - "lu", - "lv", - "mg", - "mh", - "mi", - "mk", - "ml", - "mn", - "mr", - "ms", - "mt", - "my", - "na", - "nb", - "nd", - "ne", - "ng", - "nl", - "nn", - "no", - "nr", - "nv", - "ny", - "oc", - "oj", - "om", - "or", - "os", - "pa", - "pi", - "pl", - "ps", - "pt", - "qu", - "rm", - "rn", - "ro", - "ru", - "rw", - "sa", - "sc", - "sd", - "se", - "sg", - "si", - "sk", - "sl", - "sm", - "sn", - "so", - "sq", - "sr", - "ss", - "st", - "su", - "sv", - "sw", - "ta", - "te", - "tg", - "th", - "ti", - "tk", - "tl", - "tn", - "to", - "tr", - "ts", - "tt", - "tw", - "ty", - "ug", - "uk", - "ur", - "uz", - "ve", - "vi", - "vo", - "wa", - "wo", - "xh", - "yi", - "yo", - "za", - "zh", - "zu" - ] + "description": "Legal name the partner goes by" }, - "category": { + "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/NamedTypeWithLink" + "$ref": "#/components/schemas/LegalEntityIdentifier" } - } - }, - "description": "New legal form record to be referenced by business partners" - }, - "LegalFormResponse": { - "type": "object", - "properties": { - "technicalKey": { - "type": "string" - }, - "name": { - "type": "string" }, - "url": { - "type": "string" + "legalShortName": { + "type": "string", + "description": "Abbreviated name or shorthand" }, - "mainAbbreviation": { - "type": "string" + "legalForm": { + "type": "string", + "description": "Technical key of the legal form" }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LegalEntityState" + } }, - "categories": { + "classifications": { "type": "array", "items": { - "$ref": "#/components/schemas/NamedTypeWithLink" + "$ref": "#/components/schemas/Classification" } + }, + "legalAddress": { + "$ref": "#/components/schemas/LogisticAddressDto" } }, - "description": "Legal form a business partner can have" + "description": "Request for updating a business partner record of type legal entity" }, - "Locality": { + "LegalEntityState": { "type": "object", "properties": { - "value": { - "type": "string" + "officialDenotation": { + "type": "string", + "description": "Exact, official denotation of the status" }, - "shortName": { - "type": "string" + "validFrom": { + "type": "string", + "description": "Since when the status is/was valid", + "format": "date-time" + }, + "validTo": { + "type": "string", + "description": "Until the status was valid, if applicable", + "format": "date-time" }, "type": { "type": "string", + "description": "The type of this specified status", "enum": [ - "BLOCK", - "CITY", - "DISTRICT", - "OTHER", - "POST_OFFICE_CITY", - "QUARTER" + "ACTIVE", + "INACTIVE" ] } }, - "description": "Locality record for an address such as city, block or district" + "description": "Status record of a legal entity" }, - "LocalityResponse": { + "LegalEntityStateResponse": { "type": "object", "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" + "officialDenotation": { + "type": "string", + "description": "Exact, official denotation of the status" }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoLocalityType" + "validFrom": { + "type": "string", + "description": "Since when the status is/was valid", + "format": "date-time" }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" - } - }, - "description": "Locality record of an address such as city, block or district" - }, - "MainAddressSearchResponse": { - "type": "object", - "properties": { - "site": { - "type": "string" + "validTo": { + "type": "string", + "description": "Until the status was valid, if applicable", + "format": "date-time" }, - "mainAddress": { - "$ref": "#/components/schemas/AddressResponse" + "type": { + "$ref": "#/components/schemas/TypeKeyNameDtoBusinessStateType" } }, - "description": "Main address record with parent BPN" + "description": "Status record of a legal entity" }, - "Name": { + "LegalEntityUpdateWrapper": { "type": "object", "properties": { - "value": { - "type": "string" + "entities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LegalEntityPartnerCreateResponse" + } }, - "shortName": { - "type": "string" + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ErrorInfoLegalEntityUpdateError" + } }, - "type": { - "type": "string", - "enum": [ - "ACRONYM", - "DOING_BUSINESS_AS", - "ESTABLISHMENT", - "INTERNATIONAL", - "LOCAL", - "OTHER", - "REGISTERED", - "TRANSLITERATED", - "VAT_REGISTERED" - ] + "errorCount": { + "type": "integer", + "format": "int32" }, - "language": { - "type": "string", - "enum": [ - "undefined", - "aa", - "ab", - "ae", - "af", - "ak", - "am", - "an", - "ar", - "as", - "av", - "ay", - "az", - "ba", - "be", - "bg", - "bh", - "bi", - "bm", - "bn", - "bo", - "br", - "bs", - "ca", - "ce", - "ch", - "co", - "cr", - "cs", - "cu", - "cv", - "cy", - "da", - "de", - "dv", - "dz", - "ee", - "el", - "en", - "eo", - "es", - "et", - "eu", - "fa", - "ff", - "fi", - "fj", - "fo", - "fr", - "fy", - "ga", - "gd", - "gl", - "gn", - "gu", - "gv", - "ha", - "he", - "hi", - "ho", - "hr", - "ht", - "hu", - "hy", - "hz", - "ia", - "id", - "ie", - "ig", - "ii", - "ik", - "io", - "is", - "it", - "iu", - "ja", - "jv", - "ka", - "kg", - "ki", - "kj", - "kk", - "kl", - "km", - "kn", - "ko", - "kr", - "ks", - "ku", - "kv", - "kw", - "ky", - "la", - "lb", - "lg", - "li", - "ln", - "lo", - "lt", - "lu", - "lv", - "mg", - "mh", - "mi", - "mk", - "ml", - "mn", - "mr", - "ms", - "mt", - "my", - "na", - "nb", - "nd", - "ne", - "ng", - "nl", - "nn", - "no", - "nr", - "nv", - "ny", - "oc", - "oj", - "om", - "or", - "os", - "pa", - "pi", - "pl", - "ps", - "pt", - "qu", - "rm", - "rn", - "ro", - "ru", - "rw", - "sa", - "sc", - "sd", - "se", - "sg", - "si", - "sk", - "sl", - "sm", - "sn", - "so", - "sq", - "sr", - "ss", - "st", - "su", - "sv", - "sw", - "ta", - "te", - "tg", - "th", - "ti", - "tk", - "tl", - "tn", - "to", - "tr", - "ts", - "tt", - "tw", - "ty", - "ug", - "uk", - "ur", - "uz", - "ve", - "vi", - "vo", - "wa", - "wo", - "xh", - "yi", - "yo", - "za", - "zh", - "zu" - ] + "entityCount": { + "type": "integer", + "format": "int32" } }, - "description": "Name record for a business partner" + "description": "Holds information about successfully and failed entities after the creating/updating of several objects" }, - "NameResponse": { + "LegalFormRequest": { "type": "object", "properties": { - "value": { - "type": "string" - }, - "shortName": { + "technicalKey": { "type": "string" }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoNameType" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" - } - }, - "description": "Name record of a business partner" - }, - "NamedTypeWithLink": { - "type": "object", - "properties": { "name": { "type": "string" }, - "url": { + "abbreviation": { "type": "string" } }, - "description": "General type with name and URL link for further information" + "description": "New legal form record to be referenced by business partners" }, - "PageResponseAddressMatchResponse": { + "LegalFormResponse": { "type": "object", "properties": { - "totalElements": { - "type": "integer", - "format": "int64" - }, - "totalPages": { - "type": "integer", - "format": "int32" - }, - "page": { - "type": "integer", - "format": "int32" + "technicalKey": { + "type": "string", + "description": "Unique key to be used for reference" }, - "contentSize": { - "type": "integer", - "format": "int32" + "name": { + "type": "string", + "description": "Full name of the legal form" }, - "content": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AddressMatchResponse" - } + "abbreviation": { + "type": "string", + "description": "Abbreviation of the legal form name" } }, - "description": "Paginated collection of results" + "description": "Legal form a business partner can have" }, - "PageResponseAddressPartnerResponse": { + "LogisticAddressDto": { "type": "object", "properties": { - "totalElements": { - "type": "integer", - "format": "int64" - }, - "totalPages": { - "type": "integer", - "format": "int32" - }, - "page": { - "type": "integer", - "format": "int32" - }, - "contentSize": { - "type": "integer", - "format": "int32" + "name": { + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." }, - "content": { + "states": { "type": "array", "items": { - "$ref": "#/components/schemas/AddressPartnerResponse" + "$ref": "#/components/schemas/AddressState" } - } - }, - "description": "Paginated collection of results" - }, - "PageResponseAddressPartnerSearchResponse": { - "type": "object", - "properties": { - "totalElements": { - "type": "integer", - "format": "int64" - }, - "totalPages": { - "type": "integer", - "format": "int32" - }, - "page": { - "type": "integer", - "format": "int32" - }, - "contentSize": { - "type": "integer", - "format": "int32" }, - "content": { + "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/AddressPartnerSearchResponse" + "$ref": "#/components/schemas/AddressIdentifier" } - } - }, - "description": "Paginated collection of results" - }, - "PageResponseBusinessPartnerMatchResponse": { - "type": "object", - "properties": { - "totalElements": { - "type": "integer", - "format": "int64" - }, - "totalPages": { - "type": "integer", - "format": "int32" - }, - "page": { - "type": "integer", - "format": "int32" }, - "contentSize": { - "type": "integer", - "format": "int32" + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddress" }, - "content": { - "type": "array", - "items": { - "$ref": "#/components/schemas/BusinessPartnerMatchResponse" - } + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" } }, - "description": "Paginated collection of results" + "description": "Address record for a business partner" }, - "PageResponseChangelogEntryResponse": { + "LogisticAddressResponse": { "type": "object", "properties": { - "totalElements": { - "type": "integer", - "format": "int64" - }, - "totalPages": { - "type": "integer", - "format": "int32" - }, - "page": { - "type": "integer", - "format": "int32" + "bpna": { + "type": "string", + "description": "Business Partner Number of this address" }, - "contentSize": { - "type": "integer", - "format": "int32" + "name": { + "type": "string", + "description": "Name of the logistic address of the business partner. This is not according to official\nregisters but according to the name the uploading sharing member chooses." }, - "content": { + "states": { "type": "array", "items": { - "$ref": "#/components/schemas/ChangelogEntryResponse" + "$ref": "#/components/schemas/AddressStateResponse" } - } - }, - "description": "Paginated collection of results" - }, - "PageResponseLegalEntityMatchResponse": { - "type": "object", - "properties": { - "totalElements": { - "type": "integer", - "format": "int64" - }, - "totalPages": { - "type": "integer", - "format": "int32" - }, - "page": { - "type": "integer", - "format": "int32" - }, - "contentSize": { - "type": "integer", - "format": "int32" }, - "content": { + "identifiers": { "type": "array", "items": { - "$ref": "#/components/schemas/LegalEntityMatchResponse" + "$ref": "#/components/schemas/IdentifierResponse" } + }, + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddress" + }, + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" + }, + "bpnLegalEntity": { + "type": "string", + "description": "BPN of the related legal entity, if available" + }, + "bpnSite": { + "type": "string", + "description": "BPN of the related site, if available" + }, + "createdAt": { + "type": "string", + "description": "The timestamp the business partner data was created", + "format": "date-time" + }, + "updatedAt": { + "type": "string", + "description": "The timestamp the business partner data was last updated", + "format": "date-time" + }, + "isLegalAddress": { + "type": "boolean", + "description": "Flag if this is the legal address of its related legal entity" + }, + "isMainAddress": { + "type": "boolean", + "description": "Flag if this is the main address of its related site" } }, - "description": "Paginated collection of results" + "description": "Logistic address " }, - "PageResponseLegalFormResponse": { + "MainAddressResponse": { "type": "object", "properties": { - "totalElements": { - "type": "integer", - "format": "int64" + "physicalPostalAddress": { + "$ref": "#/components/schemas/PhysicalPostalAddress" }, - "totalPages": { - "type": "integer", - "format": "int32" + "alternativePostalAddress": { + "$ref": "#/components/schemas/AlternativePostalAddress" }, - "page": { - "type": "integer", - "format": "int32" + "bpnSite": { + "type": "string" }, - "contentSize": { - "type": "integer", - "format": "int32" + "createdAt": { + "type": "string", + "format": "date-time" }, - "content": { - "type": "array", - "items": { - "$ref": "#/components/schemas/LegalFormResponse" - } + "updatedAt": { + "type": "string", + "format": "date-time" } }, - "description": "Paginated collection of results" + "description": "Main address for site" }, - "PageResponseSitePartnerResponse": { + "PageResponseAddressMatchResponse": { "type": "object", "properties": { "totalElements": { "type": "integer", + "description": "Total number of all results in all pages", "format": "int64" }, "totalPages": { "type": "integer", + "description": "Total number pages", "format": "int32" }, "page": { "type": "integer", + "description": "Current page number", "format": "int32" }, "contentSize": { "type": "integer", + "description": "Number of results in the page", "format": "int32" }, "content": { "type": "array", + "description": "Collection of results in the page", "items": { - "$ref": "#/components/schemas/SitePartnerResponse" + "$ref": "#/components/schemas/AddressMatchResponse" } } }, "description": "Paginated collection of results" }, - "PageResponseSitePartnerSearchResponse": { + "PageResponseChangelogEntryResponse": { "type": "object", "properties": { "totalElements": { "type": "integer", + "description": "Total number of all results in all pages", "format": "int64" }, "totalPages": { "type": "integer", + "description": "Total number pages", "format": "int32" }, "page": { "type": "integer", + "description": "Current page number", "format": "int32" }, "contentSize": { "type": "integer", + "description": "Number of results in the page", "format": "int32" }, "content": { "type": "array", + "description": "Collection of results in the page", "items": { - "$ref": "#/components/schemas/SitePartnerSearchResponse" + "$ref": "#/components/schemas/ChangelogEntryResponse" } } }, "description": "Paginated collection of results" }, - "PageResponseSuggestionResponse": { + "PageResponseIdentifierTypeDto": { "type": "object", "properties": { "totalElements": { "type": "integer", + "description": "Total number of all results in all pages", "format": "int64" }, "totalPages": { "type": "integer", + "description": "Total number pages", "format": "int32" }, "page": { "type": "integer", + "description": "Current page number", "format": "int32" }, "contentSize": { "type": "integer", + "description": "Number of results in the page", "format": "int32" }, "content": { "type": "array", + "description": "Collection of results in the page", "items": { - "$ref": "#/components/schemas/SuggestionResponse" + "$ref": "#/components/schemas/IdentifierTypeDto" } } }, "description": "Paginated collection of results" }, - "PageResponseTypeKeyNameDtoString": { + "PageResponseLegalEntityMatchResponse": { "type": "object", "properties": { "totalElements": { "type": "integer", + "description": "Total number of all results in all pages", "format": "int64" }, "totalPages": { "type": "integer", + "description": "Total number pages", "format": "int32" }, "page": { "type": "integer", + "description": "Current page number", "format": "int32" }, "contentSize": { "type": "integer", + "description": "Number of results in the page", "format": "int32" }, "content": { "type": "array", + "description": "Collection of results in the page", "items": { - "$ref": "#/components/schemas/TypeKeyNameDtoString" + "$ref": "#/components/schemas/LegalEntityMatchResponse" } } }, "description": "Paginated collection of results" }, - "PageResponseTypeKeyNameUrlDtoString": { + "PageResponseLegalFormResponse": { "type": "object", "properties": { "totalElements": { "type": "integer", + "description": "Total number of all results in all pages", "format": "int64" }, "totalPages": { "type": "integer", + "description": "Total number pages", "format": "int32" }, - "page": { - "type": "integer", - "format": "int32" - }, - "contentSize": { - "type": "integer", - "format": "int32" - }, - "content": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoString" - } - } - }, - "description": "Paginated collection of results" - }, - "PostalDeliveryPoint": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" - }, - "number": { - "type": "string" - }, - "type": { - "type": "string", - "enum": [ - "INTERURBAN_DELIVERY_POINT", - "MAIL_STATION", - "MAILBOX", - "OTHER", - "POST_OFFICE_BOX" - ] - } - }, - "description": "Postal delivery point record for an address" - }, - "PostalDeliveryPointResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" - }, - "number": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoPostalDeliveryPointType" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" - } - }, - "description": "Postal delivery point record of an address" - }, - "Postcode": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "type": { - "type": "string", - "enum": [ - "CEDEX", - "LARGE_MAIL_USER", - "OTHER", - "POST_BOX", - "REGULAR" - ] - } - }, - "description": "Postcode record for an address" - }, - "PostcodeResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoPostCodeType" - } - }, - "description": "Postcode record of an address" - }, - "Premise": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" - }, - "number": { - "type": "string" - }, - "type": { - "type": "string", - "enum": [ - "BUILDING", - "OTHER", - "LEVEL", - "HARBOUR", - "ROOM", - "SUITE", - "UNIT", - "WAREHOUSE" - ] - } - }, - "description": "Premise record for an address such as building, room or floor" - }, - "PremiseResponse": { - "type": "object", - "properties": { - "value": { - "type": "string" - }, - "shortName": { - "type": "string" - }, - "number": { - "type": "string" - }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoPremiseType" - }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" - } - }, - "description": "Premise record of an address such as building, room or floor" - }, - "RelationResponse": { - "type": "object", - "properties": { - "relationClass": { - "$ref": "#/components/schemas/TypeKeyNameDtoRelationClass" - }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameDtoRelationType" - }, - "startNode": { - "type": "string" - }, - "endNode": { - "type": "string" - }, - "startedAt": { - "type": "string", - "format": "date-time" - }, - "endedAt": { - "type": "string", - "format": "date-time" - } - }, - "description": "Directed relation between two business partners" - }, - "SiteBpnSearchRequest": { - "type": "object", - "properties": { - "legalEntities": { - "type": "array", - "items": { - "type": "string" - } - }, - "sites": { - "type": "array", - "items": { - "type": "string" - } - } - } - }, - "SitePartnerCreateRequest": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "mainAddress": { - "$ref": "#/components/schemas/Address" - }, - "legalEntity": { - "type": "string" - }, - "index": { - "type": "string" - } - }, - "description": "Request for creating new business partner record of type site" - }, - "SitePartnerCreateResponse": { - "type": "object", - "properties": { - "bpn": { - "type": "string" - }, - "name": { - "type": "string" - }, - "mainAddress": { - "$ref": "#/components/schemas/AddressResponse" - }, - "index": { - "type": "string" - } - }, - "description": "Created business partner record of type site" - }, - "SitePartnerResponse": { - "type": "object", - "properties": { - "bpn": { - "type": "string" - }, - "name": { - "type": "string" - } - }, - "description": "Business partner of type site" - }, - "SitePartnerSearchResponse": { - "type": "object", - "properties": { - "site": { - "$ref": "#/components/schemas/SitePartnerResponse" - }, - "bpnLegalEntity": { - "type": "string" - } - }, - "description": "Business partner of type site with parent BPN" - }, - "SitePartnerUpdateRequest": { - "type": "object", - "properties": { - "bpn": { - "type": "string" - }, - "name": { - "type": "string" - }, - "mainAddress": { - "$ref": "#/components/schemas/Address" - } - }, - "description": "Request for updating a business partner record of type site" - }, - "SuggestionResponse": { - "type": "object", - "properties": { - "suggestion": { - "type": "string" + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" }, - "relevancy": { - "type": "number", - "format": "float" + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" + }, + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/LegalFormResponse" + } } }, - "description": "Shows a ranked suggestion based on a given search text" + "description": "Paginated collection of results" }, - "SyncResponse": { + "PageResponseLogisticAddressResponse": { "type": "object", "properties": { - "type": { - "type": "string", - "enum": [ - "OPENSEARCH", - "SAAS_IMPORT" - ] - }, - "status": { - "type": "string", - "enum": [ - "NOT_SYNCED", - "RUNNING", - "SUCCESS", - "ERROR" - ] + "totalElements": { + "type": "integer", + "description": "Total number of all results in all pages", + "format": "int64" }, - "count": { + "totalPages": { "type": "integer", + "description": "Total number pages", "format": "int32" }, - "progress": { - "type": "number", - "format": "float" - }, - "errorDetails": { - "type": "string" + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" }, - "startedAt": { - "type": "string", - "format": "date-time" + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" }, - "finishedAt": { - "type": "string", - "format": "date-time" + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/LogisticAddressResponse" + } } - } + }, + "description": "Paginated collection of results" }, - "Thoroughfare": { + "PageResponseSitePoolResponse": { "type": "object", "properties": { - "value": { - "type": "string" - }, - "name": { - "type": "string" + "totalElements": { + "type": "integer", + "description": "Total number of all results in all pages", + "format": "int64" }, - "shortName": { - "type": "string" + "totalPages": { + "type": "integer", + "description": "Total number pages", + "format": "int32" }, - "number": { - "type": "string" + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" }, - "direction": { - "type": "string" + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" }, - "type": { - "type": "string", - "enum": [ - "INDUSTRIAL_ZONE", - "OTHER", - "RIVER", - "SQUARE", - "STREET" - ] + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/SitePoolResponse" + } } }, - "description": "Thoroughfare record for an address such as street, square or industrial zone" + "description": "Paginated collection of results" }, - "ThoroughfareResponse": { + "PageResponseSiteResponse": { "type": "object", "properties": { - "value": { - "type": "string" - }, - "name": { - "type": "string" - }, - "shortName": { - "type": "string" + "totalElements": { + "type": "integer", + "description": "Total number of all results in all pages", + "format": "int64" }, - "number": { - "type": "string" + "totalPages": { + "type": "integer", + "description": "Total number pages", + "format": "int32" }, - "direction": { - "type": "string" + "page": { + "type": "integer", + "description": "Current page number", + "format": "int32" }, - "type": { - "$ref": "#/components/schemas/TypeKeyNameUrlDtoThoroughfareType" + "contentSize": { + "type": "integer", + "description": "Number of results in the page", + "format": "int32" }, - "language": { - "$ref": "#/components/schemas/TypeKeyNameDtoLanguageCode" + "content": { + "type": "array", + "description": "Collection of results in the page", + "items": { + "$ref": "#/components/schemas/SiteResponse" + } } }, - "description": "Thoroughfare record of an address such as street, square or industrial zone" + "description": "Paginated collection of results" }, - "TypeKeyNameDtoCharacterSet": { + "PhysicalPostalAddress": { "type": "object", "properties": { - "technicalKey": { - "type": "string", - "enum": [ - "ARABIC", - "CHINESE", - "CHINESE_TRADITIONAL", - "CYRILLIC", - "GREEK", - "HANGUL_KOREAN", - "HEBREW", - "HIRAGANA", - "KANJI", - "KATAKANA", - "LATIN", - "THAI", - "WESTERN_LATIN_STANDARD", - "UNDEFINED" - ] + "geographicCoordinates": { + "$ref": "#/components/schemas/GeoCoordinates" }, - "name": { - "type": "string" - } - }, - "description": "Named type uniquely identified by its technical key" - }, - "TypeKeyNameDtoCountryCode": { - "type": "object", - "properties": { - "technicalKey": { + "country": { "type": "string", + "description": "Describes the country", "enum": [ "UNDEFINED", "AC", @@ -8035,678 +4397,537 @@ "ZW" ] }, - "name": { - "type": "string" + "postalCode": { + "type": "string", + "description": "A postal code, also known as postcode, PIN or ZIP Code" + }, + "city": { + "type": "string", + "description": "The city of the address (Synonym: Town, village, municipality)" + }, + "street": { + "$ref": "#/components/schemas/Street" + }, + "administrativeAreaLevel1": { + "type": "string", + "description": "Identifying code of the Region within the country (e.g. Bayern)" + }, + "administrativeAreaLevel2": { + "type": "string", + "description": "Further possibility to describe the region/address(e.g. County/Landkreis)" + }, + "administrativeAreaLevel3": { + "type": "string", + "description": "Further possibility to describe the region/address(e.g. Township/Gemeinde)" + }, + "district": { + "type": "string", + "description": "Divides the city in several smaller areas" + }, + "companyPostalCode": { + "type": "string", + "description": "A separate postal code for a company, also known as postcode, PIN or ZIP Code" + }, + "industrialZone": { + "type": "string", + "description": "The practice of designating an area for industrial development" + }, + "building": { + "type": "string", + "description": "Describes a specific building within the address" + }, + "floor": { + "type": "string", + "description": "Describes the floor/level the delivery shall take place" + }, + "door": { + "type": "string", + "description": "Describes the door/room/suite on the respective floor the delivery shall take place" + } + }, + "description": "Physical Postal Address Part" + }, + "PoolLegalEntityResponse": { + "type": "object", + "properties": { + "legalName": { + "type": "string", + "description": "Legal name the partner goes by" + }, + "bpnl": { + "type": "string", + "description": "Business Partner Number of this legal entity" + }, + "identifiers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LegalEntityIdentifierResponse" + } + }, + "legalShortName": { + "type": "string", + "description": "Abbreviated name or shorthand" + }, + "legalForm": { + "$ref": "#/components/schemas/LegalFormResponse" + }, + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LegalEntityStateResponse" + } + }, + "classifications": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassificationResponse" + } + }, + "relations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RelationResponse" + } + }, + "currentness": { + "type": "string", + "description": "The timestamp the business partner data was last indicated to be still current", + "format": "date-time" + }, + "createdAt": { + "type": "string", + "description": "The timestamp the business partner data was created", + "format": "date-time" + }, + "updatedAt": { + "type": "string", + "description": "The timestamp the business partner data was last updated", + "format": "date-time" + }, + "legalAddress": { + "$ref": "#/components/schemas/LogisticAddressResponse" + } + }, + "description": "Legal entity record" + }, + "RelationResponse": { + "type": "object", + "properties": { + "type": { + "$ref": "#/components/schemas/TypeKeyNameDtoRelationType" + }, + "startBpn": { + "type": "string", + "description": "BPN of partner which is the source of the relation" + }, + "endBpn": { + "type": "string", + "description": "BPN of partner which is the target of the relation" + }, + "validFrom": { + "type": "string", + "description": "Time when the relation started", + "format": "date-time" + }, + "validTo": { + "type": "string", + "description": "Time when the relation ended", + "format": "date-time" + } + }, + "description": "Directed relation between two business partners" + }, + "SiteBpnSearchRequest": { + "type": "object", + "properties": { + "legalEntities": { + "type": "array", + "items": { + "type": "string" + } + }, + "sites": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "SiteCreateWrapper": { + "type": "object", + "properties": { + "entities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SitePartnerCreateResponse" + } + }, + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ErrorInfoSiteCreateError" + } + }, + "errorCount": { + "type": "integer", + "format": "int32" + }, + "entityCount": { + "type": "integer", + "format": "int32" } }, - "description": "Named type uniquely identified by its technical key" + "description": "Holds information about successfully and failed entities after the creating/updating of several objects" }, - "TypeKeyNameDtoCurrencyCode": { + "SitePartnerCreateRequest": { "type": "object", "properties": { - "technicalKey": { + "name": { "type": "string", - "enum": [ - "UNDEFINED", - "AED", - "AFN", - "ALL", - "AMD", - "ANG", - "AOA", - "ARS", - "AUD", - "AWG", - "AZN", - "BAM", - "BBD", - "BDT", - "BGN", - "BHD", - "BIF", - "BMD", - "BND", - "BOB", - "BOV", - "BRL", - "BSD", - "BTN", - "BWP", - "BYN", - "BYR", - "BZD", - "CAD", - "CDF", - "CHE", - "CHF", - "CHW", - "CLF", - "CLP", - "CNY", - "COP", - "COU", - "CRC", - "CUC", - "CUP", - "CVE", - "CZK", - "DJF", - "DKK", - "DOP", - "DZD", - "EGP", - "ERN", - "ETB", - "EUR", - "FJD", - "FKP", - "GBP", - "GEL", - "GHS", - "GIP", - "GMD", - "GNF", - "GTQ", - "GYD", - "HKD", - "HNL", - "HRK", - "HTG", - "HUF", - "IDR", - "ILS", - "INR", - "IQD", - "IRR", - "ISK", - "JMD", - "JOD", - "JPY", - "KES", - "KGS", - "KHR", - "KMF", - "KPW", - "KRW", - "KWD", - "KYD", - "KZT", - "LAK", - "LBP", - "LKR", - "LRD", - "LSL", - "LTL", - "LYD", - "MAD", - "MDL", - "MGA", - "MKD", - "MMK", - "MNT", - "MOP", - "MRO", - "MRU", - "MUR", - "MVR", - "MWK", - "MXN", - "MXV", - "MYR", - "MZN", - "NAD", - "NGN", - "NIO", - "NOK", - "NPR", - "NZD", - "OMR", - "PAB", - "PEN", - "PGK", - "PHP", - "PKR", - "PLN", - "PYG", - "QAR", - "RON", - "RSD", - "RUB", - "RUR", - "RWF", - "SAR", - "SBD", - "SCR", - "SDG", - "SEK", - "SGD", - "SHP", - "SLL", - "SOS", - "SRD", - "SSP", - "STD", - "STN", - "SVC", - "SYP", - "SZL", - "THB", - "TJS", - "TMT", - "TND", - "TOP", - "TRY", - "TTD", - "TWD", - "TZS", - "UAH", - "UGX", - "USD", - "USN", - "USS", - "UYI", - "UYU", - "UZS", - "VEF", - "VES", - "VND", - "VUV", - "WST", - "XAF", - "XAG", - "XAU", - "XBA", - "XBB", - "XBC", - "XBD", - "XCD", - "XDR", - "XOF", - "XPD", - "XPF", - "XPT", - "XSU", - "XTS", - "XUA", - "XXX", - "YER", - "ZAR", - "ZMW", - "ZWL" - ] + "description": "Site name" }, - "name": { + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteState" + } + }, + "mainAddress": { + "$ref": "#/components/schemas/LogisticAddressDto" + }, + "bpnlParent": { + "type": "string" + }, + "index": { "type": "string" } }, - "description": "Named type uniquely identified by its technical key" + "description": "Request for creating new business partner record of type site" }, - "TypeKeyNameDtoLanguageCode": { + "SitePartnerCreateResponse": { "type": "object", "properties": { - "technicalKey": { + "bpns": { "type": "string", - "enum": [ - "undefined", - "aa", - "ab", - "ae", - "af", - "ak", - "am", - "an", - "ar", - "as", - "av", - "ay", - "az", - "ba", - "be", - "bg", - "bh", - "bi", - "bm", - "bn", - "bo", - "br", - "bs", - "ca", - "ce", - "ch", - "co", - "cr", - "cs", - "cu", - "cv", - "cy", - "da", - "de", - "dv", - "dz", - "ee", - "el", - "en", - "eo", - "es", - "et", - "eu", - "fa", - "ff", - "fi", - "fj", - "fo", - "fr", - "fy", - "ga", - "gd", - "gl", - "gn", - "gu", - "gv", - "ha", - "he", - "hi", - "ho", - "hr", - "ht", - "hu", - "hy", - "hz", - "ia", - "id", - "ie", - "ig", - "ii", - "ik", - "io", - "is", - "it", - "iu", - "ja", - "jv", - "ka", - "kg", - "ki", - "kj", - "kk", - "kl", - "km", - "kn", - "ko", - "kr", - "ks", - "ku", - "kv", - "kw", - "ky", - "la", - "lb", - "lg", - "li", - "ln", - "lo", - "lt", - "lu", - "lv", - "mg", - "mh", - "mi", - "mk", - "ml", - "mn", - "mr", - "ms", - "mt", - "my", - "na", - "nb", - "nd", - "ne", - "ng", - "nl", - "nn", - "no", - "nr", - "nv", - "ny", - "oc", - "oj", - "om", - "or", - "os", - "pa", - "pi", - "pl", - "ps", - "pt", - "qu", - "rm", - "rn", - "ro", - "ru", - "rw", - "sa", - "sc", - "sd", - "se", - "sg", - "si", - "sk", - "sl", - "sm", - "sn", - "so", - "sq", - "sr", - "ss", - "st", - "su", - "sv", - "sw", - "ta", - "te", - "tg", - "th", - "ti", - "tk", - "tl", - "tn", - "to", - "tr", - "ts", - "tt", - "tw", - "ty", - "ug", - "uk", - "ur", - "uz", - "ve", - "vi", - "vo", - "wa", - "wo", - "xh", - "yi", - "yo", - "za", - "zh", - "zu" - ] + "description": "Business Partner Number, main identifier value for sites" }, "name": { + "type": "string", + "description": "Site name" + }, + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteStateResponse" + } + }, + "bpnLegalEntity": { + "type": "string", + "description": "Business Partner Number of the related legal entity" + }, + "createdAt": { + "type": "string", + "description": "The timestamp the business partner data was created", + "format": "date-time" + }, + "updatedAt": { + "type": "string", + "description": "The timestamp the business partner data was last updated", + "format": "date-time" + }, + "mainAddress": { + "$ref": "#/components/schemas/LogisticAddressResponse" + }, + "index": { "type": "string" } }, - "description": "Named type uniquely identified by its technical key" + "description": "Created business partner record of type site" }, - "TypeKeyNameDtoRelationClass": { + "SitePartnerUpdateRequest": { "type": "object", "properties": { - "technicalKey": { - "type": "string", - "enum": [ - "SAAS_HIERARCHY", - "SAAS_TRANSITION", - "CX_HIERARCHY", - "DNB_HIERARCHY", - "LEI_HIERARCHY" - ] + "bpns": { + "type": "string" }, "name": { - "type": "string" + "type": "string", + "description": "Site name" + }, + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteState" + } + }, + "mainAddress": { + "$ref": "#/components/schemas/LogisticAddressDto" } }, - "description": "Named type uniquely identified by its technical key" + "description": "Request for updating a business partner record of type site" }, - "TypeKeyNameDtoRelationType": { + "SitePoolResponse": { "type": "object", "properties": { - "technicalKey": { + "bpns": { "type": "string", - "enum": [ - "CX_LEGAL_SUCCESSOR_OF", - "CX_LEGAL_PREDECESSOR_OF", - "CX_ADDRESS_OF", - "CX_SITE_OF", - "CX_OWNED_BY", - "DIRECT_LEGAL_RELATION", - "COMMERCIAL_ULTIMATE", - "DOMESTIC_BRANCH_RELATION", - "INTERNATIONAL_BRANCH_RELATION", - "DOMESTIC_LEGAL_ULTIMATE_RELATION", - "GLOBAL_LEGAL_ULTIMATE_RELATION", - "LEGAL_PREDECESSOR", - "LEGAL_SUCCESSOR", - "DNB_PARENT", - "DNB_HEADQUARTER", - "DNB_DOMESTIC_ULTIMATE", - "DNB_GLOBAL_ULTIMATE", - "LEI_DIRECT_PARENT", - "LEI_INTERNATIONAL_BRANCH", - "LEI_ULTIMATE_PARENT" - ] + "description": "Business Partner Number, main identifier value for sites" }, "name": { - "type": "string" + "type": "string", + "description": "Site name" + }, + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteStateResponse" + } + }, + "bpnLegalEntity": { + "type": "string", + "description": "Business Partner Number of the related legal entity" + }, + "createdAt": { + "type": "string", + "description": "The timestamp the business partner data was created", + "format": "date-time" + }, + "updatedAt": { + "type": "string", + "description": "The timestamp the business partner data was last updated", + "format": "date-time" + }, + "mainAddress": { + "$ref": "#/components/schemas/LogisticAddressResponse" } }, - "description": "Named type uniquely identified by its technical key" + "description": "Site with legal entity reference." }, - "TypeKeyNameDtoString": { + "SiteResponse": { "type": "object", "properties": { - "technicalKey": { - "type": "string" + "bpns": { + "type": "string", + "description": "Business Partner Number, main identifier value for sites" }, "name": { - "type": "string" + "type": "string", + "description": "Site name" + }, + "states": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SiteStateResponse" + } + }, + "bpnLegalEntity": { + "type": "string", + "description": "Business Partner Number of the related legal entity" + }, + "createdAt": { + "type": "string", + "description": "The timestamp the business partner data was created", + "format": "date-time" + }, + "updatedAt": { + "type": "string", + "description": "The timestamp the business partner data was last updated", + "format": "date-time" } }, - "description": "Named type uniquely identified by its technical key" + "description": "Site of a legal entity" }, - "TypeKeyNameUrlDtoAddressType": { + "SiteState": { "type": "object", "properties": { - "technicalKey": { + "description": { "type": "string", - "enum": [ - "BRANCH_OFFICE", - "CARE_OF", - "HEADQUARTER", - "LEGAL_ALTERNATIVE", - "PO_BOX", - "REGISTERED", - "REGISTERED_AGENT_MAIL", - "REGISTERED_AGENT_PHYSICAL", - "VAT_REGISTERED", - "UNSPECIFIC" - ] + "description": "Description of the status" }, - "name": { - "type": "string" + "validFrom": { + "type": "string", + "description": "Since when the status is/was valid", + "format": "date-time" }, - "url": { - "type": "string" + "validTo": { + "type": "string", + "description": "Until the status was valid, if applicable", + "format": "date-time" + }, + "type": { + "type": "string", + "description": "The type of this specified status", + "enum": [ + "ACTIVE", + "INACTIVE" + ] } - } + }, + "description": "Status record of a site" }, - "TypeKeyNameUrlDtoAdministrativeAreaType": { + "SiteStateResponse": { "type": "object", "properties": { - "technicalKey": { + "description": { "type": "string", - "enum": [ - "COUNTY", - "REGION", - "OTHER" - ] + "description": "Description of the status" }, - "name": { - "type": "string" + "validFrom": { + "type": "string", + "description": "Since when the status is/was valid", + "format": "date-time" }, - "url": { - "type": "string" + "validTo": { + "type": "string", + "description": "Until the status was valid, if applicable", + "format": "date-time" + }, + "type": { + "$ref": "#/components/schemas/TypeKeyNameDtoBusinessStateType" } - } + }, + "description": "Status record of a site" }, - "TypeKeyNameUrlDtoBusinessPartnerType": { + "SiteUpdateWrapper": { "type": "object", "properties": { - "technicalKey": { - "type": "string", - "enum": [ - "BRAND", - "LEGAL_ENTITY", - "ORGANIZATIONAL_UNIT", - "SITE", - "UNKNOWN" - ] + "entities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SitePartnerCreateResponse" + } }, - "name": { - "type": "string" + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ErrorInfoSiteUpdateError" + } }, - "url": { - "type": "string" + "errorCount": { + "type": "integer", + "format": "int32" + }, + "entityCount": { + "type": "integer", + "format": "int32" } - } + }, + "description": "Holds information about successfully and failed entities after the creating/updating of several objects" }, - "TypeKeyNameUrlDtoBusinessStatusType": { + "Street": { "type": "object", "properties": { - "technicalKey": { + "name": { "type": "string", - "enum": [ - "ACTIVE", - "DISSOLVED", - "IN_LIQUIDATION", - "INACTIVE", - "INSOLVENCY", - "UNKNOWN" - ] + "description": "Describes the official Name of the Street." }, - "name": { - "type": "string" + "houseNumber": { + "type": "string", + "description": "Describes the House Number" }, - "url": { - "type": "string" + "milestone": { + "type": "string", + "description": "The Milestone is relevant for long roads without specific house numbers." + }, + "direction": { + "type": "string", + "description": "Describes the direction" } - } + }, + "description": "A public road in a city, town, or village, typically with houses and buildings on one or both sides." }, - "TypeKeyNameUrlDtoLocalityType": { + "SyncResponse": { "type": "object", "properties": { - "technicalKey": { + "type": { "type": "string", "enum": [ - "BLOCK", - "CITY", - "DISTRICT", - "OTHER", - "POST_OFFICE_CITY", - "QUARTER" + "OPENSEARCH", + "SAAS_IMPORT" ] }, - "name": { - "type": "string" - }, - "url": { - "type": "string" - } - } - }, - "TypeKeyNameUrlDtoNameType": { - "type": "object", - "properties": { - "technicalKey": { + "status": { "type": "string", "enum": [ - "ACRONYM", - "DOING_BUSINESS_AS", - "ESTABLISHMENT", - "INTERNATIONAL", - "LOCAL", - "OTHER", - "REGISTERED", - "TRANSLITERATED", - "VAT_REGISTERED" + "NOT_SYNCED", + "RUNNING", + "SUCCESS", + "ERROR" ] }, - "name": { - "type": "string" + "count": { + "type": "integer", + "format": "int32" + }, + "progress": { + "type": "number", + "format": "float" }, - "url": { + "errorDetails": { "type": "string" + }, + "startedAt": { + "type": "string", + "format": "date-time" + }, + "finishedAt": { + "type": "string", + "format": "date-time" } } }, - "TypeKeyNameUrlDtoPostCodeType": { + "TypeKeyNameDtoBusinessStateType": { "type": "object", "properties": { "technicalKey": { "type": "string", "enum": [ - "CEDEX", - "LARGE_MAIL_USER", - "OTHER", - "POST_BOX", - "REGULAR" + "ACTIVE", + "INACTIVE" ] }, "name": { "type": "string" - }, - "url": { - "type": "string" } - } + }, + "description": "Named type uniquely identified by its technical key" }, - "TypeKeyNameUrlDtoPostalDeliveryPointType": { + "TypeKeyNameDtoClassificationType": { "type": "object", "properties": { "technicalKey": { "type": "string", "enum": [ - "INTERURBAN_DELIVERY_POINT", - "MAIL_STATION", - "MAILBOX", - "OTHER", - "POST_OFFICE_BOX" + "NACE", + "NAF", + "NAICS", + "SIC" ] }, "name": { "type": "string" - }, - "url": { - "type": "string" } - } + }, + "description": "Named type uniquely identified by its technical key" }, - "TypeKeyNameUrlDtoPremiseType": { + "TypeKeyNameDtoRelationType": { "type": "object", "properties": { "technicalKey": { "type": "string", "enum": [ - "BUILDING", - "OTHER", - "LEVEL", - "HARBOUR", - "ROOM", - "SUITE", - "UNIT", - "WAREHOUSE" + "CX_LEGAL_SUCCESSOR_OF", + "CX_LEGAL_PREDECESSOR_OF" ] }, "name": { "type": "string" - }, - "url": { - "type": "string" } - } + }, + "description": "Named type uniquely identified by its technical key" }, - "TypeKeyNameUrlDtoString": { + "TypeKeyNameDtoString": { "type": "object", "properties": { "technicalKey": { @@ -8714,32 +4935,9 @@ }, "name": { "type": "string" - }, - "url": { - "type": "string" - } - } - }, - "TypeKeyNameUrlDtoThoroughfareType": { - "type": "object", - "properties": { - "technicalKey": { - "type": "string", - "enum": [ - "INDUSTRIAL_ZONE", - "OTHER", - "RIVER", - "SQUARE", - "STREET" - ] - }, - "name": { - "type": "string" - }, - "url": { - "type": "string" } - } + }, + "description": "Named type uniquely identified by its technical key" } } } diff --git a/docs/api/pool.yaml b/docs/api/pool.yaml index ebf8d233b..426ebd884 100644 --- a/docs/api/pool.yaml +++ b/docs/api/pool.yaml @@ -2,7 +2,7 @@ openapi: 3.0.1 info: title: Business Partner Data Management Pool description: Service that manages and shares business partner data with other CatenaX services - version: 4.0.0 + version: 4.0.0-SNAPSHOT servers: - url: http://localhost:8080 description: Generated server url @@ -24,13 +24,11 @@ paths: required: true responses: '200': - description: The successfully updated records + description: Update sites request was processed successfully, possible errors are returned content: - '*/*': + application/json: schema: - type: array - items: - $ref: '#/components/schemas/SitePartnerCreateResponse' + $ref: '#/components/schemas/SiteUpdateWrapper' '400': description: On malformed requests post: @@ -49,13 +47,11 @@ paths: required: true responses: '200': - description: New business partner record successfully created + description: New sites request was processed successfully, possible errors are returned content: - '*/*': + application/json: schema: - type: array - items: - $ref: '#/components/schemas/SitePartnerCreateResponse' + $ref: '#/components/schemas/SiteCreateWrapper' '400': description: On malformed requests /api/catena/legal-entities: @@ -63,75 +59,15 @@ paths: tags: - legal-entity-controller summary: Get page of legal entity business partners matching the search criteria - description: This endpoint tries to find matches among all existing business partners of type legal entity, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. + description: This endpoint tries to find matches among all existing business partners of type legal entity, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. Note that when using search parameters the max page is 20. operationId: getLegalEntities parameters: - - name: name + - name: legalName in: query description: Filter legal entities by name required: false schema: type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - name: page in: query description: Number of page to get results from @@ -153,7 +89,7 @@ paths: '200': description: Page of business partners matching the search criteria, may be empty content: - '*/*': + application/json: schema: $ref: '#/components/schemas/PageResponseLegalEntityMatchResponse' '400': @@ -170,21 +106,17 @@ paths: schema: type: array items: - $ref: '#/components/schemas/LegalEntityUpdateRequest' + $ref: '#/components/schemas/LegalEntityPartnerUpdateRequest' required: true responses: '200': - description: The successfully updated records + description: Update legal entities request was processed successfully, possible errors are returned content: - '*/*': + application/json: schema: - type: array - items: - $ref: '#/components/schemas/LegalEntityPartnerCreateResponse' + $ref: '#/components/schemas/LegalEntityUpdateWrapper' '400': description: On malformed requests - '404': - description: Metadata referenced by technical key not found post: tags: - legal-entity-controller @@ -201,104 +133,413 @@ paths: required: true responses: '200': - description: New business partner record successfully created + description: New legal entities request was processed successfully, possible errors are returned content: - '*/*': + application/json: schema: - type: array - items: - $ref: '#/components/schemas/LegalEntityPartnerCreateResponse' + $ref: '#/components/schemas/LegalEntityCreateWrapper' '400': description: On malformed requests - '404': - description: Metadata referenced by technical key not found /api/catena/addresses: get: tags: - address-controller summary: Get page of addresses matching the search criteria - description: This endpoint tries to find matches among all existing business partners of type address, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. + description: This endpoint tries to find matches among all existing business partners of type address, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. Note that when using search parameters the max page is 20. operationId: getAddresses_1 parameters: - - name: administrativeArea + - name: name in: query - description: Filter business partners by administrative area name + description: Filter business partners by name required: false schema: type: string - - name: postCode + - name: page in: query - description: Filter business partners by postcode or postcodes + description: Number of page to get results from required: false schema: + minimum: 0 type: string - - name: locality + default: '0' + - name: size in: query - description: Filter business partners by locality full denotation + description: Size of each page required: false schema: + maximum: 100 + minimum: 0 type: string - - name: thoroughfare + default: '10' + responses: + '200': + description: Page of addresses matching the search criteria, may be empty + content: + application/json: + schema: + $ref: '#/components/schemas/PageResponseAddressMatchResponse' + '400': + description: On malformed search or pagination request + put: + tags: + - address-controller + summary: Update existing address business partners + description: Update existing business partner records of type address referenced via BPNA. The endpoint expects to receive the full updated record, including values that didn't change. + operationId: updateAddresses + requestBody: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/AddressPartnerUpdateRequest' + required: true + responses: + '200': + description: The successfully updated records, possible errors are returned + content: + application/json: + schema: + $ref: '#/components/schemas/AddressUpdateWrapper' + '400': + description: On malformed requests + post: + tags: + - address-controller + summary: Create new address business partners + description: Create new business partners of type address by specifying the BPN of the parent each address belongs to. A parent can be either a site or legal entity business partner. If the parent cannot be found, the record is ignored.For matching purposes, on each record you can specify your own index value which will reappear in the corresponding record of the response. + operationId: createAddresses + requestBody: + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/AddressPartnerCreateRequest' + required: true + responses: + '200': + description: New business partner record successfully created, possible errors are returned + content: + application/json: + schema: + $ref: '#/components/schemas/AddressCreateWrapper' + '400': + description: On malformed requests + /api/opensearch/business-partner: + get: + tags: + - open-search-controller + summary: Fetch information about the latest OpenSearch export + description: Fetch information about the latest export (either ongoing or already finished) + operationId: getBusinessPartners + responses: + '200': + description: Export information found + content: + application/json: + schema: + $ref: '#/components/schemas/SyncResponse' + '500': + description: Fetching failed (no connection to database) + post: + tags: + - open-search-controller + summary: Index new business partner records on OpenSearch + description: 'Triggers an asynchronous export of business partner records from BPDM to OpenSearch. Only exports records which have been updated since the last export. ' + operationId: export + responses: + '200': + description: Export of records successfully + content: + application/json: + schema: + $ref: '#/components/schemas/SyncResponse' + '500': + description: Export failed (no connection to OpenSearch or database) + delete: + tags: + - open-search-controller + summary: Clear business partner index on OpenSearch + description: Deletes all business partner records in the OpenSearch index. Also resets the timestamp from the last export. + operationId: clear + responses: + '200': + description: Index successfully cleared + '500': + description: Clearing failed (no connection to OpenSearch or database) + /api/catena/sites/search: + post: + tags: + - site-controller + summary: Search site partners by BPNs and/or parent BPNs + description: Search business partners of type site by their BPNSs or by the BPNLs of their parent legal entities + operationId: searchSites + parameters: + - name: page in: query - description: Filter business partners by thoroughfare full denotation + description: Number of page to get results from required: false schema: + minimum: 0 type: string - - name: premise + default: '0' + - name: size in: query - description: Filter business partners by premise full denotation + description: Size of each page required: false schema: + maximum: 100 + minimum: 0 type: string - - name: postalDeliveryPoint + default: '10' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SiteBpnSearchRequest' + required: true + responses: + '200': + description: Found sites that belong to specified legal entites + content: + application/json: + schema: + $ref: '#/components/schemas/PageResponseSitePoolResponse' + '400': + description: On malformed request parameters + /api/catena/sites/main-addresses/search: + post: + tags: + - site-controller + summary: Search Main Addresses + description: Search main addresses of site business partners by BPNS + operationId: searchMainAddresses + requestBody: + content: + application/json: + schema: + type: array + items: + type: string + required: true + responses: + '200': + description: The found main addresses + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/MainAddressResponse' + '400': + description: On malformed request parameters + /api/catena/legal-forms: + get: + tags: + - metadata-controller + summary: Get page of legal forms + description: Lists all currently known legal forms in a paginated result + operationId: getLegalForms + parameters: + - name: page in: query - description: Filter business partners by postal delivery point full denotation + description: Number of page to get results from required: false schema: + minimum: 0 type: string - - name: countryCode + default: '0' + - name: size in: query - description: Filter business partners by ISO 3166-1 alpha-2 country code + description: Size of each page required: false schema: + maximum: 100 + minimum: 0 type: string - enum: - - UNDEFINED - - AC - - AD - - AE - - AF - - AG - - AI - - AL - - AM - - AN - - AO - - AQ - - AR - - AS - - AT - - AU - - AW - - AX - - AZ - - BA - - BB - - BD - - BE - - BF - - BG - - BH - - BI - - BJ - - BL - - BM - - BN - - BO - - BQ - - BR - - BS - - BT + default: '10' + responses: + '200': + description: Page of existing legal forms, may be empty + content: + application/json: + schema: + $ref: '#/components/schemas/PageResponseLegalFormResponse' + '400': + description: On malformed request parameters + post: + tags: + - metadata-controller + summary: Create new legal form + description: 'Create a new legal form which can be referenced by business partner records. The actual name of the legal form is free to choose and doesn''t need to be unique. The technical key can be freely chosen but needs to be unique for the lsaType as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.' + operationId: createLegalForm + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/LegalFormRequest' + required: true + responses: + '200': + description: New legal form successfully created + content: + application/json: + schema: + $ref: '#/components/schemas/LegalFormResponse' + '400': + description: On malformed request parameters + '409': + description: Legal form with specified technical key already exists + /api/catena/legal-entities/{bpnl}/confirm-up-to-date: + post: + tags: + - legal-entity-controller + 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 bpnl. + operationId: setLegalEntityCurrentness + parameters: + - name: bpnl + in: path + description: Bpnl value + required: true + schema: + type: string + responses: + '200': + description: Business partner's "currentness" successfully updated + '400': + description: On malformed request parameters + '404': + description: No business partner found for specified bpnl + /api/catena/legal-entities/search: + post: + tags: + - legal-entity-controller + summary: Search legal entity partners by BPNLs + description: Search legal entity partners by their BPNLs. The response can contain less results than the number of BPNLs that were requested, if some of the BPNLs did not exist. For a single request, the maximum number of BPNLs to search for is limited to ${bpdm.bpn.search-request-limit} entries. + operationId: searchSites_1 + requestBody: + content: + application/json: + schema: + type: array + items: + type: string + required: true + responses: + '200': + description: Found legal entites + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/PoolLegalEntityResponse' + '400': + description: On malformed request parameters or if number of requested bpns exceeds limit + /api/catena/legal-entities/legal-addresses/search: + post: + tags: + - legal-entity-controller + summary: Search Legal Addresses + description: Search legal addresses of legal entities by BPNL + operationId: searchLegalAddresses + requestBody: + content: + application/json: + schema: + type: array + items: + type: string + required: true + responses: + '200': + description: The found legal addresses + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/LegalAddressResponse' + '400': + description: On malformed request parameters + /api/catena/identifier-types: + get: + tags: + - metadata-controller + summary: Get page of identifier types filtered by lsaType and (optionally) country (specified by its ISO 3166-1 alpha-2 country code) + description: Lists all matching identifier types including validity details in a paginated result + operationId: getIdentifierTypes + parameters: + - name: page + in: query + description: Number of page to get results from + required: false + schema: + minimum: 0 + type: string + default: '0' + - name: size + in: query + description: Size of each page + required: false + schema: + maximum: 100 + minimum: 0 + type: string + default: '10' + - name: lsaType + in: query + required: true + schema: + type: string + description: Specifies if an identifier type is valid for legal entities (L) or addresses (A). Sites (S) are not supported. + enum: + - LEGAL_ENTITY + - ADDRESS + - name: country + in: query + required: false + schema: + type: string + enum: + - UNDEFINED + - AC + - AD + - AE + - AF + - AG + - AI + - AL + - AM + - AN + - AO + - AQ + - AR + - AS + - AT + - AU + - AW + - AX + - AZ + - BA + - BB + - BD + - BE + - BF + - BG + - BH + - BI + - BJ + - BL + - BM + - BN + - BO + - BQ + - BR + - BS + - BT - BU - BV - BW @@ -535,6 +776,46 @@ paths: - ZM - ZR - ZW + responses: + '200': + description: Page of existing identifier types, may be empty + content: + application/json: + schema: + $ref: '#/components/schemas/PageResponseIdentifierTypeDto' + '400': + description: On malformed request parameters + post: + tags: + - metadata-controller + summary: Create new identifier type + description: 'Create a new identifier type (including validity details) which can be referenced by business partner records. Identifier types such as BPN or VAT determine with which kind of values a business partner can be identified with. The actual name of the identifier type is free to choose and doesn''t need to be unique. The technical key can be freely chosen but needs to be unique for the lsaType as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.' + operationId: createIdentifierType + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IdentifierTypeDto' + required: true + responses: + '200': + description: New identifier type successfully created + content: + application/json: + schema: + $ref: '#/components/schemas/IdentifierTypeDto' + '400': + description: On malformed request parameters + '409': + description: Identifier type with specified technical key already exists + /api/catena/business-partners/changelog/search: + post: + tags: + - changelog-controller + summary: Get business partner changelog entries from time, by BPN and/or LSA type + description: Get business partner changelog entries from time, by BPN and/or LSA type + operationId: getChangelogEntries + parameters: - name: page in: query description: Number of page to get results from @@ -552,1722 +833,90 @@ paths: minimum: 0 type: string default: '10' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ChangeLogSearchRequest' + required: true responses: '200': - description: Page of addresses matching the search criteria, may be empty + description: The specified changelog entries content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/PageResponseAddressMatchResponse' + $ref: '#/components/schemas/PageResponseChangelogEntryResponse' '400': - description: On malformed search or pagination request - put: + description: On malformed pagination request + '404': + description: No business partner found for specified bpn + /api/catena/bpn/search: + post: tags: - - address-controller - summary: Update existing address business partners - description: Update existing business partner records of type address referenced via BPNA. The endpoint expects to receive the full updated record, including values that didn't change. - operationId: updateAddresses + - bpn-controller + summary: Find business partner numbers by identifiers + description: Find business partner numbers by identifiers. The response can contain less results than the number of identifier values that were requested, if some of the identifiers did not exist. For a single request, the maximum number of identifier values to search for is limited to ${bpdm.bpn.search-request-limit} entries. + operationId: findBpnsByIdentifiers requestBody: content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/AddressPartnerUpdateRequest' + $ref: '#/components/schemas/IdentifiersSearchRequest' required: true responses: '200': - description: The successfully updated records + description: Found bpn to identifier value mappings content: - '*/*': + application/json: schema: + uniqueItems: true type: array items: - $ref: '#/components/schemas/AddressPartnerResponse' + $ref: '#/components/schemas/BpnIdentifierMappingResponse' '400': - description: On malformed requests + description: On malformed request parameters or if number of requested bpns exceeds limit + '404': + description: Specified identifier type not found + /api/catena/addresses/search: post: tags: - address-controller - summary: Create new address business partners - description: Create new business partners of type address by specifying the BPN of the parent each address belongs to. A parent can be either a site or legal entity business partner. If the parent cannot be found, the record is ignored.For matching purposes, on each record you can specify your own index value which will reappear in the corresponding record of the response. - operationId: createAddresses + summary: Search address partners by BPNs and/or parent BPNs + description: Search business partners of type address by their BPN or their parent partners BPN (BPNLs or BPNS). + operationId: searchAddresses + parameters: + - name: page + in: query + description: Number of page to get results from + required: false + schema: + minimum: 0 + type: string + default: '0' + - name: size + in: query + description: Size of each page + required: false + schema: + maximum: 100 + minimum: 0 + type: string + default: '10' requestBody: content: application/json: schema: - type: array - items: - $ref: '#/components/schemas/AddressPartnerCreateRequest' + $ref: '#/components/schemas/AddressPartnerBpnSearchRequest' required: true responses: '200': - description: New business partner record successfully created - content: - '*/*': - schema: - type: array - items: - $ref: '#/components/schemas/AddressPartnerCreateResponse' - '400': - description: On malformed requests - /api/saas/business-partner/sync: - get: - tags: - - saas-controller - summary: Fetch information about the SaaS synchronization - description: Fetch information about the latest import (either ongoing or already finished) - operationId: getSyncStatus - responses: - '200': - description: Import information found - content: - '*/*': - schema: - $ref: '#/components/schemas/SyncResponse' - '500': - description: Fetching failed (no connection to database) - post: - tags: - - saas-controller - summary: Import new business partner records from SaaS - description: Triggers an asynchronous import of new business partner records from SaaS. A SaaS record counts as new when it does not have a BPN and the BPDM service does not already have a record with the same SaaS ID. This import only regards records with a modifiedAfter timestamp since the last import. - operationId: importBusinessPartners - responses: - '200': - description: Import successfully started - content: - '*/*': - schema: - $ref: '#/components/schemas/SyncResponse' - '409': - description: Import already running - content: - '*/*': - schema: - $ref: '#/components/schemas/SyncResponse' - '500': - description: Import couldn't start to unexpected error - /api/opensearch/business-partner: - get: - tags: - - open-search-controller - summary: Fetch information about the latest OpenSearch export - description: Fetch information about the latest export (either ongoing or already finished) - operationId: getBusinessPartners - responses: - '200': - description: Export information found - content: - '*/*': - schema: - $ref: '#/components/schemas/SyncResponse' - '500': - description: Fetching failed (no connection to database) - post: - tags: - - open-search-controller - summary: Index new business partner records on OpenSearch - description: 'Triggers an asynchronous export of business partner records from BPDM to OpenSearch. Only exports records which have been updated since the last export. ' - operationId: export - responses: - '200': - description: Export of records successfully - content: - '*/*': - schema: - $ref: '#/components/schemas/SyncResponse' - '500': - description: Export failed (no connection to OpenSearch or database) - delete: - tags: - - open-search-controller - summary: Clear business partner index on OpenSearch - description: Deletes all business partner records in the OpenSearch index. Also resets the timestamp from the last export. - operationId: clear - responses: - '200': - description: Index successfully cleared - '500': - description: Clearing failed (no connection to OpenSearch or database) - /api/catena/sites/search: - post: - tags: - - site-controller - summary: Search site partners by BPNs and/or parent BPNs - description: Search business partners of type site by their BPNSs or by the BPNLs of their parent legal entities - operationId: searchSites - parameters: - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/SiteBpnSearchRequest' - required: true - responses: - '200': - description: Found sites that belong to specified legal entites - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSitePartnerSearchResponse' - '400': - description: On malformed request parameters - /api/catena/sites/main-addresses/search: - post: - tags: - - site-controller - summary: Search Main Addresses - description: Search main addresses of site business partners by BPNS - operationId: searchMainAddresses - requestBody: - content: - application/json: - schema: - type: array - items: - type: string - required: true - responses: - '200': - description: The found main addresses - content: - '*/*': - schema: - type: array - items: - $ref: '#/components/schemas/MainAddressSearchResponse' - '400': - description: On malformed request parameters - /api/catena/legal-forms: - get: - tags: - - metadata-controller - summary: Get page of legal forms - description: Lists all currently known legal forms in a paginated result - operationId: getLegalForms - parameters: - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Page of existing legal forms, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseLegalFormResponse' - '400': - description: On malformed request parameters - post: - tags: - - metadata-controller - summary: Create new legal form - description: 'Create a new legal form which can be referenced by business partner records. The actual name of the legal form is free to choose and doesn''t need to be unique. The technical key can be freely chosen but needs to be unique as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.' - operationId: createLegalForm - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/LegalFormRequest' - required: true - responses: - '200': - description: New legal form successfully created - content: - '*/*': - schema: - $ref: '#/components/schemas/LegalFormResponse' - '400': - description: On malformed request parameters - '409': - description: Legal form with specified technical key already exists - /api/catena/legal-entities/{bpn}/confirm-up-to-date: - post: - tags: - - legal-entity-controller - 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. - operationId: setLegalEntityCurrentness - parameters: - - name: bpn - in: path - description: Bpn value - required: true - schema: - type: string - responses: - '200': - description: Business partner's "currentness" successfully updated - '400': - description: On malformed request parameters - '404': - description: No business partner found for specified bpn - /api/catena/legal-entities/search: - post: - tags: - - legal-entity-controller - summary: Search legal entity partners by BPNLs - description: Search legal entity partners by their BPNLs. The response can contain less results than the number of BPNLs that were requested, if some of the BPNLs did not exist. For a single request, the maximum number of BPNLs to search for is limited to 5000 entries. - operationId: searchSites_1 - requestBody: - content: - application/json: - schema: - type: array - items: - type: string - required: true - responses: - '200': - description: Found legal entites - content: - '*/*': - schema: - type: array - items: - $ref: '#/components/schemas/LegalEntityPartnerResponse' - '400': - description: On malformed request parameters or if number of requested bpns exceeds limit - /api/catena/legal-entities/legal-addresses/search: - post: - tags: - - legal-entity-controller - summary: Search Legal Addresses - description: Search legal addresses of legal entities by BPNL - operationId: searchLegalAddresses - requestBody: - content: - application/json: - schema: - type: array - items: - type: string - required: true - responses: - '200': - description: The found legal addresses - content: - '*/*': - schema: - type: array - items: - $ref: '#/components/schemas/LegalAddressSearchResponse' - '400': - description: On malformed request parameters - /api/catena/issuing-bodies: - get: - tags: - - metadata-controller - summary: Get page of issuing bodies - description: Lists all currently known issuing bodies in a paginated result - operationId: getIssuingBodies - parameters: - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Page of existing issuing bodies, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseTypeKeyNameUrlDtoString' - '400': - description: On malformed request parameters - post: - tags: - - metadata-controller - summary: Create new issuing body - description: 'Create a new issuing body which can be referenced by business partner records. An issuing body should be an entity which the Catena organisation trusts to issue identifiers.The actual name of the issuing body is free to choose and doesn''t need to be unique. The technical key can be freely chosen but needs to be unique as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.' - operationId: createIssuingBody - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' - required: true - responses: - '200': - description: New issuing body successfully created - content: - '*/*': - schema: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' - '400': - description: On malformed request parameters - '409': - description: Issuing body with specified technical key already exists - /api/catena/identifier-types: - get: - tags: - - metadata-controller - summary: Get page of identifier types - description: Lists all currently known identifier types in a paginated result - operationId: getIdentifierTypes - parameters: - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Page of existing identifier types, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseTypeKeyNameUrlDtoString' - '400': - description: On malformed request parameters - post: - tags: - - metadata-controller - summary: Create new identifier type - description: 'Create a new identifier type which can be referenced by business partner records. Identifier types such as BPN or VAT determine with which kind of values a business partner can be identified with. The actual name of the identifier type is free to choose and doesn''t need to be unique. The technical key can be freely chosen but needs to be unique as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.' - operationId: createIdentifierType - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' - required: true - responses: - '200': - description: New identifier type successfully created - content: - '*/*': - schema: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' - '400': - description: On malformed request parameters - '409': - description: Identifier type with specified technical key already exists - /api/catena/identifier-status: - get: - tags: - - metadata-controller - summary: Get page of identifier statuses - description: Lists all currently known identifier statuses in a paginated result - operationId: getIdentifierStati - parameters: - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Page of existing identifier statuses, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseTypeKeyNameDtoString' - '400': - description: On malformed request parameters - post: - tags: - - metadata-controller - summary: Create new identifier status - description: 'Create a new identifier status which can be referenced by business partner records. A status further distinguishes an identifier by adding current status information such as active or revoked.The actual name of the identifier status is free to choose and doesn''t need to be unique. The technical key can be freely chosen but needs to be unique as it is used as reference by the business partner records. A recommendation for technical keys: They should be short, descriptive and use a restricted common character set in order to ensure compatibility with older systems.' - operationId: createIdentifierStatus - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/TypeKeyNameDtoString' - required: true - responses: - '200': - description: New identifier status successfully created - content: - '*/*': - schema: - $ref: '#/components/schemas/TypeKeyNameDtoString' - '400': - description: On malformed request parameters - '409': - description: Identifier status with specified technical key already exists - /api/catena/bpn/search: - post: - tags: - - bpn-controller - summary: Find business partner numbers by identifiers - description: Find business partner numbers by identifiers. The response can contain less results than the number of identifier values that were requested, if some of the identifiers did not exist. For a single request, the maximum number of identifier values to search for is limited to 5000 entries. - operationId: findBpnsByIdentifiers - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/IdentifiersSearchRequest' - required: true - responses: - '200': - description: Found bpn to identifier value mappings - content: - '*/*': - schema: - uniqueItems: true - type: array - items: - $ref: '#/components/schemas/BpnIdentifierMappingResponse' - '400': - description: On malformed request parameters or if number of requested bpns exceeds limit - '404': - description: Specified identifier type not found - /api/catena/addresses/search: - post: - tags: - - address-controller - summary: Search address partners by BPNs and/or parent BPNs - description: Search business partners of type address by their BPN or their parent partners BPN (BPNLs or BPNS). - operationId: searchAddresses - parameters: - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AddressPartnerBpnSearchRequest' - required: true - responses: - '200': - description: Found sites for the specified sites and legal entities - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseAddressPartnerSearchResponse' - '400': - description: On malformed pagination request - /api/catena/suggestions/sites/names: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in business partner sites - description: Performs search on site names in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible site names in the search set. - operationId: getSiteSuggestion - parameters: - - name: text - in: query - description: Show site names best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/legal-entities/statuses: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in business statuses - description: Performs search on business status denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible business status denotations in the search set. - operationId: getStatusSuggestion - parameters: - - name: text - in: query - description: Show business status denotations best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/legal-entities/names: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in business partner names - description: Performs search on business partner names in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible names in the search set. - operationId: getNameSuggestion - parameters: - - name: text - in: query - description: Show names best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/legal-entities/legal-forms: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in business partner legal forms - description: Performs search on legal form names in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible legal form names in the search set. - operationId: getLegalFormSuggestion - parameters: - - name: text - in: query - description: Show legal form names best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/legal-entities/classifications: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in business partner classifications - description: Performs search on business partner classifications in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible business partner classifications in the search set. - operationId: getClassificationSuggestion - parameters: - - name: text - in: query - description: Show business partner classifications best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/addresses/thoroughfares: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in thoroughfares - description: Performs search on thoroughfare denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible thoroughfare names in the search set. - operationId: getThoroughfareSuggestion - parameters: - - name: text - in: query - description: Show thoroughfare names best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/addresses/premises: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in premises - description: Performs search on premise denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible premise names in the search set. - operationId: getPremiseSuggestion - parameters: - - name: text - in: query - description: Show premise names best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/addresses/postcodes: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in postcodes - description: Performs search on postcode values in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible postcode values in the search set. - operationId: getPostcodeSuggestion - parameters: - - name: text - in: query - description: Show postcodes best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/addresses/postal-delivery-points: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in postal delivery points - description: Performs search on postal delivery point denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible postal delivery point names in the search set. - operationId: getPostalDeliverPointSuggestion - parameters: - - name: text - in: query - description: Show postal delivery point names best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/addresses/localities: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in localities - description: Performs search on locality denotations in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible locality names in the search set. - operationId: getLocalitySuggestion - parameters: - - name: text - in: query - description: Show locality names this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' - /api/catena/suggestions/addresses/administrative-areas: - get: - tags: - - suggestion-controller - summary: Find best matches for given text in administrative areas - description: Performs search on administrative area names in order to find the best matches for the given text. By specifying further request parameters the set of business partners to search in can be restricted. If no text is given, the endpoint lists possible administrative area names in the search set. - operationId: getAdminAreaSuggestion - parameters: - - name: text - in: query - description: Show administrative area names best matching this text - required: false - schema: - type: string - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Best matches found, may be empty + description: Found sites for the specified sites and legal entities content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/PageResponseSuggestionResponse' + $ref: '#/components/schemas/PageResponseLogisticAddressResponse' + '400': + description: On malformed pagination request /api/catena/sites/{bpn}: get: tags: @@ -2286,9 +935,9 @@ paths: '200': description: Found site with specified bpn content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/SitePartnerSearchResponse' + $ref: '#/components/schemas/SitePoolResponse' '400': description: On malformed request parameters '404': @@ -2318,24 +967,24 @@ paths: '200': description: Found business partner with specified identifier content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/LegalEntityPartnerResponse' + $ref: '#/components/schemas/PoolLegalEntityResponse' '400': description: On malformed request parameters '404': description: No business partner found under specified identifier or specified identifier type not found - /api/catena/legal-entities/{bpn}/sites: + /api/catena/legal-entities/{bpnl}/sites: get: tags: - legal-entity-controller 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. operationId: getSites parameters: - - name: bpn + - name: bpnl in: path - description: Bpn value + description: Bpnl value required: true schema: type: string @@ -2358,16 +1007,16 @@ paths: default: '10' responses: '200': - description: The sites for the specified bpn + description: The sites for the specified bpnl content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/PageResponseSitePartnerResponse' + $ref: '#/components/schemas/PageResponseSiteResponse' '400': description: On malformed pagination request '404': - description: No business partner found for specified bpn - /api/catena/legal-entities/{bpn}/addresses: + description: No business partner found for specified bpnl + /api/catena/legal-entities/{bpnl}/addresses: get: tags: - legal-entity-controller @@ -2375,7 +1024,7 @@ paths: description: Get business partners of type address belonging to a business partner of type legal entity, identified by the business partner's bpn ignoring case. operationId: getAddresses parameters: - - name: bpn + - name: bpnl in: path description: Bpn value required: true @@ -2402,23 +1051,24 @@ paths: '200': description: The addresses for the specified bpn content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/PageResponseAddressPartnerResponse' + $ref: '#/components/schemas/PageResponseLogisticAddressResponse' '400': description: On malformed pagination request '404': description: No business partner found for specified bpn - /api/catena/identifier-types/for-country: + /api/catena/field-quality-rules/: get: tags: - metadata-controller - summary: Get valid identifier types for a country - description: Returns which identifier types are valid and which ones are mandatory for a country specified by its ISO 3166-1 alpha-2 country code. - operationId: getValidIdentifierTypesForCountry + summary: Get all field quality rules filtered by country (specified by its ISO 3166-1 alpha-2 country code) + description: List the country specific data rules for entity fields.All fields that are not in this list are considered to be forbidden. + operationId: getFieldQualityRules parameters: - name: country in: query + description: ISO 3166-1 alpha-2 country code required: true schema: type: string @@ -2697,200 +1347,24 @@ paths: - ZW responses: '200': - description: The identifier types + description: List of the existing rules for the given country content: - '*/*': + application/json: schema: type: array items: - $ref: '#/components/schemas/CountryIdentifierTypeResponse' - '400': - description: On malformed request parameters - /api/catena/business-partners/{bpn}/changelog: - get: - tags: - - business-partner-controller - summary: Get business partner changelog entries by bpn - description: Get business partner changelog entries by bpn ignoring case. - operationId: getChangelogEntries - parameters: - - name: bpn - in: path - description: Bpn value - required: true - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: The changelog entries for the specified bpn - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseChangelogEntryResponse' - '400': - description: On malformed pagination request - '404': - description: No business partner found for specified bpn - /api/catena/business-partner: - get: - tags: - - business-partner-legacy-controller - summary: Get page of business partners matching the search criteria - description: This endpoint tries to find matches among all existing business partners, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. - operationId: searchBusinessPartners - parameters: - - name: name - in: query - description: Filter legal entities by name - required: false - schema: - type: string - - name: legalForm - in: query - description: Filter legal entities by legal form name - required: false - schema: - type: string - - name: status - in: query - description: Filter legal entities by status official denotation - required: false - schema: - type: string - - name: classification - in: query - description: Filter legal entities by classification denotation - required: false - schema: - type: string - - name: administrativeArea - in: query - description: Filter business partners by administrative area name - required: false - schema: - type: string - - name: postCode - in: query - description: Filter business partners by postcode or postcodes - required: false - schema: - type: string - - name: locality - in: query - description: Filter business partners by locality full denotation - required: false - schema: - type: string - - name: thoroughfare - in: query - description: Filter business partners by thoroughfare full denotation - required: false - schema: - type: string - - name: premise - in: query - description: Filter business partners by premise full denotation - required: false - schema: - type: string - - name: postalDeliveryPoint - in: query - description: Filter business partners by postal delivery point full denotation - required: false - schema: - type: string - - name: siteName - in: query - description: Filter sites by name - required: false - schema: - type: string - - name: page - in: query - description: Number of page to get results from - required: false - schema: - minimum: 0 - type: string - default: '0' - - name: size - in: query - description: Size of each page - required: false - schema: - maximum: 100 - minimum: 0 - type: string - default: '10' - responses: - '200': - description: Page of business partners matching the search criteria, may be empty - content: - '*/*': - schema: - $ref: '#/components/schemas/PageResponseBusinessPartnerMatchResponse' - '400': - description: On malformed search or pagination request - deprecated: true - /api/catena/business-partner/{idValue}: - get: - tags: - - business-partner-legacy-controller - summary: Get business partner by identifier - description: This endpoint tries to find a business partner by the specified identifier. The identifier value is case insensitively compared but needs to be given exactly. By default the value given is interpreted as a BPN. By specifying the technical key of another identifier typethe value is matched against the identifiers of that given type. - operationId: getLegalEntity_1 - parameters: - - name: idValue - in: path - description: Identifier value - required: true - schema: - type: string - - name: idType - in: query - description: Type of identifier to use, defaults to BPN when omitted - required: false - schema: - type: string - default: BPN - responses: - '200': - description: Found business partner with specified identifier - content: - '*/*': - schema: - $ref: '#/components/schemas/BusinessPartnerResponse' + $ref: '#/components/schemas/FieldQualityRuleDto' '400': description: On malformed request parameters - '404': - description: No business partner found under specified identifier or specified identifier type not found - deprecated: true - /api/catena/addresses/{bpn}: + /api/catena/addresses/{bpna}: get: tags: - address-controller - summary: Get address partners by bpn + summary: Get address partners by bpna description: Get business partners of type address by bpn-a ignoring case. operationId: getAddress parameters: - - name: bpn + - name: bpna in: path description: Bpn value required: true @@ -2898,30 +1372,228 @@ paths: type: string responses: '200': - description: Found address with specified bpn + description: Found address with specified bpna content: - '*/*': + application/json: schema: - $ref: '#/components/schemas/AddressPartnerSearchResponse' + $ref: '#/components/schemas/LogisticAddressResponse' '400': description: On malformed request parameters '404': - description: No address found under specified bpn + description: No address found under specified bpna components: schemas: - Address: + AddressCreateWrapper: + type: object + properties: + entities: + type: array + items: + $ref: '#/components/schemas/AddressPartnerCreateResponse' + errors: + type: array + items: + $ref: '#/components/schemas/ErrorInfoAddressCreateError' + errorCount: + type: integer + format: int32 + entityCount: + type: integer + format: int32 + description: Holds information about successfully and failed entities after the creating/updating of several objects + AddressIdentifier: + type: object + properties: + value: + type: string + description: Value of the identifier + type: + type: string + description: Technical key of the type to which this identifier belongs to + description: Identifier record for a logistic address + AddressMatchResponse: + type: object + properties: + score: + type: number + format: float + address: + $ref: '#/components/schemas/LogisticAddressResponse' + description: Match with score for a business partner record of type address + AddressPartnerBpnSearchRequest: + type: object + properties: + legalEntities: + type: array + items: + type: string + sites: + type: array + items: + type: string + addresses: + type: array + items: + type: string + description: Request for searching business partners of type address by parent BPNs + AddressPartnerCreateRequest: + type: object + properties: + name: + type: string + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: + type: array + items: + $ref: '#/components/schemas/AddressState' + identifiers: + type: array + items: + $ref: '#/components/schemas/AddressIdentifier' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddress' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + bpnParent: + type: string + index: + type: string + description: Request for creating new business partner record of type address + AddressPartnerCreateResponse: type: object properties: - version: - $ref: '#/components/schemas/AddressVersion' - careOf: + bpna: + type: string + description: Business Partner Number of this address + name: type: string - contexts: + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: type: array items: - type: string + $ref: '#/components/schemas/AddressStateResponse' + identifiers: + type: array + items: + $ref: '#/components/schemas/IdentifierResponse' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddress' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + bpnLegalEntity: + type: string + description: BPN of the related legal entity, if available + bpnSite: + type: string + description: BPN of the related site, if available + createdAt: + type: string + description: The timestamp the business partner data was created + format: date-time + updatedAt: + type: string + description: The timestamp the business partner data was last updated + format: date-time + isLegalAddress: + type: boolean + description: Flag if this is the legal address of its related legal entity + isMainAddress: + type: boolean + description: Flag if this is the main address of its related site + index: + type: string + description: Created business partners of type address + AddressPartnerUpdateRequest: + type: object + properties: + bpna: + type: string + name: + type: string + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: + type: array + items: + $ref: '#/components/schemas/AddressState' + identifiers: + type: array + items: + $ref: '#/components/schemas/AddressIdentifier' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddress' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + description: Request for updating a business partner record of type address + AddressState: + type: object + properties: + description: + type: string + description: Description of the status + validFrom: + type: string + description: Since when the status is/was valid + format: date-time + validTo: + type: string + description: Until the status was valid, if applicable + format: date-time + type: + type: string + description: The type of this specified status + enum: + - ACTIVE + - INACTIVE + description: Status record for a address + AddressStateResponse: + type: object + properties: + description: + type: string + description: Exact, official denotation of the status + validFrom: + type: string + description: Since when the status is/was valid + format: date-time + validTo: + type: string + description: Until the status was valid, if applicable + format: date-time + type: + $ref: '#/components/schemas/TypeKeyNameDtoBusinessStateType' + description: Status record of a legal entity + AddressUpdateWrapper: + type: object + properties: + entities: + type: array + items: + $ref: '#/components/schemas/LogisticAddressResponse' + errors: + type: array + items: + $ref: '#/components/schemas/ErrorInfoAddressUpdateError' + errorCount: + type: integer + format: int32 + entityCount: + type: integer + format: int32 + description: Holds information about successfully and failed entities after the creating/updating of several objects + AlternativePostalAddress: + type: object + properties: + geographicCoordinates: + $ref: '#/components/schemas/GeoCoordinates' country: type: string + description: Describes the country enum: - UNDEFINED - AC @@ -3195,86 +1867,206 @@ components: - ZM - ZR - ZW - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeArea' - postCodes: - type: array - items: - $ref: '#/components/schemas/Postcode' - localities: - type: array - items: - $ref: '#/components/schemas/Locality' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/Thoroughfare' - premises: - type: array - items: - $ref: '#/components/schemas/Premise' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPoint' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - type: string - enum: - - BRANCH_OFFICE - - CARE_OF - - HEADQUARTER - - LEGAL_ALTERNATIVE - - PO_BOX - - REGISTERED - - REGISTERED_AGENT_MAIL - - REGISTERED_AGENT_PHYSICAL - - VAT_REGISTERED - - UNSPECIFIC - description: Localized address record for a business partner - AddressMatchResponse: + postalCode: + type: string + description: A postal code, also known as postcode, PIN or ZIP Code + city: + type: string + description: 'The city of the address (Synonym: Town, village, municipality)' + administrativeAreaLevel1: + type: string + description: Identifying code of the Region within the country (e.g. Bayern) + deliveryServiceNumber: + type: string + description: Describes the PO Box or private Bag number the delivery should be placed at. + deliveryServiceType: + type: string + description: The type of this specified delivery + enum: + - PO_BOX + - PRIVATE_BAG + - BOITE_POSTALE + deliveryServiceQualifier: + type: string + description: Delivery Service Qualifier + description: Alternative Postal Address Part + BpnIdentifierMappingResponse: type: object properties: - score: - type: number - format: float - address: - $ref: '#/components/schemas/AddressPartnerSearchResponse' - description: Match with score for a business partner record of type address - AddressPartnerBpnSearchRequest: + idValue: + type: string + bpn: + type: string + description: Mapping of Business Partner Number to identifier value + ChangeLogSearchRequest: type: object properties: - legalEntities: - type: array - items: - type: string - sites: + fromTime: + type: string + format: date-time + bpns: + uniqueItems: true type: array items: type: string - addresses: + lsaTypes: + uniqueItems: true type: array items: type: string - description: Request for searching business partners of type address by parent BPNs - AddressPartnerCreateRequest: + enum: + - LEGAL_ENTITY + - ADDRESS + - SITE + description: Request for searching and filtering the business partner changelog + ChangelogEntryResponse: type: object properties: - version: - $ref: '#/components/schemas/AddressVersion' - careOf: + bpn: type: string - contexts: - type: array - items: - type: string + changelogType: + type: string + enum: + - CREATE + - UPDATE + timestamp: + type: string + format: date-time + lsaType: + type: string + enum: + - LEGAL_ENTITY + - ADDRESS + - SITE + description: Changelog entry for a business partner + Classification: + type: object + properties: + value: + type: string + description: Name of the classification + code: + type: string + description: Identifying code of the classification, if applicable + type: + type: string + description: Type of specified classification + enum: + - NACE + - NAF + - NAICS + - SIC + description: Classification record for a business partner + ClassificationResponse: + type: object + properties: + value: + type: string + description: Name of the classification + code: + type: string + description: Identifying code of the classification, if applicable + type: + $ref: '#/components/schemas/TypeKeyNameDtoClassificationType' + description: Classification record of a business partner + ErrorInfoAddressCreateError: + title: ErrorInfo + type: object + properties: + errorCode: + type: string + description: AddressCreateError + enum: + - BpnNotValid + - SiteNotFound + - LegalEntityNotFound + message: + type: string + entityKey: + type: string + description: Holds information about failures when creating or updating an entity + ErrorInfoAddressUpdateError: + title: ErrorInfo + type: object + properties: + errorCode: + type: string + description: AddressUpdateError + enum: + - AddressNotFound + message: + type: string + entityKey: + type: string + description: Holds information about failures when creating or updating an entity + ErrorInfoLegalEntityCreateError: + title: ErrorInfo + type: object + properties: + errorCode: + type: string + description: LegalEntityCreateError + enum: + - LegalEntityDuplicateIdentifier + message: + type: string + entityKey: + type: string + description: Holds information about failures when creating or updating an entity + ErrorInfoLegalEntityUpdateError: + title: ErrorInfo + type: object + properties: + errorCode: + type: string + description: LegalEntityUpdateError + enum: + - LegalEntityNotFound + message: + type: string + entityKey: + type: string + description: Holds information about failures when creating or updating an entity + ErrorInfoSiteCreateError: + title: ErrorInfo + type: object + properties: + errorCode: + type: string + description: SiteCreateError + enum: + - LegalEntityNotFound + message: + type: string + entityKey: + type: string + description: Holds information about failures when creating or updating an entity + ErrorInfoSiteUpdateError: + title: ErrorInfo + type: object + properties: + errorCode: + type: string + description: SiteUpdateError + enum: + - SiteNotFound + message: + type: string + entityKey: + type: string + description: Holds information about failures when creating or updating an entity + FieldQualityRuleDto: + type: object + properties: + fieldPath: + type: string + description: Path to the field + schemaName: + type: string + description: Schema name of the entity the field belongs to country: type: string + description: Country for wich the rule is valid enum: - UNDEFINED - AC @@ -3544,175 +2336,49 @@ components: - YE - YT - YU - - ZA - - ZM - - ZR - - ZW - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeArea' - postCodes: - type: array - items: - $ref: '#/components/schemas/Postcode' - localities: - type: array - items: - $ref: '#/components/schemas/Locality' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/Thoroughfare' - premises: - type: array - items: - $ref: '#/components/schemas/Premise' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPoint' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - type: string - enum: - - BRANCH_OFFICE - - CARE_OF - - HEADQUARTER - - LEGAL_ALTERNATIVE - - PO_BOX - - REGISTERED - - REGISTERED_AGENT_MAIL - - REGISTERED_AGENT_PHYSICAL - - VAT_REGISTERED - - UNSPECIFIC - parent: - type: string - index: - type: string - description: Request for creating new business partner record of type address - AddressPartnerCreateResponse: - type: object - properties: - bpn: - type: string - version: - $ref: '#/components/schemas/AddressVersionResponse' - careOf: - type: string - contexts: - type: array - items: - type: string - country: - $ref: '#/components/schemas/TypeKeyNameDtoCountryCode' - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeAreaResponse' - postCodes: - type: array - items: - $ref: '#/components/schemas/PostcodeResponse' - localities: - type: array - items: - $ref: '#/components/schemas/LocalityResponse' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/ThoroughfareResponse' - premises: - type: array - items: - $ref: '#/components/schemas/PremiseResponse' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPointResponse' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoAddressType' - index: + - ZA + - ZM + - ZR + - ZW + qualityLevel: type: string - description: Created business partners of type address - AddressPartnerResponse: + description: Defines the quality of an entity field. + enum: + - MANDATORY + - OPTIONAL + - FORBIDDEN + description: 'Rule for the quality level of an entity field ' + GeoCoordinates: type: object properties: - bpn: - type: string - version: - $ref: '#/components/schemas/AddressVersionResponse' - careOf: - type: string - contexts: - type: array - items: - type: string - country: - $ref: '#/components/schemas/TypeKeyNameDtoCountryCode' - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeAreaResponse' - postCodes: - type: array - items: - $ref: '#/components/schemas/PostcodeResponse' - localities: - type: array - items: - $ref: '#/components/schemas/LocalityResponse' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/ThoroughfareResponse' - premises: - type: array - items: - $ref: '#/components/schemas/PremiseResponse' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPointResponse' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoAddressType' - description: Business partner of type address - AddressPartnerSearchResponse: + longitude: + type: number + description: Longitude coordinate + format: float + latitude: + type: number + description: Latitude coordinate + format: float + altitude: + type: number + description: Altitude, if applicable + format: float + description: Geo coordinates record for an address + IdentifierResponse: type: object properties: - address: - $ref: '#/components/schemas/AddressPartnerResponse' - bpnLegalEntity: - type: string - bpnSite: + value: type: string - description: Business partner of type address with parent reference - AddressPartnerUpdateRequest: + description: Value of the identifier + type: + $ref: '#/components/schemas/TypeKeyNameDtoString' + description: Identifier record of a logistic address + IdentifierTypeDetailDto: type: object properties: - bpn: - type: string - version: - $ref: '#/components/schemas/AddressVersion' - careOf: - type: string - contexts: - type: array - items: - type: string country: type: string + description: Country in which this identifier is valid, null for universal identifiers enum: - UNDEFINED - AC @@ -3986,1943 +2652,627 @@ components: - ZM - ZR - ZW - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeArea' - postCodes: - type: array - items: - $ref: '#/components/schemas/Postcode' - localities: - type: array - items: - $ref: '#/components/schemas/Locality' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/Thoroughfare' - premises: - type: array - items: - $ref: '#/components/schemas/Premise' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPoint' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - type: string - enum: - - BRANCH_OFFICE - - CARE_OF - - HEADQUARTER - - LEGAL_ALTERNATIVE - - PO_BOX - - REGISTERED - - REGISTERED_AGENT_MAIL - - REGISTERED_AGENT_PHYSICAL - - VAT_REGISTERED - - UNSPECIFIC - description: Request for updating a business partner record of type address - AddressResponse: - type: object - properties: - version: - $ref: '#/components/schemas/AddressVersionResponse' - careOf: - type: string - contexts: - type: array - items: - type: string - country: - $ref: '#/components/schemas/TypeKeyNameDtoCountryCode' - administrativeAreas: - type: array - items: - $ref: '#/components/schemas/AdministrativeAreaResponse' - postCodes: - type: array - items: - $ref: '#/components/schemas/PostcodeResponse' - localities: - type: array - items: - $ref: '#/components/schemas/LocalityResponse' - thoroughfares: - type: array - items: - $ref: '#/components/schemas/ThoroughfareResponse' - premises: - type: array - items: - $ref: '#/components/schemas/PremiseResponse' - postalDeliveryPoints: - type: array - items: - $ref: '#/components/schemas/PostalDeliveryPointResponse' - geographicCoordinates: - $ref: '#/components/schemas/GeoCoordinates' - types: - type: array - items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoAddressType' - description: Localized address record of a business partner - AddressVersion: - type: object - properties: - characterSet: - type: string - enum: - - ARABIC - - CHINESE - - CHINESE_TRADITIONAL - - CYRILLIC - - GREEK - - HANGUL_KOREAN - - HEBREW - - HIRAGANA - - KANJI - - KATAKANA - - LATIN - - THAI - - WESTERN_LATIN_STANDARD - - UNDEFINED - language: - type: string - enum: - - undefined - - aa - - ab - - ae - - af - - ak - - am - - an - - ar - - as - - av - - ay - - az - - ba - - be - - bg - - bh - - bi - - bm - - bn - - bo - - br - - bs - - ca - - ce - - ch - - co - - cr - - cs - - cu - - cv - - cy - - da - - de - - dv - - dz - - ee - - el - - en - - eo - - es - - et - - eu - - fa - - ff - - fi - - fj - - fo - - fr - - fy - - ga - - gd - - gl - - gn - - gu - - gv - - ha - - he - - hi - - ho - - hr - - ht - - hu - - hy - - hz - - ia - - id - - ie - - ig - - ii - - ik - - io - - is - - it - - iu - - ja - - jv - - ka - - kg - - ki - - kj - - kk - - kl - - km - - kn - - ko - - kr - - ks - - ku - - kv - - kw - - ky - - la - - lb - - lg - - li - - ln - - lo - - lt - - lu - - lv - - mg - - mh - - mi - - mk - - ml - - mn - - mr - - ms - - mt - - my - - na - - nb - - nd - - ne - - ng - - nl - - nn - - 'no' - - nr - - nv - - ny - - oc - - oj - - om - - or - - os - - pa - - pi - - pl - - ps - - pt - - qu - - rm - - rn - - ro - - ru - - rw - - sa - - sc - - sd - - se - - sg - - si - - sk - - sl - - sm - - sn - - so - - sq - - sr - - ss - - st - - su - - sv - - sw - - ta - - te - - tg - - th - - ti - - tk - - tl - - tn - - to - - tr - - ts - - tt - - tw - - ty - - ug - - uk - - ur - - uz - - ve - - vi - - vo - - wa - - wo - - xh - - yi - - yo - - za - - zh - - zu - description: Localization record for an address - AddressVersionResponse: - type: object - properties: - characterSet: - $ref: '#/components/schemas/TypeKeyNameDtoCharacterSet' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Localization record of an address - AdministrativeArea: + mandatory: + type: boolean + description: True if identifier is mandatory in this country + description: Identifier type validity details + IdentifierTypeDto: type: object properties: - value: - type: string - shortName: - type: string - fipsCode: + technicalKey: type: string - type: + description: Unique key (in combination with lsaType) to be used as reference + lsaType: type: string + description: Specifies if an identifier type is valid for legal entities (L) or addresses (A). Sites (S) are not supported. enum: - - COUNTY - - REGION - - OTHER - description: Areas such as country regions or counties - AdministrativeAreaResponse: - type: object - properties: - value: - type: string - shortName: - type: string - fipsCode: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoAdministrativeAreaType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Area of an address such as country region or county - BankAccount: - type: object - properties: - trustScores: - type: array - items: - type: number - format: float - currency: + - LEGAL_ENTITY + - ADDRESS + name: type: string - enum: - - UNDEFINED - - AED - - AFN - - ALL - - AMD - - ANG - - AOA - - ARS - - AUD - - AWG - - AZN - - BAM - - BBD - - BDT - - BGN - - BHD - - BIF - - BMD - - BND - - BOB - - BOV - - BRL - - BSD - - BTN - - BWP - - BYN - - BYR - - BZD - - CAD - - CDF - - CHE - - CHF - - CHW - - CLF - - CLP - - CNY - - COP - - COU - - CRC - - CUC - - CUP - - CVE - - CZK - - DJF - - DKK - - DOP - - DZD - - EGP - - ERN - - ETB - - EUR - - FJD - - FKP - - GBP - - GEL - - GHS - - GIP - - GMD - - GNF - - GTQ - - GYD - - HKD - - HNL - - HRK - - HTG - - HUF - - IDR - - ILS - - INR - - IQD - - IRR - - ISK - - JMD - - JOD - - JPY - - KES - - KGS - - KHR - - KMF - - KPW - - KRW - - KWD - - KYD - - KZT - - LAK - - LBP - - LKR - - LRD - - LSL - - LTL - - LYD - - MAD - - MDL - - MGA - - MKD - - MMK - - MNT - - MOP - - MRO - - MRU - - MUR - - MVR - - MWK - - MXN - - MXV - - MYR - - MZN - - NAD - - NGN - - NIO - - NOK - - NPR - - NZD - - OMR - - PAB - - PEN - - PGK - - PHP - - PKR - - PLN - - PYG - - QAR - - RON - - RSD - - RUB - - RUR - - RWF - - SAR - - SBD - - SCR - - SDG - - SEK - - SGD - - SHP - - SLL - - SOS - - SRD - - SSP - - STD - - STN - - SVC - - SYP - - SZL - - THB - - TJS - - TMT - - TND - - TOP - - TRY - - TTD - - TWD - - TZS - - UAH - - UGX - - USD - - USN - - USS - - UYI - - UYU - - UZS - - VEF - - VES - - VND - - VUV - - WST - - XAF - - XAG - - XAU - - XBA - - XBB - - XBC - - XBD - - XCD - - XDR - - XOF - - XPD - - XPF - - XPT - - XSU - - XTS - - XUA - - XXX - - YER - - ZAR - - ZMW - - ZWL - internationalBankAccountIdentifier: - type: string - internationalBankIdentifier: - type: string - nationalBankAccountIdentifier: - type: string - nationalBankIdentifier: - type: string - description: Bank account record of a business partner - BankAccountResponse: - type: object - properties: - trustScores: + description: Full name + details: type: array + description: Validity details items: - type: number - format: float - currency: - $ref: '#/components/schemas/TypeKeyNameDtoCurrencyCode' - internationalBankAccountIdentifier: - type: string - internationalBankIdentifier: - type: string - nationalBankAccountIdentifier: - type: string - nationalBankIdentifier: - type: string - description: Bank account record for a business partner - BpnIdentifierMappingResponse: - type: object - properties: - idValue: - type: string - bpn: - type: string - description: Mapping of Business Partner Number to identifier value - BusinessPartnerMatchResponse: - type: object - properties: - score: - type: number - format: float - businessPartner: - $ref: '#/components/schemas/BusinessPartnerResponse' - description: Match with score for a business partner of type legal entity in legacy format - deprecated: true - BusinessPartnerResponse: + $ref: '#/components/schemas/IdentifierTypeDetailDto' + description: Identifier type definition for legal entity or address + IdentifiersSearchRequest: type: object properties: - uuid: + lsaType: type: string - bpn: + description: Specifies if an identifier type is valid for legal entities (L) or addresses (A). Sites (S) are not supported. + enum: + - LEGAL_ENTITY + - ADDRESS + idType: type: string - identifiers: - type: array - items: - $ref: '#/components/schemas/IdentifierResponse' - names: - type: array - items: - $ref: '#/components/schemas/NameResponse' - legalForm: - $ref: '#/components/schemas/LegalFormResponse' - status: - $ref: '#/components/schemas/BusinessStatusResponse' - profileClassifications: - type: array - items: - $ref: '#/components/schemas/ClassificationResponse' - types: - type: array - items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoBusinessPartnerType' - bankAccounts: - type: array - items: - $ref: '#/components/schemas/BankAccountResponse' - roles: - type: array - items: - $ref: '#/components/schemas/TypeKeyNameDtoString' - relations: - type: array - items: - $ref: '#/components/schemas/RelationResponse' - addresses: - type: array - items: - $ref: '#/components/schemas/AddressPartnerResponse' - sites: + idValues: type: array items: - $ref: '#/components/schemas/SitePartnerResponse' - currentness: - type: string - format: date-time - description: Business Partner of type legal entity in deprecated response format - deprecated: true - BusinessStatus: - type: object - properties: - officialDenotation: - type: string - validFrom: - type: string - format: date-time - validUntil: - type: string - format: date-time - type: - type: string - enum: - - ACTIVE - - DISSOLVED - - IN_LIQUIDATION - - INACTIVE - - INSOLVENCY - - UNKNOWN - description: Status record for a business partner - BusinessStatusResponse: + type: string + description: Contains identifiers to search legal entities by + LegalAddressResponse: type: object properties: - officialDenotation: - type: string - validFrom: + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddress' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + bpnLegalEntity: type: string - format: date-time - validUntil: + createdAt: type: string format: date-time - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoBusinessStatusType' - description: Status of a business partner - ChangelogEntryResponse: - type: object - properties: - bpn: - type: string - changelogType: - type: string - enum: - - CREATE - - UPDATE - timestamp: + updatedAt: type: string format: date-time - description: Changelog entry for a business partner - Classification: - type: object - properties: - value: - type: string - code: - type: string - type: - type: string - enum: - - NACE - - NAF - - NAICS - - SIC - description: Classification record for a business partner - ClassificationResponse: - type: object - properties: - value: - type: string - code: - type: string - type: - $ref: '#/components/schemas/NamedTypeWithLink' - description: Classification record of a business partner - CountryIdentifierTypeResponse: + description: Legal address for legal entity + LegalEntityCreateWrapper: type: object - properties: - identifierType: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' - mandatory: - type: boolean - description: Valid identifiers for a country - GeoCoordinates: - type: object - properties: - longitude: - type: number - format: float - latitude: - type: number - format: float - altitude: - type: number - format: float - description: Geo coordinates record for an address - Identifier: + properties: + entities: + type: array + items: + $ref: '#/components/schemas/LegalEntityPartnerCreateResponse' + errors: + type: array + items: + $ref: '#/components/schemas/ErrorInfoLegalEntityCreateError' + errorCount: + type: integer + format: int32 + entityCount: + type: integer + format: int32 + description: Holds information about successfully and failed entities after the creating/updating of several objects + LegalEntityIdentifier: type: object properties: value: type: string + description: Value of the identifier type: type: string + description: Technical key of the type to which this identifier belongs to issuingBody: type: string - status: - type: string - description: Identifier record for a business partner - IdentifierResponse: + description: Body which issued the identifier + description: Identifier record for a legal entity + LegalEntityIdentifierResponse: type: object properties: value: type: string + description: Value of the identifier type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' - issuingBody: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' - status: $ref: '#/components/schemas/TypeKeyNameDtoString' - description: Identifier record of a business partner - IdentifiersSearchRequest: - type: object - properties: - idType: - type: string - idValues: - type: array - items: - type: string - description: Contains identifiers to search legal entities by - LegalAddressSearchResponse: - type: object - properties: - legalEntity: + issuingBody: type: string - legalAddress: - $ref: '#/components/schemas/AddressResponse' - description: Legal address record with parent BPN + description: Body which issued the identifier + description: Identifier record of a legal entity LegalEntityMatchResponse: type: object properties: score: type: number format: float - legalEntity: - $ref: '#/components/schemas/LegalEntityPartnerResponse' - description: Match with score for a business partner record of type legal entity - LegalEntityPartnerCreateRequest: - type: object - properties: + legalName: + type: string + description: Legal name the partner goes by + bpnl: + type: string + description: Business Partner Number of this legal entity identifiers: type: array items: - $ref: '#/components/schemas/Identifier' - names: - type: array - items: - $ref: '#/components/schemas/Name' - legalForm: + $ref: '#/components/schemas/LegalEntityIdentifierResponse' + legalShortName: type: string - status: - $ref: '#/components/schemas/BusinessStatus' - profileClassifications: + description: Abbreviated name or shorthand + legalForm: + $ref: '#/components/schemas/LegalFormResponse' + states: type: array items: - $ref: '#/components/schemas/Classification' - types: + $ref: '#/components/schemas/LegalEntityStateResponse' + classifications: type: array items: - type: string - enum: - - BRAND - - LEGAL_ENTITY - - ORGANIZATIONAL_UNIT - - SITE - - UNKNOWN - bankAccounts: + $ref: '#/components/schemas/ClassificationResponse' + relations: type: array items: - $ref: '#/components/schemas/BankAccount' - legalAddress: - $ref: '#/components/schemas/Address' - index: + $ref: '#/components/schemas/RelationResponse' + currentness: type: string - description: Request for creating new business partner record of type legal entity - LegalEntityPartnerCreateResponse: + description: The timestamp the business partner data was last indicated to be still current + format: date-time + createdAt: + type: string + description: The timestamp the business partner data was created + format: date-time + updatedAt: + type: string + description: The timestamp the business partner data was last updated + format: date-time + legalAddress: + $ref: '#/components/schemas/LogisticAddressResponse' + description: Match with score for a business partner record of type legal entity + LegalEntityPartnerCreateRequest: type: object properties: - bpn: + legalName: type: string + description: Legal name the partner goes by identifiers: type: array items: - $ref: '#/components/schemas/IdentifierResponse' - names: - type: array - items: - $ref: '#/components/schemas/NameResponse' + $ref: '#/components/schemas/LegalEntityIdentifier' + legalShortName: + type: string + description: Abbreviated name or shorthand legalForm: - $ref: '#/components/schemas/LegalFormResponse' - status: - $ref: '#/components/schemas/BusinessStatusResponse' - profileClassifications: - type: array - items: - $ref: '#/components/schemas/ClassificationResponse' - types: - type: array - items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoBusinessPartnerType' - bankAccounts: - type: array - items: - $ref: '#/components/schemas/BankAccountResponse' - roles: + type: string + description: Technical key of the legal form + states: type: array items: - $ref: '#/components/schemas/TypeKeyNameDtoString' - relations: + $ref: '#/components/schemas/LegalEntityState' + classifications: type: array items: - $ref: '#/components/schemas/RelationResponse' - currentness: - type: string - format: date-time + $ref: '#/components/schemas/Classification' legalAddress: - $ref: '#/components/schemas/AddressResponse' + $ref: '#/components/schemas/LogisticAddressDto' index: type: string - description: Created business partner of type legal entity - LegalEntityPartnerResponse: + description: Request for creating new business partner record of type legal entity + LegalEntityPartnerCreateResponse: type: object properties: - bpn: + legalName: type: string + description: Legal name the partner goes by + bpnl: + type: string + description: Business Partner Number of this legal entity identifiers: type: array items: - $ref: '#/components/schemas/IdentifierResponse' - names: - type: array - items: - $ref: '#/components/schemas/NameResponse' + $ref: '#/components/schemas/LegalEntityIdentifierResponse' + legalShortName: + type: string + description: Abbreviated name or shorthand legalForm: $ref: '#/components/schemas/LegalFormResponse' - status: - $ref: '#/components/schemas/BusinessStatusResponse' - profileClassifications: - type: array - items: - $ref: '#/components/schemas/ClassificationResponse' - types: - type: array - items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoBusinessPartnerType' - bankAccounts: + states: type: array items: - $ref: '#/components/schemas/BankAccountResponse' - roles: + $ref: '#/components/schemas/LegalEntityStateResponse' + classifications: type: array items: - $ref: '#/components/schemas/TypeKeyNameDtoString' + $ref: '#/components/schemas/ClassificationResponse' relations: type: array items: $ref: '#/components/schemas/RelationResponse' currentness: type: string + description: The timestamp the business partner data was last indicated to be still current + format: date-time + createdAt: + type: string + description: The timestamp the business partner data was created format: date-time - description: Business partner of type legal entity with currentness - LegalEntityUpdateRequest: + updatedAt: + type: string + description: The timestamp the business partner data was last updated + format: date-time + legalAddress: + $ref: '#/components/schemas/LogisticAddressResponse' + index: + type: string + description: Created business partner of type legal entity + LegalEntityPartnerUpdateRequest: type: object properties: - bpn: + bpnl: + type: string + legalName: type: string + description: Legal name the partner goes by identifiers: type: array items: - $ref: '#/components/schemas/Identifier' - names: - type: array - items: - $ref: '#/components/schemas/Name' + $ref: '#/components/schemas/LegalEntityIdentifier' + legalShortName: + type: string + description: Abbreviated name or shorthand legalForm: type: string - status: - $ref: '#/components/schemas/BusinessStatus' - profileClassifications: + description: Technical key of the legal form + states: type: array items: - $ref: '#/components/schemas/Classification' - types: - type: array - items: - type: string - enum: - - BRAND - - LEGAL_ENTITY - - ORGANIZATIONAL_UNIT - - SITE - - UNKNOWN - bankAccounts: + $ref: '#/components/schemas/LegalEntityState' + classifications: type: array items: - $ref: '#/components/schemas/BankAccount' + $ref: '#/components/schemas/Classification' legalAddress: - $ref: '#/components/schemas/Address' + $ref: '#/components/schemas/LogisticAddressDto' description: Request for updating a business partner record of type legal entity - LegalFormRequest: - type: object - properties: - technicalKey: - type: string - name: - type: string - url: - type: string - mainAbbreviation: - type: string - language: - type: string - enum: - - undefined - - aa - - ab - - ae - - af - - ak - - am - - an - - ar - - as - - av - - ay - - az - - ba - - be - - bg - - bh - - bi - - bm - - bn - - bo - - br - - bs - - ca - - ce - - ch - - co - - cr - - cs - - cu - - cv - - cy - - da - - de - - dv - - dz - - ee - - el - - en - - eo - - es - - et - - eu - - fa - - ff - - fi - - fj - - fo - - fr - - fy - - ga - - gd - - gl - - gn - - gu - - gv - - ha - - he - - hi - - ho - - hr - - ht - - hu - - hy - - hz - - ia - - id - - ie - - ig - - ii - - ik - - io - - is - - it - - iu - - ja - - jv - - ka - - kg - - ki - - kj - - kk - - kl - - km - - kn - - ko - - kr - - ks - - ku - - kv - - kw - - ky - - la - - lb - - lg - - li - - ln - - lo - - lt - - lu - - lv - - mg - - mh - - mi - - mk - - ml - - mn - - mr - - ms - - mt - - my - - na - - nb - - nd - - ne - - ng - - nl - - nn - - 'no' - - nr - - nv - - ny - - oc - - oj - - om - - or - - os - - pa - - pi - - pl - - ps - - pt - - qu - - rm - - rn - - ro - - ru - - rw - - sa - - sc - - sd - - se - - sg - - si - - sk - - sl - - sm - - sn - - so - - sq - - sr - - ss - - st - - su - - sv - - sw - - ta - - te - - tg - - th - - ti - - tk - - tl - - tn - - to - - tr - - ts - - tt - - tw - - ty - - ug - - uk - - ur - - uz - - ve - - vi - - vo - - wa - - wo - - xh - - yi - - yo - - za - - zh - - zu - category: - type: array - items: - $ref: '#/components/schemas/NamedTypeWithLink' - description: New legal form record to be referenced by business partners - LegalFormResponse: + LegalEntityState: type: object properties: - technicalKey: - type: string - name: - type: string - url: - type: string - mainAbbreviation: + officialDenotation: type: string - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - categories: - type: array - items: - $ref: '#/components/schemas/NamedTypeWithLink' - description: Legal form a business partner can have - Locality: - type: object - properties: - value: + description: Exact, official denotation of the status + validFrom: type: string - shortName: + description: Since when the status is/was valid + format: date-time + validTo: type: string + description: Until the status was valid, if applicable + format: date-time type: type: string + description: The type of this specified status enum: - - BLOCK - - CITY - - DISTRICT - - OTHER - - POST_OFFICE_CITY - - QUARTER - description: Locality record for an address such as city, block or district - LocalityResponse: - type: object - properties: - value: - type: string - shortName: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoLocalityType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Locality record of an address such as city, block or district - MainAddressSearchResponse: - type: object - properties: - site: - type: string - mainAddress: - $ref: '#/components/schemas/AddressResponse' - description: Main address record with parent BPN - Name: + - ACTIVE + - INACTIVE + description: Status record of a legal entity + LegalEntityStateResponse: type: object properties: - value: - type: string - shortName: - type: string - type: - type: string - enum: - - ACRONYM - - DOING_BUSINESS_AS - - ESTABLISHMENT - - INTERNATIONAL - - LOCAL - - OTHER - - REGISTERED - - TRANSLITERATED - - VAT_REGISTERED - language: + officialDenotation: type: string - enum: - - undefined - - aa - - ab - - ae - - af - - ak - - am - - an - - ar - - as - - av - - ay - - az - - ba - - be - - bg - - bh - - bi - - bm - - bn - - bo - - br - - bs - - ca - - ce - - ch - - co - - cr - - cs - - cu - - cv - - cy - - da - - de - - dv - - dz - - ee - - el - - en - - eo - - es - - et - - eu - - fa - - ff - - fi - - fj - - fo - - fr - - fy - - ga - - gd - - gl - - gn - - gu - - gv - - ha - - he - - hi - - ho - - hr - - ht - - hu - - hy - - hz - - ia - - id - - ie - - ig - - ii - - ik - - io - - is - - it - - iu - - ja - - jv - - ka - - kg - - ki - - kj - - kk - - kl - - km - - kn - - ko - - kr - - ks - - ku - - kv - - kw - - ky - - la - - lb - - lg - - li - - ln - - lo - - lt - - lu - - lv - - mg - - mh - - mi - - mk - - ml - - mn - - mr - - ms - - mt - - my - - na - - nb - - nd - - ne - - ng - - nl - - nn - - 'no' - - nr - - nv - - ny - - oc - - oj - - om - - or - - os - - pa - - pi - - pl - - ps - - pt - - qu - - rm - - rn - - ro - - ru - - rw - - sa - - sc - - sd - - se - - sg - - si - - sk - - sl - - sm - - sn - - so - - sq - - sr - - ss - - st - - su - - sv - - sw - - ta - - te - - tg - - th - - ti - - tk - - tl - - tn - - to - - tr - - ts - - tt - - tw - - ty - - ug - - uk - - ur - - uz - - ve - - vi - - vo - - wa - - wo - - xh - - yi - - yo - - za - - zh - - zu - description: Name record for a business partner - NameResponse: - type: object - properties: - value: + description: Exact, official denotation of the status + validFrom: type: string - shortName: + description: Since when the status is/was valid + format: date-time + validTo: type: string + description: Until the status was valid, if applicable + format: date-time type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoNameType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Name record of a business partner - NamedTypeWithLink: - type: object - properties: - name: - type: string - url: - type: string - description: General type with name and URL link for further information - PageResponseAddressMatchResponse: - type: object - properties: - totalElements: - type: integer - format: int64 - totalPages: - type: integer - format: int32 - page: - type: integer - format: int32 - contentSize: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/AddressMatchResponse' - description: Paginated collection of results - PageResponseAddressPartnerResponse: - type: object - properties: - totalElements: - type: integer - format: int64 - totalPages: - type: integer - format: int32 - page: - type: integer - format: int32 - contentSize: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/AddressPartnerResponse' - description: Paginated collection of results - PageResponseAddressPartnerSearchResponse: - type: object - properties: - totalElements: - type: integer - format: int64 - totalPages: - type: integer - format: int32 - page: - type: integer - format: int32 - contentSize: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/AddressPartnerSearchResponse' - description: Paginated collection of results - PageResponseBusinessPartnerMatchResponse: - type: object - properties: - totalElements: - type: integer - format: int64 - totalPages: - type: integer - format: int32 - page: - type: integer - format: int32 - contentSize: - type: integer - format: int32 - content: - type: array - items: - $ref: '#/components/schemas/BusinessPartnerMatchResponse' - description: Paginated collection of results - PageResponseChangelogEntryResponse: + $ref: '#/components/schemas/TypeKeyNameDtoBusinessStateType' + description: Status record of a legal entity + LegalEntityUpdateWrapper: type: object properties: - totalElements: - type: integer - format: int64 - totalPages: - type: integer - format: int32 - page: + entities: + type: array + items: + $ref: '#/components/schemas/LegalEntityPartnerCreateResponse' + errors: + type: array + items: + $ref: '#/components/schemas/ErrorInfoLegalEntityUpdateError' + errorCount: type: integer format: int32 - contentSize: + entityCount: type: integer format: int32 - content: + description: Holds information about successfully and failed entities after the creating/updating of several objects + LegalFormRequest: + type: object + properties: + technicalKey: + type: string + name: + type: string + abbreviation: + type: string + description: New legal form record to be referenced by business partners + LegalFormResponse: + type: object + properties: + technicalKey: + type: string + description: Unique key to be used for reference + name: + type: string + description: Full name of the legal form + abbreviation: + type: string + description: Abbreviation of the legal form name + description: Legal form a business partner can have + LogisticAddressDto: + type: object + properties: + name: + type: string + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: type: array items: - $ref: '#/components/schemas/ChangelogEntryResponse' - description: Paginated collection of results - PageResponseLegalEntityMatchResponse: + $ref: '#/components/schemas/AddressState' + identifiers: + type: array + items: + $ref: '#/components/schemas/AddressIdentifier' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddress' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + description: Address record for a business partner + LogisticAddressResponse: type: object properties: - totalElements: - type: integer - format: int64 - totalPages: - type: integer - format: int32 - page: - type: integer - format: int32 - contentSize: - type: integer - format: int32 - content: + bpna: + type: string + description: Business Partner Number of this address + name: + type: string + description: |- + Name of the logistic address of the business partner. This is not according to official + registers but according to the name the uploading sharing member chooses. + states: type: array items: - $ref: '#/components/schemas/LegalEntityMatchResponse' - description: Paginated collection of results - PageResponseLegalFormResponse: + $ref: '#/components/schemas/AddressStateResponse' + identifiers: + type: array + items: + $ref: '#/components/schemas/IdentifierResponse' + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddress' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + bpnLegalEntity: + type: string + description: BPN of the related legal entity, if available + bpnSite: + type: string + description: BPN of the related site, if available + createdAt: + type: string + description: The timestamp the business partner data was created + format: date-time + updatedAt: + type: string + description: The timestamp the business partner data was last updated + format: date-time + isLegalAddress: + type: boolean + description: Flag if this is the legal address of its related legal entity + isMainAddress: + type: boolean + description: Flag if this is the main address of its related site + description: 'Logistic address ' + MainAddressResponse: + type: object + properties: + physicalPostalAddress: + $ref: '#/components/schemas/PhysicalPostalAddress' + alternativePostalAddress: + $ref: '#/components/schemas/AlternativePostalAddress' + bpnSite: + type: string + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + description: Main address for site + PageResponseAddressMatchResponse: type: object properties: totalElements: type: integer + description: Total number of all results in all pages format: int64 totalPages: type: integer + description: Total number pages format: int32 page: type: integer + description: Current page number format: int32 contentSize: type: integer + description: Number of results in the page format: int32 content: type: array + description: Collection of results in the page items: - $ref: '#/components/schemas/LegalFormResponse' + $ref: '#/components/schemas/AddressMatchResponse' description: Paginated collection of results - PageResponseSitePartnerResponse: + PageResponseChangelogEntryResponse: type: object properties: totalElements: type: integer + description: Total number of all results in all pages format: int64 totalPages: type: integer + description: Total number pages format: int32 page: type: integer + description: Current page number format: int32 contentSize: type: integer + description: Number of results in the page format: int32 content: type: array + description: Collection of results in the page items: - $ref: '#/components/schemas/SitePartnerResponse' + $ref: '#/components/schemas/ChangelogEntryResponse' description: Paginated collection of results - PageResponseSitePartnerSearchResponse: + PageResponseIdentifierTypeDto: type: object properties: totalElements: type: integer + description: Total number of all results in all pages format: int64 totalPages: type: integer + description: Total number pages format: int32 page: type: integer + description: Current page number format: int32 contentSize: type: integer + description: Number of results in the page format: int32 content: type: array + description: Collection of results in the page items: - $ref: '#/components/schemas/SitePartnerSearchResponse' + $ref: '#/components/schemas/IdentifierTypeDto' description: Paginated collection of results - PageResponseSuggestionResponse: + PageResponseLegalEntityMatchResponse: type: object properties: totalElements: type: integer + description: Total number of all results in all pages format: int64 totalPages: type: integer + description: Total number pages format: int32 page: type: integer + description: Current page number format: int32 contentSize: type: integer + description: Number of results in the page format: int32 content: type: array + description: Collection of results in the page items: - $ref: '#/components/schemas/SuggestionResponse' + $ref: '#/components/schemas/LegalEntityMatchResponse' description: Paginated collection of results - PageResponseTypeKeyNameDtoString: + PageResponseLegalFormResponse: type: object properties: totalElements: type: integer + description: Total number of all results in all pages format: int64 totalPages: type: integer + description: Total number pages format: int32 page: type: integer + description: Current page number format: int32 contentSize: type: integer + description: Number of results in the page format: int32 content: type: array + description: Collection of results in the page items: - $ref: '#/components/schemas/TypeKeyNameDtoString' + $ref: '#/components/schemas/LegalFormResponse' description: Paginated collection of results - PageResponseTypeKeyNameUrlDtoString: + PageResponseLogisticAddressResponse: type: object properties: totalElements: type: integer + description: Total number of all results in all pages format: int64 totalPages: type: integer + description: Total number pages format: int32 page: type: integer + description: Current page number format: int32 contentSize: type: integer + description: Number of results in the page format: int32 content: type: array + description: Collection of results in the page items: - $ref: '#/components/schemas/TypeKeyNameUrlDtoString' + $ref: '#/components/schemas/LogisticAddressResponse' description: Paginated collection of results - PostalDeliveryPoint: - type: object - properties: - value: - type: string - shortName: - type: string - number: - type: string - type: - type: string - enum: - - INTERURBAN_DELIVERY_POINT - - MAIL_STATION - - MAILBOX - - OTHER - - POST_OFFICE_BOX - description: Postal delivery point record for an address - PostalDeliveryPointResponse: - type: object - properties: - value: - type: string - shortName: - type: string - number: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoPostalDeliveryPointType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Postal delivery point record of an address - Postcode: - type: object - properties: - value: - type: string - type: - type: string - enum: - - CEDEX - - LARGE_MAIL_USER - - OTHER - - POST_BOX - - REGULAR - description: Postcode record for an address - PostcodeResponse: - type: object - properties: - value: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoPostCodeType' - description: Postcode record of an address - Premise: - type: object - properties: - value: - type: string - shortName: - type: string - number: - type: string - type: - type: string - enum: - - BUILDING - - OTHER - - LEVEL - - HARBOUR - - ROOM - - SUITE - - UNIT - - WAREHOUSE - description: Premise record for an address such as building, room or floor - PremiseResponse: + PageResponseSitePoolResponse: type: object properties: - value: - type: string - shortName: - type: string - number: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoPremiseType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Premise record of an address such as building, room or floor - RelationResponse: - type: object - properties: - relationClass: - $ref: '#/components/schemas/TypeKeyNameDtoRelationClass' - type: - $ref: '#/components/schemas/TypeKeyNameDtoRelationType' - startNode: - type: string - endNode: - type: string - startedAt: - type: string - format: date-time - endedAt: - type: string - format: date-time - description: Directed relation between two business partners - SiteBpnSearchRequest: - type: object - properties: - legalEntities: - type: array - items: - type: string - sites: - type: array - items: - type: string - SitePartnerCreateRequest: - type: object - properties: - name: - type: string - mainAddress: - $ref: '#/components/schemas/Address' - legalEntity: - type: string - index: - type: string - description: Request for creating new business partner record of type site - SitePartnerCreateResponse: - type: object - properties: - bpn: - type: string - name: - type: string - mainAddress: - $ref: '#/components/schemas/AddressResponse' - index: - type: string - description: Created business partner record of type site - SitePartnerResponse: - type: object - properties: - bpn: - type: string - name: - type: string - description: Business partner of type site - SitePartnerSearchResponse: - type: object - properties: - site: - $ref: '#/components/schemas/SitePartnerResponse' - bpnLegalEntity: - type: string - description: Business partner of type site with parent BPN - SitePartnerUpdateRequest: - type: object - properties: - bpn: - type: string - name: - type: string - mainAddress: - $ref: '#/components/schemas/Address' - description: Request for updating a business partner record of type site - SuggestionResponse: - type: object - properties: - suggestion: - type: string - relevancy: - type: number - format: float - description: Shows a ranked suggestion based on a given search text - SyncResponse: - type: object - properties: - type: - type: string - enum: - - OPENSEARCH - - SAAS_IMPORT - status: - type: string - enum: - - NOT_SYNCED - - RUNNING - - SUCCESS - - ERROR - count: + totalElements: type: integer - format: int32 - progress: - type: number - format: float - errorDetails: - type: string - startedAt: - type: string - format: date-time - finishedAt: - type: string - format: date-time - Thoroughfare: - type: object - properties: - value: - type: string - name: - type: string - shortName: - type: string - number: - type: string - direction: - type: string - type: - type: string - enum: - - INDUSTRIAL_ZONE - - OTHER - - RIVER - - SQUARE - - STREET - description: Thoroughfare record for an address such as street, square or industrial zone - ThoroughfareResponse: - type: object - properties: - value: - type: string - name: - type: string - shortName: - type: string - number: - type: string - direction: - type: string - type: - $ref: '#/components/schemas/TypeKeyNameUrlDtoThoroughfareType' - language: - $ref: '#/components/schemas/TypeKeyNameDtoLanguageCode' - description: Thoroughfare record of an address such as street, square or industrial zone - TypeKeyNameDtoCharacterSet: + description: Total number of all results in all pages + format: int64 + totalPages: + type: integer + description: Total number pages + format: int32 + page: + type: integer + description: Current page number + format: int32 + contentSize: + type: integer + description: Number of results in the page + format: int32 + content: + type: array + description: Collection of results in the page + items: + $ref: '#/components/schemas/SitePoolResponse' + description: Paginated collection of results + PageResponseSiteResponse: type: object properties: - technicalKey: - type: string - enum: - - ARABIC - - CHINESE - - CHINESE_TRADITIONAL - - CYRILLIC - - GREEK - - HANGUL_KOREAN - - HEBREW - - HIRAGANA - - KANJI - - KATAKANA - - LATIN - - THAI - - WESTERN_LATIN_STANDARD - - UNDEFINED - name: - type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoCountryCode: + totalElements: + type: integer + description: Total number of all results in all pages + format: int64 + totalPages: + type: integer + description: Total number pages + format: int32 + page: + type: integer + description: Current page number + format: int32 + contentSize: + type: integer + description: Number of results in the page + format: int32 + content: + type: array + description: Collection of results in the page + items: + $ref: '#/components/schemas/SiteResponse' + description: Paginated collection of results + PhysicalPostalAddress: type: object properties: - technicalKey: + geographicCoordinates: + $ref: '#/components/schemas/GeoCoordinates' + country: type: string + description: Describes the country enum: - UNDEFINED - AC @@ -6196,617 +3546,390 @@ components: - ZM - ZR - ZW - name: + postalCode: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoCurrencyCode: + description: A postal code, also known as postcode, PIN or ZIP Code + city: + type: string + description: 'The city of the address (Synonym: Town, village, municipality)' + street: + $ref: '#/components/schemas/Street' + administrativeAreaLevel1: + type: string + description: Identifying code of the Region within the country (e.g. Bayern) + administrativeAreaLevel2: + type: string + description: Further possibility to describe the region/address(e.g. County/Landkreis) + administrativeAreaLevel3: + type: string + description: Further possibility to describe the region/address(e.g. Township/Gemeinde) + district: + type: string + description: Divides the city in several smaller areas + companyPostalCode: + type: string + description: A separate postal code for a company, also known as postcode, PIN or ZIP Code + industrialZone: + type: string + description: The practice of designating an area for industrial development + building: + type: string + description: Describes a specific building within the address + floor: + type: string + description: Describes the floor/level the delivery shall take place + door: + type: string + description: Describes the door/room/suite on the respective floor the delivery shall take place + description: Physical Postal Address Part + PoolLegalEntityResponse: type: object properties: - technicalKey: + legalName: type: string - enum: - - UNDEFINED - - AED - - AFN - - ALL - - AMD - - ANG - - AOA - - ARS - - AUD - - AWG - - AZN - - BAM - - BBD - - BDT - - BGN - - BHD - - BIF - - BMD - - BND - - BOB - - BOV - - BRL - - BSD - - BTN - - BWP - - BYN - - BYR - - BZD - - CAD - - CDF - - CHE - - CHF - - CHW - - CLF - - CLP - - CNY - - COP - - COU - - CRC - - CUC - - CUP - - CVE - - CZK - - DJF - - DKK - - DOP - - DZD - - EGP - - ERN - - ETB - - EUR - - FJD - - FKP - - GBP - - GEL - - GHS - - GIP - - GMD - - GNF - - GTQ - - GYD - - HKD - - HNL - - HRK - - HTG - - HUF - - IDR - - ILS - - INR - - IQD - - IRR - - ISK - - JMD - - JOD - - JPY - - KES - - KGS - - KHR - - KMF - - KPW - - KRW - - KWD - - KYD - - KZT - - LAK - - LBP - - LKR - - LRD - - LSL - - LTL - - LYD - - MAD - - MDL - - MGA - - MKD - - MMK - - MNT - - MOP - - MRO - - MRU - - MUR - - MVR - - MWK - - MXN - - MXV - - MYR - - MZN - - NAD - - NGN - - NIO - - NOK - - NPR - - NZD - - OMR - - PAB - - PEN - - PGK - - PHP - - PKR - - PLN - - PYG - - QAR - - RON - - RSD - - RUB - - RUR - - RWF - - SAR - - SBD - - SCR - - SDG - - SEK - - SGD - - SHP - - SLL - - SOS - - SRD - - SSP - - STD - - STN - - SVC - - SYP - - SZL - - THB - - TJS - - TMT - - TND - - TOP - - TRY - - TTD - - TWD - - TZS - - UAH - - UGX - - USD - - USN - - USS - - UYI - - UYU - - UZS - - VEF - - VES - - VND - - VUV - - WST - - XAF - - XAG - - XAU - - XBA - - XBB - - XBC - - XBD - - XCD - - XDR - - XOF - - XPD - - XPF - - XPT - - XSU - - XTS - - XUA - - XXX - - YER - - ZAR - - ZMW - - ZWL - name: + description: Legal name the partner goes by + bpnl: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoLanguageCode: + description: Business Partner Number of this legal entity + identifiers: + type: array + items: + $ref: '#/components/schemas/LegalEntityIdentifierResponse' + legalShortName: + type: string + description: Abbreviated name or shorthand + legalForm: + $ref: '#/components/schemas/LegalFormResponse' + states: + type: array + items: + $ref: '#/components/schemas/LegalEntityStateResponse' + classifications: + type: array + items: + $ref: '#/components/schemas/ClassificationResponse' + relations: + type: array + items: + $ref: '#/components/schemas/RelationResponse' + currentness: + type: string + description: The timestamp the business partner data was last indicated to be still current + format: date-time + createdAt: + type: string + description: The timestamp the business partner data was created + format: date-time + updatedAt: + type: string + description: The timestamp the business partner data was last updated + format: date-time + legalAddress: + $ref: '#/components/schemas/LogisticAddressResponse' + description: Legal entity record + RelationResponse: type: object properties: - technicalKey: + type: + $ref: '#/components/schemas/TypeKeyNameDtoRelationType' + startBpn: type: string - enum: - - undefined - - aa - - ab - - ae - - af - - ak - - am - - an - - ar - - as - - av - - ay - - az - - ba - - be - - bg - - bh - - bi - - bm - - bn - - bo - - br - - bs - - ca - - ce - - ch - - co - - cr - - cs - - cu - - cv - - cy - - da - - de - - dv - - dz - - ee - - el - - en - - eo - - es - - et - - eu - - fa - - ff - - fi - - fj - - fo - - fr - - fy - - ga - - gd - - gl - - gn - - gu - - gv - - ha - - he - - hi - - ho - - hr - - ht - - hu - - hy - - hz - - ia - - id - - ie - - ig - - ii - - ik - - io - - is - - it - - iu - - ja - - jv - - ka - - kg - - ki - - kj - - kk - - kl - - km - - kn - - ko - - kr - - ks - - ku - - kv - - kw - - ky - - la - - lb - - lg - - li - - ln - - lo - - lt - - lu - - lv - - mg - - mh - - mi - - mk - - ml - - mn - - mr - - ms - - mt - - my - - na - - nb - - nd - - ne - - ng - - nl - - nn - - 'no' - - nr - - nv - - ny - - oc - - oj - - om - - or - - os - - pa - - pi - - pl - - ps - - pt - - qu - - rm - - rn - - ro - - ru - - rw - - sa - - sc - - sd - - se - - sg - - si - - sk - - sl - - sm - - sn - - so - - sq - - sr - - ss - - st - - su - - sv - - sw - - ta - - te - - tg - - th - - ti - - tk - - tl - - tn - - to - - tr - - ts - - tt - - tw - - ty - - ug - - uk - - ur - - uz - - ve - - vi - - vo - - wa - - wo - - xh - - yi - - yo - - za - - zh - - zu - name: + description: BPN of partner which is the source of the relation + endBpn: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoRelationClass: + description: BPN of partner which is the target of the relation + validFrom: + type: string + description: Time when the relation started + format: date-time + validTo: + type: string + description: Time when the relation ended + format: date-time + description: Directed relation between two business partners + SiteBpnSearchRequest: + type: object + properties: + legalEntities: + type: array + items: + type: string + sites: + type: array + items: + type: string + SiteCreateWrapper: + type: object + properties: + entities: + type: array + items: + $ref: '#/components/schemas/SitePartnerCreateResponse' + errors: + type: array + items: + $ref: '#/components/schemas/ErrorInfoSiteCreateError' + errorCount: + type: integer + format: int32 + entityCount: + type: integer + format: int32 + description: Holds information about successfully and failed entities after the creating/updating of several objects + SitePartnerCreateRequest: type: object properties: - technicalKey: - type: string - enum: - - SAAS_HIERARCHY - - SAAS_TRANSITION - - CX_HIERARCHY - - DNB_HIERARCHY - - LEI_HIERARCHY name: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoRelationType: + description: Site name + states: + type: array + items: + $ref: '#/components/schemas/SiteState' + mainAddress: + $ref: '#/components/schemas/LogisticAddressDto' + bpnlParent: + type: string + index: + type: string + description: Request for creating new business partner record of type site + SitePartnerCreateResponse: type: object properties: - technicalKey: + bpns: type: string - enum: - - CX_LEGAL_SUCCESSOR_OF - - CX_LEGAL_PREDECESSOR_OF - - CX_ADDRESS_OF - - CX_SITE_OF - - CX_OWNED_BY - - DIRECT_LEGAL_RELATION - - COMMERCIAL_ULTIMATE - - DOMESTIC_BRANCH_RELATION - - INTERNATIONAL_BRANCH_RELATION - - DOMESTIC_LEGAL_ULTIMATE_RELATION - - GLOBAL_LEGAL_ULTIMATE_RELATION - - LEGAL_PREDECESSOR - - LEGAL_SUCCESSOR - - DNB_PARENT - - DNB_HEADQUARTER - - DNB_DOMESTIC_ULTIMATE - - DNB_GLOBAL_ULTIMATE - - LEI_DIRECT_PARENT - - LEI_INTERNATIONAL_BRANCH - - LEI_ULTIMATE_PARENT + description: Business Partner Number, main identifier value for sites name: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameDtoString: + description: Site name + states: + type: array + items: + $ref: '#/components/schemas/SiteStateResponse' + bpnLegalEntity: + type: string + description: Business Partner Number of the related legal entity + createdAt: + type: string + description: The timestamp the business partner data was created + format: date-time + updatedAt: + type: string + description: The timestamp the business partner data was last updated + format: date-time + mainAddress: + $ref: '#/components/schemas/LogisticAddressResponse' + index: + type: string + description: Created business partner record of type site + SitePartnerUpdateRequest: type: object properties: - technicalKey: + bpns: type: string name: type: string - description: Named type uniquely identified by its technical key - TypeKeyNameUrlDtoAddressType: + description: Site name + states: + type: array + items: + $ref: '#/components/schemas/SiteState' + mainAddress: + $ref: '#/components/schemas/LogisticAddressDto' + description: Request for updating a business partner record of type site + SitePoolResponse: type: object properties: - technicalKey: + bpns: type: string - enum: - - BRANCH_OFFICE - - CARE_OF - - HEADQUARTER - - LEGAL_ALTERNATIVE - - PO_BOX - - REGISTERED - - REGISTERED_AGENT_MAIL - - REGISTERED_AGENT_PHYSICAL - - VAT_REGISTERED - - UNSPECIFIC + description: Business Partner Number, main identifier value for sites name: type: string - url: + description: Site name + states: + type: array + items: + $ref: '#/components/schemas/SiteStateResponse' + bpnLegalEntity: + type: string + description: Business Partner Number of the related legal entity + createdAt: type: string - TypeKeyNameUrlDtoAdministrativeAreaType: + description: The timestamp the business partner data was created + format: date-time + updatedAt: + type: string + description: The timestamp the business partner data was last updated + format: date-time + mainAddress: + $ref: '#/components/schemas/LogisticAddressResponse' + description: Site with legal entity reference. + SiteResponse: type: object properties: - technicalKey: + bpns: type: string - enum: - - COUNTY - - REGION - - OTHER + description: Business Partner Number, main identifier value for sites name: type: string - url: + description: Site name + states: + type: array + items: + $ref: '#/components/schemas/SiteStateResponse' + bpnLegalEntity: + type: string + description: Business Partner Number of the related legal entity + createdAt: + type: string + description: The timestamp the business partner data was created + format: date-time + updatedAt: type: string - TypeKeyNameUrlDtoBusinessPartnerType: + description: The timestamp the business partner data was last updated + format: date-time + description: Site of a legal entity + SiteState: type: object properties: - technicalKey: + description: type: string - enum: - - BRAND - - LEGAL_ENTITY - - ORGANIZATIONAL_UNIT - - SITE - - UNKNOWN - name: + description: Description of the status + validFrom: type: string - url: + description: Since when the status is/was valid + format: date-time + validTo: type: string - TypeKeyNameUrlDtoBusinessStatusType: - type: object - properties: - technicalKey: + description: Until the status was valid, if applicable + format: date-time + type: type: string + description: The type of this specified status enum: - ACTIVE - - DISSOLVED - - IN_LIQUIDATION - INACTIVE - - INSOLVENCY - - UNKNOWN - name: - type: string - url: - type: string - TypeKeyNameUrlDtoLocalityType: + description: Status record of a site + SiteStateResponse: type: object properties: - technicalKey: + description: type: string - enum: - - BLOCK - - CITY - - DISTRICT - - OTHER - - POST_OFFICE_CITY - - QUARTER - name: + description: Description of the status + validFrom: type: string - url: + description: Since when the status is/was valid + format: date-time + validTo: type: string - TypeKeyNameUrlDtoNameType: + description: Until the status was valid, if applicable + format: date-time + type: + $ref: '#/components/schemas/TypeKeyNameDtoBusinessStateType' + description: Status record of a site + SiteUpdateWrapper: + type: object + properties: + entities: + type: array + items: + $ref: '#/components/schemas/SitePartnerCreateResponse' + errors: + type: array + items: + $ref: '#/components/schemas/ErrorInfoSiteUpdateError' + errorCount: + type: integer + format: int32 + entityCount: + type: integer + format: int32 + description: Holds information about successfully and failed entities after the creating/updating of several objects + Street: type: object properties: - technicalKey: - type: string - enum: - - ACRONYM - - DOING_BUSINESS_AS - - ESTABLISHMENT - - INTERNATIONAL - - LOCAL - - OTHER - - REGISTERED - - TRANSLITERATED - - VAT_REGISTERED name: type: string - url: + description: Describes the official Name of the Street. + houseNumber: type: string - TypeKeyNameUrlDtoPostCodeType: + description: Describes the House Number + milestone: + type: string + description: The Milestone is relevant for long roads without specific house numbers. + direction: + type: string + description: Describes the direction + description: A public road in a city, town, or village, typically with houses and buildings on one or both sides. + SyncResponse: type: object properties: - technicalKey: + type: type: string enum: - - CEDEX - - LARGE_MAIL_USER - - OTHER - - POST_BOX - - REGULAR - name: + - OPENSEARCH + - SAAS_IMPORT + status: + type: string + enum: + - NOT_SYNCED + - RUNNING + - SUCCESS + - ERROR + count: + type: integer + format: int32 + progress: + type: number + format: float + errorDetails: + type: string + startedAt: type: string - url: + format: date-time + finishedAt: type: string - TypeKeyNameUrlDtoPostalDeliveryPointType: + format: date-time + TypeKeyNameDtoBusinessStateType: type: object properties: technicalKey: type: string enum: - - INTERURBAN_DELIVERY_POINT - - MAIL_STATION - - MAILBOX - - OTHER - - POST_OFFICE_BOX + - ACTIVE + - INACTIVE name: type: string - url: - type: string - TypeKeyNameUrlDtoPremiseType: + description: Named type uniquely identified by its technical key + TypeKeyNameDtoClassificationType: type: object properties: technicalKey: type: string enum: - - BUILDING - - OTHER - - LEVEL - - HARBOUR - - ROOM - - SUITE - - UNIT - - WAREHOUSE + - NACE + - NAF + - NAICS + - SIC name: type: string - url: - type: string - TypeKeyNameUrlDtoString: + description: Named type uniquely identified by its technical key + TypeKeyNameDtoRelationType: type: object properties: technicalKey: type: string + enum: + - CX_LEGAL_SUCCESSOR_OF + - CX_LEGAL_PREDECESSOR_OF name: type: string - url: - type: string - TypeKeyNameUrlDtoThoroughfareType: + description: Named type uniquely identified by its technical key + TypeKeyNameDtoString: type: object properties: technicalKey: type: string - enum: - - INDUSTRIAL_ZONE - - OTHER - - RIVER - - SQUARE - - STREET name: type: string - url: - type: string + description: Named type uniquely identified by its technical key From 26c3b1b39e38e2817aae6e9c2bf84c1da0594130 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Thu, 15 Jun 2023 13:21:47 +0100 Subject: [PATCH 62/83] fix(gate): Removal of unused columns in the persistence --- .../bpdm/gate/entity/AlternativePostalAddress.kt | 6 ------ .../eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt | 4 ---- .../tractusx/bpdm/gate/entity/LogisticAddress.kt | 3 --- .../bpdm/gate/entity/PhysicalPostalAddress.kt | 12 ------------ .../bpdm/gate/service/AddressPersistenceService.kt | 2 -- .../gate/service/LegalEntityPersistenceService.kt | 1 - .../tractusx/bpdm/gate/service/ResponseMappings.kt | 10 ---------- .../bpdm/gate/service/SitePersistenceService.kt | 1 - .../db/migration/V5_0_0_0__unused_column_removal.sql | 7 +++++++ 9 files changed, 7 insertions(+), 39 deletions(-) create mode 100644 bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt index ed57cbbf2..868ffa1ad 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt @@ -54,12 +54,6 @@ class AlternativePostalAddress( @Column(name = "alt_admin_area_l3") val administrativeAreaLevel3: String? = null, - /** - * Further possibility to describe the region/address(e.g. Sub-Province for China - */ - @Column(name = "alt_admin_area_l4") - val administrativeAreaLevel4: String? = null, - /** * A postal code, also known as postcode, PIN or ZIP Code */ diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt index 621fad714..2655cbb89 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.gate.entity import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum -import java.time.Instant @Entity @Table( @@ -42,9 +41,6 @@ class LegalEntity( @Column(name = "legal_form_id", nullable = false) var legalForm: String?, - @Column(name = "currentness", nullable = false) - var currentness: Instant, - @Column(name = "data_type") @Enumerated(EnumType.STRING) var dataType: OutputInputEnum diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt index d4e28226b..06a7dd83c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt @@ -38,9 +38,6 @@ class LogisticAddress( @Column(name = "external_id", nullable = false, unique = true) var externalId: String, - @Column(name = "site_external_id", nullable = true) - var siteExternalId: String, - @ManyToOne @JoinColumn(name = "legal_entity_id") var legalEntity: LegalEntity?, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt index 100235bbd..e0981815d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt @@ -53,12 +53,6 @@ class PhysicalPostalAddress( @Column(name = "phy_admin_area_l3") val administrativeAreaLevel3: String? = null, - /** - * Further possibility to describe the region/address(e.g. Sub-Province for China - */ - @Column(name = "phy_admin_area_l4") - val administrativeAreaLevel4: String? = null, - /** * A postal code, also known as postcode, PIN or ZIP Code */ @@ -77,12 +71,6 @@ class PhysicalPostalAddress( @Column(name = "phy_district_l1") val districtLevel1: String? = null, - /** - * Divides the DistrictLevel1 in several smaller areas. Synonym: Subdistrict - */ - @Column(name = "phy_district_l2") - val districtLevel2: String? = null, - @Embedded @AttributeOverride(name = "name", column = Column(name = "phy_street_name")) @AttributeOverride(name = "houseNumber", column = Column(name = "phy_street_number")) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index 3af030c25..8ae46f06e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -71,7 +71,6 @@ class AddressPersistenceService( address.externalId = changeAddress.externalId address.legalEntity = legalEntityRecord address.site = siteRecord - address.siteExternalId = changeAddress.siteExternalId.toString() address.physicalPostalAddress = changeAddress.address.physicalPostalAddress.toPhysicalPostalAddressEntity() address.alternativePostalAddress = changeAddress.address.alternativePostalAddress?.toAlternativePostalAddressEntity() @@ -114,7 +113,6 @@ class AddressPersistenceService( address.externalId = changeAddress.externalId address.legalEntity = legalEntityRecord address.site = siteRecord - address.siteExternalId = changeAddress.siteExternalId.toString() address.physicalPostalAddress = changeAddress.address.physicalPostalAddress.toPhysicalPostalAddressEntity() address.alternativePostalAddress = changeAddress.address.alternativePostalAddress?.toAlternativePostalAddressEntity() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 4abee05d2..92c7b0c0c 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -96,7 +96,6 @@ class LegalEntityPersistenceService( address.name = changeAddress.name address.externalId = changeAddress.externalId address.legalEntity = changeAddress.legalEntity - address.siteExternalId = changeAddress.siteExternalId address.physicalPostalAddress = changeAddress.physicalPostalAddress address.alternativePostalAddress = changeAddress.alternativePostalAddress diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 18745faac..815312bdd 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -26,14 +26,11 @@ import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.entity.* import org.springframework.data.domain.Page -import java.time.Instant -import java.time.temporal.ChronoUnit fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site?, datatype: OutputInputEnum): LogisticAddress { val logisticAddress = LogisticAddress( externalId = externalId, - siteExternalId = siteExternalId.toString(), name = address.nameParts.firstOrNull(), physicalPostalAddress = address.physicalPostalAddress.toPhysicalPostalAddressEntity(), alternativePostalAddress = address.alternativePostalAddress?.toAlternativePostalAddressEntity(), @@ -53,7 +50,6 @@ fun AddressGateOutputRequest.toAddressGateOutput(legalEntity: LegalEntity?, site val logisticAddress = LogisticAddress( bpn = bpn, externalId = externalId, - siteExternalId = siteExternalId.toString(), name = address.nameParts.firstOrNull(), physicalPostalAddress = address.physicalPostalAddress.toPhysicalPostalAddressEntity(), alternativePostalAddress = address.alternativePostalAddress?.toAlternativePostalAddressEntity(), @@ -195,7 +191,6 @@ fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalE val legalEntity = LegalEntity( externalId = externalId, - currentness = createCurrentnessTimestamp(), legalForm = legalEntity.legalForm, legalName = Name(legalNameParts[0], legalEntity.legalShortName), dataType = datatype @@ -223,7 +218,6 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal val legalEntity = LegalEntity( bpn = bpn, externalId = externalId, - currentness = createCurrentnessTimestamp(), legalForm = legalEntity.legalForm, legalName = Name(legalNameParts[0], legalEntity.legalShortName), dataType = datatype @@ -251,10 +245,6 @@ fun toEntityClassification(dto: ClassificationDto, legalEntity: LegalEntity): Cl return Classification(dto.value, dto.code, dto.type, legalEntity) } -private fun createCurrentnessTimestamp(): Instant { - return Instant.now().truncatedTo(ChronoUnit.MICROS) -} - fun getMainAddressForSiteExternalId(siteExternalId: String): String { return siteExternalId + "_site" } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 7c689f718..5dd0c7ea0 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -100,7 +100,6 @@ class SitePersistenceService( address.name = changeAddress.name address.externalId = changeAddress.externalId address.legalEntity = changeAddress.legalEntity - address.siteExternalId = changeAddress.siteExternalId address.physicalPostalAddress = changeAddress.physicalPostalAddress address.alternativePostalAddress = changeAddress.alternativePostalAddress diff --git a/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql b/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql new file mode 100644 index 000000000..032fcfbf6 --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql @@ -0,0 +1,7 @@ +ALTER TABLE logistic_addresses DROP COLUMN site_external_id; + +ALTER TABLE logistic_addresses DROP COLUMN phy_admin_area_l4; + +ALTER TABLE logistic_addresses DROP COLUMN phy_district_l2; + +ALTER TABLE legal_entities DROP COLUMN currentness; \ No newline at end of file From 0b6c4816594768463a6828fb91554d3700dc776f Mon Sep 17 00:00:00 2001 From: alexsilva Date: Fri, 16 Jun 2023 15:08:15 +0100 Subject: [PATCH 63/83] fix(gate): Removal of Region Table --- .../gate/entity/AlternativePostalAddress.kt | 5 +-- .../bpdm/gate/entity/PhysicalPostalAddress.kt | 5 +-- .../tractusx/bpdm/gate/entity/Region.kt | 40 ------------------- .../V5_0_0_0__unused_column_removal.sql | 19 ++++++++- 4 files changed, 22 insertions(+), 47 deletions(-) delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Region.kt diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt index 868ffa1ad..b5326fb4a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt @@ -38,9 +38,8 @@ class AlternativePostalAddress( /** * Region within the country */ - @ManyToOne - @JoinColumn(name = "alt_admin_area_l1_region") - val administrativeAreaLevel1: Region?, + @Column(name = "alt_admin_area_l1_region") + val administrativeAreaLevel1: String? = null, /** * Further possibility to describe the region/address(e.g. County) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt index e0981815d..27ad5de05 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/PhysicalPostalAddress.kt @@ -37,9 +37,8 @@ class PhysicalPostalAddress( /** * Region within the country */ - @ManyToOne - @JoinColumn(name = "phy_admin_area_l1_region") - val administrativeAreaLevel1: Region?, + @Column(name = "phy_admin_area_l1_region") + val administrativeAreaLevel1: String? = null, /** * Further possibility to describe the region/address(e.g. County) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Region.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Region.kt deleted file mode 100644 index 203b2a9a5..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/Region.kt +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.entity - -import com.neovisionaries.i18n.CountryCode -import jakarta.persistence.* -import org.eclipse.tractusx.bpdm.common.model.BaseEntity - -@Entity -@Table( - name = "regions", -) -class Region( - @Column(name = "country_code") - @Enumerated(EnumType.STRING) - val countryCode: CountryCode, - - @Column(name = "region_code") - val regionCode: String, - - @Column(name = "region_name") - val regionName: String -) : BaseEntity() \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql b/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql index 032fcfbf6..c88be1b40 100644 --- a/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql +++ b/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql @@ -4,4 +4,21 @@ ALTER TABLE logistic_addresses DROP COLUMN phy_admin_area_l4; ALTER TABLE logistic_addresses DROP COLUMN phy_district_l2; -ALTER TABLE legal_entities DROP COLUMN currentness; \ No newline at end of file +ALTER TABLE legal_entities DROP COLUMN currentness; + +-- Remove Regions Constraints +ALTER TABLE logistic_addresses +DROP CONSTRAINT IF EXISTS fk1msrc2opgg7y8hllv9mxydm41; + +ALTER TABLE logistic_addresses +DROP CONSTRAINT IF EXISTS fkejpo9hh93uu777fbmmixh8v2f; + +-- Alter columns from BIGINT to VARCHAR +ALTER TABLE logistic_addresses +ALTER COLUMN alt_admin_area_l1_region TYPE VARCHAR(255); + +ALTER TABLE logistic_addresses +ALTER COLUMN phy_admin_area_l1_region TYPE VARCHAR(255); + +-- Removal of Regions Table +DROP TABLE IF EXISTS regions; \ No newline at end of file From 87705599e022c4321fd13b4d8c6b94ac86faf782 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Tue, 20 Jun 2023 08:37:17 +0100 Subject: [PATCH 64/83] fix(gate): Removal of Identifier Entities and Unit test fix --- .../tractusx/bpdm/gate/entity/LegalEntity.kt | 2 - .../bpdm/gate/entity/LegalEntityIdentifier.kt | 47 ------------------- .../bpdm/gate/entity/LogisticAddress.kt | 2 - .../gate/service/AddressPersistenceService.kt | 2 - .../service/LegalEntityPersistenceService.kt | 11 ++--- .../bpdm/gate/service/ResponseMappings.kt | 22 --------- .../gate/service/SitePersistenceService.kt | 9 ++-- .../V5_0_0_0__unused_column_removal.sql | 7 ++- .../tractusx/bpdm/gate/util/RequestValues.kt | 3 -- .../tractusx/bpdm/gate/util/ResponseValues.kt | 25 ---------- 10 files changed, 14 insertions(+), 116 deletions(-) delete mode 100644 bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityIdentifier.kt diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt index 2655cbb89..7c2b4c75d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntity.kt @@ -46,8 +46,6 @@ class LegalEntity( var dataType: OutputInputEnum ) : BaseEntity() { - @OneToMany(mappedBy = "legalEntity", cascade = [CascadeType.ALL], orphanRemoval = true) - val identifiers: MutableSet = mutableSetOf() @OneToMany(mappedBy = "legalEntity", cascade = [CascadeType.ALL], orphanRemoval = true) val states: MutableSet = mutableSetOf() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityIdentifier.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityIdentifier.kt deleted file mode 100644 index 2b028481e..000000000 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LegalEntityIdentifier.kt +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * 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 org.eclipse.tractusx.bpdm.gate.entity - -import jakarta.persistence.* -import org.eclipse.tractusx.bpdm.common.model.BaseEntity - -@Entity -@Table( - name = "legal_entity_identifiers", - indexes = [ - Index(columnList = "legal_entity_id") - ] -) -class LegalEntityIdentifier( - @Column(name = "`value`", nullable = false) - var value: String, - - - @Column(name = "identifier_type_key") - var type: String?, - - @Column(name = "issuing_body") - var issuingBody: String?, - - @ManyToOne - @JoinColumn(name = "legal_entity_id", nullable = false) - var legalEntity: LegalEntity - -) : BaseEntity() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt index 06a7dd83c..5e6a1861d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/LogisticAddress.kt @@ -60,8 +60,6 @@ class LogisticAddress( var alternativePostalAddress: AlternativePostalAddress? ) : BaseEntity() { - @OneToMany(mappedBy = "address", cascade = [CascadeType.ALL], orphanRemoval = true) - val identifiers: MutableSet = mutableSetOf() @OneToMany(mappedBy = "address", cascade = [CascadeType.ALL], orphanRemoval = true) val states: MutableSet = mutableSetOf() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt index 8ae46f06e..fff779601 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressPersistenceService.kt @@ -74,7 +74,6 @@ class AddressPersistenceService( address.physicalPostalAddress = changeAddress.address.physicalPostalAddress.toPhysicalPostalAddressEntity() address.alternativePostalAddress = changeAddress.address.alternativePostalAddress?.toAlternativePostalAddressEntity() - address.identifiers.replace(changeAddress.address.identifiers.map { toEntityIdentifier(it, address) }) address.states.replace(changeAddress.address.states.map { toEntityAddress(it, address) }) } @@ -116,7 +115,6 @@ class AddressPersistenceService( address.physicalPostalAddress = changeAddress.address.physicalPostalAddress.toPhysicalPostalAddressEntity() address.alternativePostalAddress = changeAddress.address.alternativePostalAddress?.toAlternativePostalAddressEntity() - address.identifiers.replace(changeAddress.address.identifiers.map { toEntityIdentifier(it, address) }) address.states.replace(changeAddress.address.states.map { toEntityAddress(it, address) }) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 92c7b0c0c..49ed7dab4 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -28,6 +28,10 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.entity.* import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository +import org.eclipse.tractusx.bpdm.gate.entity.AddressState +import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity +import org.eclipse.tractusx.bpdm.gate.entity.LogisticAddress +import org.eclipse.tractusx.bpdm.gate.entity.Name import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.springframework.http.HttpStatus @@ -83,7 +87,6 @@ class LegalEntityPersistenceService( legalEntity.externalId = legalEntityRequest.externalId legalEntity.legalForm = legalEntityRequest.legalEntity.legalForm legalEntity.legalName = Name(value = legalEntityRequest.legalNameParts[0], shortName = legalEntityRequest.legalEntity.legalShortName) - legalEntity.identifiers.replace(legalEntityRequest.legalEntity.identifiers.map { toEntityIdentifier(it, legalEntity) }) legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.legalAddress = logisticAddressRecord @@ -99,7 +102,6 @@ class LegalEntityPersistenceService( address.physicalPostalAddress = changeAddress.physicalPostalAddress address.alternativePostalAddress = changeAddress.alternativePostalAddress - address.identifiers.replace(changeAddress.identifiers.map { toEntityIdentifier(it, address) }) address.states.replace(changeAddress.states.map { toEntityAddress(it, address) }) } @@ -108,10 +110,6 @@ class LegalEntityPersistenceService( return AddressState(dto.description, dto.validFrom, dto.validTo, dto.type, address) } - fun toEntityIdentifier(dto: AddressIdentifier, address: LogisticAddress): AddressIdentifier { - return AddressIdentifier(dto.value, dto.type, address) - } - @Transactional fun persistLegalEntitiesOutputBP(legalEntities: Collection, datatype: OutputInputEnum) { //finds Legal Entity by External ID @@ -149,7 +147,6 @@ class LegalEntityPersistenceService( legalEntity.externalId = legalEntityRequest.externalId legalEntity.legalForm = legalEntityRequest.legalEntity.legalForm legalEntity.legalName = Name(value = legalEntityRequest.legalNameParts[0], shortName = legalEntityRequest.legalEntity.legalShortName) - legalEntity.identifiers.replace(legalEntityRequest.legalEntity.identifiers.map { toEntityIdentifier(it, legalEntity) }) legalEntity.states.replace(legalEntityRequest.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.replace(legalEntityRequest.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) legalEntity.legalAddress = logisticAddressRecord diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 815312bdd..7763a0a01 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -39,7 +39,6 @@ fun AddressGateInputRequest.toAddressGate(legalEntity: LegalEntity?, site: Site? dataType = datatype ) - logisticAddress.identifiers.addAll(this.address.identifiers.map { toEntityIdentifier(it, logisticAddress) }.toSet()) logisticAddress.states.addAll(this.address.states.map { toEntityAddress(it, logisticAddress) }.toSet()) return logisticAddress @@ -58,7 +57,6 @@ fun AddressGateOutputRequest.toAddressGateOutput(legalEntity: LegalEntity?, site dataType = datatype ) - logisticAddress.identifiers.addAll(this.address.identifiers.map { toEntityIdentifier(it, logisticAddress) }.toSet()) logisticAddress.states.addAll(this.address.states.map { toEntityAddress(it, logisticAddress) }.toSet()) return logisticAddress @@ -68,10 +66,6 @@ fun toEntityAddress(dto: AddressStateDto, address: LogisticAddress): AddressStat return AddressState(dto.description, dto.validFrom, dto.validTo, dto.type, address) } -fun toEntityIdentifier(dto: AddressIdentifierDto, address: LogisticAddress): AddressIdentifier { - return AddressIdentifier(dto.value, dto.type, address) -} - fun AlternativePostalAddressDto.toAlternativePostalAddressEntity(): AlternativePostalAddress { return AlternativePostalAddress( @@ -196,7 +190,6 @@ fun LegalEntityGateInputRequest.toLegalEntity(datatype: OutputInputEnum): LegalE dataType = datatype ) - legalEntity.identifiers.addAll(this.legalEntity.identifiers.map { toEntityIdentifier(it, legalEntity) }) legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) @@ -223,7 +216,6 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal dataType = datatype ) - legalEntity.identifiers.addAll(this.legalEntity.identifiers.map { toEntityIdentifier(it, legalEntity) }) legalEntity.states.addAll(this.legalEntity.states.map { toEntityState(it, legalEntity) }) legalEntity.classifications.addAll(this.legalEntity.classifications.map { toEntityClassification(it, legalEntity) }) @@ -233,10 +225,6 @@ fun LegalEntityGateOutputRequest.toLegalEntity(datatype: OutputInputEnum): Legal } -fun toEntityIdentifier(dto: LegalEntityIdentifierDto, legalEntity: LegalEntity): LegalEntityIdentifier { - return LegalEntityIdentifier(dto.value, dto.type, dto.issuingBody, legalEntity) -} - fun toEntityState(dto: LegalEntityStateDto, legalEntity: LegalEntity): LegalEntityState { return LegalEntityState(dto.officialDenotation, dto.validFrom, dto.validTo, dto.type, legalEntity) } @@ -272,7 +260,6 @@ fun LogisticAddress.toLogisticAddressDto(): LogisticAddressGateDto { val logisticAddress = LogisticAddressGateDto( nameParts = name?.let { listOf(name!!) }?: emptyList(), states = mapToDtoStates(states), - identifiers = mapToDtoIdentifiers(identifiers), physicalPostalAddress = physicalPostalAddress.toPhysicalPostalAddress(), alternativePostalAddress = alternativePostalAddress?.toAlternativePostalAddressDto(), ) @@ -284,10 +271,6 @@ fun mapToDtoStates(states: MutableSet): Collection): Collection { - return identifier.map { AddressIdentifierDto(it.value, it.type) } -} - fun AlternativePostalAddress.toAlternativePostalAddressDto(): AlternativePostalAddressDto { val basePostalAddressDto = BasePostalAddressDto( @@ -360,7 +343,6 @@ fun LegalEntity.toLegalEntityDto(): LegalEntityDto { legalShortName = legalName.shortName, states = mapToLegalEntityStateDto(states), classifications = mapToLegalEntityClassificationsDto(classifications), - identifiers = mapToLegalEntityIdentifierDto(identifiers) ) } @@ -369,10 +351,6 @@ fun mapToLegalEntityStateDto(states: MutableSet): Collection): Collection { - return identifier.map { LegalEntityIdentifierDto(it.value, it.type.toString(), it.issuingBody) } -} - fun mapToLegalEntityClassificationsDto(classification: MutableSet): Collection { return classification.map { ClassificationDto(it.value, it.code, it.type) } } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index 5dd0c7ea0..e3ac6518e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -27,6 +27,10 @@ import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.entity.* import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository +import org.eclipse.tractusx.bpdm.gate.entity.AddressState +import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity +import org.eclipse.tractusx.bpdm.gate.entity.LogisticAddress +import org.eclipse.tractusx.bpdm.gate.entity.Site import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository @@ -103,7 +107,6 @@ class SitePersistenceService( address.physicalPostalAddress = changeAddress.physicalPostalAddress address.alternativePostalAddress = changeAddress.alternativePostalAddress - address.identifiers.replace(changeAddress.identifiers.map { toEntityIdentifier(it, address) }) address.states.replace(changeAddress.states.map { toEntityAddress(it, address) }) } @@ -112,10 +115,6 @@ class SitePersistenceService( return AddressState(dto.description, dto.validFrom, dto.validTo, dto.type, address) } - fun toEntityIdentifier(dto: AddressIdentifier, address: LogisticAddress): AddressIdentifier { - return AddressIdentifier(dto.value, dto.type, address) - } - @Transactional fun persistSitesOutputBP(sites: Collection, datatype: OutputInputEnum) { diff --git a/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql b/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql index c88be1b40..9b589a527 100644 --- a/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql +++ b/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql @@ -21,4 +21,9 @@ ALTER TABLE logistic_addresses ALTER COLUMN phy_admin_area_l1_region TYPE VARCHAR(255); -- Removal of Regions Table -DROP TABLE IF EXISTS regions; \ No newline at end of file +DROP TABLE IF EXISTS regions; + +-- Removal of Identifiers TYPE +DROP TABLE IF EXISTS legal_entity_identifiers CASCADE; + +DROP TABLE IF EXISTS address_identifiers CASCADE; \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index 422b8db3a..6bee4240c 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -239,7 +239,6 @@ object RequestValues { val legalEntity1 = LegalEntityDto( - identifiers = listOf(identifier1, identifier2), legalShortName = CommonValues.shortName1, legalForm = CommonValues.legalFormTechnicalKey1, states = listOf(leBusinessStatus1), @@ -247,7 +246,6 @@ object RequestValues { ) val legalEntity2 = LegalEntityDto( - identifiers = listOf(identifier3, identifier4), legalShortName = CommonValues.shortName3, legalForm = CommonValues.legalFormTechnicalKey2, states = listOf(leBusinessStatus2), @@ -255,7 +253,6 @@ object RequestValues { ) val legalEntity3 = LegalEntityDto( - identifiers = listOf(identifier1, identifier2), legalShortName = CommonValues.shortName1, legalForm = CommonValues.legalFormTechnicalKey1, states = listOf(leBusinessStatus1), diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index fc0150f5e..fb056b2cb 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.util -import org.eclipse.tractusx.bpdm.common.dto.AddressIdentifierDto import org.eclipse.tractusx.bpdm.common.dto.BasePhysicalAddressDto import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.dto.StreetDto @@ -218,7 +217,6 @@ object ResponseValues { ), legalEntity = LegalEntityResponse( bpnl = CommonValues.bpn1, - identifiers = listOf(identifier1, identifier2), legalShortName = CommonValues.shortName1, legalForm = legalForm1, states = listOf(leBusinessStatus1), @@ -242,7 +240,6 @@ object ResponseValues { ), legalEntity = LegalEntityResponse( bpnl = CommonValues.bpn2, - identifiers = listOf(identifier3, identifier4), legalShortName = CommonValues.shortName3, legalForm = legalForm2, states = listOf(leBusinessStatus2), @@ -255,7 +252,6 @@ object ResponseValues { val legalEntityResponseGate1 = LegalEntityResponse( bpnl = CommonValues.bpn1, - identifiers = listOf(identifier1, identifier2), legalShortName = CommonValues.shortName1, legalForm = legalForm1, states = listOf(leBusinessStatus1), @@ -267,7 +263,6 @@ object ResponseValues { val legalEntityResponseGate2 = LegalEntityResponse( bpnl = CommonValues.bpn2, - identifiers = listOf(identifier3, identifier4), legalShortName = CommonValues.shortName3, legalForm = legalForm2, states = listOf(leBusinessStatus2), @@ -281,10 +276,6 @@ object ResponseValues { address = RequestValues.address1 .copy( nameParts = listOf(CommonValues.name1), - identifiers = listOf( - AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!), - AddressIdentifierDto(SaasValues.identifier2.value!!, SaasValues.identifier2.type?.technicalKey!!) - ) ), externalId = CommonValues.externalIdAddress1, legalEntityExternalId = CommonValues.externalId1, @@ -294,10 +285,6 @@ object ResponseValues { address = RequestValues.address2 .copy( nameParts = listOf(CommonValues.nameSite1), - identifiers = listOf( - AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!), - AddressIdentifierDto(SaasValues.identifier2.value!!, SaasValues.identifier2.type?.technicalKey!!) - ) ), externalId = CommonValues.externalIdAddress2, siteExternalId = CommonValues.externalIdSite1, @@ -306,9 +293,6 @@ object ResponseValues { val logisticAddressGateInputResponse1 = AddressGateInputResponse( address = RequestValues.logisticAddress1.copy( nameParts = listOf(CommonValues.name1), - identifiers = listOf( - AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) - ) ), externalId = CommonValues.externalIdAddress1, legalEntityExternalId = null, @@ -317,9 +301,6 @@ object ResponseValues { val logisticAddressGateInputResponse2 = AddressGateInputResponse( address = RequestValues.logisticAddress2.copy( nameParts = listOf(CommonValues.name2), - identifiers = listOf( - AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) - ) ), externalId = CommonValues.externalIdAddress2, siteExternalId = null, @@ -329,9 +310,6 @@ object ResponseValues { val logisticAddressGateOutputResponse1 = AddressGateOutputResponse( address = RequestValues.logisticAddress1.copy( nameParts = listOf(CommonValues.name1), - identifiers = listOf( - AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) - ) ), externalId = CommonValues.externalIdAddress1, legalEntityExternalId = null, @@ -341,9 +319,6 @@ object ResponseValues { val logisticAddressGateOutputResponse2 = AddressGateOutputResponse( address = RequestValues.logisticAddress2.copy( nameParts = listOf(CommonValues.name2), - identifiers = listOf( - AddressIdentifierDto(SaasValues.identifier1.value!!, SaasValues.identifier1.type?.technicalKey!!) - ) ), externalId = CommonValues.externalIdAddress2, siteExternalId = null, From 0893f74dc7b88a8b23bbe9504efa456f1b26daeb Mon Sep 17 00:00:00 2001 From: alexsilva Date: Thu, 22 Jun 2023 10:04:18 +0100 Subject: [PATCH 65/83] fix(gate): fix migration file versioning --- ...sed_column_removal.sql => V4_0_0_1__unused_column_removal.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bpdm-gate/src/main/resources/db/migration/{V5_0_0_0__unused_column_removal.sql => V4_0_0_1__unused_column_removal.sql} (100%) diff --git a/bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql b/bpdm-gate/src/main/resources/db/migration/V4_0_0_1__unused_column_removal.sql similarity index 100% rename from bpdm-gate/src/main/resources/db/migration/V5_0_0_0__unused_column_removal.sql rename to bpdm-gate/src/main/resources/db/migration/V4_0_0_1__unused_column_removal.sql From 7009738179ddbbc3bcb4be040d448ac686af9be1 Mon Sep 17 00:00:00 2001 From: SujitMBRDI Date: Thu, 15 Jun 2023 15:24:17 +0530 Subject: [PATCH 66/83] API-Model: Update postman collection with new data model #288 --- .../BPDM Bridge Dummy.postman_collection.json | 109 +++ .../postman/BPDM Gate.postman_collection.json | 379 +++++++-- .../postman/BPDM Pool.postman_collection.json | 774 +++++++----------- docs/postman/Local.postman_environment.json | 24 +- 4 files changed, 728 insertions(+), 558 deletions(-) create mode 100644 docs/postman/BPDM Bridge Dummy.postman_collection.json diff --git a/docs/postman/BPDM Bridge Dummy.postman_collection.json b/docs/postman/BPDM Bridge Dummy.postman_collection.json new file mode 100644 index 000000000..30b9633a9 --- /dev/null +++ b/docs/postman/BPDM Bridge Dummy.postman_collection.json @@ -0,0 +1,109 @@ +{ + "info": { + "_postman_id": "7b41c91f-d0b5-46c5-aeba-24dfec0c8d58", + "name": "BPDM Bridge Dummy", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "26818013" + }, + "item": [ + { + "name": "Bridge Sync", + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{Bridge-Host}}/api/bridge/sync", + "host": [ + "{{Bridge-Host}}" + ], + "path": [ + "api", + "bridge", + "sync" + ] + } + }, + "response": [] + } + ], + "auth": { + "type": "oauth2", + "oauth2": [ + { + "key": "client_authentication", + "value": "body", + "type": "string" + }, + { + "key": "clientSecret", + "value": "{{Bridge-Client-Secret}}", + "type": "string" + }, + { + "key": "clientId", + "value": "{{Bridge-Client-ID}}", + "type": "string" + }, + { + "key": "accessTokenUrl", + "value": "https://{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", + "type": "string" + }, + { + "key": "tokenName", + "value": "BPDM Bridge Token {{Environment}}", + "type": "string" + }, + { + "key": "refreshRequestParams", + "value": [], + "type": "any" + }, + { + "key": "tokenRequestParams", + "value": [], + "type": "any" + }, + { + "key": "authRequestParams", + "value": [], + "type": "any" + }, + { + "key": "challengeAlgorithm", + "value": "S256", + "type": "string" + }, + { + "key": "grant_type", + "value": "client_credentials", + "type": "string" + }, + { + "key": "addTokenTo", + "value": "header", + "type": "string" + } + ] + }, + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ] +} \ No newline at end of file diff --git a/docs/postman/BPDM Gate.postman_collection.json b/docs/postman/BPDM Gate.postman_collection.json index c123e4f25..e8e911efc 100644 --- a/docs/postman/BPDM Gate.postman_collection.json +++ b/docs/postman/BPDM Gate.postman_collection.json @@ -1,11 +1,88 @@ { "info": { - "_postman_id": "90341b2a-db32-4d38-b6b6-864fd85a21c8", - "name": "BPDM Gate Copy", + "_postman_id": "326ec7da-09af-411a-ae73-3612d9c592f7", + "name": "BPDM Gate", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "1816771" + "_exporter_id": "26818013" }, "item": [ + { + "name": "Sharing-state", + "item": [ + { + "name": "Sharing States", + "request": { + "method": "GET", + "header": [ + { + "key": "Accept", + "value": "application/json", + "type": "text" + } + ], + "url": { + "raw": "{{Gate-Host}}/api/catena/sharing-state?page=0&size=10&lsaType=LEGAL_ENTITY", + "host": [ + "{{Gate-Host}}" + ], + "path": [ + "api", + "catena", + "sharing-state" + ], + "query": [ + { + "key": "page", + "value": "0" + }, + { + "key": "size", + "value": "10" + }, + { + "key": "lsaType", + "value": "LEGAL_ENTITY" + }, + { + "key": "externalIds", + "value": "12044444", + "disabled": true + } + ] + } + }, + "response": [] + }, + { + "name": "Sharing State", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"lsaType\": \"LegalEntity\",\n \"externalId\": \"string\",\n \"sharingStateType\": \"Pending\",\n \"sharingErrorCode\": \"SharingProcessError\",\n \"sharingErrorMessage\": \"string\",\n \"bpn\": \"string\",\n \"sharingProcessStarted\": \"2023-06-05T06:56:40.785Z\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{Gate-Host}}/api/catena/sharing-state", + "host": [ + "{{Gate-Host}}" + ], + "path": [ + "api", + "catena", + "sharing-state" + ] + } + }, + "response": [] + } + ] + }, { "name": "Input", "item": [ @@ -44,7 +121,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{Gate-Host}}/api/catena/input/legal-entities/external-id", + "raw": "{{Gate-Host}}/api/catena/input/legal-entities/12044444", "host": [ "{{Gate-Host}}" ], @@ -53,7 +130,7 @@ "catena", "input", "legal-entities", - "external-id" + "12044444" ] } }, @@ -66,7 +143,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n {\n \"identifiers\": [\n {\n \"value\": \"string\",\n \"type\": \"string\",\n \"issuingBody\": \"string\",\n \"status\": \"string\"\n }\n ],\n \"names\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"type\": \"ACRONYM\",\n \"language\": \"undefined\"\n }\n ],\n \"legalForm\": \"string\",\n \"status\": {\n \"officialDenotation\": \"string\",\n \"validFrom\": \"2023-03-21T13:47:05.538Z\",\n \"validUntil\": \"2023-03-21T13:47:05.538Z\",\n \"type\": \"ACTIVE\"\n },\n \"profileClassifications\": [\n {\n \"value\": \"string\",\n \"code\": \"string\",\n \"type\": \"NACE\"\n }\n ],\n \"types\": [\n \"BRAND\"\n ],\n \"bankAccounts\": [\n {\n \"trustScores\": [\n 0\n ],\n \"currency\": \"UNDEFINED\",\n \"internationalBankAccountIdentifier\": \"string\",\n \"internationalBankIdentifier\": \"string\",\n \"nationalBankAccountIdentifier\": \"string\",\n \"nationalBankIdentifier\": \"string\"\n }\n ],\n \"legalAddress\": {\n \"version\": {\n \"characterSet\": \"ARABIC\",\n \"language\": \"undefined\"\n },\n \"careOf\": \"string\",\n \"contexts\": [\n \"string\"\n ],\n \"country\": \"UNDEFINED\",\n \"administrativeAreas\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"fipsCode\": \"string\",\n \"type\": \"COUNTY\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"string\",\n \"type\": \"CEDEX\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"type\": \"BLOCK\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"string\",\n \"name\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"direction\": \"string\",\n \"type\": \"INDUSTRIAL_ZONE\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"INTERURBAN_DELIVERY_POINT\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"BRANCH_OFFICE\"\n ]\n },\n \"externalId\": \"string\",\n \"bpn\": \"string\"\n }\n]", + "raw": "[\n {\n \"legalNameParts\": [\n \"Name of Company\"\n ],\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_ID_TYPE\",\n \"issuingBody\": \"CUSTOM_ISSUE_BODY\"\n }\n ],\n \"legalShortName\": \"NoC\",\n \"legalForm\": \"CUSTOM_LEGAL_FORM\",\n \"states\": [\n {\n \"officialDenotation\": \"Active\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"validTo\": \"2023-06-05T07:31:01.213Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"classifications\": [\n {\n \"value\": \"Farming of cattle, dairy farming\",\n \"code\": \"01.21\",\n \"type\": \"NACE\"\n }\n ],\n \"roles\": [\n \"SUPPLIER\"\n ],\n \"legalAddress\": {\n \"nameParts\": [\n \"WESTERN_LATIN_STANDARD\"\n ],\n \"states\": [\n {\n \"description\": \"WESTERN_LATIN_STANDARD\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"validTo\": \"2023-06-05T07:31:01.213Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"12345678910\",\n \"type\": \"CUSTOM_ID_ADD_TYPE\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70546\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"namePrefix\": \"test prefix\",\n \"additionalNamePrefix\": \"test1\",\n \"name\": \"Stuttgarter Strasse\",\n \"additionalNameSuffix\": \"test2\",\n \"houseNumber\": \"1\",\n \"milestone\": \"Stuttgarter Strasse 1\",\n \"direction\": \"Stuttgarter Str.\",\n \"nameSuffix\": \"test\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg\",\n \"administrativeAreaLevel2\": \"test1\",\n \"administrativeAreaLevel3\": \"test2\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"GM01\",\n \"industrialZone\": \"HEADQUARTER\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"test\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart 1\",\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg 1\",\n \"deliveryServiceNumber\": \"1234\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test\"\n },\n \"roles\": [\n \"SUPPLIER\"\n ]\n },\n \"externalId\": \"12044444\"\n }\n]", "options": { "raw": { "language": "json" @@ -89,13 +166,13 @@ "response": [] }, { - "name": "Legal Entity Validation", + "name": "Legal Entity Search", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"identifiers\": [\n {\n \"value\": \"string\",\n \"type\": \"string\",\n \"issuingBody\": \"string\",\n \"status\": \"string\"\n }\n ],\n \"names\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"type\": \"ACRONYM\",\n \"language\": \"undefined\"\n }\n ],\n \"legalForm\": \"string\",\n \"status\": {\n \"officialDenotation\": \"string\",\n \"validFrom\": \"2023-03-21T13:48:49.321Z\",\n \"validUntil\": \"2023-03-21T13:48:49.321Z\",\n \"type\": \"ACTIVE\"\n },\n \"profileClassifications\": [\n {\n \"value\": \"string\",\n \"code\": \"string\",\n \"type\": \"NACE\"\n }\n ],\n \"types\": [\n \"BRAND\"\n ],\n \"bankAccounts\": [\n {\n \"trustScores\": [\n 0\n ],\n \"currency\": \"UNDEFINED\",\n \"internationalBankAccountIdentifier\": \"string\",\n \"internationalBankIdentifier\": \"string\",\n \"nationalBankAccountIdentifier\": \"string\",\n \"nationalBankIdentifier\": \"string\"\n }\n ],\n \"legalAddress\": {\n \"version\": {\n \"characterSet\": \"ARABIC\",\n \"language\": \"undefined\"\n },\n \"careOf\": \"string\",\n \"contexts\": [\n \"string\"\n ],\n \"country\": \"UNDEFINED\",\n \"administrativeAreas\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"fipsCode\": \"string\",\n \"type\": \"COUNTY\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"string\",\n \"type\": \"CEDEX\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"type\": \"BLOCK\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"string\",\n \"name\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"direction\": \"string\",\n \"type\": \"INDUSTRIAL_ZONE\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"INTERURBAN_DELIVERY_POINT\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"BRANCH_OFFICE\"\n ]\n },\n \"externalId\": \"string\",\n \"bpn\": \"string\"\n}", + "raw": "[\n 12044444\n]", "options": { "raw": { "language": "json" @@ -103,7 +180,7 @@ } }, "url": { - "raw": "{{Gate-Host}}/api/catena/input/legal-entities/validation", + "raw": "{{Gate-Host}}/api/catena/input/legal-entities/search?page=0&size=10", "host": [ "{{Gate-Host}}" ], @@ -112,7 +189,17 @@ "catena", "input", "legal-entities", - "validation" + "search" + ], + "query": [ + { + "key": "page", + "value": "0" + }, + { + "key": "size", + "value": "10" + } ] } }, @@ -155,7 +242,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{Gate-Host}}/api/catena/input/sites/external-id", + "raw": "{{Gate-Host}}/api/catena/input/sites/12044444", "host": [ "{{Gate-Host}}" ], @@ -164,7 +251,7 @@ "catena", "input", "sites", - "external-id" + "12044444" ] } }, @@ -177,7 +264,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n {\n \"name\": \"string\",\n \"mainAddress\": {\n \"version\": {\n \"characterSet\": \"ARABIC\",\n \"language\": \"undefined\"\n },\n \"careOf\": \"string\",\n \"contexts\": [\n \"string\"\n ],\n \"country\": \"UNDEFINED\",\n \"administrativeAreas\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"fipsCode\": \"string\",\n \"type\": \"COUNTY\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"string\",\n \"type\": \"CEDEX\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"type\": \"BLOCK\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"string\",\n \"name\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"direction\": \"string\",\n \"type\": \"INDUSTRIAL_ZONE\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"INTERURBAN_DELIVERY_POINT\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"BRANCH_OFFICE\"\n ]\n },\n \"externalId\": \"string\",\n \"legalEntityExternalId\": \"string\",\n \"bpn\": \"string\"\n }\n]", + "raw": "[\n {\n \"nameParts\": [\n \"Factory UT\"\n ],\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-05T08:29:20.015Z\",\n \"validTo\": \"2023-06-05T08:29:20.015Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"roles\": [\n \"SUPPLIER\"\n ],\n \"mainAddress\": {\n \"nameParts\": [\n \"WESTERN_LATIN_STANDARD\"\n ],\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-05T08:29:20.015Z\",\n \"validTo\": \"2023-06-05T08:29:20.015Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_SITE_ID\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70327\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"namePrefix\": \"test prefix\",\n \"additionalNamePrefix\": \"test\",\n \"name\": \"Untertuerckheim Strasse 1\",\n \"additionalNameSuffix\": \"test suffix\",\n \"houseNumber\": \"1234\",\n \"milestone\": \"Untertuerckheim Strasse 1\",\n \"direction\": \"Untertuerckheim Strasse 1\",\n \"nameSuffix\": \"test1 suffix\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttember\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"71034\",\n \"industrialZone\": \"Sindelfinden\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"1\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart\",\n \"administrativeAreaLevel1\": \"Stuttgart\",\n \"deliveryServiceNumber\": \"Untertuerckheim Strasse 1\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test qualifier\"\n },\n \"roles\": [\n \"SUPPLIER\"\n ]\n },\n \"externalId\": \"12044444\",\n \"legalEntityExternalId\": \"12044444\"\n }\n]", "options": { "raw": { "language": "json" @@ -200,13 +287,13 @@ "response": [] }, { - "name": "Site Validation", + "name": "Site Search", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"name\": \"string\",\n \"mainAddress\": {\n \"version\": {\n \"characterSet\": \"ARABIC\",\n \"language\": \"undefined\"\n },\n \"careOf\": \"string\",\n \"contexts\": [\n \"string\"\n ],\n \"country\": \"UNDEFINED\",\n \"administrativeAreas\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"fipsCode\": \"string\",\n \"type\": \"COUNTY\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"string\",\n \"type\": \"CEDEX\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"type\": \"BLOCK\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"string\",\n \"name\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"direction\": \"string\",\n \"type\": \"INDUSTRIAL_ZONE\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"INTERURBAN_DELIVERY_POINT\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"BRANCH_OFFICE\"\n ]\n },\n \"externalId\": \"string\",\n \"legalEntityExternalId\": \"string\",\n \"bpn\": \"string\"\n}", + "raw": "[\n \"12044444\"\n]", "options": { "raw": { "language": "json" @@ -214,7 +301,7 @@ } }, "url": { - "raw": "{{Gate-Host}}/api/catena/input/sites/validation", + "raw": "{{Gate-Host}}/api/catena/input/sites/search", "host": [ "{{Gate-Host}}" ], @@ -223,7 +310,7 @@ "catena", "input", "sites", - "validation" + "search" ] } }, @@ -266,7 +353,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{Gate-Host}}/api/catena/input/addresses/external-id", + "raw": "{{Gate-Host}}/api/catena/input/addresses/12044444_site", "host": [ "{{Gate-Host}}" ], @@ -275,7 +362,7 @@ "catena", "input", "addresses", - "external-id" + "12044444_site" ] } }, @@ -288,7 +375,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n {\n \"version\": {\n \"characterSet\": \"ARABIC\",\n \"language\": \"undefined\"\n },\n \"careOf\": \"string\",\n \"contexts\": [\n \"string\"\n ],\n \"country\": \"UNDEFINED\",\n \"administrativeAreas\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"fipsCode\": \"string\",\n \"type\": \"COUNTY\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"string\",\n \"type\": \"CEDEX\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"type\": \"BLOCK\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"string\",\n \"name\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"direction\": \"string\",\n \"type\": \"INDUSTRIAL_ZONE\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"INTERURBAN_DELIVERY_POINT\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"BRANCH_OFFICE\"\n ],\n \"externalId\": \"string\",\n \"legalEntityExternalId\": \"string\",\n \"siteExternalId\": \"string\",\n \"bpn\": \"string\"\n }\n]", + "raw": "[\n {\n \"nameParts\": [\n \"WESTERN_LATIN_STANDARD\"\n ],\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-05T10:32:30.231Z\",\n \"validTo\": \"2023-06-05T10:32:30.231Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_ADDRESS_ID\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70327\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"namePrefix\": \"test prefix\",\n \"additionalNamePrefix\": \"test\",\n \"name\": \"Untertuerckheim Strasse 1\",\n \"additionalNameSuffix\": \"test suffix\",\n \"houseNumber\": \"1234\",\n \"milestone\": \"Untertuerckheim Strasse 1\",\n \"direction\": \"Untertuerckheim Strasse 1\",\n \"nameSuffix\": \"test1 suffix\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttember\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"71034\",\n \"industrialZone\": \"Sindelfinden\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"1\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart\",\n \"administrativeAreaLevel1\": \"Stuttgart\",\n \"deliveryServiceNumber\": \"Untertuerckheim Strasse 1\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test qualifier\"\n },\n \"roles\": [\n \"SUPPLIER\"\n ],\n \"externalId\": \"12044444_legalAddress\",\n \"legalEntityExternalId\": \"12044444\",\n \"siteExternalId\": null,\n \"bpn\": \"BPNA000000000001\"\n }\n]", "options": { "raw": { "language": "json" @@ -311,13 +398,13 @@ "response": [] }, { - "name": "Address Validation", + "name": "Address Search", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"version\": {\n \"characterSet\": \"ARABIC\",\n \"language\": \"undefined\"\n },\n \"careOf\": \"string\",\n \"contexts\": [\n \"string\"\n ],\n \"country\": \"UNDEFINED\",\n \"administrativeAreas\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"fipsCode\": \"string\",\n \"type\": \"COUNTY\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"string\",\n \"type\": \"CEDEX\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"type\": \"BLOCK\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"string\",\n \"name\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"direction\": \"string\",\n \"type\": \"INDUSTRIAL_ZONE\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"string\",\n \"shortName\": \"string\",\n \"number\": \"string\",\n \"type\": \"INTERURBAN_DELIVERY_POINT\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"BRANCH_OFFICE\"\n ],\n \"externalId\": \"string\",\n \"legalEntityExternalId\": \"string\",\n \"siteExternalId\": \"string\",\n \"bpn\": \"string\"\n}", + "raw": "[\n \"12044444_legalAddress\"\n]", "options": { "raw": { "language": "json" @@ -325,7 +412,7 @@ } }, "url": { - "raw": "{{Gate-Host}}/api/catena/input/addresses/validation", + "raw": "{{Gate-Host}}/api/catena/input/addresses/search", "host": [ "{{Gate-Host}}" ], @@ -334,7 +421,7 @@ "catena", "input", "addresses", - "validation" + "search" ] } }, @@ -354,7 +441,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n \"external-id\"\n]", + "raw": "[\n \"12044444\"\n]", "options": { "raw": { "language": "json" @@ -390,7 +477,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n \"external-id\"\n]", + "raw": "[\n \"12044444\"\n]", "options": { "raw": { "language": "json" @@ -426,7 +513,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n \"external-id\"\n]", + "raw": "[\n \"12044444_legalAddress\"\n]", "options": { "raw": { "language": "json" @@ -454,52 +541,185 @@ } }, "response": [] + }, + { + "name": "Legal Entity", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "[\n {\n \"legalNameParts\": [\n \"Name of Company\"\n ],\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_ID_TYPE\",\n \"issuingBody\": \"CUSTOM_ISSUE_BODY\"\n }\n ],\n \"legalShortName\": \"NoC\",\n \"legalForm\": \"CUSTOM_LEGAL_FORM\",\n \"states\": [\n {\n \"officialDenotation\": \"Active\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"validTo\": \"2023-06-05T07:31:01.213Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"classifications\": [\n {\n \"value\": \"Farming of cattle, dairy farming\",\n \"code\": \"01.21\",\n \"type\": \"NACE\"\n }\n ],\n \"roles\": [\n \"SUPPLIER\"\n ],\n \"legalAddress\": {\n \"nameParts\": [\n \"WESTERN_LATIN_STANDARD\"\n ],\n \"states\": [\n {\n \"description\": \"WESTERN_LATIN_STANDARD\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"validTo\": \"2023-06-05T07:31:01.213Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"12345678910\",\n \"type\": \"CUSTOM_ID_ADD_TYPE\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70546\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"namePrefix\": \"test prefix\",\n \"additionalNamePrefix\": \"test1\",\n \"name\": \"Stuttgarter Strasse\",\n \"additionalNameSuffix\": \"test2\",\n \"houseNumber\": \"1\",\n \"milestone\": \"Stuttgarter Strasse 1\",\n \"direction\": \"Stuttgarter Str.\",\n \"nameSuffix\": \"test\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg\",\n \"administrativeAreaLevel2\": \"test1\",\n \"administrativeAreaLevel3\": \"test2\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"GM01\",\n \"industrialZone\": \"HEADQUARTER\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"test\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart 1\",\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg 1\",\n \"deliveryServiceNumber\": \"1234\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test\"\n },\n \"roles\": [\n \"SUPPLIER\"\n ],\n \"bpn\": \"BPNL0000000001YN\"\n },\n \"externalId\": \"12044444\",\n \"bpn\": \"BPNL0000000001YN\"\n }\n]", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{Gate-Host}}/api/catena/output/legal-entities", + "host": [ + "{{Gate-Host}}" + ], + "path": [ + "api", + "catena", + "output", + "legal-entities" + ] + } + }, + "response": [] + }, + { + "name": "Site", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "[\n {\n \"nameParts\": [\n \"Factory UT\"\n ],\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-05T08:29:20.015Z\",\n \"validTo\": \"2023-06-05T08:29:20.015Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"roles\": [\n \"SUPPLIER\"\n ],\n \"mainAddress\": {\n \"nameParts\": [\n \"WESTERN_LATIN_STANDARD\"\n ],\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-05T08:29:20.015Z\",\n \"validTo\": \"2023-06-05T08:29:20.015Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_SITE_ID\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70327\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"namePrefix\": \"test prefix\",\n \"additionalNamePrefix\": \"test\",\n \"name\": \"Untertuerckheim Strasse 1\",\n \"additionalNameSuffix\": \"test suffix\",\n \"houseNumber\": \"1234\",\n \"milestone\": \"Untertuerckheim Strasse 1\",\n \"direction\": \"Untertuerckheim Strasse 1\",\n \"nameSuffix\": \"test1 suffix\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttember\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"71034\",\n \"industrialZone\": \"Sindelfinden\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"1\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart\",\n \"administrativeAreaLevel1\": \"Stuttgart\",\n \"deliveryServiceNumber\": \"Untertuerckheim Strasse 1\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test qualifier\"\n },\n \"roles\": [\n \"SUPPLIER\"\n ],\n \"bpn\": \"BPNS000000000001\"\n },\n \"externalId\": \"12044444\",\n \"legalEntityExternalId\": \"12044444\",\n \"bpn\": \"BPNL0000000001YN\"\n }\n]", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{Gate-Host}}/api/catena/output/sites", + "host": [ + "{{Gate-Host}}" + ], + "path": [ + "api", + "catena", + "output", + "sites" + ] + } + }, + "response": [] + }, + { + "name": "Address", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "[\n {\n \"nameParts\": [\n \"WESTERN_LATIN_STANDARD\"\n ],\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-05T10:32:30.231Z\",\n \"validTo\": \"2023-06-05T10:32:30.231Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_ADDRESS_ID\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70327\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"namePrefix\": \"test prefix\",\n \"additionalNamePrefix\": \"test\",\n \"name\": \"Untertuerckheim Strasse 1\",\n \"additionalNameSuffix\": \"test suffix\",\n \"houseNumber\": \"1234\",\n \"milestone\": \"Untertuerckheim Strasse 1\",\n \"direction\": \"Untertuerckheim Strasse 1\",\n \"nameSuffix\": \"test1 suffix\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttember\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"71034\",\n \"industrialZone\": \"Sindelfinden\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"1\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart\",\n \"administrativeAreaLevel1\": \"Stuttgart\",\n \"deliveryServiceNumber\": \"Untertuerckheim Strasse 1\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test qualifier\"\n },\n \"roles\": [\n \"SUPPLIER\"\n ],\n \"externalId\": \"12044444_legalAddress\",\n \"legalEntityExternalId\": \"12044444\",\n \"siteExternalId\": \"12044444_sites\",\n \"bpn\": \"BPNA000000000001\"\n }\n]", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{Gate-Host}}/api/catena/output/addresses", + "host": [ + "{{Gate-Host}}" + ], + "path": [ + "api", + "catena", + "output", + "addresses" + ] + } + }, + "response": [] } ] }, { - "name": "Determine Type", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"identifiers\": [\n {\n \"value\": \"DE216038746\",\n \"type\": \"EU_VAT_ID_DE\",\n \"issuingBody\": null,\n \"status\": null\n }\n ],\n \"names\": [\n {\n \"value\": \"eXXcellent solutions gmbh\",\n \"shortName\": null,\n \"type\": \"REGISTERED\",\n \"language\": \"de\"\n }\n ],\n \"legalForm\": null,\n \"address\": {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"de\"\n },\n \"careOf\": null,\n \"contexts\": [],\n \"country\": \"DE\",\n \"administrativeAreas\": [],\n \"postCodes\": [\n {\n \"value\": \"89075\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Ulm\",\n \"shortName\": null,\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Beim Alten Fritz 2\",\n \"name\": null,\n \"shortName\": null,\n \"number\": null,\n \"direction\": null,\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [],\n \"postalDeliveryPoints\": [],\n \"geographicCoordinates\": null,\n \"types\": [\n \"UNSPECIFIC\"\n ]\n }\n}", - "options": { - "raw": { - "language": "json" + "name": "Changelog", + "item": [ + { + "name": "Output Changelog", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"fromTime\": \"2020-12-16T05:54:48.942Z\",\n \"externalIds\": [\n \"12044444\"\n ],\n \"lsaTypes\": [\n \"LEGAL_ENTITY\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{Gate-Host}}/api/catena/output/changelog/search?page=0&size=10", + "host": [ + "{{Gate-Host}}" + ], + "path": [ + "api", + "catena", + "output", + "changelog", + "search" + ], + "query": [ + { + "key": "page", + "value": "0" + }, + { + "key": "size", + "value": "10" + } + ] } - } + }, + "response": [] }, - "url": { - "raw": "{{Gate-Host}}/api/catena/business-partners/type-match", - "host": [ - "{{Gate-Host}}" - ], - "path": [ - "api", - "catena", - "business-partners", - "type-match" - ] + { + "name": "Input Changelog", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"fromTime\": \"2020-12-16T05:54:48.942Z\",\n \"externalIds\": [\n \"12044444\"\n ],\n \"lsaTypes\": [\n \"LEGAL_ENTITY\"\n ]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{Gate-Host}}/api/catena/input/changelog/search?page=0&size=10", + "host": [ + "{{Gate-Host}}" + ], + "path": [ + "api", + "catena", + "input", + "changelog", + "search" + ], + "query": [ + { + "key": "page", + "value": "0" + }, + { + "key": "size", + "value": "10" + } + ] + } + }, + "response": [] } - }, - "response": [] + ] } ], "auth": { "type": "oauth2", "oauth2": [ - { - "key": "clientSecret", - "value": "{{Gate-Client-Secret}}", - "type": "string" - }, - { - "key": "clientId", - "value": "{{Gate-Client-ID}}", - "type": "string" - }, { "key": "accessTokenUrl", "value": "https://{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", @@ -511,13 +731,18 @@ "type": "string" }, { - "key": "challengeAlgorithm", - "value": "S256", + "key": "client_authentication", + "value": "body", "type": "string" }, { - "key": "redirect_uri", - "value": "https://catenax-dev003-app-onboarding.azurewebsites.net", + "key": "clientSecret", + "value": "{{Gate-Client-Secret}}", + "type": "string" + }, + { + "key": "clientId", + "value": "{{Gate-Client-ID}}", "type": "string" }, { @@ -526,18 +751,28 @@ "type": "string" }, { - "key": "authUrl", - "value": "https://catenaxdev003akssrv.germanywestcentral.cloudapp.azure.com/iamcentralidp/auth/realms/CX-Central/protocol/openid-connect/auth", - "type": "string" + "key": "refreshRequestParams", + "value": [], + "type": "any" }, { - "key": "addTokenTo", - "value": "header", + "key": "tokenRequestParams", + "value": [], + "type": "any" + }, + { + "key": "authRequestParams", + "value": [], + "type": "any" + }, + { + "key": "challengeAlgorithm", + "value": "S256", "type": "string" }, { - "key": "client_authentication", - "value": "body", + "key": "addTokenTo", + "value": "header", "type": "string" } ] diff --git a/docs/postman/BPDM Pool.postman_collection.json b/docs/postman/BPDM Pool.postman_collection.json index 18e21c32d..ec7500962 100644 --- a/docs/postman/BPDM Pool.postman_collection.json +++ b/docs/postman/BPDM Pool.postman_collection.json @@ -1,23 +1,51 @@ { "info": { - "_postman_id": "719b2373-ba52-4e10-b0a6-f5dc1dca9ce5", - "name": "BPDM Pool Copy", - "description": "API Documentation can be found at: https://{{Pool-Host}}/", + "_postman_id": "7c864024-7b7c-4bb6-aab8-0be237fbb80f", + "name": "BPDM Pool", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "1816771" + "_exporter_id": "26818013" }, "item": [ { - "name": "Legal Entity Controller", + "name": "Metadata Controller", "item": [ { - "name": "Create Legal Entities", + "name": "Legal Forms", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{Pool-Host}}/api/catena/legal-forms?page=0&size=10", + "host": [ + "{{Pool-Host}}" + ], + "path": [ + "api", + "catena", + "legal-forms" + ], + "query": [ + { + "key": "page", + "value": "0" + }, + { + "key": "size", + "value": "10" + } + ] + } + }, + "response": [] + }, + { + "name": "Create Legal Form", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "[\n {\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_ID_TYPE\",\n \"issuingBody\": \"CUSTOM_ISSUE_BODY\",\n \"status\": \"CUSTOM_ID_STATUS\"\n }\n ],\n \"names\": [\n {\n \"value\": \"Name of Company\",\n \"shortName\": \"NoC\",\n \"type\": \"ACRONYM\",\n \"language\": \"en\"\n }\n ],\n \"legalForm\": \"CUSTOM_LEGAL_FORM\",\n \"status\": {\n \"officialDenotation\": \"Active\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"type\": \"ACTIVE\"\n },\n \"profileClassifications\": [\n {\n \"value\": \"Farming of cattle, dairy farming\",\n \"code\": \"01.21\",\n \"type\": \"NACE\"\n }\n ],\n \"bankAccounts\": [\n {\n \"currency\": \"EUR\",\n \"internationalBankAccountIdentifier\": \"11223445569\",\n \"internationalBankIdentifier\": \"TEST1234\",\n \"nationalBankAccountIdentifier\": \"004566676\",\n \"nationalBankIdentifier\": \"TEST223\"\n }\n ],\n \"legalAddress\": {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"70546\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Stuttgart\",\n \"shortName\": \"S\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Stuttgarter Strasse 1\",\n \"name\": \"Stuttgarter Strasse\",\n \"shortName\": \"Stuttgarter Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Building A\",\n \"shortName\": \"A\",\n \"number\": \"A\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"On-site Mailbox\",\n \"type\": \"MAILBOX\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"HEADQUARTER\",\n \"REGISTERED\"\n ]\n },\n \"index\": \"0\"\n },\n {\n \"identifiers\": [\n {\n \"value\": \"987654321\",\n \"type\": \"CUSTOM_ID_TYPE\",\n \"issuingBody\": \"CUSTOM_ISSUE_BODY\",\n \"status\": \"CUSTOM_ID_STATUS\"\n }\n ],\n \"names\": [\n {\n \"value\": \"Other Test Company\",\n \"shortName\": \"OTC\",\n \"type\": \"REGISTERED\",\n \"language\": \"en\"\n }\n ],\n \"legalForm\": \"CUSTOM_LEGAL_FORM\",\n \"status\": {\n \"officialDenotation\": \"Dissolved\",\n \"validFrom\": \"2021-03-14T05:54:48.942Z\",\n \"type\": \"DISSOLVED\"\n },\n \"profileClassifications\": [\n {\n \"value\": \"Warehousing and Storage\",\n \"code\": \"49\",\n \"type\": \"NAICS\"\n }\n ],\n \"bankAccounts\": [\n {\n \"currency\": \"EUR\",\n \"internationalBankAccountIdentifier\": \"7654432212\",\n \"internationalBankIdentifier\": \"TEST1234\",\n \"nationalBankAccountIdentifier\": \"999847444\",\n \"nationalBankIdentifier\": \"TEST223\"\n }\n ],\n \"legalAddress\": {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Bavaria\",\n \"shortName\": \"B\",\n \"fipsCode\": \"GM02\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"80331\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Munich\",\n \"shortName\": \"M\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Muenchener Strasse 1\",\n \"name\": \"Muenchener Strasse\",\n \"shortName\": \"Munchener Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Block 1\",\n \"shortName\": \"B1\",\n \"number\": \"1\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"On-site Mailbox\",\n \"type\": \"MAILBOX\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"HEADQUARTER\",\n \"REGISTERED\"\n ]\n },\n \"index\": \"1\"\n }\n]", + "raw": "{\n \"technicalKey\": \"CUSTOM_LEGAL_FORM_test1\",\n \"name\": \"Custom Legal Form for Testing 1\",\n \"abbreviation\": null\n}", "options": { "raw": { "language": "json" @@ -25,27 +53,60 @@ } }, "url": { - "raw": "{{Pool-Host}}/api/catena/legal-entities", + "raw": "{{Pool-Host}}/api/catena/legal-forms", "host": [ "{{Pool-Host}}" ], "path": [ "api", "catena", - "legal-entities" + "legal-forms" ] } }, "response": [] }, { - "name": "Update Legal Entities", + "name": "Identifier Types", "request": { - "method": "PUT", + "method": "GET", + "header": [], + "url": { + "raw": "{{Pool-Host}}/api/catena/identifier-types?page=0&size=100&lsaType=ADDRESS", + "host": [ + "{{Pool-Host}}" + ], + "path": [ + "api", + "catena", + "identifier-types" + ], + "query": [ + { + "key": "page", + "value": "0" + }, + { + "key": "size", + "value": "100" + }, + { + "key": "lsaType", + "value": "ADDRESS" + } + ] + } + }, + "response": [] + }, + { + "name": "Create Identifier Type", + "request": { + "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "[\n {\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_ID_TYPE\",\n \"issuingBody\": \"CUSTOM_ISSUE_BODY\",\n \"status\": \"CUSTOM_ID_STATUS\"\n }\n ],\n \"names\": [\n {\n \"value\": \"Name of Company\",\n \"shortName\": \"NoC\",\n \"type\": \"ACRONYM\",\n \"language\": \"en\"\n }\n ],\n \"legalForm\": \"CUSTOM_LEGAL_FORM\",\n \"status\": {\n \"officialDenotation\": \"Active\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"type\": \"ACTIVE\"\n },\n \"profileClassifications\": [\n {\n \"value\": \"Farming of cattle, dairy farming\",\n \"code\": \"01.21\",\n \"type\": \"NACE\"\n }\n ],\n \"bankAccounts\": [\n {\n \"currency\": \"EUR\",\n \"internationalBankAccountIdentifier\": \"11223445569\",\n \"internationalBankIdentifier\": \"TEST1234\",\n \"nationalBankAccountIdentifier\": \"004566676\",\n \"nationalBankIdentifier\": \"TEST223\"\n }\n ],\n \"legalAddress\": {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"70546\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Stuttgart\",\n \"shortName\": \"S\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Stuttgarter Strasse 1\",\n \"name\": \"Stuttgarter Strasse\",\n \"shortName\": \"Stuttgarter Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Building A\",\n \"shortName\": \"A\",\n \"number\": \"A\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"On-site Mailbox\",\n \"type\": \"MAILBOX\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"HEADQUARTER\",\n \"REGISTERED\"\n ]\n },\n \"bpn\": \"BPNL000000000001\"\n },\n {\n \"identifiers\": [\n {\n \"value\": \"987654321\",\n \"type\": \"CUSTOM_ID_TYPE\",\n \"issuingBody\": \"CUSTOM_ISSUE_BODY\",\n \"status\": \"CUSTOM_ID_STATUS\"\n }\n ],\n \"names\": [\n {\n \"value\": \"Other Test Company\",\n \"shortName\": \"OTC\",\n \"type\": \"REGISTERED\",\n \"language\": \"en\"\n }\n ],\n \"legalForm\": \"CUSTOM_LEGAL_FORM\",\n \"status\": {\n \"officialDenotation\": \"Dissolved\",\n \"validFrom\": \"2021-03-14T05:54:48.942Z\",\n \"type\": \"DISSOLVED\"\n },\n \"profileClassifications\": [\n {\n \"value\": \"Warehousing and Storage\",\n \"code\": \"49\",\n \"type\": \"NAICS\"\n }\n ],\n \"bankAccounts\": [\n {\n \"currency\": \"EUR\",\n \"internationalBankAccountIdentifier\": \"7654432212\",\n \"internationalBankIdentifier\": \"TEST1234\",\n \"nationalBankAccountIdentifier\": \"999847444\",\n \"nationalBankIdentifier\": \"TEST223\"\n }\n ],\n \"legalAddress\": {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Bavaria\",\n \"shortName\": \"B\",\n \"fipsCode\": \"GM02\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"80331\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Munich\",\n \"shortName\": \"M\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Muenchener Strasse 1\",\n \"name\": \"Muenchener Strasse\",\n \"shortName\": \"Munchener Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Block 1\",\n \"shortName\": \"B1\",\n \"number\": \"1\",\n \"type\": \"BUILDING\"\n }\n ],\n \"postalDeliveryPoints\": [\n {\n \"value\": \"On-site Mailbox\",\n \"type\": \"MAILBOX\"\n }\n ],\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"types\": [\n \"HEADQUARTER\",\n \"REGISTERED\"\n ]\n },\n \"bpn\": \"BPNL0000000001YN\"\n }\n]", + "raw": "{\n \"technicalKey\": \"CUSTOM_ID_ADD_TYPE\",\n \"lsaType\": \"ADDRESS\",\n \"name\": \"Custom Identifier Type of Address for Testing\",\n \"details\": [\n {\n \"country\": \"DE\",\n \"mandatory\": true\n }\n ]\n}", "options": { "raw": { "language": "json" @@ -53,47 +114,52 @@ } }, "url": { - "raw": "{{Pool-Host}}/api/catena/legal-entities", + "raw": "{{Pool-Host}}/api/catena/identifier-types", "host": [ "{{Pool-Host}}" ], "path": [ "api", "catena", - "legal-entities" + "identifier-types" ] } }, "response": [] }, { - "name": "Legal Entity", + "name": "Feild Quality Rules", "request": { "method": "GET", "header": [], "url": { - "raw": "{{Pool-Host}}/api/catena/legal-entities/ID-VALUE?idType=EU_VAT_ID_DE", + "raw": "{{Pool-Host}}/api/catena/field-quality-rules/?country=DE", "host": [ "{{Pool-Host}}" ], "path": [ "api", "catena", - "legal-entities", - "ID-VALUE" + "field-quality-rules", + "" ], "query": [ { - "key": "idType", - "value": "EU_VAT_ID_DE" + "key": "country", + "value": "DE" } ] } }, "response": [] - }, + } + ] + }, + { + "name": "Legal Entity Controller", + "item": [ { - "name": "Search Legal Entities", + "name": "Legal Entities", "request": { "method": "GET", "header": [], @@ -109,7 +175,7 @@ ], "query": [ { - "key": "name", + "key": "legalName", "value": "company", "disabled": true }, @@ -177,13 +243,90 @@ "response": [] }, { - "name": "Filter Legal Entities", + "name": "Update Legal Entity", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "[\n {\n \"bpnl\": \"BPNL000000000001\",\n \"legalName\": \"Name of Company\",\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_ID_TYPE\",\n \"issuingBody\": \"CUSTOM_ISSUE_BODY\"\n }\n ],\n \"legalShortName\": \"NoC\",\n \"legalForm\": \"CUSTOM_LEGAL_FORM\",\n \"states\": [\n {\n \"officialDenotation\": \"Active\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"validTo\": \"2023-06-05T07:31:01.213Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"classifications\": [\n {\n \"value\": \"Farming of cattle, dairy farming\",\n \"code\": \"01.21\",\n \"type\": \"NACE\"\n }\n ],\n \"legalAddress\": {\n \"name\": \"WESTERN_LATIN_STANDARD\",\n \"states\": [\n {\n \"description\": \"WESTERN_LATIN_STANDARD\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"validTo\": \"2023-06-05T07:31:01.213Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"12345678910\",\n \"type\": \"CUSTOM_ID_ADD_TYPE\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70546\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"name\": \"Stuttgarter Strasse\",\n \"houseNumber\": \"1\",\n \"milestone\": \"Stuttgarter Strasse 1\",\n \"direction\": \"Stuttgarter Str.\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg\",\n \"administrativeAreaLevel2\": \"test1\",\n \"administrativeAreaLevel3\": \"test2\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"GM01\",\n \"industrialZone\": \"HEADQUARTER\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"test\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart 1\",\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg 1\",\n \"deliveryServiceNumber\": \"1234\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test\"\n }\n }\n }\n]", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{Pool-Host}}/api/catena/legal-entities", + "host": [ + "{{Pool-Host}}" + ], + "path": [ + "api", + "catena", + "legal-entities" + ] + } + }, + "response": [] + }, + { + "name": "Create Legal Entities", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "[\n {\n \"legalName\": \"Name of Company\",\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_ID_TYPE\",\n \"issuingBody\": \"CUSTOM_ISSUE_BODY\"\n }\n ],\n \"legalShortName\": \"NoC\",\n \"legalForm\": \"CUSTOM_LEGAL_FORM\",\n \"states\": [\n {\n \"officialDenotation\": \"Active\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"validTo\": \"2023-06-05T07:31:01.213Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"classifications\": [\n {\n \"value\": \"Farming of cattle, dairy farming\",\n \"code\": \"01.21\",\n \"type\": \"NACE\"\n }\n ],\n \"legalAddress\": {\n \"name\": \"WESTERN_LATIN_STANDARD\",\n \"states\": [\n {\n \"description\": \"WESTERN_LATIN_STANDARD\",\n \"validFrom\": \"2020-12-16T05:54:48.942Z\",\n \"validTo\": \"2023-06-05T07:31:01.213Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"12345678910\",\n \"type\": \"CUSTOM_ID_ADD_TYPE\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70546\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"name\": \"Stuttgarter Strasse\",\n \"houseNumber\": \"1\",\n \"milestone\": \"Stuttgarter Strasse 1\",\n \"direction\": \"Stuttgarter Str.\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg\",\n \"administrativeAreaLevel2\": \"test1\",\n \"administrativeAreaLevel3\": \"test2\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"GM01\",\n \"industrialZone\": \"HEADQUARTER\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"test\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart 1\",\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg 1\",\n \"deliveryServiceNumber\": \"1234\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test\"\n }\n },\n \"index\": \"0\"\n }\n]", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{Pool-Host}}/api/catena/legal-entities", + "host": [ + "{{Pool-Host}}" + ], + "path": [ + "api", + "catena", + "legal-entities" + ] + } + }, + "response": [] + }, + { + "name": "Confirm up to date", + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{Pool-Host}}/api/catena/legal-entities/BPNL000000000001/confirm-up-to-date", + "host": [ + "{{Pool-Host}}" + ], + "path": [ + "api", + "catena", + "legal-entities", + "BPNL000000000001", + "confirm-up-to-date" + ] + } + }, + "response": [] + }, + { + "name": "Search Legal Entities", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "[\n \"BPNL000000000001\"\n]", + "raw": "[\n \"BPNL000000000001\"\n]", "options": { "raw": { "language": "json" @@ -206,13 +349,13 @@ "response": [] }, { - "name": "Filter Legal Addresses", + "name": "Search Legal Addresses", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "[\n \"BPNL000000000001\"\n]", + "raw": "[\n \"BPNL000000000001\"\n]", "options": { "raw": { "language": "json" @@ -235,6 +378,32 @@ }, "response": [] }, + { + "name": "Legal Entity", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{Pool-Host}}/api/catena/legal-entities/123456789?idType=CUSTOM_ID_TYPE", + "host": [ + "{{Pool-Host}}" + ], + "path": [ + "api", + "catena", + "legal-entities", + "123456789" + ], + "query": [ + { + "key": "idType", + "value": "CUSTOM_ID_TYPE" + } + ] + } + }, + "response": [] + }, { "name": "Legal Entity Sites", "request": { @@ -272,7 +441,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{Pool-Host}}/api/catena/legal-entities/BPNL0000000001YN/addresses?page=0&size=10", + "raw": "{{Pool-Host}}/api/catena/legal-entities/BPNL000000000001/addresses?page=0&size=10", "host": [ "{{Pool-Host}}" ], @@ -280,7 +449,7 @@ "api", "catena", "legal-entities", - "BPNL0000000001YN", + "BPNL000000000001", "addresses" ], "query": [ @@ -309,7 +478,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n {\n \"name\": \"Factory UT\",\n \"mainAddress\": {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"70327\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Stuttgart\",\n \"shortName\": \"S\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Untertuerckheim Strasse 1\",\n \"name\": \"Untertuerckheim Strasse\",\n \"shortName\": \"Untertuerckheim Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Gate 1\",\n \"shortName\": \"G1\",\n \"number\": \"1\",\n \"type\": \"BUILDING\"\n }\n ],\n \"types\": [\n \"UNSPECIFIC\"\n ]\n },\n \"legalEntity\": \"BPNL000000000001\",\n \"index\": \"0\"\n },\n {\n \"name\": \"Factory Sindelfingen\",\n \"mainAddress\": {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"71034\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Sindelfinden\",\n \"shortName\": \"BB\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Sindelfinger Strasse 1\",\n \"name\": \"Sindelfinger Strasse\",\n \"shortName\": \"Sindelfinger Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Building 8\",\n \"shortName\": \"G8\",\n \"number\": \"8\",\n \"type\": \"BUILDING\"\n }\n ],\n \"types\": [\n \"UNSPECIFIC\"\n ]\n },\n \"legalEntity\": \"BPNL000000000001\",\n \"index\": \"1\"\n }\n]", + "raw": "[\n {\n \"name\": \"Factory UT\",\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-06T08:18:05.777Z\",\n \"validTo\": \"2024-06-06T08:18:05.777Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"mainAddress\": {\n \"name\": \"WESTERN_LATIN_STANDARD\",\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-06T08:18:05.777Z\",\n \"validTo\": \"2024-06-06T08:18:05.777Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_SITE_ID\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70327\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"name\": \"Untertuerckheim Strasse 1\",\n \"houseNumber\": \"1234\",\n \"milestone\": \"Untertuerckheim Strasse 1\",\n \"direction\": \"Untertuerckheim Strasse 1\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttember\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"71034\",\n \"industrialZone\": \"Sindelfinden\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"1\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart\",\n \"administrativeAreaLevel1\": \"Stuttgart\",\n \"deliveryServiceNumber\": \"Untertuerckheim Strasse 1\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test qualifier\"\n }\n },\n \"bpnlParent\": \"BPNL000000000001\",\n \"index\": \"1\"\n }\n]", "options": { "raw": { "language": "json" @@ -337,7 +506,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n {\n \"name\": \"Factory UT\",\n \"mainAddress\": {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"70327\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Stuttgart\",\n \"shortName\": \"S\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Untertuerckheim Strasse 1\",\n \"name\": \"Untertuerckheim Strasse\",\n \"shortName\": \"Untertuerckheim Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Gate 1\",\n \"shortName\": \"G1\",\n \"number\": \"1\",\n \"type\": \"BUILDING\"\n }\n ],\n \"types\": [\n \"UNSPECIFIC\"\n ]\n },\n \"bpn\": \"BPNS000000000001\"\n },\n {\n \"name\": \"Factory Sindelfingen\",\n \"mainAddress\": {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"71034\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Sindelfinden\",\n \"shortName\": \"BB\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Sindelfinger Strasse 1\",\n \"name\": \"Sindelfinger Strasse\",\n \"shortName\": \"Sindelfinger Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Building 8\",\n \"shortName\": \"G8\",\n \"number\": \"8\",\n \"type\": \"BUILDING\"\n }\n ],\n \"types\": [\n \"UNSPECIFIC\"\n ]\n },\n \"bpn\": \"BPNS0000000001YN\"\n }\n]", + "raw": "[\n {\n \"bpns\": \"BPNS000000000001\",\n \"name\": \"Factory UT\",\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-06T08:18:05.777Z\",\n \"validTo\": \"2024-06-06T08:18:05.777Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"mainAddress\": {\n \"name\": \"WESTERN_LATIN_STANDARD\",\n \"states\": [\n {\n \"description\": \"Baden-Wuerttemberg\",\n \"validFrom\": \"2023-06-06T08:18:05.777Z\",\n \"validTo\": \"2024-06-06T08:18:05.777Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"123456789\",\n \"type\": \"CUSTOM_SITE_ID\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70327\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"name\": \"Untertuerckheim Strasse 1\",\n \"houseNumber\": \"1234\",\n \"milestone\": \"Untertuerckheim Strasse 1\",\n \"direction\": \"Untertuerckheim Strasse 1\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttember\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"71034\",\n \"industrialZone\": \"Sindelfinden\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"1\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart\",\n \"administrativeAreaLevel1\": \"Stuttgart\",\n \"deliveryServiceNumber\": \"Untertuerckheim Strasse 1\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test qualifier\"\n }\n }\n }\n]", "options": { "raw": { "language": "json" @@ -359,33 +528,13 @@ "response": [] }, { - "name": "Site", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/sites/BPNS000000000001", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "sites", - "BPNS000000000001" - ] - } - }, - "response": [] - }, - { - "name": "Filter Sites", + "name": "Search Sites", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"sites\": [\n \"BPNS000000000001\"\n ]\n}", + "raw": "{\n \"legalEntities\": [\n \"BPNL000000000001\"\n ],\n \"sites\": [\n \"BPNS000000000001\"\n ]\n}", "options": { "raw": { "language": "json" @@ -418,7 +567,7 @@ "response": [] }, { - "name": "Filter Main Addresses", + "name": "Search Main Addresses", "request": { "method": "POST", "header": [], @@ -446,6 +595,26 @@ } }, "response": [] + }, + { + "name": "Site", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{Pool-Host}}/api/catena/sites/BPNS000000000001", + "host": [ + "{{Pool-Host}}" + ], + "path": [ + "api", + "catena", + "sites", + "BPNS000000000001" + ] + } + }, + "response": [] } ] }, @@ -459,7 +628,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"70327\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Stuttgart\",\n \"shortName\": \"S\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Tor Strasse 1\",\n \"name\": \"Tor Strasse\",\n \"shortName\": \"Tor Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Gate 1\",\n \"shortName\": \"1\",\n \"number\": \"1\",\n \"type\": \"BUILDING\"\n }\n ],\n \"types\": [\n \"UNSPECIFIC\"\n ],\n \"parent\": \"BPNS000000000001\",\n \"index\": \"0\"\n },\n {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"80331\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Bavaria\",\n \"shortName\": \"B\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Standort Strasse 10\",\n \"name\": \"Standort Strasse\",\n \"shortName\": \"Standort Str.\",\n \"number\": \"10\",\n \"type\": \"STREET\"\n }\n ],\n \"types\": [\n \"UNSPECIFIC\"\n ],\n \"parent\": \"BPNL0000000001YN\",\n \"index\": \"1\"\n }\n]", + "raw": "[\n {\n \"name\": \"WESTERN_LATIN_STANDARD\",\n \"states\": [\n {\n \"description\": \"WESTERN_LATIN_STANDARD\",\n \"validFrom\": \"2023-06-06T10:02:00.355Z\",\n \"validTo\": \"2024-06-06T10:02:00.355Z\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"12345678910\",\n \"type\": \"CUSTOM_ID_ADD_TYPE\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70546\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"name\": \"Stuttgarter Strasse\",\n \"houseNumber\": \"1\",\n \"milestone\": \"Stuttgarter Strasse 1\",\n \"direction\": \"Stuttgarter Str.\"\n },\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"GM01\",\n \"industrialZone\": \"HEADQUARTER\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": null\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"1234\",\n \"city\": \"Stuttgart\",\n \"administrativeAreaLevel1\": \"Baden-Wuerttemberg test1\",\n \"deliveryServiceNumber\": \"test\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test1\"\n },\n \"bpnParent\": \"BPNL000000000001\",\n \"index\": \"0\"\n }\n]", "options": { "raw": { "language": "json" @@ -509,32 +678,12 @@ "response": [] }, { - "name": "Address Partner", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/addresses/BPNA000000000001", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "addresses", - "BPNA000000000001" - ] - } - }, - "response": [] - }, - { - "name": "Search Address Partners", + "name": "Address Partners", "request": { "method": "GET", "header": [], "url": { - "raw": "{{Pool-Host}}/api/catena/addresses?administrativeArea=baden&countryCode=DE&page=0&size=10", + "raw": "{{Pool-Host}}/api/catena/addresses?page=0&size=10", "host": [ "{{Pool-Host}}" ], @@ -546,7 +695,8 @@ "query": [ { "key": "administrativeArea", - "value": "baden" + "value": null, + "disabled": true }, { "key": "postCode", @@ -575,7 +725,8 @@ }, { "key": "countryCode", - "value": "DE" + "value": null, + "disabled": true }, { "key": "page", @@ -591,13 +742,13 @@ "response": [] }, { - "name": "Filter Address Partners", + "name": "Search Address Partners", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"addresses\": [\n \"BPNA000000000001\"\n ]\n}", + "raw": "{\n \"legalEntities\": [\n \"BPNL000000000001\"\n ],\n \"sites\": [\n \"BPNS000000000001\"\n ],\n \"addresses\": [\n \"BPNA000000000001\"\n ]\n}", "options": { "raw": { "language": "json" @@ -628,64 +779,22 @@ } }, "response": [] - } - ] - }, - { - "name": "Opensearch Controller", - "item": [ + }, { - "name": "Update Opensearch Index", - "request": { - "method": "POST", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/opensearch/business-partner", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "opensearch", - "business-partner" - ] - } - }, - "response": [] - }, - { - "name": "Check Opensearch Last Update Status", + "name": "Address Partner", "request": { "method": "GET", "header": [], "url": { - "raw": "{{Pool-Host}}/api/opensearch/business-partner", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "opensearch", - "business-partner" - ] - } - }, - "response": [] - }, - { - "name": "Empty Opensearch Index", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/opensearch/business-partner", + "raw": "{{Pool-Host}}/api/catena/addresses/BPNA000000000001", "host": [ "{{Pool-Host}}" ], "path": [ "api", - "opensearch", - "business-partner" + "catena", + "addresses", + "BPNA000000000001" ] } }, @@ -694,213 +803,78 @@ ] }, { - "name": "Metadata Controller", + "name": "Opensearch Controller", "item": [ { - "name": "Create Identifier Type", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"technicalKey\": \"CUSTOM_ID_TYPE\",\n \"name\": \"Custom Identifier Type for Testing\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{Pool-Host}}/api/catena/identifier-types", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "identifier-types" - ] - } - }, - "response": [] - }, - { - "name": "Identifier Types", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/identifier-types?page=0&size=10", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "identifier-types" - ], - "query": [ - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - }, - { - "name": "Identifier Type Rules", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/identifier-types/for-country?country=DE", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "identifier-types", - "for-country" - ], - "query": [ - { - "key": "country", - "value": "DE" - } - ] - } - }, - "response": [] - }, - { - "name": "Create Issuing Body", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"technicalKey\": \"CUSTOM_ISSUE_BODY\",\n \"name\": \"Custom Issuing Body for Testing\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{Pool-Host}}/api/catena/issuing-bodies", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "issuing-bodies" - ] - } - }, - "response": [] - }, - { - "name": "Issuing Bodies", + "name": "Check Opensearch Last Update Status", "request": { "method": "GET", "header": [], "url": { - "raw": "{{Pool-Host}}/api/catena/issuing-bodies?page=0&size=10", + "raw": "{{Pool-Host}}/api/opensearch/business-partner", "host": [ "{{Pool-Host}}" ], "path": [ "api", - "catena", - "issuing-bodies" - ], - "query": [ - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } + "opensearch", + "business-partner" ] } }, "response": [] }, { - "name": "Create Identifier Status", + "name": "Update Opensearch Index", "request": { "method": "POST", "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"technicalKey\": \"CUSTOM_ID_STATUS\",\n \"name\": \"Custom Identifier Status for Testing\"\n}", - "options": { - "raw": { - "language": "json" - } - } - }, "url": { - "raw": "{{Pool-Host}}/api/catena/identifier-status", + "raw": "{{Pool-Host}}/api/opensearch/business-partner", "host": [ "{{Pool-Host}}" ], "path": [ "api", - "catena", - "identifier-status" + "opensearch", + "business-partner" ] } }, "response": [] }, { - "name": "Identifier Stati", + "name": "Empty Opensearch Index", "request": { - "method": "GET", + "method": "DELETE", "header": [], "url": { - "raw": "{{Pool-Host}}/api/catena/identifier-status?page=0&size=10", + "raw": "{{Pool-Host}}/api/opensearch/business-partner", "host": [ "{{Pool-Host}}" ], "path": [ "api", - "catena", - "identifier-status" - ], - "query": [ - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } + "opensearch", + "business-partner" ] } }, "response": [] - }, + } + ] + }, + { + "name": "BPN Controller", + "item": [ { - "name": "Create Legal Form", + "name": "Search BPNs", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"technicalKey\": \"CUSTOM_LEGAL_FORM\",\n \"name\": \"Custom Legal Form for Testing\",\n \"mainAbbreviation\": \"CLF_0001\",\n \"language\": \"en\",\n \"category\": [\n {\n \"name\": \"holding company\"\n }\n ]\n}", + "raw": "{\n \"lsaType\": \"LEGAL_ENTITY\",\n \"idType\": \"CUSTOM_ID_TYPE\",\n \"idValues\": [\n \"123456789\"\n ]\n}", "options": { "raw": { "language": "json" @@ -908,43 +882,15 @@ } }, "url": { - "raw": "{{Pool-Host}}/api/catena/legal-forms", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "legal-forms" - ] - } - }, - "response": [] - }, - { - "name": "Legal Forms", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/legal-forms?page=0&size=10", + "raw": "{{Pool-Host}}/api/catena/bpn/search", "host": [ "{{Pool-Host}}" ], "path": [ "api", "catena", - "legal-forms" - ], - "query": [ - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } + "bpn", + "search" ] } }, @@ -953,58 +899,16 @@ ] }, { - "name": "SaaS Controller", + "name": "Changelog Controller", "item": [ { - "name": "Sharing Process Import Status", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "https://{{Pool-Host}}/api/cdq/business-partner/sync", - "protocol": "https", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "cdq", - "business-partner", - "sync" - ] - } - }, - "response": [] - }, - { - "name": "Start Sharing Process Data Import", - "request": { - "method": "POST", - "header": [], - "url": { - "raw": "https://{{Pool-Host}}/api/cdq/business-partner/sync", - "protocol": "https", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "cdq", - "business-partner", - "sync" - ] - } - }, - "response": [] - }, - { - "name": "Import Mapping Filter", + "name": "Business Partner Changelog", "request": { "method": "POST", "header": [], "body": { "mode": "raw", - "raw": "{\n \"importIdentifiers\": [\n \"string\"\n ]\n}", + "raw": "{\n \"fromTime\": \"2023-03-21T09:00:25.298594Z\",\n \"bpns\": [\n \"BPNL000000000001\"\n ],\n \"lsaTypes\": [\n \"LEGAL_ENTITY\"\n ]\n}", "options": { "raw": { "language": "json" @@ -1012,63 +916,7 @@ } }, "url": { - "raw": "https://{{Pool-Host}}/api/saas/identifier-mappings/filter", - "protocol": "https", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "saas", - "identifier-mappings", - "filter" - ] - } - }, - "response": [] - }, - { - "name": "Identifier Mappings", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "https://{{Pool-Host}}/api/saas/identifier-mappings?page=0&size=10", - "protocol": "https", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "saas", - "identifier-mappings" - ], - "query": [ - { - "key": "page", - "value": "0" - }, - { - "key": "size", - "value": "10" - } - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Business Partner Controller", - "item": [ - { - "name": "Business Partner Changelog", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{Pool-Host}}/api/catena/business-partners/changelog?page=0&size=10&modifiedAfter=2023-03-21T09:00:25.298594Z&bpn=BPNL0000000001YN&bpn=BPNL000000000001", + "raw": "{{Pool-Host}}/api/catena/business-partners/changelog/search?page=0&size=10", "host": [ "{{Pool-Host}}" ], @@ -1076,7 +924,8 @@ "api", "catena", "business-partners", - "changelog" + "changelog", + "search" ], "query": [ { @@ -1086,53 +935,7 @@ { "key": "size", "value": "10" - }, - { - "key": "modifiedAfter", - "value": "2023-03-21T09:00:25.298594Z" - }, - { - "key": "bpn", - "value": "BPNL0000000001YN" - }, - { - "key": "bpn", - "value": "BPNL000000000001" - } - ] - } - }, - "response": [] - } - ] - }, - { - "name": "BPN Controller", - "item": [ - { - "name": "Search BPNs", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"idType\": \"EU_VAT_ID_DE\",\n \"idValues\": [\n \"VAT_ID_VALUE\"\n ]\n}", - "options": { - "raw": { - "language": "json" } - } - }, - "url": { - "raw": "{{Pool-Host}}/api/catena/bpn/search", - "host": [ - "{{Pool-Host}}" - ], - "path": [ - "api", - "catena", - "bpn", - "search" ] } }, @@ -1145,8 +948,8 @@ "type": "oauth2", "oauth2": [ { - "key": "accessTokenUrl", - "value": "{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", + "key": "client_authentication", + "value": "body", "type": "string" }, { @@ -1159,39 +962,44 @@ "value": "{{Pool-Client-ID}}", "type": "string" }, + { + "key": "accessTokenUrl", + "value": "https://{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", + "type": "string" + }, { "key": "tokenName", "value": "BPDM Pool Token {{Environment}}", "type": "string" }, { - "key": "challengeAlgorithm", - "value": "S256", - "type": "string" + "key": "refreshRequestParams", + "value": [], + "type": "any" }, { - "key": "redirect_uri", - "value": "https://catenax-dev003-app-onboarding.azurewebsites.net", - "type": "string" + "key": "tokenRequestParams", + "value": [], + "type": "any" }, { - "key": "grant_type", - "value": "client_credentials", - "type": "string" + "key": "authRequestParams", + "value": [], + "type": "any" }, { - "key": "authUrl", - "value": "https://catenaxdev003akssrv.germanywestcentral.cloudapp.azure.com/iamcentralidp/auth/realms/CX-Central/protocol/openid-connect/auth", + "key": "challengeAlgorithm", + "value": "S256", "type": "string" }, { - "key": "addTokenTo", - "value": "header", + "key": "grant_type", + "value": "client_credentials", "type": "string" }, { - "key": "client_authentication", - "value": "body", + "key": "addTokenTo", + "value": "header", "type": "string" } ] diff --git a/docs/postman/Local.postman_environment.json b/docs/postman/Local.postman_environment.json index 07410e524..4a2e72cb4 100644 --- a/docs/postman/Local.postman_environment.json +++ b/docs/postman/Local.postman_environment.json @@ -1,5 +1,5 @@ { - "id": "a1dfc379-77c6-4831-bc9c-862759f36f9a", + "id": "6c6dd52d-bf34-496d-9d33-57802fa339d0", "name": "Local", "values": [ { @@ -49,9 +49,27 @@ "value": "", "type": "secret", "enabled": true + }, + { + "key": "Bridge-Host", + "value": "http://localhost:8083", + "type": "default", + "enabled": true + }, + { + "key": "Bridge-Client-ID", + "value": "bridge-client", + "type": "default", + "enabled": true + }, + { + "key": "Bridge-Client-Secret", + "value": "", + "type": "secret", + "enabled": true } ], "_postman_variable_scope": "environment", - "_postman_exported_at": "2023-03-24T14:12:35.754Z", - "_postman_exported_using": "Postman/10.11.2" + "_postman_exported_at": "2023-06-15T09:50:00.606Z", + "_postman_exported_using": "Postman/10.14.2" } \ No newline at end of file From b5e79e2efbbcc8a02ac9bcccea3d083ad3bf4b9f Mon Sep 17 00:00:00 2001 From: SujitMBRDI Date: Fri, 23 Jun 2023 11:53:07 +0530 Subject: [PATCH 67/83] Removed protocol and updated changes on review comments --- .../BPDM Bridge Dummy.postman_collection.json | 10 +++---- .../postman/BPDM Gate.postman_collection.json | 4 +-- .../postman/BPDM Pool.postman_collection.json | 26 ++++++++++--------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/docs/postman/BPDM Bridge Dummy.postman_collection.json b/docs/postman/BPDM Bridge Dummy.postman_collection.json index 30b9633a9..cc3a88a65 100644 --- a/docs/postman/BPDM Bridge Dummy.postman_collection.json +++ b/docs/postman/BPDM Bridge Dummy.postman_collection.json @@ -29,6 +29,11 @@ "auth": { "type": "oauth2", "oauth2": [ + { + "key": "accessTokenUrl", + "value": "{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", + "type": "string" + }, { "key": "client_authentication", "value": "body", @@ -44,11 +49,6 @@ "value": "{{Bridge-Client-ID}}", "type": "string" }, - { - "key": "accessTokenUrl", - "value": "https://{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", - "type": "string" - }, { "key": "tokenName", "value": "BPDM Bridge Token {{Environment}}", diff --git a/docs/postman/BPDM Gate.postman_collection.json b/docs/postman/BPDM Gate.postman_collection.json index e8e911efc..d40db0763 100644 --- a/docs/postman/BPDM Gate.postman_collection.json +++ b/docs/postman/BPDM Gate.postman_collection.json @@ -60,7 +60,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\n \"lsaType\": \"LegalEntity\",\n \"externalId\": \"string\",\n \"sharingStateType\": \"Pending\",\n \"sharingErrorCode\": \"SharingProcessError\",\n \"sharingErrorMessage\": \"string\",\n \"bpn\": \"string\",\n \"sharingProcessStarted\": \"2023-06-05T06:56:40.785Z\"\n}", + "raw": "{\n \"lsaType\": \"LEGAL_ENTITY\",\n \"externalId\": \"string\",\n \"sharingStateType\": \"Pending\",\n \"sharingErrorCode\": \"SharingProcessError\",\n \"sharingErrorMessage\": \"string\",\n \"bpn\": \"string\",\n \"sharingProcessStarted\": \"2023-06-05T06:56:40.785Z\"\n}", "options": { "raw": { "language": "json" @@ -722,7 +722,7 @@ "oauth2": [ { "key": "accessTokenUrl", - "value": "https://{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", + "value": "{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", "type": "string" }, { diff --git a/docs/postman/BPDM Pool.postman_collection.json b/docs/postman/BPDM Pool.postman_collection.json index ec7500962..7d9df3dae 100644 --- a/docs/postman/BPDM Pool.postman_collection.json +++ b/docs/postman/BPDM Pool.postman_collection.json @@ -128,7 +128,7 @@ "response": [] }, { - "name": "Feild Quality Rules", + "name": "Field Quality Rules", "request": { "method": "GET", "header": [], @@ -656,7 +656,7 @@ "header": [], "body": { "mode": "raw", - "raw": "[\n {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"70327\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Stuttgart\",\n \"shortName\": \"S\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Tor Strasse 1\",\n \"name\": \"Tor Strasse\",\n \"shortName\": \"Tor Str.\",\n \"number\": \"1\",\n \"type\": \"STREET\"\n }\n ],\n \"premises\": [\n {\n \"value\": \"Gate 1\",\n \"shortName\": \"1\",\n \"number\": \"1\",\n \"type\": \"BUILDING\"\n }\n ],\n \"types\": [\n \"UNSPECIFIC\"\n ],\n \"bpn\": \"BPNA000000000001\"\n },\n {\n \"version\": {\n \"characterSet\": \"WESTERN_LATIN_STANDARD\",\n \"language\": \"en\"\n },\n \"country\": \"DE\",\n \"administrativeAreas\": [\n {\n \"value\": \"Baden-Wuerttemberg\",\n \"shortName\": \"BW\",\n \"fipsCode\": \"GM01\",\n \"type\": \"REGION\"\n }\n ],\n \"postCodes\": [\n {\n \"value\": \"80331\",\n \"type\": \"REGULAR\"\n }\n ],\n \"localities\": [\n {\n \"value\": \"Bavaria\",\n \"shortName\": \"B\",\n \"type\": \"CITY\"\n }\n ],\n \"thoroughfares\": [\n {\n \"value\": \"Standort Strasse 10\",\n \"name\": \"Standort Strasse\",\n \"shortName\": \"Standort Str.\",\n \"number\": \"10\",\n \"type\": \"STREET\"\n }\n ],\n \"types\": [\n \"UNSPECIFIC\"\n ],\n \"bpn\": \"BPNA0000000001YN\"\n }\n]", + "raw": "[\n {\n \"bpna\": \"BPNA000000000001\",\n \"name\": \"WESTERN_LATIN_STANDARD\",\n \"states\": [\n {\n \"description\": \"WESTERN_LATIN_STANDARD\",\n \"validFrom\": \"2020-12-16T05:54:48.942\",\n \"validTo\": \"2023-06-05T07:31:01.213\",\n \"type\": \"ACTIVE\"\n }\n ],\n \"identifiers\": [\n {\n \"value\": \"12345678910\",\n \"type\": \"CUSTOM_ID_ADD_TYPE\"\n }\n ],\n \"physicalPostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"70546\",\n \"city\": \"Stuttgart\",\n \"street\": {\n \"name\": \"Stuttgarter Strasse\",\n \"houseNumber\": \"1\",\n \"milestone\": \"Stuttgarter Strasse 1\",\n \"direction\": \"Stuttgarter Str.\"\n },\n \"administrativeAreaLevel1\": null,\n \"administrativeAreaLevel2\": \"test1\",\n \"administrativeAreaLevel3\": \"test2\",\n \"district\": \"Stuttgart\",\n \"companyPostalCode\": \"GM01\",\n \"industrialZone\": \"HEADQUARTER\",\n \"building\": \"Building A\",\n \"floor\": \"A\",\n \"door\": \"test\"\n },\n \"alternativePostalAddress\": {\n \"geographicCoordinates\": {\n \"longitude\": 0,\n \"latitude\": 0,\n \"altitude\": 0\n },\n \"country\": \"DE\",\n \"postalCode\": \"Stuttgart 1\",\n \"city\": \"string\",\n \"administrativeAreaLevel1\": \"test1\",\n \"deliveryServiceNumber\": \"test2\",\n \"deliveryServiceType\": \"PO_BOX\",\n \"deliveryServiceQualifier\": \"test3\"\n }\n }\n]", "options": { "raw": { "language": "json" @@ -683,7 +683,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{Pool-Host}}/api/catena/addresses?page=0&size=10", + "raw": "{{Pool-Host}}/api/catena/addresses", "host": [ "{{Pool-Host}}" ], @@ -695,7 +695,7 @@ "query": [ { "key": "administrativeArea", - "value": null, + "value": "", "disabled": true }, { @@ -725,16 +725,18 @@ }, { "key": "countryCode", - "value": null, + "value": "", "disabled": true }, { "key": "page", - "value": "0" + "value": "0", + "disabled": true }, { "key": "size", - "value": "10" + "value": "10", + "disabled": true } ] } @@ -947,6 +949,11 @@ "auth": { "type": "oauth2", "oauth2": [ + { + "key": "accessTokenUrl", + "value": "{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", + "type": "string" + }, { "key": "client_authentication", "value": "body", @@ -962,11 +969,6 @@ "value": "{{Pool-Client-ID}}", "type": "string" }, - { - "key": "accessTokenUrl", - "value": "https://{{Keycloak-Host}}/auth/realms/CX-Central/protocol/openid-connect/token", - "type": "string" - }, { "key": "tokenName", "value": "BPDM Pool Token {{Environment}}", From 004aa3f485d5c0473290f62a61a3d07fab7f4fb6 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 16 Jun 2023 10:42:58 +0100 Subject: [PATCH 68/83] Feat(Gate): Add dataType column to ChangelogEntry entity --- .../tractusx/bpdm/gate/controller/ChangelogController.kt | 7 ++++--- .../eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt | 8 +++++++- .../tractusx/bpdm/gate/repository/ChangelogRepository.kt | 8 ++++++++ .../eclipse/tractusx/bpdm/gate/service/AddressService.kt | 8 ++------ .../tractusx/bpdm/gate/service/ChangelogService.kt | 7 +++++-- .../org/eclipse/tractusx/bpdm/gate/service/SiteService.kt | 7 ++----- .../V4_0_0_1__update_change_log_entry_add_column.sql | 3 +++ 7 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 bpdm-gate/src/main/resources/db/migration/V4_0_0_1__update_change_log_entry_add_column.sql diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 30383e275..ff3f6a7bd 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.GateChangelogApi import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse @@ -37,13 +38,13 @@ class ChangelogController( override fun getInputChangelog( paginationRequest: PaginationRequest, searchRequest: ChangeLogSearchRequest ): PageChangeLogResponse { - return changelogService.getChangeLogEntries(searchRequest.externalIds, searchRequest.lsaTypes, searchRequest.fromTime, paginationRequest.page, paginationRequest.size) + return changelogService.getChangeLogEntries(searchRequest.externalIds, searchRequest.lsaTypes, searchRequest.fromTime,OutputInputEnum.Input, paginationRequest.page, paginationRequest.size) } override fun getOutputChangelog(paginationRequest: PaginationRequest, searchRequest: ChangeLogSearchRequest): PageChangeLogResponse { - throw NotImplementedError() - TODO("Not yet implemented") + + return changelogService.getChangeLogEntries(searchRequest.externalIds, searchRequest.lsaTypes, searchRequest.fromTime,OutputInputEnum.Output, paginationRequest.page, paginationRequest.size) } } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt index f830e5e76..3d8bb350e 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/ChangelogEntry.kt @@ -21,6 +21,7 @@ package org.eclipse.tractusx.bpdm.gate.entity import jakarta.persistence.* import org.eclipse.tractusx.bpdm.common.model.BaseEntity +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.LsaType @@ -32,7 +33,12 @@ class ChangelogEntry( val externalId: String, @Enumerated(EnumType.STRING) @Column(name = "business_partner_type", nullable = false, updatable = false) - val businessPartnerType: LsaType + val businessPartnerType: LsaType, + @Column(name = "data_type") + @Enumerated(EnumType.STRING) + var dataType: OutputInputEnum + + ) : BaseEntity() diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt index c27bd60c4..86e7eebaa 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/repository/ChangelogRepository.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.repository +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.springframework.data.jpa.domain.Specification @@ -67,6 +68,13 @@ interface ChangelogRepository : JpaRepository, JpaSpecific null } } + + fun byOutputInputEnum(outputInputEnum: OutputInputEnum?) = + Specification { root, _, builder -> + outputInputEnum?.let { + builder.equal(root.get(ChangelogEntry::dataType.name), outputInputEnum) + } + } } @Query("select distinct u.externalId from ChangelogEntry u where u.externalId in :externalIdList") diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index 7302b640f..e79f30516 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -24,11 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.LsaType -import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry import org.eclipse.tractusx.bpdm.gate.entity.LogisticAddress @@ -117,7 +113,7 @@ class AddressService( // create changelog entry if all goes well from saasClient addresses.forEach { address -> - changelogRepository.save(ChangelogEntry(address.externalId, LsaType.ADDRESS)) + changelogRepository.save(ChangelogEntry(address.externalId, LsaType.ADDRESS,OutputInputEnum.Input)) } addressPersistenceService.persistAddressBP(addresses, OutputInputEnum.Input) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt index edab530f7..0543d0c28 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ChangelogService.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.service +import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse @@ -28,6 +29,7 @@ import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byCreatedAtGreaterThan import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byExternalIdsIn import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byLsaTypes +import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository.Specs.byOutputInputEnum import org.springframework.data.domain.PageRequest import org.springframework.data.jpa.domain.Specification import org.springframework.stereotype.Service @@ -36,11 +38,12 @@ import java.time.Instant @Service class ChangelogService(private val changelogRepository: ChangelogRepository) { - fun getChangeLogEntries(externalIds: Set?, lsaTypes: Set?, createdAt: Instant?, page: Int, pageSize: Int): PageChangeLogResponse { + fun getChangeLogEntries(externalIds: Set?, lsaTypes: Set?, createdAt: Instant?, outputInputEnum: OutputInputEnum?,page: Int, pageSize: Int): PageChangeLogResponse { val nonNullExternalIds = externalIds ?: emptySet() - val spec = Specification.allOf(byExternalIdsIn(externalIds = nonNullExternalIds), byCreatedAtGreaterThan(createdAt = createdAt), byLsaTypes(lsaTypes)) + val spec = Specification.allOf(byExternalIdsIn(externalIds = nonNullExternalIds), byCreatedAtGreaterThan(createdAt = createdAt), byLsaTypes(lsaTypes), byOutputInputEnum(outputInputEnum)) + val pageable = PageRequest.of(page, pageSize) val pageResponse = changelogRepository.findAll(spec, pageable) val setDistinctList = changelogRepository.findExternalIdsInListDistinct(nonNullExternalIds) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index f2921001f..ecf4628bd 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -24,10 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse +import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.config.BpnConfigProperties import org.eclipse.tractusx.bpdm.gate.entity.Site import org.eclipse.tractusx.bpdm.gate.exception.SaasNonexistentParentException @@ -80,7 +77,7 @@ class SiteService( */ fun getSitesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { - val sitePage = if (externalIds != null && externalIds.isNotEmpty()) { + val sitePage = if (!externalIds.isNullOrEmpty()) { siteRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) } else { siteRepository.findByDataType(OutputInputEnum.Output, PageRequest.of(page, size)) diff --git a/bpdm-gate/src/main/resources/db/migration/V4_0_0_1__update_change_log_entry_add_column.sql b/bpdm-gate/src/main/resources/db/migration/V4_0_0_1__update_change_log_entry_add_column.sql new file mode 100644 index 000000000..9b93f0200 --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V4_0_0_1__update_change_log_entry_add_column.sql @@ -0,0 +1,3 @@ +ALTER TABLE changelog_entries + ADD COLUMN data_type VARCHAR(255) NOT NULL; + From 5f7163c341827b4812dcaa3ce47d62ab769a8d55 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 22 Jun 2023 15:27:42 +0100 Subject: [PATCH 69/83] Feat(Gate): Add logic to create changelog from Output Changes --- .../tractusx/bpdm/gate/service/AddressService.kt | 5 +++++ .../service/LegalEntityPersistenceService.kt | 16 +++++++--------- .../bpdm/gate/service/LegalEntityService.kt | 2 +- .../bpdm/gate/service/SitePersistenceService.kt | 16 +++++++--------- ...0_0_1__update_change_log_entry_add_column.sql | 3 --- ...0_0_2__update_change_log_entry_add_column.sql | 3 +++ 6 files changed, 23 insertions(+), 22 deletions(-) delete mode 100644 bpdm-gate/src/main/resources/db/migration/V4_0_0_1__update_change_log_entry_add_column.sql create mode 100644 bpdm-gate/src/main/resources/db/migration/V4_0_0_2__update_change_log_entry_add_column.sql diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index e79f30516..ec3b91819 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -124,6 +124,11 @@ class AddressService( **/ fun upsertOutputAddresses(addresses: Collection) { + // create changelog entry if all goes well from saasClient + addresses.forEach { address -> + changelogRepository.save(ChangelogEntry(address.externalId, LsaType.ADDRESS,OutputInputEnum.Output)) + } + addressPersistenceService.persistOutputAddressBP(addresses, OutputInputEnum.Output) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt index 49ed7dab4..5686a4693 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityPersistenceService.kt @@ -28,10 +28,6 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.entity.* import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository -import org.eclipse.tractusx.bpdm.gate.entity.AddressState -import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity -import org.eclipse.tractusx.bpdm.gate.entity.LogisticAddress -import org.eclipse.tractusx.bpdm.gate.entity.Name import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.springframework.http.HttpStatus @@ -65,18 +61,18 @@ class LegalEntityPersistenceService( updateLegalEntity(existingLegalEntity, legalEntity, logisticAddressRecord) gateLegalEntityRepository.save(existingLegalEntity) - saveChangelog(legalEntity) + saveChangelog(legalEntity.externalId,datatype) } ?: run { gateLegalEntityRepository.save(fullLegalEntity) - saveChangelog(legalEntity) + saveChangelog(legalEntity.externalId,datatype) } } } //Creates Changelog For both Legal Entity and Logistic Address when they are created or updated - private fun saveChangelog(legalEntity: LegalEntityGateInputRequest) { - changelogRepository.save(ChangelogEntry(getMainAddressForLegalEntityExternalId(legalEntity.externalId), LsaType.ADDRESS)) - changelogRepository.save(ChangelogEntry(legalEntity.externalId, LsaType.LEGAL_ENTITY)) + private fun saveChangelog(externalId: String,outputInputEnum: OutputInputEnum) { + changelogRepository.save(ChangelogEntry(getMainAddressForLegalEntityExternalId(externalId), LsaType.ADDRESS,outputInputEnum)) + changelogRepository.save(ChangelogEntry(externalId, LsaType.LEGAL_ENTITY,outputInputEnum)) } private fun updateLegalEntity( @@ -128,11 +124,13 @@ class LegalEntityPersistenceService( updateLegalEntityOutput(existingLegalEntity, legalEntity, logisticAddressRecord) gateLegalEntityRepository.save(existingLegalEntity) + saveChangelog(legalEntity.externalId,datatype) } ?: run { if (legalEntityRecord.find { it.externalId == fullLegalEntity.externalId && it.dataType == OutputInputEnum.Input } == null) { throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Legal Entity doesn't exist") } else { gateLegalEntityRepository.save(fullLegalEntity) + saveChangelog(legalEntity.externalId,datatype) } } } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 6a4d4b575..7626cd12f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -86,7 +86,7 @@ class LegalEntityService( */ fun getLegalEntitiesOutput(externalIds: Collection?, page: Int, size: Int): PageResponse { - val legalEntityPage = if (externalIds != null && externalIds.isNotEmpty()) { + val legalEntityPage = if (!externalIds.isNullOrEmpty()) { legalEntityRepository.findByExternalIdInAndDataType(externalIds, OutputInputEnum.Output, PageRequest.of(page, size)) } else { legalEntityRepository.findByDataType(OutputInputEnum.Output, PageRequest.of(page, size)) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt index e3ac6518e..cb4e465a8 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SitePersistenceService.kt @@ -27,10 +27,6 @@ import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.entity.* import org.eclipse.tractusx.bpdm.gate.repository.ChangelogRepository -import org.eclipse.tractusx.bpdm.gate.entity.AddressState -import org.eclipse.tractusx.bpdm.gate.entity.LegalEntity -import org.eclipse.tractusx.bpdm.gate.entity.LogisticAddress -import org.eclipse.tractusx.bpdm.gate.entity.Site import org.eclipse.tractusx.bpdm.gate.repository.GateAddressRepository import org.eclipse.tractusx.bpdm.gate.repository.LegalEntityRepository import org.eclipse.tractusx.bpdm.gate.repository.SiteRepository @@ -66,18 +62,18 @@ class SitePersistenceService( updateAddress(logisticAddressRecord, fullSite.mainAddress) updateSite(existingSite, site, legalEntityRecord) siteRepository.save(existingSite) - saveChangelog(site) + saveChangelog(site.externalId,datatype) } ?: run { siteRepository.save(fullSite) - saveChangelog(site) + saveChangelog(site.externalId,datatype) } } } //Creates Changelog For both Site and Logistic Address when they are created or updated - private fun saveChangelog(site: SiteGateInputRequest) { - changelogRepository.save(ChangelogEntry(getMainAddressForSiteExternalId(site.externalId), LsaType.ADDRESS)) - changelogRepository.save(ChangelogEntry(site.externalId, LsaType.SITE)) + private fun saveChangelog(externalId: String,outputInputEnum: OutputInputEnum) { + changelogRepository.save(ChangelogEntry(getMainAddressForSiteExternalId(externalId), LsaType.ADDRESS,outputInputEnum)) + changelogRepository.save(ChangelogEntry(externalId, LsaType.SITE,outputInputEnum)) } private fun getAddressRecord(externalId: String, datatype: OutputInputEnum): LogisticAddress { @@ -134,11 +130,13 @@ class SitePersistenceService( updateAddress(logisticAddressRecord, fullSite.mainAddress) updateSiteOutput(existingSite, site, legalEntityRecord) siteRepository.save(existingSite) + saveChangelog(site.externalId,datatype) } ?: run { if (siteRecord.find { it.externalId == fullSite.externalId && it.dataType == OutputInputEnum.Input } == null) { throw ResponseStatusException(HttpStatus.BAD_REQUEST, "Input Site doesn't exist") } else { siteRepository.save(fullSite) + saveChangelog(site.externalId,datatype) } } } diff --git a/bpdm-gate/src/main/resources/db/migration/V4_0_0_1__update_change_log_entry_add_column.sql b/bpdm-gate/src/main/resources/db/migration/V4_0_0_1__update_change_log_entry_add_column.sql deleted file mode 100644 index 9b93f0200..000000000 --- a/bpdm-gate/src/main/resources/db/migration/V4_0_0_1__update_change_log_entry_add_column.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE changelog_entries - ADD COLUMN data_type VARCHAR(255) NOT NULL; - diff --git a/bpdm-gate/src/main/resources/db/migration/V4_0_0_2__update_change_log_entry_add_column.sql b/bpdm-gate/src/main/resources/db/migration/V4_0_0_2__update_change_log_entry_add_column.sql new file mode 100644 index 000000000..33547b8ab --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V4_0_0_2__update_change_log_entry_add_column.sql @@ -0,0 +1,3 @@ +ALTER TABLE changelog_entries + ADD COLUMN data_type VARCHAR(255) NOT NULL DEFAULT 'Input'; + From 5fa6dae156310c32aaac845c01b331b346552394 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Tue, 20 Jun 2023 12:52:27 +0100 Subject: [PATCH 70/83] Feat(Bridge): Configured Spring Security to use roles from JWT for API authorization --- bpdm-bridge-dummy/pom.xml | 4 +++ .../BpdmSecurityConfigurerAdapterImpl.kt | 2 ++ .../dummy/config/BridgeAuthProperties.kt | 31 +++++++++++++++++++ .../dummy/controller/BridgeController.kt | 6 +++- .../src/main/resources/application.properties | 1 + 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BridgeAuthProperties.kt diff --git a/bpdm-bridge-dummy/pom.xml b/bpdm-bridge-dummy/pom.xml index a2d8263a1..9e2d02625 100644 --- a/bpdm-bridge-dummy/pom.xml +++ b/bpdm-bridge-dummy/pom.xml @@ -76,6 +76,10 @@ org.springframework.boot spring-boot-starter-oauth2-client + + org.springframework.boot + spring-boot-starter-security + org.springframework.boot spring-boot-configuration-processor diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt index eff0ac21c..48af81a8c 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt @@ -24,11 +24,13 @@ import org.eclipse.tractusx.bpdm.common.config.CustomJwtAuthenticationConverter import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.springframework.context.annotation.Configuration import org.springframework.http.HttpMethod +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.web.util.matcher.AntPathRequestMatcher @Configuration +@EnableMethodSecurity(prePostEnabled = true) class BpdmSecurityConfigurerAdapterImpl( val securityConfigProperties: SecurityConfigProperties ) : BpdmSecurityConfigurerAdapter { diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BridgeAuthProperties.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BridgeAuthProperties.kt new file mode 100644 index 000000000..afb8c62c5 --- /dev/null +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BridgeAuthProperties.kt @@ -0,0 +1,31 @@ +/******************************************************************************* + * 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") +class BridgeAuthProperties { + var syncAuthorities: List = listOf() + + val syncAuthority: String + get() = syncAuthorities.joinToString(", ") { "ROLE_$it" } +} \ No newline at end of file diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt index 274edd8d8..c5878cd1f 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt @@ -19,8 +19,10 @@ package com.catenax.bpdm.bridge.dummy.controller +import com.catenax.bpdm.bridge.dummy.config.BridgeAuthProperties import com.catenax.bpdm.bridge.dummy.service.SyncService import io.swagger.v3.oas.annotations.Operation +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @@ -28,13 +30,15 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/api/bridge") class BridgeController( - val syncService: SyncService + val syncService: SyncService, + val bridgeAuthProperties: BridgeAuthProperties ) { @Operation( summary = "Start sync between Gate and Pool" ) @PostMapping("/sync") + @PreAuthorize("hasAnyAuthority(@bridgeController.bridgeAuthProperties.syncAuthority)") fun triggerSync() { syncService.sync() } diff --git a/bpdm-bridge-dummy/src/main/resources/application.properties b/bpdm-bridge-dummy/src/main/resources/application.properties index 048d7f263..e6dad87ea 100644 --- a/bpdm-bridge-dummy/src/main/resources/application.properties +++ b/bpdm-bridge-dummy/src/main/resources/application.properties @@ -32,6 +32,7 @@ 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/ +bpdm.bridge.syncAuthorities=sync_company_data ## #Springdoc swagger configuration springdoc.api-docs.enabled=true From 6faf53c4c07fd85514733377c0071a44de8f22cc Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 22 Jun 2023 16:30:16 +0100 Subject: [PATCH 71/83] Feat(Bridge-Common): Configured Spring Security to use roles from JWT on Common --- .../bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt | 2 -- .../catenax/bpdm/bridge/dummy/config/BridgeAuthProperties.kt | 3 ++- .../catenax/bpdm/bridge/dummy/controller/BridgeController.kt | 2 +- .../src/main/resources/application-auth.properties | 1 + bpdm-bridge-dummy/src/main/resources/application.properties | 2 +- .../org/eclipse/tractusx/bpdm/common/config/SecurityConfig.kt | 2 ++ 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt index 48af81a8c..eff0ac21c 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BpdmSecurityConfigurerAdapterImpl.kt @@ -24,13 +24,11 @@ import org.eclipse.tractusx.bpdm.common.config.CustomJwtAuthenticationConverter import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.springframework.context.annotation.Configuration import org.springframework.http.HttpMethod -import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.web.util.matcher.AntPathRequestMatcher @Configuration -@EnableMethodSecurity(prePostEnabled = true) class BpdmSecurityConfigurerAdapterImpl( val securityConfigProperties: SecurityConfigProperties ) : BpdmSecurityConfigurerAdapter { diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BridgeAuthProperties.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BridgeAuthProperties.kt index afb8c62c5..2915a8dba 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BridgeAuthProperties.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/config/BridgeAuthProperties.kt @@ -20,8 +20,9 @@ package com.catenax.bpdm.bridge.dummy.config import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.context.annotation.Configuration - +@Configuration @ConfigurationProperties(prefix = "bpdm.bridge") class BridgeAuthProperties { var syncAuthorities: List = listOf() diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt index c5878cd1f..d7aada2eb 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt @@ -38,7 +38,7 @@ class BridgeController( summary = "Start sync between Gate and Pool" ) @PostMapping("/sync") - @PreAuthorize("hasAnyAuthority(@bridgeController.bridgeAuthProperties.syncAuthority)") + @PreAuthorize("hasAnyAuthority(@bridgeAuthProperties.syncAuthority)") fun triggerSync() { syncService.sync() } diff --git a/bpdm-bridge-dummy/src/main/resources/application-auth.properties b/bpdm-bridge-dummy/src/main/resources/application-auth.properties index 2f3c2d57d..7a8c7d614 100644 --- a/bpdm-bridge-dummy/src/main/resources/application-auth.properties +++ b/bpdm-bridge-dummy/src/main/resources/application-auth.properties @@ -20,6 +20,7 @@ # Security config (defined in common) for restricting access to the bridge dummy resource server bpdm.security.enabled=true bpdm.security.cors-origins=* +bpdm.bridge.syncAuthorities=sync_company_data # OAuth configuration bpdm.security.client-id=BPDM_BRIDGE_DUMMY bpdm.security.realm=master diff --git a/bpdm-bridge-dummy/src/main/resources/application.properties b/bpdm-bridge-dummy/src/main/resources/application.properties index e6dad87ea..6c457e705 100644 --- a/bpdm-bridge-dummy/src/main/resources/application.properties +++ b/bpdm-bridge-dummy/src/main/resources/application.properties @@ -32,7 +32,7 @@ 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/ -bpdm.bridge.syncAuthorities=sync_company_data + ## #Springdoc swagger configuration springdoc.api-docs.enabled=true diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/config/SecurityConfig.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/config/SecurityConfig.kt index e518d1722..9975fc72b 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/config/SecurityConfig.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/config/SecurityConfig.kt @@ -23,6 +23,7 @@ import mu.KotlinLogging import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer @@ -57,6 +58,7 @@ class NoAuthenticationConfig { havingValue = "true" ) @Configuration +@EnableMethodSecurity(prePostEnabled = true) class OAuthSecurityConfig( val configProperties: SecurityConfigProperties, val bpdmSecurityConfigurerAdapter: BpdmSecurityConfigurerAdapter From 3319d8866ee8be2fdb46df4a3074ce141775c1db Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 23 Jun 2023 10:51:42 +0100 Subject: [PATCH 72/83] Feat(Bridge): Remove unnecessary value from controller --- .../catenax/bpdm/bridge/dummy/controller/BridgeController.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt index d7aada2eb..6d9e66fd3 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/controller/BridgeController.kt @@ -19,7 +19,6 @@ package com.catenax.bpdm.bridge.dummy.controller -import com.catenax.bpdm.bridge.dummy.config.BridgeAuthProperties import com.catenax.bpdm.bridge.dummy.service.SyncService import io.swagger.v3.oas.annotations.Operation import org.springframework.security.access.prepost.PreAuthorize @@ -30,8 +29,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/api/bridge") class BridgeController( - val syncService: SyncService, - val bridgeAuthProperties: BridgeAuthProperties + val syncService: SyncService ) { @Operation( From 2b32254d8f0d9eed3b5dcda69522ef310d024510 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 22 Jun 2023 12:47:10 +0100 Subject: [PATCH 73/83] Feat(Gate): Configured Spring Security to use roles from JWT for API authorization --- bpdm-gate/pom.xml | 5 ++++ .../BpdmSecurityConfigurerAdapterImpl.kt | 2 ++ .../config/GateSecurityConfigProperties.kt | 25 +++++++++++++++++-- .../bpdm/gate/controller/AddressController.kt | 18 +++++++++++-- .../gate/controller/ChangelogController.kt | 9 ++++++- .../gate/controller/LegalEntityController.kt | 16 +++++++++--- .../gate/controller/SharingStateController.kt | 11 +++++--- .../bpdm/gate/controller/SiteController.kt | 14 ++++++++++- .../src/main/resources/application.properties | 4 +++ 9 files changed, 91 insertions(+), 13 deletions(-) diff --git a/bpdm-gate/pom.xml b/bpdm-gate/pom.xml index 2e191cd9a..48d8123f9 100644 --- a/bpdm-gate/pom.xml +++ b/bpdm-gate/pom.xml @@ -152,6 +152,11 @@ postgresql test + + org.springframework.security + spring-security-test + test + diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/BpdmSecurityConfigurerAdapterImpl.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/BpdmSecurityConfigurerAdapterImpl.kt index 12804ccb0..8bcd835da 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/BpdmSecurityConfigurerAdapterImpl.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/BpdmSecurityConfigurerAdapterImpl.kt @@ -24,11 +24,13 @@ import org.eclipse.tractusx.bpdm.common.config.CustomJwtAuthenticationConverter import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.springframework.context.annotation.Configuration import org.springframework.http.HttpMethod +import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.web.util.matcher.AntPathRequestMatcher @Configuration +@EnableMethodSecurity(prePostEnabled = true) class BpdmSecurityConfigurerAdapterImpl( val securityConfigProperties: SecurityConfigProperties ) : BpdmSecurityConfigurerAdapter { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/GateSecurityConfigProperties.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/GateSecurityConfigProperties.kt index 3af63d8f5..50e2b4adc 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/GateSecurityConfigProperties.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/GateSecurityConfigProperties.kt @@ -25,5 +25,26 @@ import org.springframework.boot.context.properties.ConfigurationProperties @ConfigurationProperties(prefix = "bpdm.gate-security") data class GateSecurityConfigProperties( val oauth2ClientRegistration: String = "gate-client", - val poolSecurityEnabled: Boolean = false -) + val poolSecurityEnabled: Boolean = false, + val readCompanyInputData: String = "read_company_input_data", + val changeCompanyInputData: String = "change_company_input_data", + val readCompanyOutputData: String = "read_company_output_data", + val changeCompanyOutputData: String = "change_company_output_data" +){ + + fun getReadCompanyInputDataAsRole(): String { + return "ROLE_$readCompanyInputData" + } + + fun getChangeCompanyInputDataAsRole(): String { + return "ROLE_$changeCompanyInputData" + } + + fun getReadCompanyOutputDataAsRole(): String { + return "ROLE_$readCompanyOutputData" + } + + fun getChangeCompanyOutputDataAsRole(): String { + return "ROLE_$changeCompanyOutputData" + } +} diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt index ab2111418..8cd34e07b 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.controller +import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateAddressApi @@ -27,22 +28,29 @@ import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties +import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.AddressService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.RestController @RestController class AddressController( private val addressService: AddressService, - private val apiConfigProperties: ApiConfigProperties + private val apiConfigProperties: ApiConfigProperties, + val gateSecurityConfigProperties: GateSecurityConfigProperties, + val securityConfigProperties: SecurityConfigProperties ) : GateAddressApi { + + @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.getChangeCompanyInputDataAsRole())") override fun upsertAddresses(addresses: Collection): ResponseEntity { if (addresses.size > apiConfigProperties.upsertLimit || addresses.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) } + if (addresses.any { (it.siteExternalId == null && it.legalEntityExternalId == null) || (it.siteExternalId != null && it.legalEntityExternalId != null) }) { @@ -52,10 +60,14 @@ class AddressController( return ResponseEntity(HttpStatus.OK) } + + @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getAddressByExternalId(externalId: String): AddressGateInputResponse { + gateSecurityConfigProperties.getReadCompanyOutputDataAsRole() return addressService.getAddressByExternalId(externalId) } + @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getAddressesByExternalIds( paginationRequest: PaginationRequest, externalIds: Collection @@ -63,10 +75,11 @@ class AddressController( return addressService.getAddresses(page = paginationRequest.page, size = paginationRequest.size, externalIds = externalIds) } + @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getAddresses(paginationRequest: PaginationRequest): PageResponse { return addressService.getAddresses(page = paginationRequest.page, size = paginationRequest.size) } - + @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getAddressesOutput( paginationRequest: PaginationRequest, externalIds: Collection? @@ -74,6 +87,7 @@ class AddressController( return addressService.getAddressesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } + @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") override fun putAddressesOutput(addresses: Collection): ResponseEntity { if (addresses.size > apiConfigProperties.upsertLimit || addresses.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index ff3f6a7bd..1308dfca0 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -19,28 +19,35 @@ package org.eclipse.tractusx.bpdm.gate.controller +import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.GateChangelogApi import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogResponse import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogResponse +import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties import org.eclipse.tractusx.bpdm.gate.service.ChangelogService +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.RestController @RestController @Validated class ChangelogController( - private val changelogService: ChangelogService + private val changelogService: ChangelogService, + val gateSecurityConfigProperties: GateSecurityConfigProperties, + val securityConfigProperties: SecurityConfigProperties ) : GateChangelogApi { + @PreAuthorize("!@changelogController.securityConfigProperties.enabled || hasAuthority(@changelogController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getInputChangelog( paginationRequest: PaginationRequest, searchRequest: ChangeLogSearchRequest ): PageChangeLogResponse { return changelogService.getChangeLogEntries(searchRequest.externalIds, searchRequest.lsaTypes, searchRequest.fromTime,OutputInputEnum.Input, paginationRequest.page, paginationRequest.size) } + @PreAuthorize("!@changelogController.securityConfigProperties.enabled || hasAuthority(@changelogController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getOutputChangelog(paginationRequest: PaginationRequest, searchRequest: ChangeLogSearchRequest): PageChangeLogResponse { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt index dbc2818ac..4dd085257 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.controller +import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateLegalEntityApi @@ -27,18 +28,22 @@ import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties +import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.LegalEntityService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.RestController @RestController class LegalEntityController( val legalEntityService: LegalEntityService, - val apiConfigProperties: ApiConfigProperties + val apiConfigProperties: ApiConfigProperties, + val gateSecurityConfigProperties: GateSecurityConfigProperties, + val securityConfigProperties: SecurityConfigProperties ) : GateLegalEntityApi { - + @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getChangeCompanyInputDataAsRole())") override fun upsertLegalEntities(legalEntities: Collection): ResponseEntity { if (legalEntities.size > apiConfigProperties.upsertLimit || legalEntities.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) @@ -47,10 +52,12 @@ class LegalEntityController( return ResponseEntity(HttpStatus.OK) } + @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getLegalEntityByExternalId(externalId: String): LegalEntityGateInputResponse { return legalEntityService.getLegalEntityByExternalId(externalId) } + @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getLegalEntitiesByExternalIds( paginationRequest: PaginationRequest, externalIds: Collection @@ -58,17 +65,18 @@ class LegalEntityController( return legalEntityService.getLegalEntities(page = paginationRequest.page, size = paginationRequest.size, externalIds = externalIds) } + @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getLegalEntities(paginationRequest: PaginationRequest): PageResponse { return legalEntityService.getLegalEntities(page = paginationRequest.page, size = paginationRequest.size) } - + @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getLegalEntitiesOutput( paginationRequest: PaginationRequest, externalIds: Collection? ): PageResponse { return legalEntityService.getLegalEntitiesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } - + @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") override fun upsertLegalEntitiesOutput(legalEntities: Collection): ResponseEntity { if (legalEntities.size > apiConfigProperties.upsertLimit || legalEntities.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt index 18d20c2ce..90b4776d2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt @@ -20,28 +20,33 @@ package org.eclipse.tractusx.bpdm.gate.controller import mu.KotlinLogging +import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateSharingStateApi import org.eclipse.tractusx.bpdm.gate.api.model.LsaType import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateDto +import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties import org.eclipse.tractusx.bpdm.gate.service.SharingStateService +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.RestController @RestController class SharingStateController( - val sharingStateService: SharingStateService + val sharingStateService: SharingStateService, + val gateSecurityConfigProperties: GateSecurityConfigProperties, + val securityConfigProperties: SecurityConfigProperties ) : GateSharingStateApi { private val logger = KotlinLogging.logger { } + @PreAuthorize("!@sharingStateController.securityConfigProperties.enabled || hasAuthority(@sharingStateController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getSharingStates(paginationRequest: PaginationRequest, lsaType: LsaType?, externalIds: Collection?): PageResponse { - return sharingStateService.findSharingStates(paginationRequest, lsaType, externalIds) } + @PreAuthorize("!@sharingStateController.securityConfigProperties.enabled || hasAuthority(@sharingStateController.gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") override fun upsertSharingState(request: SharingStateDto) { - logger.info { "upsertSharingState() called with $request" } sharingStateService.upsertSharingState(request) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt index 6aba848c5..9a570ba46 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.gate.controller +import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateSiteApi @@ -27,18 +28,24 @@ import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputResponse import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateOutputResponse import org.eclipse.tractusx.bpdm.gate.config.ApiConfigProperties +import org.eclipse.tractusx.bpdm.gate.config.GateSecurityConfigProperties import org.eclipse.tractusx.bpdm.gate.containsDuplicates import org.eclipse.tractusx.bpdm.gate.service.SiteService import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity +import org.springframework.security.access.prepost.PreAuthorize import org.springframework.web.bind.annotation.RestController @RestController class SiteController( val siteService: SiteService, - val apiConfigProperties: ApiConfigProperties + val apiConfigProperties: ApiConfigProperties, + val gateSecurityConfigProperties: GateSecurityConfigProperties, + val securityConfigProperties: SecurityConfigProperties ) : GateSiteApi { + + @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getChangeCompanyInputDataAsRole())") override fun upsertSites(sites: Collection): ResponseEntity { if (sites.size > apiConfigProperties.upsertLimit || sites.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) @@ -47,10 +54,12 @@ class SiteController( return ResponseEntity(HttpStatus.OK) } + @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getSiteByExternalId(externalId: String): SiteGateInputResponse { return siteService.getSiteByExternalId(externalId) } + @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getSitesByExternalIds( paginationRequest: PaginationRequest, externalIds: Collection @@ -58,14 +67,17 @@ class SiteController( return siteService.getSites(page = paginationRequest.page, size = paginationRequest.size, externalIds = externalIds) } + @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getSites(paginationRequest: PaginationRequest): PageResponse { return siteService.getSites(page = paginationRequest.page, size = paginationRequest.size) } + @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getSitesOutput(paginationRequest: PaginationRequest, externalIds: Collection?): PageResponse { return siteService.getSitesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } + @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") override fun upsertSitesOutput(sites: Collection): ResponseEntity { if (sites.size > apiConfigProperties.upsertLimit || sites.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) diff --git a/bpdm-gate/src/main/resources/application.properties b/bpdm-gate/src/main/resources/application.properties index 91605312c..5adf151ff 100644 --- a/bpdm-gate/src/main/resources/application.properties +++ b/bpdm-gate/src/main/resources/application.properties @@ -52,6 +52,10 @@ management.health.readinessState.enabled=true # Connection to the pool # No auth on default bpdm.gate-security.pool-security-enabled=false +bpdm.gate-security.readCompanyInputData=read_company_input_data +bpdm.gate-security.changeCompanyInputData=change_company_input_data +bpdm.gate-security.readCompanyOutputData=read_company_output_data +bpdm.gate-security.changeCompanyOutputData=change_company_output_data bpdm.pool.base-url=http://localhost:8080/api/catena #No security on default bpdm.security.enabled=false From 085cd4bccc8505883b20139bb149d48709e8cbc8 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Thu, 22 Jun 2023 17:52:18 +0100 Subject: [PATCH 74/83] Feat(Gate-Common): Configured Spring Security to use roles from JWT on Common --- .../config/BpdmSecurityConfigurerAdapterImpl.kt | 2 -- .../gate/config/GateSecurityConfigProperties.kt | 14 ++++++++------ .../bpdm/gate/controller/AddressController.kt | 16 +++++++--------- .../bpdm/gate/controller/ChangelogController.kt | 8 +++----- .../gate/controller/LegalEntityController.kt | 16 +++++++--------- .../gate/controller/SharingStateController.kt | 8 +++----- .../bpdm/gate/controller/SiteController.kt | 16 +++++++--------- .../main/resources/application-auth.properties | 4 ++++ .../src/main/resources/application.properties | 4 ---- 9 files changed, 39 insertions(+), 49 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/BpdmSecurityConfigurerAdapterImpl.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/BpdmSecurityConfigurerAdapterImpl.kt index 8bcd835da..12804ccb0 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/BpdmSecurityConfigurerAdapterImpl.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/BpdmSecurityConfigurerAdapterImpl.kt @@ -24,13 +24,11 @@ import org.eclipse.tractusx.bpdm.common.config.CustomJwtAuthenticationConverter import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.springframework.context.annotation.Configuration import org.springframework.http.HttpMethod -import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.web.util.matcher.AntPathRequestMatcher @Configuration -@EnableMethodSecurity(prePostEnabled = true) class BpdmSecurityConfigurerAdapterImpl( val securityConfigProperties: SecurityConfigProperties ) : BpdmSecurityConfigurerAdapter { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/GateSecurityConfigProperties.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/GateSecurityConfigProperties.kt index 50e2b4adc..742c611f6 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/GateSecurityConfigProperties.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/config/GateSecurityConfigProperties.kt @@ -20,16 +20,18 @@ package org.eclipse.tractusx.bpdm.gate.config import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.context.annotation.Configuration +@Configuration @ConfigurationProperties(prefix = "bpdm.gate-security") data class GateSecurityConfigProperties( - val oauth2ClientRegistration: String = "gate-client", - val poolSecurityEnabled: Boolean = false, - val readCompanyInputData: String = "read_company_input_data", - val changeCompanyInputData: String = "change_company_input_data", - val readCompanyOutputData: String = "read_company_output_data", - val changeCompanyOutputData: String = "change_company_output_data" + var oauth2ClientRegistration: String = "gate-client", + var poolSecurityEnabled: Boolean = false, + var readCompanyInputData: String = "read_company_input_data", + var changeCompanyInputData: String = "change_company_input_data", + var readCompanyOutputData: String = "read_company_output_data", + var changeCompanyOutputData: String = "change_company_output_data" ){ fun getReadCompanyInputDataAsRole(): String { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt index 8cd34e07b..75df19409 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/AddressController.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.controller -import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateAddressApi @@ -40,12 +39,11 @@ import org.springframework.web.bind.annotation.RestController class AddressController( private val addressService: AddressService, private val apiConfigProperties: ApiConfigProperties, - val gateSecurityConfigProperties: GateSecurityConfigProperties, - val securityConfigProperties: SecurityConfigProperties + val gateSecurityConfigProperties: GateSecurityConfigProperties ) : GateAddressApi { - @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.getChangeCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getChangeCompanyInputDataAsRole())") override fun upsertAddresses(addresses: Collection): ResponseEntity { if (addresses.size > apiConfigProperties.upsertLimit || addresses.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) @@ -61,13 +59,13 @@ class AddressController( } - @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getAddressByExternalId(externalId: String): AddressGateInputResponse { gateSecurityConfigProperties.getReadCompanyOutputDataAsRole() return addressService.getAddressByExternalId(externalId) } - @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getAddressesByExternalIds( paginationRequest: PaginationRequest, externalIds: Collection @@ -75,11 +73,11 @@ class AddressController( return addressService.getAddresses(page = paginationRequest.page, size = paginationRequest.size, externalIds = externalIds) } - @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getAddresses(paginationRequest: PaginationRequest): PageResponse { return addressService.getAddresses(page = paginationRequest.page, size = paginationRequest.size) } - @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getAddressesOutput( paginationRequest: PaginationRequest, externalIds: Collection? @@ -87,7 +85,7 @@ class AddressController( return addressService.getAddressesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } - @PreAuthorize("!@addressController.securityConfigProperties.enabled || hasAuthority(@addressController.gateSecurityConfigProperties.gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") override fun putAddressesOutput(addresses: Collection): ResponseEntity { if (addresses.size > apiConfigProperties.upsertLimit || addresses.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 1308dfca0..99ff15003 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.controller -import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.GateChangelogApi @@ -36,18 +35,17 @@ import org.springframework.web.bind.annotation.RestController @Validated class ChangelogController( private val changelogService: ChangelogService, - val gateSecurityConfigProperties: GateSecurityConfigProperties, - val securityConfigProperties: SecurityConfigProperties + val gateSecurityConfigProperties: GateSecurityConfigProperties ) : GateChangelogApi { - @PreAuthorize("!@changelogController.securityConfigProperties.enabled || hasAuthority(@changelogController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getInputChangelog( paginationRequest: PaginationRequest, searchRequest: ChangeLogSearchRequest ): PageChangeLogResponse { return changelogService.getChangeLogEntries(searchRequest.externalIds, searchRequest.lsaTypes, searchRequest.fromTime,OutputInputEnum.Input, paginationRequest.page, paginationRequest.size) } - @PreAuthorize("!@changelogController.securityConfigProperties.enabled || hasAuthority(@changelogController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getOutputChangelog(paginationRequest: PaginationRequest, searchRequest: ChangeLogSearchRequest): PageChangeLogResponse { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt index 4dd085257..ac08f177b 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityController.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.controller -import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateLegalEntityApi @@ -40,10 +39,9 @@ import org.springframework.web.bind.annotation.RestController class LegalEntityController( val legalEntityService: LegalEntityService, val apiConfigProperties: ApiConfigProperties, - val gateSecurityConfigProperties: GateSecurityConfigProperties, - val securityConfigProperties: SecurityConfigProperties + val gateSecurityConfigProperties: GateSecurityConfigProperties ) : GateLegalEntityApi { - @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getChangeCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getChangeCompanyInputDataAsRole())") override fun upsertLegalEntities(legalEntities: Collection): ResponseEntity { if (legalEntities.size > apiConfigProperties.upsertLimit || legalEntities.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) @@ -52,12 +50,12 @@ class LegalEntityController( return ResponseEntity(HttpStatus.OK) } - @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getLegalEntityByExternalId(externalId: String): LegalEntityGateInputResponse { return legalEntityService.getLegalEntityByExternalId(externalId) } - @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getLegalEntitiesByExternalIds( paginationRequest: PaginationRequest, externalIds: Collection @@ -65,18 +63,18 @@ class LegalEntityController( return legalEntityService.getLegalEntities(page = paginationRequest.page, size = paginationRequest.size, externalIds = externalIds) } - @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getLegalEntities(paginationRequest: PaginationRequest): PageResponse { return legalEntityService.getLegalEntities(page = paginationRequest.page, size = paginationRequest.size) } - @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getLegalEntitiesOutput( paginationRequest: PaginationRequest, externalIds: Collection? ): PageResponse { return legalEntityService.getLegalEntitiesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } - @PreAuthorize("!@legalEntityController.securityConfigProperties.enabled || hasAuthority(@legalEntityController.gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") override fun upsertLegalEntitiesOutput(legalEntities: Collection): ResponseEntity { if (legalEntities.size > apiConfigProperties.upsertLimit || legalEntities.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt index 90b4776d2..26237825d 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt @@ -20,7 +20,6 @@ package org.eclipse.tractusx.bpdm.gate.controller import mu.KotlinLogging -import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateSharingStateApi @@ -34,18 +33,17 @@ import org.springframework.web.bind.annotation.RestController @RestController class SharingStateController( val sharingStateService: SharingStateService, - val gateSecurityConfigProperties: GateSecurityConfigProperties, - val securityConfigProperties: SecurityConfigProperties + val gateSecurityConfigProperties: GateSecurityConfigProperties ) : GateSharingStateApi { private val logger = KotlinLogging.logger { } - @PreAuthorize("!@sharingStateController.securityConfigProperties.enabled || hasAuthority(@sharingStateController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") + @PreAuthorize("hasAuthority(gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getSharingStates(paginationRequest: PaginationRequest, lsaType: LsaType?, externalIds: Collection?): PageResponse { return sharingStateService.findSharingStates(paginationRequest, lsaType, externalIds) } - @PreAuthorize("!@sharingStateController.securityConfigProperties.enabled || hasAuthority(@sharingStateController.gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") + @PreAuthorize("hasAuthority(gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") override fun upsertSharingState(request: SharingStateDto) { logger.info { "upsertSharingState() called with $request" } sharingStateService.upsertSharingState(request) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt index 9a570ba46..4914c88b9 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SiteController.kt @@ -19,7 +19,6 @@ package org.eclipse.tractusx.bpdm.gate.controller -import org.eclipse.tractusx.bpdm.common.config.SecurityConfigProperties import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse import org.eclipse.tractusx.bpdm.gate.api.GateSiteApi @@ -40,12 +39,11 @@ import org.springframework.web.bind.annotation.RestController class SiteController( val siteService: SiteService, val apiConfigProperties: ApiConfigProperties, - val gateSecurityConfigProperties: GateSecurityConfigProperties, - val securityConfigProperties: SecurityConfigProperties + val gateSecurityConfigProperties: GateSecurityConfigProperties ) : GateSiteApi { - @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getChangeCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getChangeCompanyInputDataAsRole())") override fun upsertSites(sites: Collection): ResponseEntity { if (sites.size > apiConfigProperties.upsertLimit || sites.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) @@ -54,12 +52,12 @@ class SiteController( return ResponseEntity(HttpStatus.OK) } - @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getSiteByExternalId(externalId: String): SiteGateInputResponse { return siteService.getSiteByExternalId(externalId) } - @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getSitesByExternalIds( paginationRequest: PaginationRequest, externalIds: Collection @@ -67,17 +65,17 @@ class SiteController( return siteService.getSites(page = paginationRequest.page, size = paginationRequest.size, externalIds = externalIds) } - @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getSites(paginationRequest: PaginationRequest): PageResponse { return siteService.getSites(page = paginationRequest.page, size = paginationRequest.size) } - @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getSitesOutput(paginationRequest: PaginationRequest, externalIds: Collection?): PageResponse { return siteService.getSitesOutput(externalIds = externalIds, page = paginationRequest.page, size = paginationRequest.size) } - @PreAuthorize("!@siteController.securityConfigProperties.enabled || hasAuthority(@siteController.gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") + @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getChangeCompanyOutputDataAsRole())") override fun upsertSitesOutput(sites: Collection): ResponseEntity { if (sites.size > apiConfigProperties.upsertLimit || sites.map { it.externalId }.containsDuplicates()) { return ResponseEntity(HttpStatus.BAD_REQUEST) diff --git a/bpdm-gate/src/main/resources/application-auth.properties b/bpdm-gate/src/main/resources/application-auth.properties index 723616fcc..dc877ff39 100644 --- a/bpdm-gate/src/main/resources/application-auth.properties +++ b/bpdm-gate/src/main/resources/application-auth.properties @@ -19,6 +19,10 @@ # Enables and configures security for the application bpdm.security.enabled=true bpdm.security.cors-origins=* +bpdm.gate-security.readCompanyInputData=read_company_input_data +bpdm.gate-security.changeCompanyInputData=change_company_input_data +bpdm.gate-security.readCompanyOutputData=read_company_output_data +bpdm.gate-security.changeCompanyOutputData=change_company_output_data #Generic OAuth configuration bpdm.security.client-id=BPDM_GATE bpdm.security.realm=master diff --git a/bpdm-gate/src/main/resources/application.properties b/bpdm-gate/src/main/resources/application.properties index 5adf151ff..91605312c 100644 --- a/bpdm-gate/src/main/resources/application.properties +++ b/bpdm-gate/src/main/resources/application.properties @@ -52,10 +52,6 @@ management.health.readinessState.enabled=true # Connection to the pool # No auth on default bpdm.gate-security.pool-security-enabled=false -bpdm.gate-security.readCompanyInputData=read_company_input_data -bpdm.gate-security.changeCompanyInputData=change_company_input_data -bpdm.gate-security.readCompanyOutputData=read_company_output_data -bpdm.gate-security.changeCompanyOutputData=change_company_output_data bpdm.pool.base-url=http://localhost:8080/api/catena #No security on default bpdm.security.enabled=false From 7161097d66ef4fc6ee309ec7eeaa3e92b80e32ed Mon Sep 17 00:00:00 2001 From: alexsilva Date: Wed, 21 Jun 2023 15:08:27 +0100 Subject: [PATCH 75/83] fix(gate): Removal Unused fields in entities, added alt_delivery_service_qualifier --- .../gate/entity/AlternativePostalAddress.kt | 36 ++----------------- .../V6_0_0_0__removal_entity_fields.sql | 14 ++++++++ .../AlternativePostalAddressToSaasMapping.kt | 7 ++-- .../pool/entity/AlternativePostalAddress.kt | 30 ---------------- .../V5_0_0_0__removal_entity_fields.sql | 12 +++++++ 5 files changed, 31 insertions(+), 68 deletions(-) create mode 100644 bpdm-gate/src/main/resources/db/migration/V6_0_0_0__removal_entity_fields.sql create mode 100644 bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt index b5326fb4a..0afbba629 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt @@ -41,18 +41,6 @@ class AlternativePostalAddress( @Column(name = "alt_admin_area_l1_region") val administrativeAreaLevel1: String? = null, - /** - * Further possibility to describe the region/address(e.g. County) - */ - @Column(name = "alt_admin_area_l2") - val administrativeAreaLevel2: String? = null, - - /** - * Further possibility to describe the region/address(e.g. Township) - */ - @Column(name = "alt_admin_area_l3") - val administrativeAreaLevel3: String? = null, - /** * A postal code, also known as postcode, PIN or ZIP Code */ @@ -65,27 +53,6 @@ class AlternativePostalAddress( @Column(name = "alt_city") val city: String, - /** - * Divides the city in several smaller areas - */ - @Column(name = "alt_district_l1") - val districtLevel1: String? = null, - - /** - * Divides the DistrictLevel1 in several smaller areas. Synonym: Subdistrict - */ - @Column(name = "alt_district_l2") - val districtLevel2: String? = null, - - @Embedded - @AttributeOverride(name = "name", column = Column(name = "alt_street_name")) - @AttributeOverride(name = "houseNumber", column = Column(name = "alt_street_number")) - @AttributeOverride(name = "milestone", column = Column(name = "alt_street_milestone")) - @AttributeOverride(name = "direction", column = Column(name = "alt_street_direction")) - val street: Street? = null, - - // specific for AlternativePostalAddress - /** * The type of this specified delivery */ @@ -98,4 +65,7 @@ class AlternativePostalAddress( */ @Column(name = "alt_delivery_service_number") val deliveryServiceNumber: String = "", + + @Column(name = "alt_delivery_service_qualifier") + val deliveryServiceQualifier: String = "", ) \ No newline at end of file diff --git a/bpdm-gate/src/main/resources/db/migration/V6_0_0_0__removal_entity_fields.sql b/bpdm-gate/src/main/resources/db/migration/V6_0_0_0__removal_entity_fields.sql new file mode 100644 index 000000000..778c736f7 --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V6_0_0_0__removal_entity_fields.sql @@ -0,0 +1,14 @@ +ALTER TABLE logistic_addresses +DROP COLUMN IF EXISTS alt_district_l1, +DROP COLUMN IF EXISTS alt_district_l2, +DROP COLUMN IF EXISTS alt_admin_area_l2, +DROP COLUMN IF EXISTS alt_admin_area_l3, +DROP COLUMN IF EXISTS alt_admin_area_l4, +DROP COLUMN IF EXISTS alt_street_name, +DROP COLUMN IF EXISTS alt_street_number, +DROP COLUMN IF EXISTS alt_street_milestone, +DROP COLUMN IF EXISTS alt_street_direction; + +ALTER TABLE logistic_addresses +ADD COLUMN IF NOT EXISTS alt_delivery_service_qualifier VARCHAR(255); + diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AlternativePostalAddressToSaasMapping.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AlternativePostalAddressToSaasMapping.kt index b10678fa4..bbfe7a573 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AlternativePostalAddressToSaasMapping.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AlternativePostalAddressToSaasMapping.kt @@ -46,8 +46,7 @@ class AlternativePostalAddressToSaasMapping(private val postalAdress: Alternativ (postalAdress.administrativeAreaLevel1)?.let { postalAdress.administrativeAreaLevel1.regionCode - }, - postalAdress.administrativeAreaLevel2 + } ) } @@ -63,9 +62,7 @@ class AlternativePostalAddressToSaasMapping(private val postalAdress: Alternativ return listOfNotNull( - postalAdress.city, - postalAdress.districtLevel1, - postalAdress.districtLevel2 + postalAdress.city ) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt index ab8ffda8e..77c17ce49 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt @@ -42,24 +42,6 @@ class AlternativePostalAddress( @JoinColumn(name = "alt_admin_area_l1_region") val administrativeAreaLevel1: Region?, - /** - * Further possibility to describe the region/address(e.g. County) - */ - @Column(name = "alt_admin_area_l2") - val administrativeAreaLevel2: String? = null, - - /** - * Further possibility to describe the region/address(e.g. Township) - */ - @Column(name = "alt_admin_area_l3") - val administrativeAreaLevel3: String? = null, - - /** - * Further possibility to describe the region/address(e.g. Sub-Province for China - */ - @Column(name = "alt_admin_area_l4") - val administrativeAreaLevel4: String? = null, - /** * A postal code, also known as postcode, PIN or ZIP Code */ @@ -72,18 +54,6 @@ class AlternativePostalAddress( @Column(name = "alt_city") val city: String, - /** - * Divides the city in several smaller areas - */ - @Column(name = "alt_district_l1") - val districtLevel1: String? = null, - - /** - * Divides the DistrictLevel1 in several smaller areas. Synonym: Subdistrict - */ - @Column(name = "alt_district_l2") - val districtLevel2: String? = null, - @Embedded @AttributeOverride(name = "name", column = Column(name = "alt_street_name")) @AttributeOverride(name = "houseNumber", column = Column(name = "alt_street_number")) diff --git a/bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql b/bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql new file mode 100644 index 000000000..95fef06d7 --- /dev/null +++ b/bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql @@ -0,0 +1,12 @@ +ALTER TABLE logistic_addresses +DROP COLUMN IF EXISTS alt_district_l1, +DROP COLUMN IF EXISTS alt_district_l2, +DROP COLUMN IF EXISTS alt_admin_area_l2, +DROP COLUMN IF EXISTS alt_admin_area_l3, +DROP COLUMN IF EXISTS alt_admin_area_l4; + + +-- DROP COLUMN IF EXISTS alt_street_name, +-- DROP COLUMN IF EXISTS alt_street_number, +-- DROP COLUMN IF EXISTS alt_street_milestone, +-- DROP COLUMN IF EXISTS alt_street_direction; \ No newline at end of file From 18186692046453dcf61550b1d7cdea069ba5b9fb Mon Sep 17 00:00:00 2001 From: alexsilva Date: Fri, 23 Jun 2023 11:28:07 +0100 Subject: [PATCH 76/83] fix(gate): Removal of address on AlternativePostalAddress.kt on Pool, added deliveryServiceQualifier --- .../tractusx/bpdm/gate/service/ResponseMappings.kt | 4 +++- .../AlternativePostalAddressToSaasMapping.kt | 4 ---- .../bpdm/pool/entity/AlternativePostalAddress.kt | 12 +++--------- .../pool/service/BusinessPartnerBuildService.kt | 3 ++- .../tractusx/bpdm/pool/service/ResponseMappings.kt | 3 ++- .../migration/V5_0_0_0__removal_entity_fields.sql | 13 +++++++------ 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 7763a0a01..a14b515f2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -75,7 +75,8 @@ fun AlternativePostalAddressDto.toAlternativePostalAddressEntity(): AlternativeP postCode = baseAddress.postalCode, city = baseAddress.city, deliveryServiceType = deliveryServiceType, - deliveryServiceNumber = deliveryServiceNumber + deliveryServiceNumber = deliveryServiceNumber, + deliveryServiceQualifier = deliveryServiceQualifier ) } @@ -287,6 +288,7 @@ fun AlternativePostalAddress.toAlternativePostalAddressDto(): AlternativePostalA return AlternativePostalAddressDto( deliveryServiceType = deliveryServiceType, deliveryServiceNumber = deliveryServiceNumber, + deliveryServiceQualifier = deliveryServiceQualifier, areaPart = areaDistrictAlternativDto, baseAddress = basePostalAddressDto ) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AlternativePostalAddressToSaasMapping.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AlternativePostalAddressToSaasMapping.kt index bbfe7a573..47a4d99ec 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AlternativePostalAddressToSaasMapping.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/opensearch/impl/service/AlternativePostalAddressToSaasMapping.kt @@ -70,10 +70,6 @@ class AlternativePostalAddressToSaasMapping(private val postalAdress: Alternativ return listOfNotNull( - postalAdress.street?.name, - postalAdress.street?.houseNumber, - postalAdress.street?.milestone, - postalAdress.street?.direction, ) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt index 77c17ce49..d4801099f 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt @@ -54,15 +54,6 @@ class AlternativePostalAddress( @Column(name = "alt_city") val city: String, - @Embedded - @AttributeOverride(name = "name", column = Column(name = "alt_street_name")) - @AttributeOverride(name = "houseNumber", column = Column(name = "alt_street_number")) - @AttributeOverride(name = "milestone", column = Column(name = "alt_street_milestone")) - @AttributeOverride(name = "direction", column = Column(name = "alt_street_direction")) - val street: Street? = null, - - // specific for AlternativePostalAddress - /** * The type of this specified delivery */ @@ -75,4 +66,7 @@ class AlternativePostalAddress( */ @Column(name = "alt_delivery_service_number") val deliveryServiceNumber: String = "", + + @Column(name = "alt_delivery_service_qualifier") + val deliveryServiceQualifier: String = "", ) \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index c8f88f3ec..17fd80a40 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -469,7 +469,8 @@ class BusinessPartnerBuildService( postCode = baseAddress.postalCode, city = baseAddress.city, deliveryServiceType = alternativeAddress.deliveryServiceType, - deliveryServiceNumber = alternativeAddress.deliveryServiceNumber + deliveryServiceNumber = alternativeAddress.deliveryServiceNumber, + deliveryServiceQualifier = alternativeAddress.deliveryServiceQualifier ) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 23869d29f..6415baf79 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -191,7 +191,8 @@ fun AlternativePostalAddress.toDto(): AlternativePostalAddressResponse { administrativeAreaLevel1 = administrativeAreaLevel1?.let { NameRegioncodeDto(it.regionName, it.regionCode) }, ), type = deliveryServiceType, - deliveryServiceNumber = deliveryServiceNumber + deliveryServiceNumber = deliveryServiceNumber, + deliveryServiceQualifier = deliveryServiceQualifier ) } diff --git a/bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql b/bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql index 95fef06d7..489a0e4c1 100644 --- a/bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql +++ b/bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql @@ -3,10 +3,11 @@ DROP COLUMN IF EXISTS alt_district_l1, DROP COLUMN IF EXISTS alt_district_l2, DROP COLUMN IF EXISTS alt_admin_area_l2, DROP COLUMN IF EXISTS alt_admin_area_l3, -DROP COLUMN IF EXISTS alt_admin_area_l4; +DROP COLUMN IF EXISTS alt_admin_area_l4, +DROP COLUMN IF EXISTS alt_street_name, +DROP COLUMN IF EXISTS alt_street_number, +DROP COLUMN IF EXISTS alt_street_milestone, +DROP COLUMN IF EXISTS alt_street_direction; - --- DROP COLUMN IF EXISTS alt_street_name, --- DROP COLUMN IF EXISTS alt_street_number, --- DROP COLUMN IF EXISTS alt_street_milestone, --- DROP COLUMN IF EXISTS alt_street_direction; \ No newline at end of file +ALTER TABLE logistic_addresses +ADD COLUMN IF NOT EXISTS alt_delivery_service_qualifier VARCHAR(255); \ No newline at end of file From ef361e0bbe0f35c3e2360a329db23be77b5fdb46 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Fri, 23 Jun 2023 11:44:09 +0100 Subject: [PATCH 77/83] fix(gate): Migration files name refactoring --- ...oval_entity_fields.sql => V4_0_0_3__removal_entity_fields.sql} | 0 ...oval_entity_fields.sql => V4_0_0_4__removal_entity_fields.sql} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename bpdm-gate/src/main/resources/db/migration/{V6_0_0_0__removal_entity_fields.sql => V4_0_0_3__removal_entity_fields.sql} (100%) rename bpdm-pool/src/main/resources/db/migration/{V5_0_0_0__removal_entity_fields.sql => V4_0_0_4__removal_entity_fields.sql} (100%) diff --git a/bpdm-gate/src/main/resources/db/migration/V6_0_0_0__removal_entity_fields.sql b/bpdm-gate/src/main/resources/db/migration/V4_0_0_3__removal_entity_fields.sql similarity index 100% rename from bpdm-gate/src/main/resources/db/migration/V6_0_0_0__removal_entity_fields.sql rename to bpdm-gate/src/main/resources/db/migration/V4_0_0_3__removal_entity_fields.sql diff --git a/bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql b/bpdm-pool/src/main/resources/db/migration/V4_0_0_4__removal_entity_fields.sql similarity index 100% rename from bpdm-pool/src/main/resources/db/migration/V5_0_0_0__removal_entity_fields.sql rename to bpdm-pool/src/main/resources/db/migration/V4_0_0_4__removal_entity_fields.sql From 734645371aefd64e99b6d91473401cd12290edc8 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Fri, 23 Jun 2023 14:56:57 +0100 Subject: [PATCH 78/83] fix(gate): deliveryServiceQualifier fix to allow null values --- .../tractusx/bpdm/gate/entity/AlternativePostalAddress.kt | 2 +- .../tractusx/bpdm/pool/entity/AlternativePostalAddress.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt index 0afbba629..d9d6d4dea 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/AlternativePostalAddress.kt @@ -67,5 +67,5 @@ class AlternativePostalAddress( val deliveryServiceNumber: String = "", @Column(name = "alt_delivery_service_qualifier") - val deliveryServiceQualifier: String = "", + val deliveryServiceQualifier: String?, ) \ No newline at end of file diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt index d4801099f..c5237b90f 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/AlternativePostalAddress.kt @@ -68,5 +68,5 @@ class AlternativePostalAddress( val deliveryServiceNumber: String = "", @Column(name = "alt_delivery_service_qualifier") - val deliveryServiceQualifier: String = "", + val deliveryServiceQualifier: String?, ) \ No newline at end of file From 5928af82e17f154a180cef201ec32cc758045304 Mon Sep 17 00:00:00 2001 From: alexsilva Date: Fri, 23 Jun 2023 15:45:24 +0100 Subject: [PATCH 79/83] fix(gate): deliveryServiceQualifier fix to allow null values --- .../tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt | 2 +- .../common/dto/response/AlternativePostalAddressResponse.kt | 2 +- .../org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt index 13a333433..2ab6287ac 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/AlternativePostalAddressDto.kt @@ -42,5 +42,5 @@ data class AlternativePostalAddressDto( val deliveryServiceType: DeliveryServiceType = DeliveryServiceType.PO_BOX, @get:Schema(description = "Delivery Service Qualifier") - val deliveryServiceQualifier: String = "", + val deliveryServiceQualifier: String?, ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/AlternativePostalAddressResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/AlternativePostalAddressResponse.kt index 57b988195..eb5881fca 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/AlternativePostalAddressResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/AlternativePostalAddressResponse.kt @@ -42,5 +42,5 @@ data class AlternativePostalAddressResponse( val type: DeliveryServiceType = DeliveryServiceType.PO_BOX, @get:Schema(description = "Delivery Service Qualifier") - val deliveryServiceQualifier: String = "", + val deliveryServiceQualifier: String?, ) diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt index 06f2b2c97..317fecbdf 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt @@ -245,6 +245,7 @@ object SaasMappings { return AlternativePostalAddressDto( deliveryServiceNumber = deliveryServiceNumber, deliveryServiceType = deliveryServiceType, + deliveryServiceQualifier = null, areaPart = AreaDistrictAlternativDto( administrativeAreaLevel1 = map.adminAreaLevel1() ), From 81bafa47d95d0a52f3ca90989370bad741c83089 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Tue, 30 May 2023 15:54:48 +0100 Subject: [PATCH 80/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker.yaml | 53 ++++++++++++----------------- DOCKER_NOTICE.md | 10 +++--- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index fc67cb2a5..e80fa9c08 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -18,16 +18,15 @@ on: env: - # github.repository as / - IMAGE_NAME: ${{ github.repository }}/${{ inputs.imageName }} - DOCKER_HUB_REGISTRY_NAMESPACE: tractusx - DOCKER_IMAGE_NAME: ${{ inputs.imageName }} + IMAGE_NAMESPACE: "tractusx" + IMAGE_NAME: ${{ inputs.imageName }} jobs: - build-docker: + docker: runs-on: ubuntu-latest permissions: packages: write + steps: - name: Checkout uses: actions/checkout@v3 @@ -38,7 +37,9 @@ jobs: uses: docker/metadata-action@v4 with: images: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }} + # Automatically prepare image tags; See action docs for more examples. + # semver patter will generate tags like these for example :1 :1.2 :1.2.3 tags: | type=ref,event=branch type=ref,event=pr @@ -46,44 +47,32 @@ jobs: type=semver,pattern={{major}} type=semver,pattern={{major}}.{{minor}} -# - name: Log into registry ${{ env.REGISTRY }} -# if: github.event_name != 'pull_request' -# uses: docker/login-action@v2 -# with: -# registry: ${{ env.REGISTRY }} -# username: ${{ github.actor }} -# password: ${{ secrets.GITHUB_TOKEN }} -# -# - name: Build and push to GHCR Registry ${{ env.REGISTRY }}/${{env.IMAGE_NAME }} -# uses: docker/build-push-action@v4 -# with: -# context: . -# push: ${{ inputs.push }} -# file: ${{ inputs.dockerfilePath }} -# tags: ${{ steps.meta.outputs.tags }} -# labels: ${{ steps.meta.outputs.labels }} -# -# - name: Checkout from registry ${{ env.REGISTRY }} -# uses: actions/checkout@v3 - - - name: Login to Docker Hub ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }} + - name: DockerHub login + if: github.event_name != 'pull_request' uses: docker/login-action@v2 with: + # Use existing DockerHub credentials present as secrets username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - - name: Build and push for Docker Hub ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} - uses: docker/build-push-action@v4 + - name: Build and push + uses: docker/build-push-action@v3 with: context: . - push: ${{ inputs.push }} + # Build image for verification purposes on every trigger event. Only push if event is not a PR + push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + # https://github.com/peter-evans/dockerhub-description + # Important step to push image description to DockerHub - name: Update Docker Hub description + if: github.event_name != 'pull_request' uses: peter-evans/dockerhub-description@v3 with: + # readme-filepath defaults to toplevel README.md, Only necessary if you have a dedicated file with your 'Notice for docker images' + # readme-filepath: path/to/dedicated/notice-for-docker-image.md username: ${{ secrets.DOCKER_HUB_USER }} password: ${{ secrets.DOCKER_HUB_TOKEN }} - repository: ${{ env.DOCKER_HUB_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }} - readme-filepath: DOCKER_NOTICE.md + repository: ${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }} + readme-filepath: "DOCKER_NOTICE.md" \ No newline at end of file diff --git a/DOCKER_NOTICE.md b/DOCKER_NOTICE.md index 760716c04..e43afcc2d 100644 --- a/DOCKER_NOTICE.md +++ b/DOCKER_NOTICE.md @@ -4,15 +4,15 @@ DockerHub: [https://hub.docker.com/r/tractusx/bpdm](https://hub.docker.com/r/tra Eclipse Tractus-X product(s) installed within the image: -__ BPDM __ +**BPDM** Eclipse Tractus-X product(s) installed within the image: -- GitHub: https://github.com/eclipse-tractusx/bpdm> +- GitHub: https://github.com/eclipse-tractusx/bpdm - Project home: https://projects.eclipse.org/projects/automotive.tractusx -- Pool Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-pool/Dockerfile> -- Gate Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-gate/Dockerfile> -- Bridge Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-brige-dumy/Dockerfile> +- Pool Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-pool/Dockerfile +- Gate Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-gate/Dockerfile +- Bridge Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-brige-dumy/Dockerfile - Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/bpdm/blob/main/LICENSE) From 06826c5c739ff9afb6efef07cf0c0f2b647144ec Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Wed, 7 Jun 2023 15:21:18 +0100 Subject: [PATCH 81/83] fix(Bridge): Try to fix deploy on ghcr registry and docker hub --- .github/workflows/build-docker-all.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build-docker-all.yaml b/.github/workflows/build-docker-all.yaml index 7325949fb..dc589fc4f 100644 --- a/.github/workflows/build-docker-all.yaml +++ b/.github/workflows/build-docker-all.yaml @@ -23,6 +23,7 @@ on: jobs: build-docker-pool: uses: ./.github/workflows/build-docker.yaml + secrets: inherit with: imageName: pool dockerfilePath: ./bpdm-pool/Dockerfile @@ -30,6 +31,7 @@ jobs: build-docker-gate: uses: ./.github/workflows/build-docker.yaml + secrets: inherit with: imageName: gate dockerfilePath: ./bpdm-gate/Dockerfile @@ -37,6 +39,7 @@ jobs: build-docker-bridge-dummy: uses: ./.github/workflows/build-docker.yaml + secrets: inherit with: imageName: bridge-dummy dockerfilePath: ./bpdm-bridge-dummy/Dockerfile From d13b3185a122e83bd892c2bb92fcb49dc0bf23ca Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Fri, 23 Jun 2023 14:48:56 +0100 Subject: [PATCH 82/83] Feat(Pool-Gate-Bridge): Rework the notice md docker for each project --- .../DOCKER_NOTICE.md | 4 +-- bpdm-gate/DOCKER_NOTICE.md | 28 +++++++++++++++++++ bpdm-pool/DOCKER_NOTICE.md | 28 +++++++++++++++++++ 3 files changed, 57 insertions(+), 3 deletions(-) rename DOCKER_NOTICE.md => bpdm-bridge-dummy/DOCKER_NOTICE.md (87%) create mode 100644 bpdm-gate/DOCKER_NOTICE.md create mode 100644 bpdm-pool/DOCKER_NOTICE.md diff --git a/DOCKER_NOTICE.md b/bpdm-bridge-dummy/DOCKER_NOTICE.md similarity index 87% rename from DOCKER_NOTICE.md rename to bpdm-bridge-dummy/DOCKER_NOTICE.md index e43afcc2d..7f2455221 100644 --- a/DOCKER_NOTICE.md +++ b/bpdm-bridge-dummy/DOCKER_NOTICE.md @@ -4,14 +4,12 @@ DockerHub: [https://hub.docker.com/r/tractusx/bpdm](https://hub.docker.com/r/tra Eclipse Tractus-X product(s) installed within the image: -**BPDM** +**BPDM Bridge** Eclipse Tractus-X product(s) installed within the image: - GitHub: https://github.com/eclipse-tractusx/bpdm - Project home: https://projects.eclipse.org/projects/automotive.tractusx -- Pool Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-pool/Dockerfile -- Gate Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-gate/Dockerfile - Bridge Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-brige-dumy/Dockerfile - Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/bpdm/blob/main/LICENSE) diff --git a/bpdm-gate/DOCKER_NOTICE.md b/bpdm-gate/DOCKER_NOTICE.md new file mode 100644 index 000000000..7e99acb08 --- /dev/null +++ b/bpdm-gate/DOCKER_NOTICE.md @@ -0,0 +1,28 @@ +## Notice for Docker image + +DockerHub: [https://hub.docker.com/r/tractusx/bpdm](https://hub.docker.com/r/tractusx/bpdm) + +Eclipse Tractus-X product(s) installed within the image: + +**BPDM Gate** + +Eclipse Tractus-X product(s) installed within the image: + +- GitHub: https://github.com/eclipse-tractusx/bpdm +- Project home: https://projects.eclipse.org/projects/automotive.tractusx +- Gate Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-gate/Dockerfile +- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/bpdm/blob/main/LICENSE) + + +**Used base image** + +- [eclipse-temurin:17-jre-alpine](https://github.com/adoptium/containers) +- Official Eclipse Temurin DockerHub page: https://hub.docker.com/_/eclipse-temurin +- Eclipse Temurin Project: https://projects.eclipse.org/projects/adoptium.temurin +- Additional information about the Eclipse Temurin images: https://github.com/docker-library/repo-info/tree/master/repos/eclipse-temurin + + +As with all Docker images, these likely also contain other software which may be under other licenses +(such as Bash, etc. from the base distribution, along with any direct or indirect dependencies of the primary software being contained). + +As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within. \ No newline at end of file diff --git a/bpdm-pool/DOCKER_NOTICE.md b/bpdm-pool/DOCKER_NOTICE.md new file mode 100644 index 000000000..38cb868f0 --- /dev/null +++ b/bpdm-pool/DOCKER_NOTICE.md @@ -0,0 +1,28 @@ +## Notice for Docker image + +DockerHub: [https://hub.docker.com/r/tractusx/bpdm](https://hub.docker.com/r/tractusx/bpdm) + +Eclipse Tractus-X product(s) installed within the image: + +**BPDM Pool** + +Eclipse Tractus-X product(s) installed within the image: + +- GitHub: https://github.com/eclipse-tractusx/bpdm +- Project home: https://projects.eclipse.org/projects/automotive.tractusx +- Pool Dockerfile: https://github.com/eclipse-tractusx/bpdm/blob/main/bpdm-pool/Dockerfile +- Project license: [Apache License, Version 2.0](https://github.com/eclipse-tractusx/bpdm/blob/main/LICENSE) + + +**Used base image** + +- [eclipse-temurin:17-jre-alpine](https://github.com/adoptium/containers) +- Official Eclipse Temurin DockerHub page: https://hub.docker.com/_/eclipse-temurin +- Eclipse Temurin Project: https://projects.eclipse.org/projects/adoptium.temurin +- Additional information about the Eclipse Temurin images: https://github.com/docker-library/repo-info/tree/master/repos/eclipse-temurin + + +As with all Docker images, these likely also contain other software which may be under other licenses +(such as Bash, etc. from the base distribution, along with any direct or indirect dependencies of the primary software being contained). + +As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within. \ No newline at end of file From cff18de35cf60b98d8aaa530f5d1c4b84b0c9979 Mon Sep 17 00:00:00 2001 From: "fabio.d.mota" Date: Mon, 26 Jun 2023 18:24:38 +0100 Subject: [PATCH 83/83] feat(Pool-Gate-Bridge): Fix workflow for publishing docker images --- .github/workflows/build-docker-all.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-docker-all.yaml b/.github/workflows/build-docker-all.yaml index dc589fc4f..88c5993e1 100644 --- a/.github/workflows/build-docker-all.yaml +++ b/.github/workflows/build-docker-all.yaml @@ -15,7 +15,6 @@ on: branches: - main - rc/** - - feat/dockerhub_images_release pull_request: branches: - main