Skip to content

Commit

Permalink
Apply the fix for the SubmodelRepositoryApiHttpController
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusmolina-iese committed Aug 22, 2024
1 parent 0e81db2 commit 5e9a545
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,28 @@ private ResponseEntity<SubmodelElement> handleSubmodelElementValueNormalGetReque

@Override
public ResponseEntity<OperationResult> invokeOperationSubmodelRepo(Base64UrlEncodedIdentifier submodelIdentifier, String idShortPath, @Valid OperationRequest body, @Valid Boolean async) {
OperationVariable[] result = repository.invokeOperation(submodelIdentifier.getIdentifier(), idShortPath, body.getInputArguments().toArray(new OperationVariable[0]));
List<OperationVariable> inVars = new ArrayList<>();
inVars.addAll(body.getInputArguments());
inVars.addAll(body.getInoutputArguments());

return new ResponseEntity<OperationResult>(createOperationResult(result), HttpStatus.OK);
List<OperationVariable> result = Arrays.asList(repository.invokeOperation(submodelIdentifier.getIdentifier(), idShortPath, inVars.toArray(new OperationVariable[0])));

List<OperationVariable> outVars = new ArrayList<>(result);
List<OperationVariable> inoutputVars = new ArrayList<>();

if (!body.getInoutputArguments().isEmpty()) {
List<String> inoutputVarsIdShorts = body.getInoutputArguments().stream().map(OperationVariable::getValue).map(SubmodelElement::getIdShort).toList();

inoutputVars = result.stream().filter(opVar -> inoutputVarsIdShorts.contains(opVar.getValue().getIdShort())).toList();

outVars.removeAll(inoutputVars);
}

return ResponseEntity.ok(createOperationResult(outVars, inoutputVars));
}

private OperationResult createOperationResult(OperationVariable[] result) {
return new DefaultOperationResult.Builder().outputArguments(Arrays.asList(result)).build();
private OperationResult createOperationResult(List<OperationVariable> outputVars, List<OperationVariable> inoutputVars) {
return new DefaultOperationResult.Builder().outputArguments(outputVars).inoutputArguments(inoutputVars).build();
}

private String getEncodedCursorFromCursorResult(CursorResult<?> cursorResult) {
Expand Down

0 comments on commit 5e9a545

Please sign in to comment.