public class

StatefulTaskProgressSink

extends Object
implements TaskProgressSink
java.lang.Object
   ↳ com.atlassian.jira.task.StatefulTaskProgressSink
Known Direct Subclasses

Class Overview

A simple TaskProgressSink thats keeps track of progress. It keeps track of the last progress stored sent. The actual reporting of progress will be made through another sink.

Summary

[Expand]
Inherited Fields
From interface com.atlassian.jira.task.TaskProgressSink
Public Constructors
StatefulTaskProgressSink(long minProgress, long maxProgress, long currentProgress, TaskProgressSink delegateSink)
Create the sink.
StatefulTaskProgressSink(long minProgress, long maxProgress, TaskProgressSink delegateSink)
Create the sink.
Public Methods
static Collection<StatefulTaskProgressSink> createPercentageSinksForRange(long startRange, long endRange, int numberOfDivisions, TaskProgressSink sink)
Return a collection of sinks that allows progress to be reported across the specified ragnge.
StepTaskProgressSink createStepSinkView(long startProgress, long length, int numberOfActions)
Create a StepTaskProgressSink that maps its progress onto a specific range of this sink.
StepTaskProgressSink createStepSinkView(long length, int numberOfActions)
Create a StepTaskProgressSink that maps its progress onto a specific range of this sink.
long getMaxProgress()
long getMinProgress()
long getProgress()
void makeProgress(String currentSubTask, String message)
Send a new progress message without changing the current task progress.
void makeProgress(long taskProgress, String currentSubTask, String message)
This method can be called to indicate that progress is being made by a task.
void makeProgressIncrement(long increment, String currentSubTask, String message)
This method can be called to indicate that progress is being made by a task.
void setProgress(long currentProgress)
Set the progress stored in the sink.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.atlassian.jira.task.TaskProgressSink

Public Constructors

public StatefulTaskProgressSink (long minProgress, long maxProgress, long currentProgress, TaskProgressSink delegateSink)

Create the sink.

Parameters
minProgress the smallest task progress that the sink can report.
maxProgress the largest task progress that the sink can report.
currentProgress the initial task progress stored within the sink.
delegateSink the sink that will be used for reporting.

public StatefulTaskProgressSink (long minProgress, long maxProgress, TaskProgressSink delegateSink)

Create the sink. The initial current progress stored in the sink will be set to its configured minimum.

Parameters
minProgress the smallest task progress that the sink can report.
maxProgress the largest task progress that the sink can report.
delegateSink the sink that will be used for reporting.

Public Methods

public static Collection<StatefulTaskProgressSink> createPercentageSinksForRange (long startRange, long endRange, int numberOfDivisions, TaskProgressSink sink)

Return a collection of sinks that allows progress to be reported across the specified ragnge. Each sink will service a small section of that range. This is commonly used when a task can be divided up into a number of steps that each need to process their progress independently. For example:

  Collection projects = ...;
  Iterator sinkIterator = StatefulTaskProgressSink.createPercentageSinksForRange(0, 100, projects.size(), ...);
  for (project : projects)
  {
      migrateProject(projects, sinkIterator.next());
  }
 

Parameters
startRange start of the progress range to divide.
endRange end of the progress range to divide.
numberOfDivisions the number of intervals in the range.
sink the sink used to report progress.
Returns
  • a Collection of StateTaskProgressSink that divides the interval as specified.

public StepTaskProgressSink createStepSinkView (long startProgress, long length, int numberOfActions)

Create a StepTaskProgressSink that maps its progress onto a specific range of this sink. This can be used to keep track of a part of a task that is divided into a number of smaller steps.

Parameters
startProgress the start of the range on this sink to map back to.
length the length of the range on this sink the view will map back to.
numberOfActions to number of steps the returned sink should work for.
Returns

public StepTaskProgressSink createStepSinkView (long length, int numberOfActions)

Create a StepTaskProgressSink that maps its progress onto a specific range of this sink. This can be used to keep track of a part of a task that is divided into a number of smaller steps. The start of the range is taken to be the current progress stored in this project.

Parameters
length the length of the range on this sink the view will map back to.
numberOfActions to number of steps the returned sink should work for.
Returns

public long getMaxProgress ()

Returns
  • the largest progress allowed.

public long getMinProgress ()

Returns
  • the smallest progess allowed.

public long getProgress ()

Returns
  • the progress recorded in this object. It is the last progress sent.

public void makeProgress (String currentSubTask, String message)

Send a new progress message without changing the current task progress.

Parameters
currentSubTask the name of the current sub task or null if there isn't one
message an optional message about the progress or null

public void makeProgress (long taskProgress, String currentSubTask, String message)

This method can be called to indicate that progress is being made by a task.

Parameters
taskProgress the current status of the task. This value will be clamped between the minimum and maximum progress specified when the object is constructed.
currentSubTask the name of the current sub task or null if there isn't one
message an optional message about the progress or null

public void makeProgressIncrement (long increment, String currentSubTask, String message)

This method can be called to indicate that progress is being made by a task. The current status is incremented by the passed amount.

Parameters
increment the amount to increment the current progress by.
currentSubTask the name of the current sub task or null if there isn't one
message an optional message about the progress or null

public void setProgress (long currentProgress)

Set the progress stored in the sink.

Parameters
currentProgress the progress to store in sink.