Package org.ametys.odf.tree
Class OdfClassificationHandler
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.odf.tree.OdfClassificationHandler
-
- All Implemented Interfaces:
LogEnabled,Initializable,Component,Serviceable
public class OdfClassificationHandler extends AbstractLogEnabled implements Component, Initializable, Serviceable
Component providing methods to retrieve ODF virtual pages, such as the ODF root, level 1 and 2 metadata names, and so on.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOdfClassificationHandler.LevelValueWrapper object for a level value
-
Field Summary
Fields Modifier and Type Field Description protected AbstractCacheManager_cacheManagerThe cache managerprotected CatalogsManager_catalogsManagerThe ODF Catalog enumerationprotected ContentTypesHelper_contentTypesHelperContent types helperprotected ContentTypeExtensionPoint_cTypeEPThe content type extension point.protected I18nUtils_i18nUtilsThe i18n utils.protected ServiceManager_managerAvalon service managerprotected OdfReferenceTableHelper_odfReferenceTableHelperOdf reference table helperprotected RootOrgUnitProvider_orgUnitProviderRoot orgunit providerprotected AmetysObjectResolver_resolverThe ametys object resolver.protected WorkspaceSelector_workspaceSelectorThe workspace selector.static StringCATALOG_ATTRIBUTE_NAMECatalog attribute name.protected static StringDEFAULT_LEVEL1_ATTRIBUTEThe default level 1 attribute.protected static StringDEFAULT_LEVEL2_ATTRIBUTEThe default level 2 attribute.static StringLEVEL_VALUES_CACHEConstant for theCacheid for theOdfClassificationHandler.LevelValues objects in cache byOdfClassificationHandler.LevelValuesCacheKey.static StringLEVEL1_ATTRIBUTE_NAMEFirst level attribute name.static StringLEVEL2_ATTRIBUTE_NAMESecond level attribute name.protected static List<String>NON_ELIGIBLE_CTYPES_FOR_LEVELContent types that are not eligible for first and second levelstatic StringROLEThe avalon role.
-
Constructor Summary
Constructors Constructor Description OdfClassificationHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String_convertRawValue2LevelValue(String attributePath, String rawLevelValue)Convert the attribute raw value into a level valuevoidclearLevelValues()Clear the cache of available values for levels used for ODF virtual pagesvoidclearLevelValues(String metadataPath, String lang)Clear the cache of available values for levelStringdecodeLevelValue(String value)Decode level value used in a URIStringencodeLevelValue(String value)Encode level value to be use into a URI.Map<String,I18nizableText>getCatalogs()Get the ODF catalogsMap<String,ModelItem>getEligibleAttributesForLevel()Get the eligible enumerated attributes for ODF page levelMap<String,ModelItem>getEnumeratedAttributes(String programContentTypeId, boolean allowMultiple)Get the enumerated attribute definitions for the given content type.Map<String,OdfClassificationHandler.LevelValue>getLevelValues(String metadata, String language)Get the first level metadata values (with translated label).StringgetOrgunitIdFromUaiCode(String lang, String uaiCode)Get the orgunit identifier given an uai codeList<String>getProgramLevelRawValues(Program program, String levelAttributePath)Get the level value of a program by extracting and transforming the raw program value at the desired attribute pathList<String>getProgramLevelValues(Program program, String levelMetaPath)Get the level value of a program by extracting and transforming the raw program value at the desired metadata pathAmetysObjectIterable<Program>getPrograms(String catalog, String lang, String level1MetaPath, String level1, String level2MetaPath, String level2, String programCode, String programName, Collection<Expression> additionalExpressions)Get a collection of programs corresponding to following parameters.voidinitialize()booleanisEligibleMetadataForLevel(String attributePath, boolean allowMultiple)True if the program attribute is eligibleMap<String,Map<String,Collection<Program>>>organizeProgramsByLevels(AmetysObjectIterable<Program> programs, String level1, String level2)Organize passed programs by levels into a Map.voidservice(ServiceManager serviceManager)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
LEVEL1_ATTRIBUTE_NAME
public static final String LEVEL1_ATTRIBUTE_NAME
First level attribute name.- See Also:
- Constant Field Values
-
LEVEL2_ATTRIBUTE_NAME
public static final String LEVEL2_ATTRIBUTE_NAME
Second level attribute name.- See Also:
- Constant Field Values
-
CATALOG_ATTRIBUTE_NAME
public static final String CATALOG_ATTRIBUTE_NAME
Catalog attribute name.- See Also:
- Constant Field Values
-
LEVEL_VALUES_CACHE
public static final String LEVEL_VALUES_CACHE
Constant for theCacheid for theOdfClassificationHandler.LevelValues objects in cache byOdfClassificationHandler.LevelValuesCacheKey.
-
DEFAULT_LEVEL1_ATTRIBUTE
protected static final String DEFAULT_LEVEL1_ATTRIBUTE
The default level 1 attribute.- See Also:
- Constant Field Values
-
DEFAULT_LEVEL2_ATTRIBUTE
protected static final String DEFAULT_LEVEL2_ATTRIBUTE
The default level 2 attribute.- See Also:
- Constant Field Values
-
NON_ELIGIBLE_CTYPES_FOR_LEVEL
protected static final List<String> NON_ELIGIBLE_CTYPES_FOR_LEVEL
Content types that are not eligible for first and second level
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver.
-
_i18nUtils
protected I18nUtils _i18nUtils
The i18n utils.
-
_cTypeEP
protected ContentTypeExtensionPoint _cTypeEP
The content type extension point.
-
_catalogsManager
protected CatalogsManager _catalogsManager
The ODF Catalog enumeration
-
_workspaceSelector
protected WorkspaceSelector _workspaceSelector
The workspace selector.
-
_manager
protected ServiceManager _manager
Avalon service manager
-
_contentTypesHelper
protected ContentTypesHelper _contentTypesHelper
Content types helper
-
_odfReferenceTableHelper
protected OdfReferenceTableHelper _odfReferenceTableHelper
Odf reference table helper
-
_orgUnitProvider
protected RootOrgUnitProvider _orgUnitProvider
Root orgunit provider
-
_cacheManager
protected AbstractCacheManager _cacheManager
The cache manager
-
-
Constructor Detail
-
OdfClassificationHandler
public OdfClassificationHandler()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
getCatalogs
public Map<String,I18nizableText> getCatalogs()
Get the ODF catalogs- Returns:
- the ODF catalogs
-
isEligibleMetadataForLevel
public boolean isEligibleMetadataForLevel(String attributePath, boolean allowMultiple)
True if the program attribute is eligible- Parameters:
attributePath- the attribute pathallowMultiple- true is we allow multiple attribute- Returns:
- true if the program attribute is eligible
-
getEligibleAttributesForLevel
public Map<String,ModelItem> getEligibleAttributesForLevel()
Get the eligible enumerated attributes for ODF page level- Returns:
- the eligible attributes
-
getEnumeratedAttributes
public Map<String,ModelItem> getEnumeratedAttributes(String programContentTypeId, boolean allowMultiple)
Get the enumerated attribute definitions for the given content type. Attribute with enumerator or content attribute are considered as enumerated- Parameters:
programContentTypeId- The content type's idallowMultiple-truetrue to allow multiple attribute- Returns:
- The definitions of enumerated attributes
-
getProgramLevelValues
public List<String> getProgramLevelValues(Program program, String levelMetaPath)
Get the level value of a program by extracting and transforming the raw program value at the desired metadata path- Parameters:
program- The programlevelMetaPath- The desired metadata path that represent a level- Returns:
- The list of final level values
-
getProgramLevelRawValues
public List<String> getProgramLevelRawValues(Program program, String levelAttributePath)
Get the level value of a program by extracting and transforming the raw program value at the desired attribute path- Parameters:
program- The programlevelAttributePath- The desired attribute path that represent a level- Returns:
- The list of level raw value
-
_convertRawValue2LevelValue
protected String _convertRawValue2LevelValue(String attributePath, String rawLevelValue)
Convert the attribute raw value into a level value- Parameters:
attributePath- The path of the attribute corresponding to the levelrawLevelValue- The raw level value- Returns:
- the converted value or
nullif there is no level value for this raw value
-
clearLevelValues
public void clearLevelValues()
Clear the cache of available values for levels used for ODF virtual pages
-
clearLevelValues
public void clearLevelValues(String metadataPath, String lang)
Clear the cache of available values for level- Parameters:
lang- the language. Can be null to clear values for all languagesmetadataPath- the path of level's metadata
-
getLevelValues
public Map<String,OdfClassificationHandler.LevelValue> getLevelValues(String metadata, String language)
Get the first level metadata values (with translated label).- Parameters:
metadata- Metadata of first levellanguage- Lang to get- Returns:
- the first level metadata values.
-
encodeLevelValue
public String encodeLevelValue(String value)
Encode level value to be use into a URI. Double-encode characters ':', '-' and '/'.- Parameters:
value- The raw value- Returns:
- the encoded value
-
decodeLevelValue
public String decodeLevelValue(String value)
Decode level value used in a URI- Parameters:
value- The encoded value- Returns:
- the decoded value
-
getPrograms
public AmetysObjectIterable<Program> getPrograms(String catalog, String lang, String level1MetaPath, String level1, String level2MetaPath, String level2, String programCode, String programName, Collection<Expression> additionalExpressions)
Get a collection of programs corresponding to following parameters.- Parameters:
catalog- Name of the catalog. Can be null to get all programs matching other arguments.lang- the content language. Can not be null.level1MetaPath- Having a non-empty value for the metadata pathlevel1- If this parameter is not null or empty and level1MetaPath too, we filter programs by the metadata level1MetaPath value of level1level2MetaPath- Having a non-empty value for the metadata pathlevel2- If this parameter is not null or empty and level2MetaPath too, we filter programs by the metadata level2MetaPath value of level2programCode- The program's code. Can be null to get all programs matching other arguments.programName- The program's name. Can be null to get all programs matching other arguments.additionalExpressions- Additional expressions to add to search- Returns:
- A collection of programs
-
getOrgunitIdFromUaiCode
public String getOrgunitIdFromUaiCode(String lang, String uaiCode)
Get the orgunit identifier given an uai code- Parameters:
lang- LanguageuaiCode- The uai code- Returns:
- The orgunit id or null if not found
-
organizeProgramsByLevels
public Map<String,Map<String,Collection<Program>>> organizeProgramsByLevels(AmetysObjectIterable<Program> programs, String level1, String level2) throws SAXException
Organize passed programs by levels into a Map.- Parameters:
programs- Programs to organizelevel1- Name of the metadata of first levellevel2- Name of the metadata of second level- Returns:
- A Map of Map with a Collection of programs which representing the organization of programs by levels.
- Throws:
SAXException- if an error occured
-
-