Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public CompletableFuture<Map<DeviceId, Optional<Map<String, String>>>>
- getMultipleDeviceLastKnownCategoriesInfo(
- Set<UserId> userIds, Set<DeviceId> deviceIds, TracingContext tracingContext) {
- logger.debug(
- tracingContext,
- "LastKnownService -> getting getUsersLastKnowns for userIds {}",
- userIds.stream().map(UserId::value).collect(Collectors.joining(",")));
- final CompletableFuture<Map<DeviceId, Optional<Map<String, String>>>> resultFuture =
- new CompletableFuture<>();
- final List<String> userIdsParams =
- userIds.stream().map(UserId::value).collect(Collectors.toList());
- final CSVParams categories = new CSVParams(WANTED_CATEGORIES);
- final Call<UsersLastKnownsInternal> call =
- lastKnownApi.getUsersLastKnowns(
- userIdsParams, categories, tracingContext.getCorrelationId().getValue());
- enqueue(
- call,
- tracingContext,
- handleResultWith404(
- resultFuture,
- true,
- result ->
- Optional.ofNullable(result)
- .map(
- r ->
- r.getUsers().stream()
- .flatMap(item -> item.getDevices().stream())
- .collect(
- JavaUtils.collectMapAndAddMissing(
- deviceIds,
- d -> DeviceId.create(d.getDeviceId()),
- d ->
- d.getLastKnowns().stream()
- .collect(
- Collectors.toMap(
- LastKnownInternal::getCategory,
- LastKnownInternal::getInfo)))))
- .orElse(Collections.emptyMap()),
- tracingContext));
- return resultFuture;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement