Skip to content

feat: Implement support for PartTypeInformation 2.0.0 - #1199

Open
OlgaIvkovic wants to merge 3 commits into
eclipse-tractusx:mainfrom
achtzig20:feat/part-type-information
Open

feat: Implement support for PartTypeInformation 2.0.0#1199
OlgaIvkovic wants to merge 3 commits into
eclipse-tractusx:mainfrom
achtzig20:feat/part-type-information

Conversation

@OlgaIvkovic

Copy link
Copy Markdown
Contributor

Description

  • Implement support for PartTypeInformation 2.0.0 submodel
  • Adjust endpoints for the PartTypeInformation Controller

Resolves #1193

Pre-review checks

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

  • DEPENDENCIES are up-to-date. Dash license tool. Committers can open IP issues for restricted libs.
  • Copyright and license header are present on all affected files (TRG 7.02)
  • Documentation Notice are present on all affected files (TRG 7.07)
  • If helm chart has been changed, the chart version has been bumped to either next major, minor or patch level (compared to released chart).
  • Changelog updated (changelog.md) with PR reference and brief summary.
  • Frontend version bumped, if needed (frontend/package.json, frontend/package-lock.json)
  • Backend version bumped, if needed (backend/pom.xml)
  • Open API specification updated, if controllers have been changed (use python script scripts/generate_openapi_yaml.py with running customer backend)

return ProductLookup.error(HttpStatus.UNAUTHORIZED);
}
log.info("{} requests part type information on {}", bpnl, materialnumber);
log.info("{} requests part type information {} on {}", bpnl, version, materialnumber);
@NoArgsConstructor
@ToString
public class PartTypeInformationBody {
private LinkedHashSet<Classification> partClassification = new LinkedHashSet<>();
private PartTypeInformationBody partTypeInformation = new PartTypeInformationBody();

@Valid
private Set<PartSitesInformationAsPlanned> partSitesInformationAsPlanned = new HashSet<>();

@ReneSchroederLJ ReneSchroederLJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for the contribution. The functionality works well, but I suggested some simplifications.


private SubmodelData fetchPartTypeSubmodelData(MaterialPartnerRelation mpr) {
return fetchSubmodelData(mpr, "urn:samm:io.catenax.part_type_information:1.0.0#PartTypeInformation",
return fetchSubmodelData(mpr, AssetType.PART_TYPE_INFORMATION_SUBMODEL.URN_SEMANTIC_ID,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I only now realize how unncessary these methods are. getSubmodelFromPartner should simply call fetchSubmodelData directly for the correct semantic id

return fetchCxId(mpr, AssetType.PART_TYPE_INFORMATION_LEGACY_SUBMODEL, "catenaXId");
}

private String fetchCxId(MaterialPartnerRelation mpr, AssetType type, String cxIdProperty) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would prefer determining the cxIdProperty with a switch statement for AssetType. That simplifies the passed properties and can also be used to prevent wrong AssetTypes from being used here.

return dataAddress;
}

public JsonNode buildPartTypeInfoLegacySubmodelRegistrationBody() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know at the moment we're handling the building of the body for PartTypeInformation separately. However this was already outdated previously. Please utilize the generic buildSubmodelRegistrationBody for both and remove the special methods.

Comment on lines 123 to 125
if (lookup.failed()) {
return ResponseEntity.status(lookup.error()).build();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (lookup.failed()) {
return ResponseEntity.status(lookup.error()).build();
}
if (lookup.error != null) {
return ResponseEntity.status(lookup.error).build();
}

Comment on lines +100 to +102
if (lookup.failed()) {
return ResponseEntity.status(lookup.error()).build();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
if (lookup.failed()) {
return ResponseEntity.status(lookup.error()).build();
}
if (lookup.error != null) {
return ResponseEntity.status(lookup.error).build();
}

import java.util.Set;

import org.eclipse.tractusx.puris.backend.common.util.PatternStore;
import org.eclipse.tractusx.puris.backend.masterdata.logic.dto.parttypeinformation.v1.PartTypeInformationLegacySAMM;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
import org.eclipse.tractusx.puris.backend.masterdata.logic.dto.parttypeinformation.v1.PartTypeInformationLegacySAMM;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file is used by both versions. It should either be moved to a common folder or be duplicated per version. For now I would move it to a common folder at the same level as the version folders

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think it makes sense to separate these test cases into a new file since they test the same file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since the names of the files are the same for v1 and v2, the imports would get confused if all of the tests were in a single file

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can use the fully qualified names for the v1 versions. So for example PartSiteInformationAsPlanned becomes org.eclipse.tractusx.puris.backend.masterdata.logic.dto.parttypeinformation.v1.PartSitesInformationAsPlanned

@@ -53,7 +53,7 @@ tests {
test("Verify response contains six data offers", function () {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please also fix this test description and add the missing 2 submodels part type information legacy and days of supply.

@@ -54,7 +54,7 @@ tests {
test("Verify response contains six data offers", function () {
expect(contractOffers).to.be.an("array");
// dtr, part type information, stock, demand, delivery, production

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same as above. please fix the description and comment,

@ReneSchroederLJ ReneSchroederLJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for incorporating. Just found 3 very minor things to fix

result &= createSubmodelContractDefinitionForPartner(AssetType.DATA_EXCHANGE_REQUEST.URN_SEMANTIC_ID, variablesService.getDataExchangeRequestApiAssetId(), partner);
result &= createSubmodelContractDefinitionForPartner(AssetType.DAYS_OF_SUPPLY.URN_SEMANTIC_ID, variablesService.getDaysOfSupplySubmodelApiAssetId(), partner);
return createSubmodelContractDefinitionForPartner(AssetType.PART_TYPE_INFORMATION_SUBMODEL.URN_SEMANTIC_ID, variablesService.getPartTypeSubmodelApiAssetId(), partner) && result;
result &= createSubmodelContractDefinitionForPartner(AssetType.PART_TYPE_INFORMATION_SUBMODEL.URN_SEMANTIC_ID, variablesService.getPartTypeSubmodelApiAssetId(), partner) && result;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
result &= createSubmodelContractDefinitionForPartner(AssetType.PART_TYPE_INFORMATION_SUBMODEL.URN_SEMANTIC_ID, variablesService.getPartTypeSubmodelApiAssetId(), partner) && result;
result &= createSubmodelContractDefinitionForPartner(AssetType.PART_TYPE_INFORMATION_SUBMODEL.URN_SEMANTIC_ID, variablesService.getPartTypeSubmodelApiAssetId(), partner);

public ResponseEntity<PartTypeInformationSAMM> getMapping(@RequestHeader("edc-bpn") String bpnl,
@Parameter(description = "The material number that the request receiving party uses for the material in question")
@PathVariable String materialnumber,
@Parameter(description = "Must be set to '$value'") @PathVariable String representation) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please fix the formatting of the method parameters for this endpoint and the other a bit. It's very confusing to read at the moment

* @return the resolved product or the status to be returned to the partner
*/
private ProductLookup resolveProduct(String bpnl, String materialnumber, String representation, String version) {
materialnumber = new String(Base64.getDecoder().decode(materialnumber.getBytes(StandardCharsets.UTF_8)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This statement should be wrapped in a try catch block since an invalid base64 will throw an exception

@ReneSchroederLJ
ReneSchroederLJ marked this pull request as ready for review August 13, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Story] Add support for PartTypeInformation 2.0.0

3 participants