Backend API

public class Node implements Comparable

A node correspond to a block on a flow-based program A node is a part of a flow.

To know more about Flow-Based programming : http://www.jpaulmorrison.com/fbp/concepts.html To see the FBP Network Protocol : https://flowbased.github.io/fbp-protocol/#graph-addnode

Created by antoine on 29/05/17.

public String getId ()

Get the unique id of the node.

public void setId (String newId)

Update the id of the node. The ID must be unique !

public Ports getInports()

Get the inports of the node.

public Ports getOutports()

Get the outports of the node.

public JSONObject getMetadata()

Get the metadata of the node.

public void setMetadata(JSONObject metadata)

Set the metadata of the node

public String getGraph()

Get the id of the graph the node is into. The graph can be the root Flow or a group.

public String getComponent()

Get the component on which this node is based. The component name is formatted as : /

public JSONObject getJson()

Get the JSON object containing all the data of the node. Usually used to send the node data to another service.

public boolean isExecutable ()

Is the node executable ?

public String getCode ()

Get the python code of the node. Will be null if not executable.

public JSONObject getResult ()

Get the result of the node’s execution if executable, pickle formatted. Otherwise all the data that it contains. Usually used to inject the data in the beginning of the next nodes for its execution.

public JSONObject getJsonResult()

Get the data of the node as a JSON formatted as key: value pairs.

public JSONObject getPickledResult()

Get the data of the node as pairs of key: pickle. A pickle is a string that is the result of the serialization of any variable in python using pickle.dumps. -> See python documentation.

public void setPickledResult (JSONObject result)

Set the pickle result object. A pickle is a string that is the result of the serialization of any variable in python using pickle.dumps. -> See python documentation.

public void setJsonResult(JSONObject result)

Set the result object, containing all the data to transfer to the nodes connected to the outports.

public void assignPortToEdge (String port, String edge)

Store the information that an edge has been connected to a port of the node.

public void unassignPortToEdge (String port, String edge)

Remove the association between the port of the node and the edge

public JSONObject getPreviousNodesData()

Retrieve the data of all the ports connected to the inports of this node.

public ArrayList previousInFlow ()

Retrieve the list of nodes connected to the inports.

public ArrayList nextInFlow ()

Retrieve the list of nodes connected to the outports. Usually used in order to know what are the next nodes to execute when running the flow.

public boolean isRunning ()

Is the node running ?

public boolean hasFinished ()

Has the node finished running ?

public boolean shouldBeReRun ()

Should the node be re-run ? If this node and this node’s previous nodes in the flow haven’t been modified since the last run it is not necessary to run it again, the result will be exactly the same.

To make sure this is reliable, it will verify that all nodes connected to the inports of this node haven’t been modified, and their own previous node that will themselves verified that their previous node haven’t been modified and so on, recursively.

public boolean noKnownError ()

Has this node a know error ? We know that the node as an error if an error has been thrown during this node’s last run. Then we check if the user modified his/her code since the last error. If he/she does, we suppose that he/she corrected the error.

public boolean lastRunReturnedError ()

Has the last run returned an error ?

public void prepareForExecution ()

Prepare the node for the execution, stopping it if it is already running.

public boolean receivedResultAfterTime (long time)

Has the node received a result after the given time ?

public void errorOccurred ()

Method used to prevent this node that an error occurred during its execution.

public void emptyTraceback ()

Empty the traceback in the metadata

private void build ()

Build the json object representing the node. The json is used to send all the information of this group to any other service.

The JSONObject contains : - id {String} - component {String} - metadata {JSONObject} - graph {String} - inports {JSONObject} - outports {JSONObject}

private Port findPort (String name)

Get a Port from its name

private Port findPortInGivenObject (Ports ports, String name)

Get a Port with the given name in the given Ports object

private ArrayList nextOrPreviousNodeInFlow (Ports ports)

Give all the nodes connected to the opposite side of the edges connected to the given ports. The given ports must be either the inports of this block or the ouports.

private ArrayList oppositeNodesForPort(Port p, boolean previousNode)

Get the nodes connected to the opposite side of the edges connected to the given port. Choose between getting the nodes at the beginning or at the end of the edges.

private void sendUpdateNodeMessage ()

Send an updatenode message to the UIs connected to the workspace this node is on.

private void nodeUpdated ()

React to a nodeUpdated event. The reaction is simply storing the timestamp of the last modification of this node.