Skip to content

Commit deb8148

Browse files
committed
Refactor AAS and Submodel repository to use updated query options and improve parameter handling
1 parent f033d5d commit deb8148

11 files changed

Lines changed: 43 additions & 53 deletions

File tree

example/basyx/aas-env.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ basyx.submodelrepository.feature.registryintegration=http://sm-template-registry
77
spring.servlet.multipart.max-file-size=128MB
88
spring.servlet.multipart.max-request-size=128MB
99
basyx.backend=MongoDB
10-
spring.data.mongodb.host=mongo
11-
spring.data.mongodb.port=27017
12-
spring.data.mongodb.database=aasenvironment
13-
spring.data.mongodb.authentication-database=admin
14-
spring.data.mongodb.username=mongoAdmin
15-
spring.data.mongodb.password=mongoPassword
10+
spring.mongodb.host=mongo
11+
spring.mongodb.port=27017
12+
spring.mongodb.database=aasenvironment
13+
spring.mongodb.authentication-database=admin
14+
spring.mongodb.username=mongoAdmin
15+
spring.mongodb.password=mongoPassword
1616

example/docker-compose.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ services:
145145
- twinengine-network
146146

147147
template-repository:
148-
image: eclipsebasyx/aas-environment:2.0.0-milestone-11
148+
image: eclipsebasyx/aas-environment:2.0.0-milestone-15
149149
container_name: template-repository
150150
volumes:
151151
- ./aas:/application/aas
@@ -162,28 +162,28 @@ services:
162162
- twinengine-network
163163

164164
aas-template-registry:
165-
image: eclipsebasyx/aas-registry-log-mongodb:2.0.0-milestone-11
165+
image: eclipsebasyx/aas-registry-log-mongodb:2.0.0-milestone-15
166166
container_name: aas-template-registry
167167
restart: always
168168
depends_on:
169169
- mongo
170170
environment:
171-
- SPRING_DATA_MONGODB_URI=mongodb://mongoAdmin:mongoPassword@mongo:27017
171+
- SPRING_MONGODB_URI=mongodb://mongoAdmin:mongoPassword@mongo:27017
172172
networks:
173173
- twinengine-network
174174

175175
sm-template-registry:
176-
image: eclipsebasyx/submodel-registry-log-mongodb:2.0.0-milestone-11
176+
image: eclipsebasyx/submodel-registry-log-mongodb:2.0.0-milestone-15
177177
container_name: sm-template-registry
178178
depends_on:
179179
- mongo
180180
environment:
181-
- SPRING_DATA_MONGODB_URI=mongodb://mongoAdmin:mongoPassword@mongo:27017
181+
- SPRING_MONGODB_URI=mongodb://mongoAdmin:mongoPassword@mongo:27017
182182
networks:
183183
- twinengine-network
184184

185185
aas-web-ui:
186-
image: eclipsebasyx/aas-gui:v2-260526
186+
image: eclipsebasyx/aas-gui:v2-260801
187187
container_name: aas-ui
188188
volumes:
189189
- ./logo:/usr/src/app/dist/Logo

source/AAS.TwinEngine.DataEngine/Api/AasRepository/Handler/AasRepositoryHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ public Task<ISubmodelElement> GetSubmodelElementByAasIdAsync(GetSubmodelElementB
107107
{
108108
var decodedIdShortPath = Uri.UnescapeDataString(request?.IdShortPath ?? string.Empty);
109109
decodedIdShortPath.ValidateIdShortPath(nameof(request.IdShortPath), logger);
110+
var queryOptions = new SubmodelQueryOptions(request?.Level.ToString(), request?.Extent.ToString());
110111

111112
return GetResourceByIdAsync(
112113
request?.AasIdentifier,
113114
request?.SubmodelId,
114115
"submodel element By AasID",
115-
async (aasId, submodelId) => await aasRepositoryService.GetSubmodelElementByAasIdAsync(aasId, submodelId, decodedIdShortPath, cancellationToken).ConfigureAwait(false));
116+
async (aasId, submodelId) => await aasRepositoryService.GetSubmodelElementByAasIdAsync(aasId, submodelId, decodedIdShortPath, queryOptions, cancellationToken).ConfigureAwait(false));
116117
}
117118

