-
Notifications
You must be signed in to change notification settings - Fork 48
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
Implement Remaining MQTTSubmodelRepo Methods #544
Merged
aaronzi
merged 10 commits into
eclipse-basyx:main
from
ShehriyarShariq-Fraunhofer:implement-remaining-mqttsubmodelrepo-methods
Dec 6, 2024
Merged
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
00dd769
stash
ShehriyarShariq-Fraunhofer 85c4847
fix: remove sideeffects from all tests
ShehriyarShariq-Fraunhofer 426e3c2
fix: update serializeSubmodelElements method
ShehriyarShariq-Fraunhofer 86ffb23
fix: Update events in README
ShehriyarShariq-Fraunhofer 8239244
chore: add missing license header
mateusmolina-iese c84de43
fix: Update File Value events
ShehriyarShariq-Fraunhofer c247df8
Merge branch 'implement-remaining-mqttsubmodelrepo-methods' of https:…
ShehriyarShariq-Fraunhofer cb277b6
ci: rerun
mateusmolina-iese 9a58739
fix: patchSubmodelElements remove pagination
ShehriyarShariq-Fraunhofer 7d51750
Merge branch 'implement-remaining-mqttsubmodelrepo-methods' of https:…
ShehriyarShariq-Fraunhofer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,31 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2024 the Eclipse BaSyx Authors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* SPDX-License-Identifier: MIT | ||
******************************************************************************/ | ||
|
||
package org.eclipse.digitaltwin.basyx.submodelrepository.feature.mqtt; | ||
|
||
import java.io.File; | ||
import java.io.InputStream; | ||
import java.util.List; | ||
|
||
|
@@ -126,6 +152,13 @@ public void deleteSubmodelElement(String submodelId, String idShortPath) throws | |
submodelElementDeleted(submodelElement, getName(), submodelId, idShortPath); | ||
} | ||
|
||
@Override | ||
public void patchSubmodelElements(String submodelId, List<SubmodelElement> submodelElementList) { | ||
decorated.patchSubmodelElements(submodelId, submodelElementList); | ||
List<SubmodelElement> patchedSubmodelElements = decorated.getSubmodelElements(submodelId, PaginationInfo.NO_LIMIT).getResult(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason to use the NO_LIMIT request to get the patched submodel elements again? They are already being passed as parameter. |
||
submodelElementsPatched(patchedSubmodelElements, getName(), submodelId); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return decorated.getName(); | ||
|
@@ -141,6 +174,35 @@ public Submodel getSubmodelByIdMetadata(String submodelId) { | |
return decorated.getSubmodelByIdMetadata(submodelId); | ||
} | ||
|
||
@Override | ||
public OperationVariable[] invokeOperation(String submodelId, String idShortPath, OperationVariable[] input) throws ElementDoesNotExistException { | ||
return decorated.invokeOperation(submodelId, idShortPath, input); | ||
} | ||
|
||
@Override | ||
public java.io.File getFileByPathSubmodel(String submodelId, String idShortPath) { | ||
return decorated.getFileByPathSubmodel(submodelId, idShortPath); | ||
} | ||
|
||
@Override | ||
public void deleteFileValue(String identifier, String idShortPath) { | ||
SubmodelElement submodelElement = decorated.getSubmodelElement(identifier, idShortPath); | ||
decorated.deleteFileValue(identifier, idShortPath); | ||
fileValueDeleted(submodelElement, getName(), identifier, idShortPath); | ||
} | ||
|
||
@Override | ||
public void setFileValue(String submodelId, String idShortPath, String fileName, InputStream inputStream){ | ||
decorated.setFileValue(submodelId, idShortPath, fileName, inputStream); | ||
SubmodelElement submodelElement = decorated.getSubmodelElement(submodelId, idShortPath); | ||
fileValueUpdated(submodelElement, getName(), submodelId, idShortPath, fileName); | ||
} | ||
|
||
@Override | ||
public InputStream getFileByFilePath(String submodelId, String filePath) { | ||
return decorated.getFileByFilePath(submodelId, filePath); | ||
} | ||
|
||
private void submodelCreated(Submodel submodel, String repoId) { | ||
sendMqttMessage(topicFactory.createCreateSubmodelTopic(repoId), SubmodelSerializer.serializeSubmodel(submodel)); | ||
} | ||
|
@@ -164,6 +226,18 @@ private void submodelElementUpdated(SubmodelElement submodelElement, String repo | |
private void submodelElementDeleted(SubmodelElement submodelElement, String repoId, String submodelId, String submodelElementId) { | ||
sendMqttMessage(topicFactory.createDeleteSubmodelElementTopic(repoId, submodelId, submodelElementId), SubmodelElementSerializer.serializeSubmodelElement(submodelElement)); | ||
} | ||
|
||
private void submodelElementsPatched(List<SubmodelElement> submodelElements, String repoId, String submodelId) { | ||
sendMqttMessage(topicFactory.createPatchSubmodelElementsTopic(repoId, submodelId), SubmodelElementSerializer.serializeSubmodelElements(submodelElements)); | ||
} | ||
|
||
private void fileValueDeleted(SubmodelElement submodelElement, String repoId, String submodelId, String submodelElementId) { | ||
sendMqttMessage(topicFactory.createDeleteFileValueTopic(repoId, submodelId, submodelElementId), SubmodelElementSerializer.serializeSubmodelElement(submodelElement)); | ||
} | ||
|
||
private void fileValueUpdated(SubmodelElement submodelElement, String repoId, String submodelId, String submodelElementId, String fileName) { | ||
sendMqttMessage(topicFactory.createUpdateFileValueTopic(repoId, submodelId, submodelElementId, fileName), SubmodelElementSerializer.serializeSubmodelElement(submodelElement)); | ||
} | ||
|
||
/** | ||
* Sends MQTT message to connected broker | ||
|
@@ -194,37 +268,4 @@ private MqttMessage createMqttMessage(String payload) { | |
} | ||
} | ||
|
||
@Override | ||
public OperationVariable[] invokeOperation(String submodelId, String idShortPath, OperationVariable[] input) throws ElementDoesNotExistException { | ||
return decorated.invokeOperation(submodelId, idShortPath, input); | ||
} | ||
|
||
@Override | ||
public java.io.File getFileByPathSubmodel(String submodelId, String idShortPath) { | ||
return decorated.getFileByPathSubmodel(submodelId, idShortPath); | ||
} | ||
|
||
@Override | ||
public void deleteFileValue(String identifier, String idShortPath) { | ||
// TODO: Eventing | ||
decorated.deleteFileValue(identifier, idShortPath); | ||
} | ||
|
||
@Override | ||
public void setFileValue(String submodelId, String idShortPath, String fileName, InputStream inputStream){ | ||
// TODO: Eventing | ||
decorated.setFileValue(submodelId, idShortPath, fileName, inputStream); | ||
} | ||
|
||
@Override | ||
public void patchSubmodelElements(String submodelId, List<SubmodelElement> submodelElementList) { | ||
// TODO: Eventing | ||
decorated.patchSubmodelElements(submodelId, submodelElementList); | ||
} | ||
|
||
@Override | ||
public InputStream getFileByFilePath(String submodelId, String filePath) { | ||
return decorated.getFileByFilePath(submodelId, filePath); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please change the topic to match the spec [1, 2] (
.../$idShortPath/attachment/updated and /deleted
)? Also, no need for the$fileName
in the topic itself.[1] https://app.swaggerhub.com/apis/Plattform_i40/SubmodelServiceSpecification/V3.0.1_SSP-001#/Submodel%20API/PutFileByPath
[2] https://app.swaggerhub.com/apis/Plattform_i40/SubmodelServiceSpecification/V3.0.1_SSP-001#/Submodel%20API/DeleteFileByPath