Skip to content

Commit

Permalink
Support level in case of GetAll$Reference
Browse files Browse the repository at this point in the history
  • Loading branch information
juileetikekar committed Nov 7, 2024
1 parent d1cffea commit cebbb8c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down
22 changes: 15 additions & 7 deletions src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit cebbb8c

Please sign in to comment.