Class ContainerProgressionTracker
java.lang.Object
org.ametys.core.schedule.progression.AbstractProgressionTracker
org.ametys.core.schedule.progression.ContainerProgressionTracker
- All Implemented Interfaces:
ProgressionTracker
Container implementation that tracks a progression with steps
-
Field Summary
Fields inherited from class org.ametys.core.schedule.progression.AbstractProgressionTracker
_factory, _label, _parent
-
Method Summary
Modifier and TypeMethodDescriptionaddContainerStep
(String id, I18nizableText label) Add a stepaddContainerStep
(String id, I18nizableText label, double weight) Add a stepaddSimpleStep
(String id, I18nizableText label) Add a stepaddSimpleStep
(String id, I18nizableText label, double weight) Add a stepdouble
Get the progression percentage, that can be simplyProgressionTracker.getIndex()
/ProgressionTracker.getSize()
or a more complex algorithm when handling children progressions<T extends ProgressionTracker>
TGet a step by its id, it searches for the step in all the tree of progression tracker<T extends ProgressionTracker>
TGet the current steplong
getIndex()
Get the index of the current steplong
getSize()
Get the sizegetStep
(int index) Get a step by its index<T extends ProgressionTracker>
TGet a step by its id in the direct children of this containervoid
Increment the unique-step of theProgressionTracker
of 1 incrementvoid
increment
(long increment) Increment the unique-step of theProgressionTracker
void
Increment theProgressionTracker
of id wanted of 1 incrementvoid
Increment theProgressionTracker
of id wanted of the requested incrementvoid
setSize
(long size) Initialize the progression with a unique sub step and set its size Use only when steps are not initialized yetvoid
Initialize the progression with a unique sub step and set its size Use only when steps are not initialized yetvoid
setSize
(long size, I18nizableText label) Initialize the progression with a unique sub step and set its size Use only when steps are not initialized yetvoid
Set the size of aProgressionTracker
by its idvoid
Set the steps from a JSONtoJSON()
Get the progression tracker as a JSONMethods inherited from class org.ametys.core.schedule.progression.AbstractProgressionTracker
_getHierarchicalLabel, _getLogger, _getLogPrefix, getId, getLabel, getParent
-
Method Details
-
getIndex
Description copied from interface:ProgressionTracker
Get the index of the current step- Returns:
- The index between [1 and size]
-
getSize
Description copied from interface:ProgressionTracker
Get the size- Returns:
- The size
-
asPercentage
Description copied from interface:ProgressionTracker
Get the progression percentage, that can be simplyProgressionTracker.getIndex()
/ProgressionTracker.getSize()
or a more complex algorithm when handling children progressions- Returns:
- The progression (between 0 and 100)
-
getStep
Get a step by its index- Parameters:
index
- The index between 0 and size-1- Returns:
- The
ProgressionTracker
found - Throws:
IllegalArgumentException
- If no progression tracker was found for id
-
getCurrentStep
Get the current step- Type Parameters:
T
- The type of tracker- Returns:
- The
ProgressionTracker
found or null if no step exists - Throws:
IllegalArgumentException
- If no step exists
-
addSimpleStep
Add a step- Parameters:
label
- The label of the stepid
- The unique id of the step- Returns:
- A new
SimpleProgressionTracker
of weight 1
-
addSimpleStep
Add a step- Parameters:
id
- The unique id of the steplabel
- The label of the stepweight
- The weight wanted- Returns:
- A new
SimpleProgressionTracker
-
addContainerStep
Add a step- Parameters:
id
- The unique id of the steplabel
- The label of the step- Returns:
- A new
ContainerProgressionTracker
of weight 1
-
addContainerStep
Add a step- Parameters:
id
- The unique id of the steplabel
- The label of the stepweight
- The weight wanted- Returns:
- A new
ContainerProgressionTracker
-
toJSON
Description copied from interface:ProgressionTracker
Get the progression tracker as a JSON- Specified by:
toJSON
in interfaceProgressionTracker
- Overrides:
toJSON
in classAbstractProgressionTracker
- Returns:
- The progression tracker's JSON
-
getStep
Get a step by its id in the direct children of this container- Type Parameters:
T
- The return type- Parameters:
id
- The id- Returns:
- The progression tracker found
- Throws:
IllegalArgumentException
- If no progression tracker was found for the id wanted
-
findStep
Get a step by its id, it searches for the step in all the tree of progression tracker- Type Parameters:
T
- The return type- Parameters:
id
- The id- Returns:
- The progression tracker found
- Throws:
IllegalArgumentException
- If no progression tracker was found for the id wanted
-
setSteps
Set the steps from a JSON- Parameters:
steps
- The steps as JSON
-
setSize
Initialize the progression with a unique sub step and set its size Use only when steps are not initialized yet- Parameters:
size
- The size to set- Throws:
IllegalArgumentException
- If no progression tracker was found for id or if theProgressionTracker
of id wanted is not of typeSimpleProgressionTracker
-
setSize
Initialize the progression with a unique sub step and set its size Use only when steps are not initialized yet- Parameters:
size
- The size to setlabel
- The unique step label- Throws:
IllegalArgumentException
- If no progression tracker was found for id or if theProgressionTracker
of id wanted is not of typeSimpleProgressionTracker
-
setSize
Initialize the progression with a unique sub step and set its size Use only when steps are not initialized yet- Parameters:
size
- The size to setlabel
- The unique step label- Throws:
IllegalArgumentException
- If no progression tracker was found for id or if theProgressionTracker
of id wanted is not of typeSimpleProgressionTracker
-
setSize
Set the size of aProgressionTracker
by its id- Parameters:
id
- The id of theProgressionTracker
wantedsize
- The size to set- Throws:
IllegalArgumentException
- If no progression tracker was found for id or if theProgressionTracker
of id wanted is not of typeSimpleProgressionTracker
-
increment
Increment the unique-step of theProgressionTracker
of 1 increment- Throws:
IllegalArgumentException
- If theProgressionTracker
of id wanted is not of typeSimpleProgressionTracker
or if no progression tracker was found for id
-
increment
Increment the unique-step of theProgressionTracker
- Parameters:
increment
- The increment wanted- Throws:
IllegalArgumentException
- If theProgressionTracker
of id wanted is not of typeSimpleProgressionTracker
or if no progression tracker was found for id
-
increment
Increment theProgressionTracker
of id wanted of 1 increment- Parameters:
id
- The id- Throws:
IllegalArgumentException
- If theProgressionTracker
of id wanted is not of typeSimpleProgressionTracker
or if no progression tracker was found for id
-
increment
Increment theProgressionTracker
of id wanted of the requested increment- Parameters:
id
- The idincrement
- The increment wanted- Throws:
IllegalArgumentException
- If theProgressionTracker
of id wanted is not of typeSimpleProgressionTracker
or if no progression tracker was found for id
-