Package org.ametys.odf
Class ODFHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.odf.ODFHelper
- All Implemented Interfaces:
LogEnabled
,PluginAware
,Component
,Contextualizable
,Serviceable
public class ODFHelper
extends AbstractLogEnabled
implements Component, Serviceable, PluginAware, Contextualizable
Helper for ODF contents
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final int
The default id of initial workflow actionprotected ContentWorkflowHelper
The content workflow helperprotected Context
The Avalon contextprotected ContentTypeExtensionPoint
The content types managerprotected CurrentUserProvider
The current user providerprotected ExternalizableDataProviderExtensionPoint
Provider for externalizable metadataprotected ObservationManager
The observation 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<String, String> copiedPrograms, Map<String, String> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) Copy aCoursePart
<C extends ModifiableContent>
CcopyProgramItem
(ProgramItem srcContent, String targetCatalog, boolean fullCopy, Map<String, String> copiedPrograms, Map<String, String> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) Copy aProgramItem
<C extends ModifiableContent>
CcopyProgramItem
(ProgramItem srcContent, String targetContentName, String targetContentLanguage, int initWorkflowActionId, String targetCatalog, boolean fullCopy, Map<String, String> copiedPrograms, Map<String, String> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) Copy aProgramItem
<C extends ModifiableContent>
CcopyProgramItem
(ProgramItem srcContent, String targetContentName, String targetContentLanguage, String targetCatalog, boolean fullCopy, Map<String, String> copiedPrograms, Map<String, String> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) Copy aProgramItem
protected void
copyProgramItemStructure
(ProgramItem srcContent, ModifiableContent targetContent, String targetContentLanguage, int initWorkflowActionId, String targetCatalogName, Map<String, String> copiedPrograms, Map<String, String> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) 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
<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 nearest program item parent into the given parentAbstractProgram
getParentProgramItems
(ProgramItem programItem) Get the parent program items of aProgramItem
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 '/'.Get the full path to program item for highest ancestors.getPaths
(ProgramItem item, String separator) Get all the paths of a ODF content.
The path is built with the contents' title and codegetPaths
(ProgramItem item, String separator, Function<ProgramItem, String> mapper, boolean includeItseft) Get all the paths of a ODF content.
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
Gets 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.boolean
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 itemsboolean
isRelationCompatible
(Content srcContent, Content targetContent, List<I18nizableText> errors, Map<String, Object> contextualParameters) Check if a relation can be establish between two ODF contentsvoid
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 -
_contentWorkflowHelper
The content workflow helper -
_cTypeEP
The content types manager -
_observationManager
The observation manager -
_currentUserProvider
The current user provider -
_ouRootProvider
Root orgunit -
_externalizableDataProviderEP
Provider for externalizable metadata -
_context
The Avalon context
-
-
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
-
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
-
getParentProgramItem
Get the 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 all the paths of a ODF content.
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 includeItseft) Get all the paths of a ODF content.
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 pathincludeItseft
- set to false to not include final item in path- Returns:
- the paths in parent program items
-
getPathOfAncestors
Get the full path to program item for highest ancestors. The path includes this final item.- Parameters:
item
- 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.
-
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
-
copyProgramItem
public <C extends ModifiableContent> C copyProgramItem(ProgramItem srcContent, String targetCatalog, boolean fullCopy, Map<String, String> copiedPrograms, Map<String, throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionString> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) Copy 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-structurecopiedPrograms
- the id of initial programs with their copied contentcopiedSubPrograms
- the id of initial subprograms with their copied contentcopiedContainers
- the id of initial containers with their copied contentcopiedCourseLists
- the id of initial course lists with their copied contentcopiedCourses
- the id of initial courses with their copied contentcopiedCourseParts
- the id of initial course parts 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<String, String> copiedPrograms, Map<String, throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionString> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) Copy 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-structurecopiedPrograms
- the id of initial programs with their copied contentcopiedSubPrograms
- the id of initial subprograms with their copied contentcopiedContainers
- the id of initial containers with their copied contentcopiedCourseLists
- the id of initial course lists with their copied contentcopiedCourses
- the id of initial courses with their copied contentcopiedCourseParts
- the id of initial course parts 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<String, String> copiedPrograms, Map<String, throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionString> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) Copy 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.copiedPrograms
- the id of initial programs with their copied contentcopiedSubPrograms
- the id of initial subprograms with their copied contentcopiedContainers
- the id of initial containers with their copied contentcopiedCourseLists
- the id of initial course lists with their copied contentcopiedCourses
- the id of initial courses with their copied contentcopiedCourseParts
- the id of initial course parts 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<String, String> copiedPrograms, Map<String, throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionString> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) Copy 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.copiedPrograms
- the id of initial programs with their copied contentcopiedSubPrograms
- the id of initial subprograms with their copied contentcopiedContainers
- the id of initial containers with their copied contentcopiedCourseLists
- the id of initial course lists with their copied contentcopiedCourses
- the id of initial courses with their copied contentcopiedCourseParts
- the id of initial course parts 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<String, String> copiedPrograms, Map<String, throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionString> copiedSubPrograms, Map<String, String> copiedContainers, Map<String, String> copiedCourseLists, Map<String, String> copiedCourses, Map<String, String> copiedCourseParts) Copy 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.copiedPrograms
- the id of initial programs with their copied contentcopiedSubPrograms
- the id of initial subprograms with their copied contentcopiedContainers
- the id of initial containers with their copied contentcopiedCourseLists
- the id of initial course lists with their copied contentcopiedCourses
- the id of initial courses with their copied contentcopiedCourseParts
- the id of initial course parts 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
-