Package org.ametys.runtime.model
Class CategorizedElementDefinitionHelper
- java.lang.Object
-
- org.ametys.runtime.model.CategorizedElementDefinitionHelper
-
public final class CategorizedElementDefinitionHelper extends Object
Helper forCategorizedElementDefinitionWrapper
-
-
Constructor Summary
Constructors Modifier Constructor Description private
CategorizedElementDefinitionHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description private static <T extends CategorizedElementDefinitionWrapper>
ViewItem_buildCategoryViewItem(I18nizableText categoryLabel, Map<I18nizableText,List<T>> groups, Comparator<I18nizableText> groupsComparator, Comparator<T> elementsComparator)
private static <T extends CategorizedElementDefinitionWrapper>
ViewItem_buildGroupViewItem(I18nizableText groupLabel, List<T> wrappers, Comparator<T> elementsComparator)
private static <T> Collection<T>
_sort(Collection<T> items, Comparator<T> comparator)
Sort a model item list using comparatorstatic <T extends CategorizedElementDefinitionWrapper>
ViewbuildViewFromCategories(Collection<T> wrappers, Comparator<I18nizableText> categoriesComparator, Comparator<I18nizableText> groupsComparator, Comparator<T> elementsComparator)
Generate the view for categorized element definition wrappers, using comparators to sort the categories, groups and elementsstatic <T extends CategorizedElementDefinitionWrapper>
Map<I18nizableText,Map<I18nizableText,List<T>>>categorizeElementDefinitionWrappers(Collection<T> wrappers)
Organize a collection of categorized element definition wrappers by categories and groups.static <T extends CategorizedElementDefinitionWrapper>
intcompareWrapperPositions(T wrapper1, T wrapper2)
Compares the two given wrappers' position.static Map<String,List<I18nizableText>>
validateValuesForWriting(Map<String,DefinitionAndValue> definitionAndValues, Map<String,ElementDefinition> flatDefinitions, org.slf4j.Logger logger)
Deprecated.TODO NEWATTRIBUTEAPI_CONFIG RUNTIME-2851 remove this method when it is not necessary anymore to have the flat definitionsstatic Map<String,List<I18nizableText>>
validateValuesForWriting(Map<String,DefinitionAndValue> definitionAndValues, org.slf4j.Logger logger)
Validate parameters before writing
-
-
-
Constructor Detail
-
CategorizedElementDefinitionHelper
private CategorizedElementDefinitionHelper()
-
-
Method Detail
-
buildViewFromCategories
public static <T extends CategorizedElementDefinitionWrapper> View buildViewFromCategories(Collection<T> wrappers, Comparator<I18nizableText> categoriesComparator, Comparator<I18nizableText> groupsComparator, Comparator<T> elementsComparator)
Generate the view for categorized element definition wrappers, using comparators to sort the categories, groups and elements- Type Parameters:
T
- type of the wrappers- Parameters:
wrappers
- the wrapperscategoriesComparator
-Comparator
used for the categories (can be null to keep order)groupsComparator
-Comparator
for the groups (can be null to keep order)elementsComparator
-Comparator
for the elements (can be null to keep order)- Returns:
- A
View
ordered from theModelItem
using theComparator
-
categorizeElementDefinitionWrappers
public static <T extends CategorizedElementDefinitionWrapper> Map<I18nizableText,Map<I18nizableText,List<T>>> categorizeElementDefinitionWrappers(Collection<T> wrappers)
Organize a collection of categorized element definition wrappers by categories and groups.- Type Parameters:
T
- type of the wrappers- Parameters:
wrappers
- a collection of element definition wrappers.- Returns:
- a Map with the same element definition wrappers, sorted first by category then by group.
-
_buildCategoryViewItem
private static <T extends CategorizedElementDefinitionWrapper> ViewItem _buildCategoryViewItem(I18nizableText categoryLabel, Map<I18nizableText,List<T>> groups, Comparator<I18nizableText> groupsComparator, Comparator<T> elementsComparator) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
_buildGroupViewItem
private static <T extends CategorizedElementDefinitionWrapper> ViewItem _buildGroupViewItem(I18nizableText groupLabel, List<T> wrappers, Comparator<T> elementsComparator) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
_sort
private static <T> Collection<T> _sort(Collection<T> items, Comparator<T> comparator)
Sort a model item list using comparator- Type Parameters:
T
- The type of item to compare- Parameters:
items
- list of items to sortcomparator
- a comparator, can be null to avoid sort- Returns:
- a sorted list (or a copy of the list if the comparator is null)
-
validateValuesForWriting
@Deprecated public static Map<String,List<I18nizableText>> validateValuesForWriting(Map<String,DefinitionAndValue> definitionAndValues, Map<String,ElementDefinition> flatDefinitions, org.slf4j.Logger logger)
Deprecated.TODO NEWATTRIBUTEAPI_CONFIG RUNTIME-2851 remove this method when it is not necessary anymore to have the flat definitionsValidate parameters before writing- Parameters:
definitionAndValues
- a map of all parameters and their valuesflatDefinitions
- flat definition ofElementDefinition
from the model filelogger
- a logger- Returns:
- a map containing the potential errors
-
validateValuesForWriting
public static Map<String,List<I18nizableText>> validateValuesForWriting(Map<String,DefinitionAndValue> definitionAndValues, org.slf4j.Logger logger)
Validate parameters before writing- Parameters:
definitionAndValues
- a map of all parameters and their valueslogger
- a logger- Returns:
- a map containing the potential errors
-
compareWrapperPositions
public static <T extends CategorizedElementDefinitionWrapper> int compareWrapperPositions(T wrapper1, T wrapper2)
Compares the two given wrappers' position. Returns a negative integer, zero, or a positive integer as the position of the first wrapper is less than, equal to, or greater than the second.- Type Parameters:
T
- type of the wrappers to compare- Parameters:
wrapper1
- the first wrapperwrapper2
- the second wrapper- Returns:
- a negative integer, zero, or a positive integer as the position of the first wrapper is less than, equal to, or greater than the second.
-
-