Package org.ametys.odf
Class ODFHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.odf.ODFHelper
- All Implemented Interfaces:
LogEnabled
,PluginAware
,Initializable
,Component
,Contextualizable
,Serviceable
public class ODFHelper
extends AbstractLogEnabled
implements Component, Serviceable, PluginAware, Contextualizable, Initializable
Helper for ODF contents
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
The default id of initial workflow actionprotected AbstractCacheManager
The cache managerprotected Context
The Avalon contextprotected ContentTypeExtensionPoint
The content types managerprotected RootOrgUnitProvider
Root orgunitprotected AmetysObjectResolver
Ametys object resolverprotected ShareableCourseHelper
Helper for shareable coursestatic final String
Request attribute to get the "Live" version of contentsstatic final String
The component role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
_cleanContentMetadata
(ModifiableContent createdContent) Clean the CONTENT metadata created after a copy but whose values reference the initial content' structureprotected Request
Get the requestvoid
contextualize
(Context context) <C extends ModifiableContent>
CcopyCoursePart
(CoursePart srcContent, String targetContentName, String targetContentLanguage, int initWorkflowActionId, String targetCatalog, boolean fullCopy, Map<Content, Content> copiedContents) Copy aCoursePart
<C extends ModifiableContent>
CcopyProgramItem
(ProgramItem srcContent, String targetCatalog, boolean fullCopy, Map<Content, Content> copiedContents) Copy aProgramItem
<C extends ModifiableContent>
CcopyProgramItem
(ProgramItem srcContent, String targetContentName, String targetContentLanguage, int initWorkflowActionId, String targetCatalog, boolean fullCopy, Map<Content, Content> copiedContents) Copy aProgramItem
<C extends ModifiableContent>
CcopyProgramItem
(ProgramItem srcContent, String targetContentName, String targetContentLanguage, String targetCatalog, boolean fullCopy, Map<Content, Content> copiedContents) Copy aProgramItem
protected void
copyProgramItemStructure
(ProgramItem srcContent, ModifiableContent targetContent, String targetContentLanguage, int initWorkflowActionId, String targetCatalogName, Map<Content, Content> copiedContents) Copy the structure of aProgramItem
getChildProgramItems
(ProgramItem programItem) Get the child program items of aProgramItem
getChildSubPrograms
(ProgramPart programPart) Get the child subprograms of aProgramPart
getCoursePart
(CoursePart srcCoursePart, String catalogName, String lang) Get the equivalentCoursePart
of the sourceCoursePart
in given catalog and languagegetCumulatedHours
(ProgramItem programItem) Count the hours accumulation in theProgramItem
getDescendantRelationAttributeName
(ProgramItem parentProgramItem, ProgramItem childProgramItem) Get the name of attribute holding the relation between a parent content and its childrenGet a readable value of aEducationalPath
getEducationalPathAsString
(EducationalPath path, Function<ProgramItem, String> mapper, CharSequence separator) Get a readable value of aEducationalPath
getEducationalPathAsString
(EducationalPath path, Function<ProgramItem, String> mapper, CharSequence separator, Predicate<ProgramItem> filterPathSegment) Get a readable value of aEducationalPath
getEducationalPaths
(ProgramItem programItem) Get allEducationalPath
of aProgramItem
The path is built with the mapper function.getEducationalPaths
(ProgramItem programItem, boolean includeItself) Get allEducationalPath
of aProgramItem
The path is built with the mapper function.getEducationalPaths
(ProgramItem programItem, boolean includeItself, boolean ignoreOrphanPath) Get allEducationalPath
of aProgramItem
The path is built with the mapper function.getEducationalPathsEnumeration
(String programItemId) Get the enumeration of educational paths for a program item for highest ancestors.Get the full educations paths (from a rootProgram
) from a full or partial pathgetEducationPathFromPaths
(List<List<ProgramItem>> paths) Get the full educations paths (from a rootProgram
) from full or partial pathsgetEducationPathFromPaths
(List<List<ProgramItem>> paths, ProgramItem withAncestor) Get the full educations paths (from a rootProgram
)from full or partial paths<T extends AmetysObject>
TgetODFContent
(String contentType, String odfContentCode, String catalogName, String lang) Get the equivalentContent
having the same code in given catalog and languagegetOrgUnitByUAICode
(String uaiCode) Get the first orgunit matching the given UAI codegetOrgUnitPath
(String orgUnitId) Get the hierarchical path of aOrgUnit
from the root orgunit.
The path is construct with the contents' names and the used separator is '/'.getOrgUnitPath
(String orgUnitId, String rootOrgUnitId) Get the hierarchical path of aOrgUnit
from the root orgunit id.
The path is construct with the contents' names and the used separator is '/'.getOrgUnitPath
(OrgUnit orgunit, String separator) Get all the path of the orgunit.
The path is built with the contents' title and codegetParentAbstractPrograms
(CoursePart coursePart) Gets (recursively) parent abstract programs of this course part.getParentAbstractPrograms
(CoursePart coursePart, boolean continueIfFound) Gets (recursively) parent abstract programs of this course part.getParentAbstractPrograms
(ProgramItem programItem) Gets (recursively) parent abstract programs of this program item.getParentAbstractPrograms
(ProgramItem programItem, boolean continueIfFound) Gets (recursively) parent abstract programs of this program item.getParentContainers
(ProgramItem programItem) Gets (recursively) parent containers of this program item.getParentContainers
(ProgramItem programItem, boolean continueIfFound) Gets (recursively) parent containers of this program item.getParentProgramItem
(ProgramItem programItem, AbstractProgram parentProgram) Get the first nearest program item parent into the given parentAbstractProgram
getParentProgramItems
(ProgramItem programItem) Get the parent program items of aProgramItem
getParentProgramItems
(ProgramItem programItem, ProgramPart parentProgramPart) Get the program item parents into the given ancestorProgramPart
getParentPrograms
(CoursePart coursePart) Gets (recursively) parent programs of this course part.getParentPrograms
(ProgramItem programItem) Gets (recursively) parent programs of this program item.getParentSubPrograms
(CoursePart coursePart) Gets (recursively) parent subprograms of this course part.getParentSubPrograms
(CoursePart coursePart, boolean continueIfFound) Gets (recursively) parent subprograms of this course part.getParentSubPrograms
(ProgramItem programItem) Gets (recursively) parent subprograms of this program item.getParentSubPrograms
(ProgramItem programItem, boolean continueIfFound) Gets (recursively) parent subprograms of this program item.getPathInCourse
(String contentId, String parentCourseId) Get the path of aCourse
or aCourseList
into aCourse
The path is construct with the contents' names and the used separator is '/'.getPathInCourse
(Content courseOrList, Course parentCourse) Get the path of aCourse
or aCourseList
into aCourse
The path is construct with the contents' names and the used separator is '/'.getPathInProgram
(String programItemId, String programId) Get the path of aProgramItem
into aProgram
The path is construct with the contents' names and the used separator is '/'.getPathInProgram
(ProgramItem item, Program parentProgram) Get the path of a ODF content into aProgram
.
The path is construct with the contents' names and the used separator is '/'.protected List<List<ProgramItem>>
getPathOfAncestors
(ProgramItem programItem) Get the full path to program item for highest ancestors.getPaths
(ProgramItem item, String separator) Get allEducationalPath
of aProgramItem
as readable values The path is built with the contents' title and codegetPaths
(ProgramItem item, String separator, Function<ProgramItem, String> mapper, boolean includeItself) Get allEducationalPath
of aProgramItem
as readable values The path is built with the mapper function.getPaths
(ProgramItem item, String separator, Function<ProgramItem, String> mapper, Predicate<ProgramItem> filterPathSegment, boolean includeItself, boolean ignoreOrphanPath) Get allEducationalPath
of aProgramItem
as readable values The path is built with the mapper function.<T extends ProgramItem>
TgetProgramItem
(T srcProgramItem, String catalogName, String lang) Get the equivalentProgramItem
of the sourceProgramItem
in given catalog and languagegetProgramItemInfo
(String programItemId, List<String> programItemPathIds) Get information of the program item<C extends Content>
AmetysObjectIterable<C>getProgramItems
(String cTypeId, String code, String catalogName, String lang) Get theProgramItem
s matching the given arguments<C extends Content>
AmetysObjectIterable<C>getProgramItems
(String cTypeId, String code, String catalogName, String lang, Expression additionnalExpr, SortCriteria sortCriteria) Get theProgramItem
s matching the given arguments<C extends Content>
AmetysObjectIterable<C>getProgramItems
(Collection<String> cTypeIds, String code, String catalogName, String lang) Get theProgramItem
s matching the given arguments<C extends Content>
AmetysObjectIterable<C>getProgramItems
(Collection<String> cTypeIds, String code, String catalogName, String lang, Expression additionnalExpr, SortCriteria sortCriteria) Get theProgramItem
s matching the given argumentsgetProgramsFromOrgUnit
(OrgUnit orgUnit, String catalog, String lang) Get the child programs of anOrgUnit
int
getRepeaterEntryPositionForPath
(ProgramItem programItem, String dataPath, List<EducationalPath> paths) Get a position of repeater entry that match the given educational pathint
getRepeaterEntryPositionForPath
(ProgramItem programItem, String dataPath, EducationalPath path) Get a position of repeater entry that match the given educational pathGets the root for ODF contentsgetRootContent
(boolean create) Gets the root for ODF contentsgetStructureInfo
(String contentId) Get information of the program item structure (type, if program has children) or orgunit (no structure for now)getStructureInfo
(List<String> programItemIds) Get information of the program item structure (type, if program has children)getSubOrgUnitIds
(OrgUnit orgUnit) Get the current orgunit and its suborgunits recursively identifiers.<T> Optional<T>
getValueForPath
(ProgramItem programItem, String dataPath, List<EducationalPath> paths) Get the value of an attribute for a given educational path.<T> Optional<T>
getValueForPath
(ProgramItem programItem, String dataPath, EducationalPath path) Get the value of an attribute for a given educational path.<T> Map<EducationalPath,
T> getValuesForPaths
(ProgramItem programItem, String dataPath, List<EducationalPath> paths, T defaultValue) Get the value of an attribute for each given educational paths<T> Map<EducationalPath,
T> getValuesForPaths
(ProgramItem programItem, String dataPath, T defaultValue) Get the value of an attribute for each available educational pathsboolean
hasAncestor
(ProgramPart part, String parentId) Return true if the givenProgramPart
has in its hierarchy a parent of given idboolean
hasParentProgramItems
(ProgramItem programItem) Determines if theProgramItem
has parent program itemsvoid
boolean
isRelationCompatible
(Content srcContent, Content targetContent, List<I18nizableText> errors, Map<String, Object> contextualParameters) Check if a relation can be establish between two ODF contentsboolean
isSameValueForAllPaths
(ProgramItem programItem, String dataPath) Determines if the values of an attribute depending of a educational path is the same for all available educational pathsboolean
isSameValueForPaths
(ProgramItem programItem, String dataPath, List<EducationalPath> paths) Determines if the values of an attribute depending of a educational path is the same for all available educational pathsboolean
isShared
(ProgramItem programItem) Determines if a program item is sharedvoid
service
(ServiceManager manager) void
setPluginInfo
(String pluginName, String featureName, String id) Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.void
Switch the ametys object to Live version if it has onevoid
Switch to Live version if is requiredMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The component role. -
REQUEST_ATTRIBUTE_VALID_LABEL
Request attribute to get the "Live" version of contents- See Also:
-
__INITIAL_WORKFLOW_ACTION_ID
The default id of initial workflow action- See Also:
-
_resolver
Ametys object resolver -
_cTypeEP
The content types manager -
_ouRootProvider
Root orgunit -
_context
The Avalon context -
_cacheManager
The cache manager
-
-
Constructor Details
-
ODFHelper
public ODFHelper()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
setPluginInfo
Description copied from interface:PluginAware
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfo
in interfacePluginAware
- Parameters:
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this component
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getRootContent
Gets the root for ODF contents- Returns:
- the root for ODF contents
-
getRootContent
Gets the root for ODF contents- Parameters:
create
-true
to create automatically the root when missing.- Returns:
- the root for ODF contents
-
getProgramItems
public <C extends Content> AmetysObjectIterable<C> getProgramItems(String cTypeId, String code, String catalogName, String lang) Get theProgramItem
s matching the given arguments- Type Parameters:
C
- The content return type- Parameters:
cTypeId
- The id of content type. Can be null to get program's items whatever their content type.code
- The code. Can be null to get program's items regardless of their codecatalogName
- The search catalog. Can be null to get program's items regardless the catalog they belong to.lang
- The search language. Can be null to get program's items regardless of their language- Returns:
- The matching program items
-
getProgramItems
public <C extends Content> AmetysObjectIterable<C> getProgramItems(Collection<String> cTypeIds, String code, String catalogName, String lang) Get theProgramItem
s matching the given arguments- Type Parameters:
C
- The content return type- Parameters:
cTypeIds
- The id of content types. Can be empty to get program's items whatever their content type.code
- The code. Can be null to get program's items regardless of their codecatalogName
- The search catalog. Can be null to get program's items regardless the catalog they belong to.lang
- The search language. Can be null to get program's items regardless of their language- Returns:
- The matching program items
-
getProgramItems
public <C extends Content> AmetysObjectIterable<C> getProgramItems(String cTypeId, String code, String catalogName, String lang, Expression additionnalExpr, SortCriteria sortCriteria) Get theProgramItem
s matching the given arguments- Type Parameters:
C
- The content return type- Parameters:
cTypeId
- The id of content type. Can be null to get program's items whatever their content type.code
- The code. Can be null to get program's items regardless of their codecatalogName
- The search catalog. Can be null to get program's items regardless the catalog they belong to.lang
- The search language. Can be null to get program's items regardless of their languageadditionnalExpr
- An additional expression for filtering result. Can be nullsortCriteria
- criteria for sorting results- Returns:
- The matching program items
-
getProgramItems
public <C extends Content> AmetysObjectIterable<C> getProgramItems(Collection<String> cTypeIds, String code, String catalogName, String lang, Expression additionnalExpr, SortCriteria sortCriteria) Get theProgramItem
s matching the given arguments- Type Parameters:
C
- The content return type- Parameters:
cTypeIds
- The id of content types. Can be empty to get program's items whatever their content type.code
- The code. Can be null to get program's items regardless of their codecatalogName
- The search catalog. Can be null to get program's items regardless the catalog they belong to.lang
- The search language. Can be null to get program's items regardless of their languageadditionnalExpr
- An additional expression for filtering result. Can be nullsortCriteria
- criteria for sorting results- Returns:
- The matching program items
-
getCoursePart
Get the equivalentCoursePart
of the sourceCoursePart
in given catalog and language- Parameters:
srcCoursePart
- The source course partcatalogName
- The name of catalog to search intolang
- The search language- Returns:
- The equivalent program item or
null
if not exists
-
getProgramItem
Get the equivalentProgramItem
of the sourceProgramItem
in given catalog and language- Type Parameters:
T
- The type of returned object, it have to be a subclass ofProgramItem
- Parameters:
srcProgramItem
- The source program itemcatalogName
- The name of catalog to search intolang
- The search language- Returns:
- The equivalent program item or
null
if not exists
-
getODFContent
public <T extends AmetysObject> T getODFContent(String contentType, String odfContentCode, String catalogName, String lang) Get the equivalentContent
having the same code in given catalog and language- Type Parameters:
T
- The type of returned object, it have to be a subclass ofAmetysObject
- Parameters:
contentType
- The content type to search forodfContentCode
- The code of the ODF contentcatalogName
- The name of catalog to search intolang
- The search language- Returns:
- The equivalent content or
null
if not exists
-
getChildProgramItems
Get the child program items of aProgramItem
- Parameters:
programItem
- The program item- Returns:
- The child program items
-
getChildSubPrograms
Get the child subprograms of aProgramPart
- Parameters:
programPart
- The program part- Returns:
- The child subprograms
-
getParentContainers
Gets (recursively) parent containers of this program item.- Parameters:
programItem
- The program item- Returns:
- parent containers of this program item.
-
getParentContainers
Gets (recursively) parent containers of this program item.- Parameters:
programItem
- The program itemcontinueIfFound
- Iftrue
continue searching corresponding parents in the parent structure, otherwise only closest items are returned.- Returns:
- parent containers of this program item.
-
getParentPrograms
Gets (recursively) parent programs of this course part.- Parameters:
coursePart
- The course part- Returns:
- parent programs of this course part.
-
getParentPrograms
Gets (recursively) parent programs of this program item.- Parameters:
programItem
- The program item- Returns:
- parent programs of this program item.
-
getParentSubPrograms
Gets (recursively) parent subprograms of this course part.- Parameters:
coursePart
- The course part- Returns:
- parent subprograms of this course part.
-
getParentSubPrograms
Gets (recursively) parent subprograms of this course part.- Parameters:
coursePart
- The course partcontinueIfFound
- Iftrue
continue searching corresponding parents in the parent structure, otherwise only closest items are returned.- Returns:
- parent subprograms of this course part.
-
getParentSubPrograms
Gets (recursively) parent subprograms of this program item.- Parameters:
programItem
- The program item- Returns:
- parent subprograms of this program item.
-
getParentSubPrograms
Gets (recursively) parent subprograms of this program item.- Parameters:
programItem
- The program itemcontinueIfFound
- Iftrue
continue searching corresponding parents in the parent structure, otherwise only closest items are returned.- Returns:
- parent subprograms of this program item.
-
getParentAbstractPrograms
Gets (recursively) parent abstract programs of this course part.- Parameters:
coursePart
- The course part- Returns:
- parent abstract programs of this course part.
-
getParentAbstractPrograms
public Set<AbstractProgram> getParentAbstractPrograms(CoursePart coursePart, boolean continueIfFound) Gets (recursively) parent abstract programs of this course part.- Parameters:
coursePart
- The course partcontinueIfFound
- Iftrue
continue searching corresponding parents in the parent structure, otherwise only closest items are returned.- Returns:
- parent abstract programs of this course part.
-
getParentAbstractPrograms
Gets (recursively) parent abstract programs of this program item.- Parameters:
programItem
- The program item- Returns:
- parent abstract programs of this program item.
-
getParentAbstractPrograms
public Set<AbstractProgram> getParentAbstractPrograms(ProgramItem programItem, boolean continueIfFound) Gets (recursively) parent abstract programs of this program item.- Parameters:
programItem
- The program itemcontinueIfFound
- Iftrue
continue searching corresponding parents in the parent structure, otherwise only closest items are returned.- Returns:
- parent abstract programs of this program item.
-
getProgramsFromOrgUnit
Get the child programs of anOrgUnit
- Parameters:
orgUnit
- the orgUnit, can be nullcatalog
- the cataloglang
- the lang- Returns:
- The child programs
-
getSubOrgUnitIds
Get the current orgunit and its suborgunits recursively identifiers. -
hasParentProgramItems
Determines if theProgramItem
has parent program items- Parameters:
programItem
- The program item- Returns:
- true if has parent program items
-
getParentProgramItems
Get the parent program items of aProgramItem
- Parameters:
programItem
- The program item- Returns:
- The parent program items
-
getParentProgramItems
public List<ProgramItem> getParentProgramItems(ProgramItem programItem, ProgramPart parentProgramPart) Get the program item parents into the given ancestorProgramPart
- Parameters:
programItem
- The program itemparentProgramPart
- The parent program, subprogram or container. If null, all parents program items will be returned.- Returns:
- The parent program items which have given parent program part has an ancestor
-
getParentProgramItem
Get the first nearest program item parent into the given parentAbstractProgram
- Parameters:
programItem
- The program itemparentProgram
- The parent program or subprogram. If null, the nearest abstract program will be returned.- Returns:
- The parent program item or null if not found.
-
getProgramItemInfo
Get information of the program item- Parameters:
programItemId
- the program item idprogramItemPathIds
- the list of program item ids containing in the path of the program item ... starting with itself. Can be null or empty- Returns:
- a map of information
-
getStructureInfo
Get information of the program item structure (type, if program has children) or orgunit (no structure for now)- Parameters:
contentId
- the content id- Returns:
- a map of information
-
getStructureInfo
Get information of the program item structure (type, if program has children)- Parameters:
programItemIds
- the list of program item id- Returns:
- a map of information
-
getOrgUnitPath
Get all the path of the orgunit.
The path is built with the contents' title and code- Parameters:
orgunit
- The orgunitseparator
- The path separator- Returns:
- the path in parent orgunit
-
getPaths
Get allEducationalPath
of aProgramItem
as readable values The path is built with the contents' title and code- Parameters:
item
- The program itemseparator
- The path separator- Returns:
- the paths in parent program items
-
getPaths
public List<String> getPaths(ProgramItem item, String separator, Function<ProgramItem, String> mapper, boolean includeItself) Get allEducationalPath
of aProgramItem
as readable values The path is built with the mapper function.- Parameters:
item
- The program itemseparator
- The path separatormapper
- the function to apply to each program item to build the pathincludeItself
- set to false to not include final item in path- Returns:
- the paths in parent program items
-
getPaths
public List<String> getPaths(ProgramItem item, String separator, Function<ProgramItem, String> mapper, Predicate<ProgramItem> filterPathSegment, boolean includeItself, boolean ignoreOrphanPath) Get allEducationalPath
of aProgramItem
as readable values The path is built with the mapper function.- Parameters:
item
- The program itemseparator
- The path separatormapper
- the function to apply to each program item to build the pathfilterPathSegment
- predicate to exclude some program item of pathincludeItself
- set to false to not include final item in pathignoreOrphanPath
- set to true to ignore paths that is not part of a Program- Returns:
- the paths in parent program items
-
getValueForPath
public <T> Optional<T> getValueForPath(ProgramItem programItem, String dataPath, EducationalPath path) Get the value of an attribute for a given educational path. The attribute is necessarily in a repeater composed of at least one educational path attribute and the attribute to be retrieved.- Type Parameters:
T
- The type of the value returned by the path- Parameters:
programItem
- The program itempath
- Full or partial educational path. Cannot be null. In case of partial educational path (ie., no root program) the full possible paths will be computed.dataPath
- The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)- Returns:
- the value for this educational path
-
getValueForPath
public <T> Optional<T> getValueForPath(ProgramItem programItem, String dataPath, List<EducationalPath> paths) Get the value of an attribute for a given educational path. The attribute is necessarily in a repeater composed of at least one educational path attribute and the attribute to be retrieved.- Type Parameters:
T
- The type of the value returned by the path- Parameters:
programItem
- The program itempaths
- Full educational paths (from root program). Cannot be null nor empty.dataPath
- The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)- Returns:
- the value for this educational path
-
getValuesForPaths
public <T> Map<EducationalPath,T> getValuesForPaths(ProgramItem programItem, String dataPath, T defaultValue) Get the value of an attribute for each available educational paths- Type Parameters:
T
- The type of the values returned by the path- Parameters:
programItem
- The program itemdataPath
- The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)defaultValue
- The default value to use if the repeater contains no entry for this educational path. Can be null.- Returns:
- the values for each educational paths
-
getValuesForPaths
public <T> Map<EducationalPath,T> getValuesForPaths(ProgramItem programItem, String dataPath, List<EducationalPath> paths, T defaultValue) Get the value of an attribute for each given educational paths- Type Parameters:
T
- The type of the value returned by the path- Parameters:
programItem
- The program itemdataPath
- The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)paths
- The full educational paths (from root programs)defaultValue
- The default value to use if the repeater contains no entry for this educational path. Can be null.- Returns:
- the values for each educational paths
-
isSameValueForAllPaths
Determines if the values of an attribute depending of a educational path is the same for all available educational paths- Parameters:
programItem
- The program itemdataPath
- The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)- Returns:
- true if the value is the same for all available educational paths
-
isSameValueForPaths
public boolean isSameValueForPaths(ProgramItem programItem, String dataPath, List<EducationalPath> paths) Determines if the values of an attribute depending of a educational path is the same for all available educational paths- Parameters:
programItem
- The program itemdataPath
- The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)paths
- The full educational paths (from root programs)- Returns:
- true if the value is the same for all available educational paths
-
getRepeaterEntryPositionForPath
public int getRepeaterEntryPositionForPath(ProgramItem programItem, String dataPath, EducationalPath path) Get a position of repeater entry that match the given educational path- Parameters:
programItem
- The program itemdataPath
- The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)path
- The full educational path (from root program). Cannot be null.- Returns:
- the index position of the entry matching the educational path with a non-empty value for requested attribute, -1 otherwise
-
getRepeaterEntryPositionForPath
public int getRepeaterEntryPositionForPath(ProgramItem programItem, String dataPath, List<EducationalPath> paths) Get a position of repeater entry that match the given educational path- Parameters:
programItem
- The program itemdataPath
- The full path of attribute to retrieve. The path must contain the path of repeater holding the value (ex: path/to/repeater/attributeName)paths
- The full educational paths (from root program). Cannot be null.- Returns:
- the index position of the entry matching the educational path with a non-empty value for requested attribute, -1 otherwise
-
getEducationPathFromPath
Get the full educations paths (from a rootProgram
) from a full or partial path- Parameters:
path
- A full or partial path composed by program item ancestors- Returns:
- the full educational paths
-
getEducationPathFromPaths
Get the full educations paths (from a rootProgram
) from full or partial paths- Parameters:
paths
- full or partial paths composed by program item ancestors- Returns:
- the full educational paths
-
getEducationPathFromPaths
public List<EducationalPath> getEducationPathFromPaths(List<List<ProgramItem>> paths, ProgramItem withAncestor) Get the full educations paths (from a rootProgram
)from full or partial paths- Parameters:
paths
- full or partial paths composed by program item ancestorswithAncestor
- filter the educational paths that contains this ancestor. Can be null.- Returns:
- the full educational paths
-
getEducationalPaths
Get allEducationalPath
of aProgramItem
The path is built with the mapper function.- Parameters:
programItem
- The program item- Returns:
- the paths in parent program items
-
getEducationalPaths
Get allEducationalPath
of aProgramItem
The path is built with the mapper function.- Parameters:
programItem
- The program itemincludeItself
- set to false to not include final item in path- Returns:
- the paths in parent program items
-
getEducationalPaths
public List<EducationalPath> getEducationalPaths(ProgramItem programItem, boolean includeItself, boolean ignoreOrphanPath) Get allEducationalPath
of aProgramItem
The path is built with the mapper function.- Parameters:
programItem
- The program itemincludeItself
- set to false to not include final item in pathignoreOrphanPath
- set to true to ignore paths that is not part of a Program- Returns:
- the paths in parent program items
-
getEducationalPathAsString
Get a readable value of aEducationalPath
- Parameters:
path
- the educational path- Returns:
- a String representing the path with program item's title separated by '>'
-
getEducationalPathAsString
public String getEducationalPathAsString(EducationalPath path, Function<ProgramItem, String> mapper, CharSequence separator) Get a readable value of aEducationalPath
- Parameters:
path
- the educational pathmapper
- the function to use for the readable value of a program itemseparator
- the separator to use- Returns:
- a String representing the path with program item's readable value given by mapper function and separated by given separator
-
getEducationalPathAsString
public String getEducationalPathAsString(EducationalPath path, Function<ProgramItem, String> mapper, CharSequence separator, Predicate<ProgramItem> filterPathSegment) Get a readable value of aEducationalPath
- Parameters:
path
- the educational pathmapper
- the function to use for the readable value of a program itemseparator
- the separator to usefilterPathSegment
- predicate to exclude some program item of path- Returns:
- a String representing the path with program item's readable value given by mapper function and separated by given separator
-
getPathOfAncestors
Get the full path to program item for highest ancestors. The path includes this final item.- Parameters:
programItem
- the program item- Returns:
- a list for each highest ancestors found. Each item of the list contains the program items to the path to this program item.
-
getEducationalPathsEnumeration
Get the enumeration of educational paths for a program item for highest ancestors. The paths does not includes this final item.- Parameters:
programItemId
- the id of program item- Returns:
- a list of educational paths with paths' label (composed by ancestors' title separated by '>') and paths' id (composed by ancestors' id seperated by coma)
-
getPathInProgram
Get the path of aProgramItem
into aProgram
The path is construct with the contents' names and the used separator is '/'.- Parameters:
programItemId
- The id of the program itemprogramId
- The id of program. Can not be null.- Returns:
- the path into the parent program or null if the item is not part of this program.
-
getPathInProgram
Get the path of a ODF content into aProgram
.
The path is construct with the contents' names and the used separator is '/'.- Parameters:
item
- The program itemparentProgram
- The parent root (sub)program. Can not be null.- Returns:
- the path from the parent program
-
getPathInCourse
Get the path of aCourse
or aCourseList
into aCourse
The path is construct with the contents' names and the used separator is '/'.- Parameters:
contentId
- The id of the contentparentCourseId
- The id of parent course. Can not be null.- Returns:
- the path into the parent course or null if the item is not part of this course.
-
getPathInCourse
Get the path of aCourse
or aCourseList
into aCourse
The path is construct with the contents' names and the used separator is '/'.- Parameters:
courseOrList
- The course or the course listparentCourse
- The parent course. Can not be null.- Returns:
- the path into the parent course or null if the item is not part of this course.
-
getOrgUnitPath
Get the hierarchical path of aOrgUnit
from the root orgunit id.
The path is construct with the contents' names and the used separator is '/'.- Parameters:
orgUnitId
- The id of the orgunitrootOrgUnitId
- The root orgunit id- Returns:
- the path into the parent program or null if the item is not part of this program.
-
getOrgUnitPath
Get the hierarchical path of aOrgUnit
from the root orgunit.
The path is construct with the contents' names and the used separator is '/'.- Parameters:
orgUnitId
- The id of the orgunit- Returns:
- the path into the parent program or null if the item is not part of this program.
-
hasAncestor
Return true if the givenProgramPart
has in its hierarchy a parent of given id- Parameters:
part
- The program partparentId
- The ancestor id- Returns:
- true if the given
ProgramPart
has in its hierarchy a parent of given id
-
isRelationCompatible
public boolean isRelationCompatible(Content srcContent, Content targetContent, List<I18nizableText> errors, Map<String, Object> contextualParameters) Check if a relation can be establish between two ODF contents- Parameters:
srcContent
- The source content (copied or moved)targetContent
- The target contenterrors
- The list of error messagescontextualParameters
- the contextual parameters- Returns:
- true if the relation is valid, false otherwise
-
getDescendantRelationAttributeName
public String getDescendantRelationAttributeName(ProgramItem parentProgramItem, ProgramItem childProgramItem) Get the name of attribute holding the relation between a parent content and its children- Parameters:
parentProgramItem
- the parent contentchildProgramItem
- the child content- Returns:
- the name of attribute the child relation
-
copyProgramItem
public <C extends ModifiableContent> C copyProgramItem(ProgramItem srcContent, String targetCatalog, boolean fullCopy, Map<Content, Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionCopy aProgramItem
- Type Parameters:
C
- The modifiable content return type- Parameters:
srcContent
- The program item to copytargetCatalog
- The target catalog. Can be null. The target catalog will be the catalog of the source object.fullCopy
- Set totrue
to copy the sub-structurecopiedContents
- the initial contents with their copied content- Returns:
- The created content
- Throws:
AmetysRepositoryException
- If an error occurred during copycom.opensymphony.workflow.WorkflowException
- If an error occurred during copy
-
copyProgramItem
public <C extends ModifiableContent> C copyProgramItem(ProgramItem srcContent, String targetContentName, String targetContentLanguage, String targetCatalog, boolean fullCopy, Map<Content, Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionCopy aProgramItem
- Type Parameters:
C
- The modifiable content return type- Parameters:
srcContent
- The program item to copytargetContentName
- The name of content to created. Can be null. If null, the new name will be get from the source object.targetContentLanguage
- The name of content to created. Can be null. If null, the language of target content will be the same as source object.targetCatalog
- The target catalog. Can be null. The target catalog will be the catalog of the source object.fullCopy
- Set totrue
to copy the sub-structurecopiedContents
- the initial contents with their copied content- Returns:
- The created content
- Throws:
AmetysObjectExistsException
- If a program item with same code, catalog and language already existsAmetysRepositoryException
- If an error occurredcom.opensymphony.workflow.WorkflowException
- If an error occurred
-
copyCoursePart
public <C extends ModifiableContent> C copyCoursePart(CoursePart srcContent, String targetContentName, String targetContentLanguage, int initWorkflowActionId, String targetCatalog, boolean fullCopy, Map<Content, Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionCopy aCoursePart
- Type Parameters:
C
- The modifiable content return type- Parameters:
srcContent
- The course part to copytargetContentName
- The name of content to created. Can be null. If null, the new name will be get from the source object.targetContentLanguage
- The name of content to created. Can be null. If null, the language of target content will be the same as source object.initWorkflowActionId
- The initial workflow action idfullCopy
- Set totrue
to copy the sub-structuretargetCatalog
- The target catalog. Can be null. The target catalog will be the catalog of the source object.copiedContents
- the initial contents with their copied content- Returns:
- The created content
- Throws:
AmetysObjectExistsException
- If a program item with same code, catalog and language already existsAmetysRepositoryException
- If an error occurredcom.opensymphony.workflow.WorkflowException
- If an error occurred
-
copyProgramItem
public <C extends ModifiableContent> C copyProgramItem(ProgramItem srcContent, String targetContentName, String targetContentLanguage, int initWorkflowActionId, String targetCatalog, boolean fullCopy, Map<Content, Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionCopy aProgramItem
- Type Parameters:
C
- The modifiable content return type- Parameters:
srcContent
- The program item to copytargetContentName
- The name of content to created. Can be null. If null, the new name will be get from the source object.targetContentLanguage
- The name of content to created. Can be null. If null, the language of target content will be the same as source object.initWorkflowActionId
- The initial workflow action idfullCopy
- Set totrue
to copy the sub-structuretargetCatalog
- The target catalog. Can be null. The target catalog will be the catalog of the source object.copiedContents
- the initial contents with their copied content- Returns:
- The created content
- Throws:
AmetysObjectExistsException
- If a program item with same code, catalog and language already existsAmetysRepositoryException
- If an error occurredcom.opensymphony.workflow.WorkflowException
- If an error occurred
-
copyProgramItemStructure
protected void copyProgramItemStructure(ProgramItem srcContent, ModifiableContent targetContent, String targetContentLanguage, int initWorkflowActionId, String targetCatalogName, Map<Content, Content> copiedContents) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionCopy the structure of aProgramItem
- Parameters:
srcContent
- the content to copytargetContent
- the target contenttargetContentLanguage
- The name of content to created. Can be null. If null, the language of target content will be the same as source object.initWorkflowActionId
- The initial workflow action idtargetCatalogName
- The target catalog. Can be null. The target catalog will be the catalog of the source object.copiedContents
- the initial contents with their copied content- Throws:
AmetysRepositoryException
- If an error occurred during copycom.opensymphony.workflow.WorkflowException
- If an error occurred during copy
-
_cleanContentMetadata
Clean the CONTENT metadata created after a copy but whose values reference the initial content' structure- Parameters:
createdContent
- The created content to clean
-
switchToLiveVersion
Switch the ametys object to Live version if it has one- Parameters:
ao
- the Ametys object- Throws:
NoLiveVersionException
- if the content has no live version
-
switchToLiveVersionIfNeeded
Switch to Live version if is required- Parameters:
ao
- the Ametys object- Throws:
NoLiveVersionException
- if the Live version is required but not exist
-
getCumulatedHours
Count the hours accumulation in theProgramItem
- Parameters:
programItem
- The program item on which we compute the total number of hours- Returns:
- The hours accumulation
-
_getRequest
Get the request- Returns:
- the request
-
getOrgUnitByUAICode
Get the first orgunit matching the given UAI code- Parameters:
uaiCode
- the UAI code- Returns:
- the orgunit or null if not found
-