Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: #586 bpdm lookup functionality #939

Merged
merged 38 commits into from
May 6, 2024

Conversation

ds-lcapellino
Copy link
Contributor

@ds-lcapellino ds-lcapellino commented May 3, 2024

Description

This PR introduces functionality to resolve the manufacturer name by a given BPN. Since IRS is planning to remove this feature on their side, TraceX must resolve BPN by its own.

If the BPDM service is not available, a null value will be inserted for the manufacturer name.
Persistence of BPNs and manufacturer names is respected in this PR.

resolves #586

Added

Pre-review checks

Please ensure to do as many of the following checks as possible, before asking for committer review:

ds-lcapellino and others added 30 commits April 12, 2024 08:01
# Conflicts:
#	tx-backend/src/main/java/org/eclipse/tractusx/traceability/bpn/domain/service/BpnRepository.java
#	tx-backend/src/main/java/org/eclipse/tractusx/traceability/bpn/infrastructure/repository/BpnRepositoryImpl.java
# Conflicts:
#	CHANGELOG.md
#	docs/api/traceability-foss-backend.json
#	tx-backend/openapi/traceability-foss-backend.json
# Conflicts:
#	tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/response/mapping/submodel/BatchMapper.java
#	tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/response/mapping/submodel/JustInSequenceMapper.java
#	tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/response/mapping/submodel/SerialPartMapper.java
#	tx-backend/src/main/java/org/eclipse/tractusx/traceability/assets/infrastructure/base/irs/model/response/relationship/Aspect.java
@ds-lcapellino ds-lcapellino added backend Backend related issues java Pull requests that update Java code bpdm BPDM api related stuff labels May 3, 2024
@ds-lcapellino ds-lcapellino requested a review from ds-mwesener May 3, 2024 11:49
Copy link
Contributor

@ds-mwesener ds-mwesener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ds-lcapellino please find my comments.

@@ -87,6 +87,13 @@ public void updateManufacturers(Map<String, String> bpns) {
}
}

@Override
public BpnEntity save(BusinessPartnerResponse businessPartner) {
String value = businessPartner.getNames() == null ? null : businessPartner.getNames().get(0).getValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you clarify with product owner if it is okay from business die to use first element out of the response?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I migrated the feature from IRS to TraceX and there this was basically the case. However, I adapted this line to check for empty Strings and use the first not empty value.
But we should talk to PO about potential risks with this implementation.


@Override
public String findByBpn(String bpn) {
String manufacturerName = bpnRepository.findManufacturerName(bpn);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to return an optional within bpnResository.findManufacturerName(bpn)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since currently have no placeholder designed for empty manufacturer names, I think it is okay to return a null value and also store in the database. With an Optional, we check if the Optional is empty and would then store a null value in the database. What do you think?

Copy link
Contributor

@ds-mwesener ds-mwesener May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using an Optional as return type. Then another developer has full control over the flow and knows that this variable might be not existing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this method wasn't introduced to my PR, I would recommend adding this to #440. I will comment the issue accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thank you.

@ds-lcapellino ds-lcapellino marked this pull request as ready for review May 6, 2024 06:48
@ds-lcapellino ds-lcapellino requested a review from ds-mwesener May 6, 2024 06:51
@ds-lcapellino
Copy link
Contributor Author

Hey @ds-mwesener,
thank you for your review. Please see my changes and comments.

Copy link
Contributor

@ds-mwesener ds-mwesener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see comments

Copy link
Contributor

@ds-mwesener ds-mwesener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ds-mwesener ds-mwesener merged commit 05f7357 into eclipse-tractusx:main May 6, 2024
16 of 17 checks passed
@ds-mwesener ds-mwesener deleted the feature/586-bpdm-lookup branch May 6, 2024 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend related issues bpdm BPDM api related stuff java Pull requests that update Java code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Backend] Trace-X uses its own BPDM lookup to identify Customer data for BPNL
2 participants