dominikriemer commented on code in PR #1675:
URL: https://github.com/apache/streampipes/pull/1675#discussion_r1229031355
##########
streampipes-extensions/streampipes-connectors-opcua/src/main/java/org/apache/streampipes/extensions/connectors/opcua/adapter/OpcUaNodeBrowser.java:
##########
@@ -104,23 +103,44 @@ private OpcNode toOpcNode(String nodeName) throws
UaException {
throw new UaException(StatusCode.BAD, "Node is not of type
BaseDataVariableTypeNode");
}
- private CompletableFuture<Void> buildTreeAsync(OpcUaClient client,
TreeInputNode tree) {
- NodeId nodeId = NodeId.parse(tree.getInternalNodeName());
- return client.getAddressSpace().browseNodesAsync(nodeId).thenCompose(nodes
-> {
- nodes.forEach(node -> {
- TreeInputNode childNode = new TreeInputNode();
- childNode.setNodeName(node.getDisplayName().getText());
- childNode.setInternalNodeName(node.getNodeId().toParseableString());
- childNode.setDataNode(isDataNode(node));
- tree.addChild(childNode);
+ private List<TreeInputNode> findChildren(OpcUaClient client,
+ NodeId nodeId) throws UaException {
+ return client
+ .getAddressSpace()
+ .browseNodes(nodeId)
+ .stream()
+ .map(node -> {
+ TreeInputNode childNode = new TreeInputNode();
+ childNode.setNodeName(node.getDisplayName().getText());
+ childNode.setInternalNodeName(node.getNodeId().toParseableString());
+ childNode.setDataNode(isDataNode(node));
+ childNode.setNodeMetadata(buildMetadata(client, node));
+ return childNode;
+ })
+ .collect(Collectors.toList());
+ }
- });
+ private Map<String, Object> buildMetadata(OpcUaClient client,
+ UaNode node) {
+ var metadata = new HashMap<String, Object>();
+ metadata.put("NamespaceIndex",
node.getNodeId().getNamespaceIndex().toString());
+ metadata.put("NodeClass", node.getNodeClass().toString());
+ metadata.put("Description", node.getDescription().getText());
+ metadata.put("BrowseName", node.getBrowseName().getName());
+ metadata.put("DisplayName", node.getDisplayName().getText());
- Stream<CompletableFuture<Void>> futures =
- tree.getChildren().stream().map(child -> buildTreeAsync(client,
child));
+ if (node instanceof UaVariableNode) {
+ var dataTypeNodeId = ((UaVariableNode) node).getDataType();
+ metadata.put("Value", String.valueOf(((UaVariableNode)
node).getValue().getValue().getValue()));
Review Comment:
We can work on that as part of #889
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]