Class: GraphService

GraphService

Service which will take care of create nodes.
It will also check the correctness of the graph.
i.e. check if there is no cycle, the workflow has a name, every service has a name too, etc..


new GraphService()

Constructor.

Source:

Members


cy :any

Instance of cytoscape.
Every manipulation of the graph is done with this property.

Type:
  • any
Source:

lastNodeID :number

Auto-increment ID for nodes.

Type:
  • number
Source:

Methods


addNode(id, service, position)

Add node to the graph.
Method used when importing json to create graph.

Parameters:
Name Type Description
id string

The node id

service Service

The Service instance of this node

position any

The position of the node

Source:

addNodeOnClick(event)

Add node to the graph (when clicking on the screen).
Display it in the current position of the mouse when click event is triggered.

Parameters:
Name Type Description
event any

The event object cytoscape used for position purposes

Source:

checkEdgeHandlesExtEnabled()

Check if the cytoscape extension edgehandles is enabled.
Used as test for event listeners in the graph.

Source:

clearGraph()

Clear the graph by removing all elements.

Source:

getEdges()

Get edges of the graph.

Source:
Returns:

The edges of the graph

Type
any

getNodeById(id)

Get a node by its id.

Parameters:
Name Type Description
id number

The id of the node

Source:
Returns:

The node of the graph which match the id (if exist)

Type
any

getNodes()

Get nodes of the graph.

Source:
Returns:

The nodes of the graph

Type
any

getNodesBySelector(selector)

Get nodes of the graph matching the specified selector.

Parameters:
Name Type Description
selector string

The selector

Source:
Returns:

The nodes matching the specified selector


getServiceByName(name)

Get a node by the name of its service.

Parameters:
Name Type Description
name string

The name of the service

Source:
Returns:

The node corresponding to the service name 'name'

Type
any

isAllServicesWithSrv()

Check if all services have a srv field (a.k.a. a command name for each service).

Source:
Returns:

true if all services have a srv, false otherwise

Type
boolean

isGraphCyclic(currentNode)

Check if the graph has cycle(s) recursively.

Parameters:
Name Type Description
currentNode any

The current node

Source:
Returns:

true if the graph has one or more cycles, false otherwise

Type
boolean

isGraphWithRoots()

Check if the graph has at least one root (basic cycle checking).

Source:
Returns:

true if the graph has one root or more, false otherwise

Type
boolean

isWorkflowWithName(workflowName)

Check if the workflow has a name.

Parameters:
Name Type Description
workflowName string

The name of the workflow

Source:
Returns:

true if the workflow has a name, false otherwise

Type
boolean

isWorkflowWithNoService()

Check if the workflow has at least one service.

Source:
Returns:

true if the workflow has at least one service, false otherwise

Type
boolean