use of org.eclipse.milo.opcua.stack.core.util.FutureUtils in project milo by eclipse.
the class DataTypeDictionaryReader method readDataTypeDictionaries.
public CompletableFuture<List<DataTypeDictionary<?>>> readDataTypeDictionaries() {
CompletableFuture<List<ReferenceDescription>> browseFuture = browseNode(new BrowseDescription(Identifiers.OPCBinarySchema_TypeSystem, BrowseDirection.Forward, Identifiers.HasComponent, false, uint(NodeClass.Variable.getValue()), uint(BrowseResultMask.All.getValue())));
CompletableFuture<Stream<NodeId>> dictionaryNodeIds = browseFuture.thenApply(references -> references.stream().filter(r -> r.getTypeDefinition().equalTo(Identifiers.DataTypeDictionaryType)).flatMap(r -> opt2stream(r.getNodeId().toNodeId(stackClient.getNamespaceTable()))));
return dictionaryNodeIds.thenApply(nodeIds -> nodeIds.map(this::readDataTypeDictionary).collect(Collectors.toList())).thenCompose(FutureUtils::sequence).thenApply(list -> list.stream().filter(Objects::nonNull).collect(Collectors.toList()));
}
Aggregations