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
Modifier and TypeClassDescriptionstatic class
Wrapper object for a level value -
Field Summary
Modifier and TypeFieldDescriptionprotected AbstractCacheManager
The cache managerprotected CatalogsManager
The ODF Catalog enumerationprotected ContentTypesHelper
Content types helperprotected ContentTypeExtensionPoint
The content type extension point.protected I18nUtils
The i18n utils.protected ServiceManager
Avalon service managerprotected OdfReferenceTableHelper
Odf reference table helperprotected RootOrgUnitProvider
Root orgunit providerprotected AmetysObjectResolver
The ametys object resolver.protected WorkspaceSelector
The workspace selector.static final String
Catalog attribute name.protected static final String
The default level 1 attribute.protected static final String
The default level 2 attribute.static final String
Constant for theCache
id for theOdfClassificationHandler.LevelValue
s objects in cache byOdfClassificationHandler.LevelValuesCacheKey
.static final String
First level attribute name.static final String
Second level attribute name.Content types that are not eligible for first and second levelstatic final String
The avalon role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
_convertRawValue2LevelValue
(String attributePath, String rawLevelValue) Convert the attribute raw value into a level valuevoid
Clear the cache of available values for levels used for ODF virtual pagesvoid
clearLevelValues
(String metadataPath, String lang) Clear the cache of available values for leveldecodeLevelValue
(String value) Decode level value used in a URIencodeLevelValue
(String value) Encode level value to be use into a URI.Get the ODF catalogsGet the eligible enumerated attributes for ODF page levelgetEnumeratedAttributes
(String programContentTypeId, boolean allowMultiple) Get the enumerated attribute definitions for the given content type.getLevelValues
(String metadata, String language) Get the first level metadata values (with translated label).getOrgunitIdFromUaiCode
(String lang, String uaiCode) Get the orgunit identifier given an uai codegetProgramLevelRawValues
(Program program, String levelAttributePath) Get the level value of a program by extracting and transforming the raw program value at the desired attribute pathgetProgramLevelValues
(Program program, String levelMetaPath) Get the level value of a program by extracting and transforming the raw program value at the desired metadata pathgetPrograms
(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.void
boolean
isEligibleMetadataForLevel
(String attributePath, boolean allowMultiple) True if the program attribute is eligibleorganizeProgramsByLevels
(AmetysObjectIterable<Program> programs, String level1, String level2) Organize passed programs by levels into a Map.void
service
(ServiceManager serviceManager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The avalon role. -
LEVEL1_ATTRIBUTE_NAME
First level attribute name.- See Also:
-
LEVEL2_ATTRIBUTE_NAME
Second level attribute name.- See Also:
-
CATALOG_ATTRIBUTE_NAME
Catalog attribute name.- See Also:
-
LEVEL_VALUES_CACHE
Constant for theCache
id for theOdfClassificationHandler.LevelValue
s objects in cache byOdfClassificationHandler.LevelValuesCacheKey
. -
DEFAULT_LEVEL1_ATTRIBUTE
The default level 1 attribute.- See Also:
-
DEFAULT_LEVEL2_ATTRIBUTE
The default level 2 attribute.- See Also:
-
NON_ELIGIBLE_CTYPES_FOR_LEVEL
Content types that are not eligible for first and second level -
_resolver
The ametys object resolver. -
_i18nUtils
The i18n utils. -
_cTypeEP
The content type extension point. -
_catalogsManager
The ODF Catalog enumeration -
_workspaceSelector
The workspace selector. -
_manager
Avalon service manager -
_contentTypesHelper
Content types helper -
_odfReferenceTableHelper
Odf reference table helper -
_orgUnitProvider
Root orgunit provider -
_cacheManager
The cache manager
-
-
Constructor Details
-
OdfClassificationHandler
public OdfClassificationHandler()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getCatalogs
Get the ODF catalogs- Returns:
- the ODF catalogs
-
isEligibleMetadataForLevel
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
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
-true
true to allow multiple attribute- Returns:
- The definitions of enumerated attributes
-
getProgramLevelValues
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
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
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
null
if there is no level value for this raw value
-
clearLevelValues
Clear the cache of available values for levels used for ODF virtual pages -
clearLevelValues
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
Encode level value to be use into a URI. Double-encode characters ':', '-' and '/'.- Parameters:
value
- The raw value- Returns:
- the encoded value
-
decodeLevelValue
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
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, organizeProgramsByLevelsCollection<Program>>> (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
-