Finding nodes
Flows provide a number of ways for locating an existing node. These methods are summarized in the following table.
| Method | Return type | Description |
|---|---|---|
s.findAll(type, label) |
Collection | Returns a list of all nodes with the specified
type and label. Either the type or label can be None,
in which case the other parameter is used. |
s.findAll(filter, recursive) |
Collection | Returns a collection of all nodes that are accepted by the specified filter.
If the recursive flag is True, any SuperNodes within the specified flow are also
searched. |
s.findByID(id) |
Node | Returns the node with the supplied ID or None if
no such node exists. The search is limited to the current stream. |
s.findByType(type, label) |
Node | Returns the node with the supplied type, label,
or both. Either the type or name can be None, in
which case the other parameter is used. If multiple nodes result in
a match, then an arbitrary one is chosen and returned. If no nodes
result in a match, then the return value is None. |
s.findDownstream(fromNodes) |
Collection | Searches from the supplied list of nodes and returns the set of nodes downstream of the supplied nodes. The returned list includes the originally supplied nodes. |
s.findUpstream(fromNodes) |
Collection | Searches from the supplied list of nodes and returns the set of nodes upstream of the supplied nodes. The returned list includes the originally supplied nodes. |
s.findProcessorForID(String id, boolean recursive) |
Node | Returns the node with the supplied ID or None if no such node
exists. If the recursive flag is true, then any composite nodes within this diagram
are also searched. |
As an example, if a flow contains a single Filter node that the script needs to access, the Filter node can be found by using the following script:
stream = modeler.script.stream()
node = stream.findByType("filter", None)
...
Alternatively, you can use the ID of a node. For example:
stream = modeler.script.stream()
node = stream.findByID("id49CVL4GHVV8") # the Derive node ID
node.setPropertyValue("mode", "Multiple")
node.setPropertyValue("name_extension", "new_derive")
To obtain the ID for any node in a flow, click the Scripting icon on the
toolbar, then select the desired node in your flow and click Insert selected node
ID. 
