Class FlowNode
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Actionable
-
- org.jenkinsci.plugins.workflow.graph.FlowNode
-
- All Implemented Interfaces:
ModelObject
,Saveable
,SearchableModelObject
,SearchItem
,ModelObjectWithContextMenu
- Direct Known Subclasses:
AtomNode
,BlockEndNode
,BlockStartNode
@ExportedBean public abstract class FlowNode extends Actionable implements Saveable
One node in a flow graph.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FlowNode(FlowExecution exec, String id, List<FlowNode> parents)
protected
FlowNode(FlowExecution exec, String id, FlowNode... parents)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
equals(Object obj)
<T extends Action>
TgetAction(Class<T> type)
List<Action>
getActions()
List<String>
getAllEnclosingIds()
Returns a read-only view of the IDs for enclosing blocks of this flow node, innermost first.String
getDisplayFunctionName()
String
getDisplayName()
List<? extends BlockStartNode>
getEnclosingBlocks()
Get the list of enclosingBlockStartNode
s, starting from innermost, for this node.String
getEnclosingId()
Get theid
of the enclosingBlockStartNode
for this node, or null if none.ErrorAction
getError()
If this node has terminated with an error, return an object that indicates that.FlowExecution
getExecution()
BallColor
getIconColor()
Returns colored orb that represents the current state of this node.String
getId()
Has to be unique within aFlowExecution
.List<String>
getParentIds()
List<FlowNode>
getParents()
Returns a read-only view of parents.<T extends Action>
TgetPersistentAction(Class<T> type)
Return the first nontransientAction
on the FlowNode, without consultingTransientActionFactory
sString
getSearchUrl()
Reference from the parentSearchItem
is throughFlowExecution.getNode(String)
protected abstract String
getTypeDisplayName()
Gets a human readable name for this type of the node.protected String
getTypeFunctionName()
Gets a human readable text that may include aStepDescriptor.getFunctionName()
.String
getUrl()
Returns the URL of thisFlowNode
, relative to the context root of Jenkins.int
hashCode()
boolean
isActive()
Checks whether a node is still part of the active part of the graph.boolean
isRunning()
Deprecated.UsuallyisActive()
is what you want.Iterable<BlockStartNode>
iterateEnclosingBlocks()
Return an iterator over all enclosing blocks, from the nearest-enclosing outward ("inside-out" order).protected Object
readResolve()
void
save()
Explicitly save all the actions in thisFlowNode
.protected void
setActions(List<Action> actions)
SPI for subtypes to directly manipulate the actions field.String
toString()
-
Methods inherited from class hudson.model.Actionable
addAction, addOrReplaceAction, doContextMenu, getAction, getActions, getAllActions, getDynamic, removeAction, removeActions, replaceAction, replaceActions
-
Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
-
-
-
-
Constructor Detail
-
FlowNode
protected FlowNode(FlowExecution exec, String id, List<FlowNode> parents)
-
FlowNode
protected FlowNode(FlowExecution exec, String id, FlowNode... parents)
-
-
Method Detail
-
readResolve
protected Object readResolve() throws ObjectStreamException
- Throws:
ObjectStreamException
-
isRunning
@Deprecated public final boolean isRunning()
Deprecated.UsuallyisActive()
is what you want. If you really wanted the original behavior, useFlowExecution.isCurrentHead(org.jenkinsci.plugins.workflow.graph.FlowNode)
.Transient flag that indicates if this node is currently actively executing something.It will be false for a node which still has active children, like a step with a running body. It will also be false for something that has finished but is pending child node creation, such as a completed fork branch which is waiting for the join node to be created.
This can only go from true to false.
-
isActive
@Exported(name="running") public final boolean isActive()
Checks whether a node is still part of the active part of the graph. UnlikeisRunning()
, this behaves intuitively for aBlockStartNode
: it will be considered active until theBlockEndNode
is added.
-
getError
@CheckForNull public final ErrorAction getError()
If this node has terminated with an error, return an object that indicates that. This is just a convenience method.
-
getExecution
@NonNull public FlowExecution getExecution()
-
getEnclosingId
@CheckForNull public String getEnclosingId()
Get theid
of the enclosingBlockStartNode
for this node, or null if none. OnlyFlowStartNode
andFlowEndNode
should generally return null.
-
getEnclosingBlocks
@NonNull public List<? extends BlockStartNode> getEnclosingBlocks()
Get the list of enclosingBlockStartNode
s, starting from innermost, for this node. May be empty if we are theFlowStartNode
orFlowEndNode
-
iterateEnclosingBlocks
@NonNull public Iterable<BlockStartNode> iterateEnclosingBlocks()
Return an iterator over all enclosing blocks, from the nearest-enclosing outward ("inside-out" order). Prefer this togetEnclosingBlocks()
unless you need ALL nodes, because it can evaluate lazily.
-
getAllEnclosingIds
@NonNull public List<String> getAllEnclosingIds()
Returns a read-only view of the IDs for enclosing blocks of this flow node, innermost first. May be empty.
-
getParentIds
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) @Exported(name="parents") @NonNull public List<String> getParentIds()
-
getId
@Exported public String getId()
Has to be unique within aFlowExecution
. Needs to remain stable across serialization and JVM restarts.- See Also:
FlowExecution.getNode(String)
-
getSearchUrl
public final String getSearchUrl()
Reference from the parentSearchItem
is throughFlowExecution.getNode(String)
- Specified by:
getSearchUrl
in interfaceSearchItem
-
getDisplayName
@Exported public String getDisplayName()
- Specified by:
getDisplayName
in interfaceModelObject
-
getDisplayFunctionName
public String getDisplayFunctionName()
-
getIconColor
@Exported public BallColor getIconColor()
Returns colored orb that represents the current state of this node.
-
getTypeDisplayName
protected abstract String getTypeDisplayName()
Gets a human readable name for this type of the node. This is used to implementgetDisplayName()
as a fallback in caseLabelAction
does not exist.
-
getTypeFunctionName
protected String getTypeFunctionName()
Gets a human readable text that may include aStepDescriptor.getFunctionName()
. It would return "echo" for a flow node linked to an EchoStep or "ws {" for WorkspaceStep. For StepEndNode it would return "} // step.getFunctionName()". Note that this method should be abstract (supposed to be implemented in all subclasses), but keeping it non-abstract to avoid binary incompatibilities.- Returns:
- the text human-readable representation of the step function name
or
getDisplayName()
by default (if not overriden in subclasses)
-
getUrl
@Exported public String getUrl() throws IOException
Returns the URL of thisFlowNode
, relative to the context root of Jenkins.- Returns:
- String like "job/foo/32/execution/node/abcde/" with no leading slash but trailing slash.
- Throws:
IOException
-
setActions
protected void setActions(List<Action> actions)
SPI for subtypes to directly manipulate the actions field. When a brand newFlowNode
is created, or whenFlowNode
and actions are stored in close proximity, it is convenient to be able to set theactions
so as to eliminate the separate call toFlowActionStorage.loadActions(FlowNode)
. This method provides such an opportunity for subtypes.
-
getPersistentAction
@CheckForNull public final <T extends Action> T getPersistentAction(@NonNull Class<T> type)
Return the first nontransientAction
on the FlowNode, without consultingTransientActionFactory
sThis is not restricted to just Actions implementing
PersistentAction
but usually they should. Used here because it is much faster than basegetAction(Class)
method.- Type Parameters:
T
- Action type- Parameters:
type
- Class of action- Returns:
- First nontransient action or null if not found.
-
getAction
@CheckForNull public <T extends Action> T getAction(Class<T> type)
- Overrides:
getAction
in classActionable
-
getActions
@Exported @NonNull public List<Action> getActions()
- Overrides:
getActions
in classActionable
-
save
public void save() throws IOException
- Specified by:
save
in interfaceSaveable
- Throws:
IOException
-
-