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 stepdoubleGet 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 steplonggetIndex()Get the index of the current steplonggetSize()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 containervoidIncrement the unique-step of theProgressionTrackerof 1 incrementvoidincrement(long increment) Increment the unique-step of theProgressionTrackervoidIncrement theProgressionTrackerof id wanted of 1 incrementvoidIncrement theProgressionTrackerof id wanted of the requested incrementvoidsetSize(long size) Initialize the progression with a unique sub step and set its size Use only when steps are not initialized yetvoidInitialize the progression with a unique sub step and set its size Use only when steps are not initialized yetvoidsetSize(long size, I18nizableText label) Initialize the progression with a unique sub step and set its size Use only when steps are not initialized yetvoidSet the size of aProgressionTrackerby its idvoidSet 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:ProgressionTrackerGet the index of the current step- Returns:
- The index between [1 and size]
-
getSize
Description copied from interface:ProgressionTrackerGet the size- Returns:
- The size
-
asPercentage
Description copied from interface:ProgressionTrackerGet 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
ProgressionTrackerfound - Throws:
IllegalArgumentException- If no progression tracker was found for id
-
getCurrentStep
Get the current step- Type Parameters:
T- The type of tracker- Returns:
- The
ProgressionTrackerfound 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
SimpleProgressionTrackerof 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
ContainerProgressionTrackerof 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:ProgressionTrackerGet the progression tracker as a JSON- Specified by:
toJSONin interfaceProgressionTracker- Overrides:
toJSONin 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 theProgressionTrackerof 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 theProgressionTrackerof 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 theProgressionTrackerof id wanted is not of typeSimpleProgressionTracker
-
setSize
Set the size of aProgressionTrackerby its id- Parameters:
id- The id of theProgressionTrackerwantedsize- The size to set- Throws:
IllegalArgumentException- If no progression tracker was found for id or if theProgressionTrackerof id wanted is not of typeSimpleProgressionTracker
-
increment
Increment the unique-step of theProgressionTrackerof 1 increment- Throws:
IllegalArgumentException- If theProgressionTrackerof id wanted is not of typeSimpleProgressionTrackeror if no progression tracker was found for id
-
increment
Increment the unique-step of theProgressionTracker- Parameters:
increment- The increment wanted- Throws:
IllegalArgumentException- If theProgressionTrackerof id wanted is not of typeSimpleProgressionTrackeror if no progression tracker was found for id
-
increment
Increment theProgressionTrackerof id wanted of 1 increment- Parameters:
id- The id- Throws:
IllegalArgumentException- If theProgressionTrackerof id wanted is not of typeSimpleProgressionTrackeror if no progression tracker was found for id
-
increment
Increment theProgressionTrackerof id wanted of the requested increment- Parameters:
id- The idincrement- The increment wanted- Throws:
IllegalArgumentException- If theProgressionTrackerof id wanted is not of typeSimpleProgressionTrackeror if no progression tracker was found for id
-