Skip to content

Conversation

@VivekHub97
Copy link
Contributor

@VivekHub97 VivekHub97 commented Oct 8, 2024

fix: Response body for posting in submodel repository and submodel service

Closes #398
Closes #457

Copy link
Member

@mdanish98 mdanish98 left a comment

Choose a reason for hiding this comment

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

Hi @VivekHub97 ,

Thanks a lot for the implementation.

Actually, this should be fixed in core [1] and [2] first and then at the Controller side, the return type here in [1] and [2] is void but it should be SubmodelElement, and then at the HttpController [3] and [4] respectively for Repo and Service, it should be like below:

@Override
public ResponseEntity<SubmodelElement> postSubmodelElementSubmodelRepo(Base64UrlEncodedIdentifier submodelIdentifier, @Valid SubmodelElement body) {
    SubmodelElement createdSME = repository.createSubmodelElement(submodelIdentifier.getIdentifier(), body);
    return new ResponseEntity<SubmodelElement>(createdSME, HttpStatus.CREATED);
}

Inside SubmodelRepoHttpController [3] the method postSubmodelElementByPathSubmodelRepo is not fixed.

Following is the summary:

  • Update interfaces of SubmodelRepository [1] and SubmodelService [2] for createSubmodelElement methods (there are multiple overloaded methods) such that the return type is SME instead of void.
  • Then handle this appropriately wherever these interfaces are implemented possibly in all implementations (Crud*Repo) and all features.
  • Update HTTP controllers for SMRepo [3] and SMService [4] like I defined above
  • Update the test cases to additionally check the creation response wherever required. (Maybe do this first to achieve Test Driven Development).

[1] basyx-java-server-sdk/basyx.submodelrepository/basyx.submodelrepository-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/SubmodelRepository.java at main · eclipse-basyx/basyx-java-server-sdk (github.com)
[2] basyx-java-server-sdk/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelService.java at main · eclipse-basyx/basyx-java-server-sdk (github.com)
[3] basyx-java-server-sdk/basyx.submodelrepository/basyx.submodelrepository-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositoryApiHTTPController.java at main · eclipse-basyx/basyx-java-server-sdk (github.com)
[4] basyx-java-server-sdk/basyx.submodelservice/basyx.submodelservice-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/http/SubmodelServiceHTTPApiController.java at main · eclipse-basyx/basyx-java-server-sdk (github.com)

Copy link
Member

@mdanish98 mdanish98 left a comment

Choose a reason for hiding this comment

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

There are no tests in the SubmodelServiceSuite. Please add them as well.

@aaronzi aaronzi merged commit 03405aa into eclipse-basyx:main Feb 17, 2025
27 checks passed
mateusmolina-iese pushed a commit to mateusmolina-iese/basyx-java-server-sdk that referenced this pull request Feb 18, 2025
aaronzi pushed a commit that referenced this pull request Feb 19, 2025
* Revert "fix: Response body for post (#484)"

This reverts commit 03405aa.

* fix: smrepo/smservice: response body for post

* refactor: smrepo/smservice: use a different strategy for obtaining the return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants