xflow.common
Class Node

java.lang.Object
  extended byxflow.common.Node
All Implemented Interfaces:
java.io.Serializable

public class Node
extends java.lang.Object
implements java.io.Serializable

The Node class represents a node in a directed graph. A directed graph is used to represent a workflow model.

See Also:
Serialized Form

Field Summary
static java.lang.String AND
           
static java.lang.String CONTAINER
           
static java.lang.String END
           
static java.lang.String OR
           
static java.lang.String PROCESS
           
static java.lang.String START
           
 
Constructor Summary
Node()
           
Node(int nodeId)
          Constructs a new node
Node(java.lang.String nodeName, java.lang.String nodeType)
          Constructs a new node
 
Method Summary
 void addDestination(Node node, java.lang.String rule)
          Adds a destination and a rule to evaluate a workflowobject's transition to this destination.
 void addFromNode(Node node)
          Adds a fromNode to this node
 boolean detectCycle()
          Detects if the graph contains cycles.
 void expand()
          Recursively loads this node and all nodes reachable from this node from database.
 java.lang.String getContainee()
          Returns the node's containee graph name.
 int getContaineeVersion()
          Returns the node's containee graph version.
 java.lang.String getDescription()
          Returns node description
 java.util.List getDestinations()
           
 java.util.List getFromNodes()
           
 java.lang.String getName()
           
 Node getNode(int nodeId)
          Finds and returns a node within a graph given a node ID
 Node getNode(java.lang.String name)
          Finds and returns a node within a graph given a node name
 int getNodeId()
          Returns the node ID
 java.lang.Integer getNodeIdAsInteger()
          Returns the node ID
 java.lang.String getNodeName()
          Deprecated. use getName Returns the node name
 java.util.List getNodes()
           
 java.util.List getNodes(java.lang.String nodeType)
           
 java.lang.String getNodeType()
          Returns the node type
 java.lang.Object getProperty(java.lang.String key)
          Gets a node's property
 java.lang.String getTimeoutHandler()
          Gets the timeout handler for a Process node
 int getTimeoutMinutes()
          Gets the timeout for a Process node
 java.lang.String getType()
           
 boolean isValidated()
           
 void print()
          Prints out node id and description of node.
 void saveDB(int gid)
          Recursively saves a node, its destinations and all links between nodes to the database.
 void setContainee(java.lang.String graphName)
          Sets the node's containee graph name.
 void setContaineeVersion(int version)
          Sets the node's containee graph version.
 void setDescription(java.lang.String d)
          Sets the node description
 void setDestinations(java.util.List destinations)
           
 void setName(java.lang.String name)
           
 void setNodeId(int nodeId)
           
 void setNodeType(java.lang.String nodeType)
           
 void setProperty(java.lang.String key, java.lang.Object value)
          Sets a property on a node
 void setTimeoutHandler(java.lang.String timeoutHandler)
          Sets the timeout handler for a Process node
 void setTimeoutMinutes(int timeoutMinutes)
          Sets the timeout value for a Process node
 void setType(java.lang.String type)
           
 void setValidated()
           
 void traverse()
          Recursively traverses all the nodes of a graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROCESS

public static final java.lang.String PROCESS
See Also:
Constant Field Values

AND

public static final java.lang.String AND
See Also:
Constant Field Values

OR

public static final java.lang.String OR
See Also:
Constant Field Values

START

public static final java.lang.String START
See Also:
Constant Field Values

END

public static final java.lang.String END
See Also:
Constant Field Values

CONTAINER

public static final java.lang.String CONTAINER
See Also:
Constant Field Values
Constructor Detail

Node

public Node()

Node

public Node(java.lang.String nodeName,
            java.lang.String nodeType)
Constructs a new node

Parameters:
nodeName -

Node

public Node(int nodeId)
Constructs a new node

Parameters:
nodeId -
Method Detail

getNodeId

public int getNodeId()
Returns the node ID

Returns:
int nodeId

setNodeId

public void setNodeId(int nodeId)

setNodeType

public void setNodeType(java.lang.String nodeType)

setDestinations

public void setDestinations(java.util.List destinations)

getNodeIdAsInteger

public java.lang.Integer getNodeIdAsInteger()
Returns the node ID

Returns:
Integer nodeId

getType

public java.lang.String getType()

setType

public void setType(java.lang.String type)

getNodeName

public java.lang.String getNodeName()
Deprecated. use getName Returns the node name

Returns:
String node name

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)

getNodeType

public java.lang.String getNodeType()
Returns the node type

Returns:
String node type

getDescription

public java.lang.String getDescription()
Returns node description

Returns:
description

setDescription

public void setDescription(java.lang.String d)
Sets the node description

Parameters:
d -

getContainee

public java.lang.String getContainee()
Returns the node's containee graph name. Only valid if node's type is CONTAINER

Returns:
containee

setContainee

public void setContainee(java.lang.String graphName)
Sets the node's containee graph name. Only valid if node's type is CONTAINER

Parameters:
graphName -

getContaineeVersion

public int getContaineeVersion()
Returns the node's containee graph version. Only valid if node's type is CONTAINER

Returns:
containeeVersion

setContaineeVersion

public void setContaineeVersion(int version)
Sets the node's containee graph version. Only valid if node's type is CONTAINER

Parameters:
version -

expand

public void expand()
            throws java.lang.Exception
Recursively loads this node and all nodes reachable from this node from database.

Throws:
java.lang.Exception

saveDB

public void saveDB(int gid)
            throws java.lang.Exception
Recursively saves a node, its destinations and all links between nodes to the database.

Parameters:
gid - The graph ID
Throws:
java.lang.Exception

detectCycle

public boolean detectCycle()
Detects if the graph contains cycles.


traverse

public void traverse()
Recursively traverses all the nodes of a graph. Useful for debugging.


print

public void print()
Prints out node id and description of node. Useful for debugging.


getNode

public Node getNode(int nodeId)
Finds and returns a node within a graph given a node ID

Parameters:
nodeId - The node ID for finding
Returns:
Node the result, null if not found

getNode

public Node getNode(java.lang.String name)
Finds and returns a node within a graph given a node name

Parameters:
name - The node name for finding
Returns:
Node the result, null if not found

addDestination

public void addDestination(Node node,
                           java.lang.String rule)
Adds a destination and a rule to evaluate a workflowobject's transition to this destination.

Parameters:
node - The destination node
rule - The rule for reaching this destination

getDestinations

public java.util.List getDestinations()
Returns:
List - this node's list of destinations

addFromNode

public void addFromNode(Node node)
Adds a fromNode to this node

Parameters:
node - The from node

getFromNodes

public java.util.List getFromNodes()
Returns:
List - this node's list of from nodes

getNodes

public java.util.List getNodes(java.lang.String nodeType)
Returns:
List - all descendant nodes of specified type

getNodes

public java.util.List getNodes()
Returns:
List - all descendant nodes

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object value)
Sets a property on a node

Parameters:
key - the property name
value - the property value - must be serializable

getProperty

public java.lang.Object getProperty(java.lang.String key)
Gets a node's property

Parameters:
key - the property name
Returns:
the property value

setTimeoutMinutes

public void setTimeoutMinutes(int timeoutMinutes)
Sets the timeout value for a Process node

Parameters:
timeoutMinutes - the timeout in minutes

getTimeoutMinutes

public int getTimeoutMinutes()
Gets the timeout for a Process node

Returns:
the timeout in minutes

setTimeoutHandler

public void setTimeoutHandler(java.lang.String timeoutHandler)
Sets the timeout handler for a Process node

Parameters:
timeoutHandler - the name of the timeout handler (a workflow name)

getTimeoutHandler

public java.lang.String getTimeoutHandler()
Gets the timeout handler for a Process node

Returns:
the timeout handler name

setValidated

public void setValidated()

isValidated

public boolean isValidated()