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.
-
-
Field Summary
Fields Modifier and Type Field Description protected CatalogsManager
_catalogsManager
The ODF Catalog enumerationprotected ContentTypesHelper
_contentTypesHelper
Content types helperprotected ContentTypeExtensionPoint
_cTypeEP
The content type extension point.protected I18nUtils
_i18nUtils
The i18n utils.protected Map<String,Map<String,String>>
_levelValuesCache
Level values cache.protected ServiceManager
_manager
Avalon service managerprotected OdfReferenceTableHelper
_odfReferenceTableHelper
Odf reference table helperprotected RootOrgUnitProvider
_orgUnitProvider
Root orgunit providerprotected AmetysObjectResolver
_resolver
The ametys object resolver.protected WorkspaceSelector
_workspaceSelector
The workspace selector.static String
CATALOG_ATTRIBUTE_NAME
Catalog attribute name.protected static String
DEFAULT_LEVEL1_ATTRIBUTE
The default level 1 attribute.protected static String
DEFAULT_LEVEL2_ATTRIBUTE
The default level 2 attribute.static String
LEVEL1_ATTRIBUTE_NAME
First level attribute name.static String
LEVEL2_ATTRIBUTE_NAME
Second level attribute name.protected static List<String>
NON_ELIGIBLE_CTYPES_FOR_LEVEL
Content types that are not eligible for first and second levelstatic String
ROLE
The avalon role.
-
Constructor Summary
Constructors Constructor Description OdfClassificationHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Stream<Map.Entry<String,ModelItem>>
_collectEligibleChildAttribute(ModelItemContainer modelItemContainer, boolean allowMultiple)
private String
_convertLevel2RawForContent(String levelValue)
private String
_convertLevel2RawForOrgUnit(String lang, String levelValue)
private String
_convertLevel2RawForRefTable(String metaContentType, String levelValue)
private String
_convertLevelValue2RawValue(String lang, String levelAttribute, String levelValue)
Convert a level value to the raw valueprivate String
_convertRaw2LevelForContent(String contentId)
private String
_convertRaw2LevelForOrgUnit(String orgUnitId)
private String
_convertRaw2LevelForRefTable(String contentId)
protected String
_convertRawValue2LevelValue(String attributePath, String rawLevelValue)
Convert the attribute raw value into a level valueprivate Map<String,String>
_getLevelValues(String attributePath, String language)
Get the available values of a program's attribute to be used as a level in the virtual ODF page hierarchy.private Map<String,String>
_getLevelValuesForContentType(String metaContentType, String language)
private <T> Map<String,String>
_getLevelValuesForEnumerator(String language, Enumerator<T> enumerator)
private Map<String,String>
_getLevelValuesForOrgUnits()
private Map<String,String>
_getLevelValuesForRefTable(String metaContentType, String language)
private boolean
_isModelItemEligible(ModelItem modelItem, boolean allowMultiple)
void
clearLevelValues()
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 levelString
decodeLevelValue(String value)
Decode level value used in a URIString
encodeLevelValue(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,String>
getLevelValues(String metadata, String language)
Get the first level metadata values (with translated label).String
getOrgunitIdFromUaiCode(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.void
initialize()
boolean
isEligibleMetadataForLevel(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.void
service(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
-
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
-
-
Constructor Detail
-
OdfClassificationHandler
public OdfClassificationHandler()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in 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
-true
true to allow multiple attribute- Returns:
- The definitions of enumerated attributes
-
_collectEligibleChildAttribute
private Stream<Map.Entry<String,ModelItem>> _collectEligibleChildAttribute(ModelItemContainer modelItemContainer, boolean allowMultiple)
-
_isModelItemEligible
private boolean _isModelItemEligible(ModelItem modelItem, boolean allowMultiple)
-
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
null
if there is no level value for this raw value
-
_convertRaw2LevelForRefTable
private String _convertRaw2LevelForRefTable(String contentId)
-
_convertRaw2LevelForOrgUnit
private String _convertRaw2LevelForOrgUnit(String orgUnitId)
-
_convertRaw2LevelForContent
private String _convertRaw2LevelForContent(String contentId)
-
_convertLevel2RawForRefTable
private String _convertLevel2RawForRefTable(String metaContentType, String levelValue)
-
_convertLevel2RawForContent
private String _convertLevel2RawForContent(String levelValue)
-
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,String> 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
-
_getLevelValues
private Map<String,String> _getLevelValues(String attributePath, String language)
Get the available values of a program's attribute to be used as a level in the virtual ODF page hierarchy.- Parameters:
attributePath
- the attribute path.language
- the language.- Returns:
- the available attribute values.
-
_getLevelValuesForRefTable
private Map<String,String> _getLevelValuesForRefTable(String metaContentType, String language)
-
_getLevelValuesForOrgUnits
private Map<String,String> _getLevelValuesForOrgUnits()
-
_getLevelValuesForContentType
private Map<String,String> _getLevelValuesForContentType(String metaContentType, String language)
-
_getLevelValuesForEnumerator
private <T> Map<String,String> _getLevelValuesForEnumerator(String language, Enumerator<T> enumerator) throws Exception
- Throws:
Exception
-
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
-
_convertLevelValue2RawValue
private String _convertLevelValue2RawValue(String lang, String levelAttribute, String levelValue)
Convert a level value to the raw value- Parameters:
lang
- The languagelevelAttribute
- The name of attribute holding the levellevelValue
- The level value- Returns:
- The raw value
-
_convertLevel2RawForOrgUnit
private String _convertLevel2RawForOrgUnit(String lang, String levelValue)
-
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
-
-