Skip to content

Commit 52d2026

Browse files
committed
keep alias name in response
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
1 parent 22dcc96 commit 52d2026

1 file changed

Lines changed: 2 additions & 32 deletions

File tree

  • bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/persistence

bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/persistence/PersistenceResource.java

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public Response httpDeletePersistenceServiceConfiguration(@Context UriInfo uriIn
271271
@RolesAllowed({ Role.ADMIN })
272272
@Path("/items")
273273
@Produces({ MediaType.APPLICATION_JSON })
274-
@Operation(operationId = "getItemsForPersistenceService", summary = "Gets a list of Items available via a specific persistence service.", security = {
274+
@Operation(operationId = "getItemsForPersistenceService", summary = "Gets a list of stored Items available via a specific persistence service with their stored name.", security = {
275275
@SecurityRequirement(name = "oauth2", scopes = { "admin" }) }, responses = {
276276
@ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersistenceItemInfo.class), uniqueItems = true))),
277277
@ApiResponse(responseCode = "404", description = "Unknown persistence service or Item not found in persistence store"),
@@ -643,8 +643,6 @@ private Response getServiceItemListDTO(@Nullable String serviceId, @Nullable Str
643643

644644
PersistenceServiceConfiguration config = persistenceServiceConfigurationRegistry.get(effectiveServiceId);
645645
Map<String, String> itemToAlias = config != null ? config.getAliases() : Map.of();
646-
Map<String, String> aliasToItem = itemToAlias.entrySet().stream()
647-
.collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey, (existing, ignored) -> existing));
648646

649647
Set<PersistenceItemInfo> itemInfo = null;
650648
try {
@@ -663,35 +661,7 @@ private Response getServiceItemListDTO(@Nullable String serviceId, @Nullable Str
663661
return JSONResponse.createErrorResponse(Status.METHOD_NOT_ALLOWED,
664662
"Not supported for persistence service:" + effectiveServiceId);
665663
}
666-
Set<PersistenceItemInfoDTO> mappedItemInfo = itemInfo.stream().map(info -> {
667-
String item = aliasToItem.get(info.getName());
668-
if (item != null) {
669-
return new PersistenceItemInfo() {
670-
671-
@Override
672-
public String getName() {
673-
return item;
674-
}
675-
676-
@Override
677-
public @Nullable Integer getCount() {
678-
return info.getCount();
679-
}
680-
681-
@Override
682-
public @Nullable Date getEarliest() {
683-
return info.getEarliest();
684-
}
685-
686-
@Override
687-
public @Nullable Date getLatest() {
688-
return info.getLatest();
689-
}
690-
};
691-
} else {
692-
return info;
693-
}
694-
}).map(this::createDTO).collect(Collectors.toSet());
664+
Set<PersistenceItemInfoDTO> mappedItemInfo = itemInfo.stream().map(this::createDTO).collect(Collectors.toSet());
695665
return JSONResponse.createResponse(Status.OK, mappedItemInfo, "");
696666
}
697667

0 commit comments

Comments
 (0)