118119
public Task<FileAttachmentResult> GetFileByPathByAasIdAsync(GetFileByPathByAasIdRequest request, CancellationToken cancellationToken)

source/AAS.TwinEngine.DataEngine/Api/AasRepository/Requests/GetSubmodelElementByAasRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
namespace AAS.TwinEngine.DataEngine.Api.AasRepository.Requests;
44

5-
public record GetSubmodelElementByAasRequest(string AasIdentifier, string SubmodelId, string IdShortPath, Level level, Extent extent);
5+
public record GetSubmodelElementByAasRequest(string AasIdentifier, string SubmodelId, string IdShortPath, Level Level, Extent Extent);

source/AAS.TwinEngine.DataEngine/Api/SubmodelRepository/Handler/SubmodelRepositoryHandler.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public class SubmodelRepositoryHandler(
1717
{
1818
public Task<ISubmodel> GetSubmodel(GetSubmodelRequest request, CancellationToken cancellationToken)
1919
{
20-
var queryOptions = request?.Level is not null || request?.Extent is not null ? new SubmodelQueryOptions(request.Level?.ToString(), request.Extent?.ToString()) : null;
20+
var queryOptions = request?.level is not null || request?.extent is not null ? new SubmodelQueryOptions(request.level?.ToString(), request.extent?.ToString()) : null;
2121

2222
return GetResourceByIdAsync(
23-
request?.SubmodelId,
23+
request?.submodelId,
2424
"submodel",
2525
id => submodelRepositoryService.GetSubmodelAsync(id, queryOptions, cancellationToken)!);
2626
}
@@ -30,8 +30,8 @@ public Task<ISubmodelElement> GetSubmodelElement(GetSubmodelElementRequest reque
3030
var decodedIdShortPath = Uri.UnescapeDataString(request?.IdShortPath ?? string.Empty);
3131
decodedIdShortPath.ValidateIdShortPath(nameof(request.IdShortPath), logger);
3232

33-
var queryOptions = request?.Level is not null || request?.Extent is not null
34-
? new SubmodelQueryOptions(request.Level?.ToString(), request.Extent?.ToString())
33+
var queryOptions = request?.level is not null || request?.extent is not null
34+
? new SubmodelQueryOptions(request.level?.ToString(), request.extent?.ToString())
3535
: null;
3636

3737
return GetResourceByIdAsync(
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
namespace AAS.TwinEngine.DataEngine.Api.SubmodelRepository.Requests;
22

3-
public record GetSubmodelElementRequest(string SubmodelId, string IdShortPath)
4-
{
5-
public Level? Level { get; set; }
6-
7-
public Extent? Extent { get; set; }
8-
}
3+
public record GetSubmodelElementRequest(string SubmodelId, string IdShortPath, Level? level = Level.deep, Extent? extent = Extent.withoutBlobValue);
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
namespace AAS.TwinEngine.DataEngine.Api.SubmodelRepository.Requests;
22

3-
public record GetSubmodelRequest(string submodelId)
4-
{
5-
public string SubmodelId { get; } = submodelId;
6-
7-
public Level? Level { get; set; }
8-
9-
public Extent? Extent { get; set; }
10-
}
3+
public record GetSubmodelRequest(string submodelId, Level? level = Level.deep, Extent? extent = Extent.withoutBlobValue);

source/AAS.TwinEngine.DataEngine/Api/SubmodelRepository/SubmodelRepositoryController.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public class SubmodelRepositoryController(
3434
/// <param name="idShort">The Asset Administration Shell's IdShort.</param>
3535
/// <param name="limit">The maximum number of elements in the response array.</param>
3636
/// <param name="cursor">A server-generated identifier retrieved from pagingMetadata.</param>
37-
/// <param name="level">Determines the structural depth of the returned content. Accepted values: <c>deep</c>, <c>core</c>.</param>
38-
/// <param name="extent">Determines the serialization of the returned content. Accepted values: <c>withBlobValue</c>, <c>withoutBlobValue</c>.</param>
37+
/// <param name="level">Determines the structural depth of the returned content.</param>
38+
/// <param name="extent">Determines the serialization of the returned content.</param>
3939
/// <response code="200">Returns the requested Submodels.</response>
4040
/// <response code="400">Bad Request, e.g. the request parameters or request format are invalid.</response>
4141
/// <response code="404">Not Found.</response>
@@ -50,9 +50,9 @@ public async Task<ActionResult<SubmodelsDto>> GetAllSubmodelsAsync(
5050
[FromQuery] string? idShort,
5151
[FromQuery] int? limit,
5252
[FromQuery] string? cursor,
53-
[FromQuery] Level? level,
54-
[FromQuery] Extent? extent,
55-
CancellationToken cancellationToken)
53+
CancellationToken cancellationToken,
54+
[FromQuery] Level level = Level.deep,
55+
[FromQuery] Extent extent = Extent.withoutBlobValue)
5656
{
5757
logger.LogInformation("Get All Submodels");
5858

@@ -77,8 +77,8 @@ public async Task<ActionResult<SubmodelsDto>> GetAllSubmodelsAsync(
7777
/// Returns a specific Submodel.
7878
/// </summary>
7979
/// <param name="submodelIdentifier">The Submodel's unique id (UTF8-BASE64-URL-encoded)</param>
80-
/// <param name="level">Determines the structural depth of the returned content. Accepted values: <c>deep</c>, <c>core</c>.</param>
81-
/// <param name="extent">Controls how blob values are serialized. Accepted values: <c>withBlobValue</c>, <c>withoutBlobValue</c>.</param>
80+
/// <param name="level">Determines the structural depth of the returned content.</param>
81+
/// <param name="extent">Controls how blob values are serialized.</param>
8282
/// <response code="200">Requested Submodel</response>
8383
/// <response code="400">Bad Request, e.g.the request parameters of the format of the request body is wrong.</response>
8484
/// <response code="404">Not Found</response>
@@ -95,7 +95,7 @@ public async Task<ActionResult<JsonObject>> GetSubmodelAsync(
9595
CancellationToken cancellationToken)
9696
{
9797
logger.LogInformation("Get Submodel");
98-
var request = new GetSubmodelRequest(submodelIdentifier) { Level = level, Extent = extent };
98+
var request = new GetSubmodelRequest(submodelIdentifier, level, extent);
9999
var response = await submodelRepositoryHandler.GetSubmodel(request, cancellationToken).ConfigureAwait(false);
100100
return Ok(Jsonization.Serialize.ToJsonObject(response));
101101
}
@@ -106,8 +106,8 @@ public async Task<ActionResult<JsonObject>> GetSubmodelAsync(
106106
/// <param name="submodelIdentifier">The Submodel's unique id (UTF8-BASE64-URL-encoded)</param>
107107
/// <param name="limit">The maximum number of elements in the response array.</param>
108108
/// <param name="cursor">A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue.</param>
109-
/// <param name="level">Determines the structural depth of the returned content. Accepted values: <c>deep</c>, <c>core</c>.</param>
110-
/// <param name="extent">Determines the serialization of the returned content. Accepted values: <c>withBlobValue</c>, <c>withoutBlobValue</c>.</param>
109+
/// <param name="level">Determines the structural depth of the returned content.</param>
110+
/// <param name="extent">Determines the serialization of the returned content.</param>
111111
/// <response code="200">List of found submodel elements</response>
112112
/// <response code="400">Bad Request, e.g. the request parameters or request format are invalid.</response>
113113
/// <response code="404">Not Found</response>
@@ -121,9 +121,10 @@ public async Task<ActionResult<SubmodelElementsDto>> GetAllSubmodelElementsAsync
121121
[FromRoute] string submodelIdentifier,
122122
[FromQuery] int? limit,
123123
[FromQuery] string? cursor,
124-
[FromQuery] Level? level,
125-
[FromQuery] Extent? extent,
126-
CancellationToken cancellationToken)
124+
CancellationToken cancellationToken,
125+
[FromQuery] Level level = Level.deep,
126+
[FromQuery] Extent extent = Extent.withoutBlobValue
127+
)
127128
{
128129
logger.LogInformation("Get All Submodel Elements");
129130
var request = new GetAllSubmodelElementsRequest(submodelIdentifier, limit, cursor, level, extent);
@@ -136,8 +137,8 @@ public async Task<ActionResult<SubmodelElementsDto>> GetAllSubmodelElementsAsync
136137
/// </summary>
137138
/// <param name="submodelIdentifier">The Submodel's unique id (UTF8-BASE64-URL-encoded)</param>
138139
/// <param name="idShortPath">The IdShort path to the submodel element (dot-separated)</param>
139-
/// <param name="level">Determines the structural depth of the returned content. Accepted values: <c>deep</c>, <c>core</c>.</param>
140-
/// <param name="extent">Controls how blob values are serialized. Accepted values: <c>withBlobValue</c>, <c>withoutBlobValue</c>.</param>
140+
/// <param name="level">Determines the structural depth of the returned content.</param>
141+
/// <param name="extent">Controls how blob values are serialized.</param>
141142
/// <response code="200">Requested submodel element</response>
142143
/// <response code="400">Bad Request, e.g.the request parameters of the format of the request body is wrong.</response>
143144
/// <response code="404">Not Found</response>
@@ -155,7 +156,7 @@ public async Task<ActionResult<JsonObject>> GetSubmodelElementAsync(
155156
CancellationToken cancellationToken)
156157
{
157158
logger.LogInformation("Get Submodel Element");
158-
var request = new GetSubmodelElementRequest(submodelIdentifier, idShortPath) { Level = level, Extent = extent };
159+
var request = new GetSubmodelElementRequest(submodelIdentifier, idShortPath, level, extent);
159160
var response = await submodelRepositoryHandler.GetSubmodelElement(request, cancellationToken).ConfigureAwait(false);
160161
return Ok(Jsonization.Serialize.ToJsonObject(response));
161162
}

source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/AasRepository/AasRepositoryService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ public async Task<SubmodelElementsPage> GetAllSubmodelElementsByAasIdAsync(strin
194194
return await submodelRepositoryService.GetAllSubmodelElementsAsync(submodelIdentifier, queryOptions, limit, cursor, cancellationToken).ConfigureAwait(false);
195195
}
196196

197-
public async Task<ISubmodelElement> GetSubmodelElementByAasIdAsync(string aasIdentifier, string submodelIdentifier, string idShortPath, CancellationToken cancellationToken)
197+
public async Task<ISubmodelElement> GetSubmodelElementByAasIdAsync(string aasIdentifier, string submodelIdentifier, string idShortPath, SubmodelQueryOptions? queryOptions, CancellationToken cancellationToken)
198198
{
199199
await ValidateSubmodelBelongsToAasAsync(aasIdentifier, submodelIdentifier, cancellationToken).ConfigureAwait(false);
200200

201-
return await submodelRepositoryService.GetSubmodelElementAsync(submodelIdentifier, idShortPath, null, cancellationToken).ConfigureAwait(false);
201+
return await submodelRepositoryService.GetSubmodelElementAsync(submodelIdentifier, idShortPath, queryOptions, cancellationToken).ConfigureAwait(false);
202202
}
203203

204204
public async Task<FileAttachmentResult> GetFileAttachmentByAasIdAsync(string aasIdentifier, string submodelId, string idShortPath, CancellationToken cancellationToken)

source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/AasRepository/IAasRepositoryService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public interface IAasRepositoryService
2222

2323
Task<SubmodelElementsPage> GetAllSubmodelElementsByAasIdAsync(string aasIdentifier, string submodelIdentifier, SubmodelQueryOptions queryOptions, int? limit, string? cursor, CancellationToken cancellationToken);
2424

25-
Task<ISubmodelElement> GetSubmodelElementByAasIdAsync(string aasIdentifier, string submodelIdentifier, string idShortPath, CancellationToken cancellationToken);
25+
Task<ISubmodelElement> GetSubmodelElementByAasIdAsync(string aasIdentifier, string submodelIdentifier, string idShortPath, SubmodelQueryOptions queryOptions, CancellationToken cancellationToken);
2626

2727
Task<FileAttachmentResult> GetFileAttachmentByAasIdAsync(string aasIdentifier, string submodelId, string idShortPath, CancellationToken cancellationToken);
2828

0 commit comments

Comments
 (0)