diff --git a/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs index 76a3924b8..05087d9f2 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs @@ -692,7 +692,10 @@ public virtual IActionResult GetAllSubmodelElementsPathAasRepository([FromRoute] [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] public virtual IActionResult GetAllSubmodelElementsReferenceAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level) - { + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); @@ -721,7 +724,8 @@ public virtual IActionResult GetAllSubmodelElementsReferenceAasRepository([FromR // TODO (jtikekar, 2023-09-04): check performace imapct due to ConvertAll var smePaginated = _paginationService.GetPaginatedList(smeList, new PaginationParameters(cursor, limit)); - var smeReferenceList = _referenceModifierService.GetReferenceResult(smePaginated.result.ConvertAll(sme => (IReferable)sme)); + var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginated.result ?? [], levelEnum); + var smeReferenceList = _referenceModifierService.GetReferenceResult(smeLevelList.ConvertAll(sme => (IReferable)sme)); var output = new ReferencePagedResult(smeReferenceList, smePaginated.paging_metadata); return new ObjectResult(output); } diff --git a/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs index 70c6b65b1..61b2db2ec 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs @@ -542,8 +542,11 @@ public virtual IActionResult GetAllSubmodelElementsPathSubmodelRepo([FromRoute][ [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] public virtual IActionResult GetAllSubmodelElementsReferenceSubmodelRepo([FromRoute][Required]string submodelIdentifier, [FromQuery]int? limit, - [FromQuery]string? cursor, [FromQuery]string? level) - { + [FromQuery]string? cursor, [FromQuery]string? level) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); if (decodedSubmodelIdentifier == null) @@ -564,8 +567,9 @@ public virtual IActionResult GetAllSubmodelElementsReferenceSubmodelRepo([FromRo var smeList = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); - var smePagedList = _paginationService.GetPaginatedList(smeList, new PaginationParameters(cursor, limit)); - var smeReferences = _referenceModifierService.GetReferenceResult(smePagedList.result.ConvertAll(sme => (IReferable)sme)); + var smePagedList = _paginationService.GetPaginatedList(smeList, new PaginationParameters(cursor, limit)); + var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePagedList.result ?? [], levelEnum); + var smeReferences = _referenceModifierService.GetReferenceResult(smeLevelList.ConvertAll(sme => (IReferable)sme)); var output = new ReferencePagedResult(smeReferences, smePagedList.paging_metadata); return new ObjectResult(output); } @@ -795,13 +799,17 @@ public virtual IActionResult GetAllSubmodelsPath([FromQuery][StringLength(3072, public virtual IActionResult GetAllSubmodelsReference([FromQuery][StringLength(3072, MinimumLength=1)]string? semanticId, [FromQuery]string? idShort, [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level) { _logger.LogInformation($"Received a request to get all the submodels."); - var levelEnum = _validateModifierService.ValidateLevel(level); + + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); var submodelList = _submodelService.GetAllSubmodels(reqSemanticId, idShort); - var submodelsPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); - var smReferences = _referenceModifierService.GetReferenceResult(submodelsPagedList.result.ConvertAll(sm => (IReferable)sm)); + var submodelsPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); + var submodelLevelList = _levelExtentModifierService.ApplyLevelExtent(submodelsPagedList.result, levelEnum); + var smReferences = _referenceModifierService.GetReferenceResult(submodelLevelList.ConvertAll(sm => (IReferable)sm)); var output = new ReferencePagedResult(smReferences, submodelsPagedList.paging_metadata); return new ObjectResult(output); }