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
Fields Modifier and Type Field Description protected static int
__INITIAL_WORKFLOW_ACTION_ID
The default id of initial workflow actionprotected ContentWorkflowHelper
_contentWorkflowHelper
The content workflow helperprotected Context
_context
The Avalon contextprotected ContentTypeExtensionPoint
_cTypeEP
The content types managerprotected CurrentUserProvider
_currentUserProvider
The current user providerprotected ExternalizableDataProviderExtensionPoint
_externalizableDataProviderEP
Provider for externalizable metadataprotected ObservationManager
_observationManager
The observation managerprotected RootOrgUnitProvider
_ouRootProvider
Root orgunitprotected AmetysObjectResolver
_resolver
Ametys object resolverprotected ShareableCourseHelper
_shareableCourseHelper
Helper for shareable coursestatic String
REQUEST_ATTRIBUTE_VALID_LABEL
Request attribute to get the "Live" version of contentsstatic String
ROLE
The component role.
-
Constructor Summary
Constructors Constructor Description ODFHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_cleanContentMetadata(ModifiableContent createdContent)
Clean the CONTENT metadata created after a copy but whose values reference the initial content' structureprotected Request
_getRequest()
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
List<ProgramItem>
getChildProgramItems(ProgramItem programItem)
Get the child program items of aProgramItem
Set<SubProgram>
getChildSubPrograms(ProgramPart programPart)
Get the child subprograms of aProgramPart
CoursePart
getCoursePart(CoursePart srcCoursePart, String catalogName, String lang)
Get the equivalentCoursePart
of the sourceCoursePart
in given catalog and languageDouble
getCumulatedHours(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 languageOrgUnit
getOrgUnitByUAICode(String uaiCode)
Get the first orgunit matching the given UAI codeString
getOrgUnitPath(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 '/'.String
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 '/'.Set<AbstractProgram>
getParentAbstractPrograms(ProgramItem programItem)
Gets (recursively) parent abstract programs of this program item.Set<Container>
getParentContainers(ProgramItem programItem)
Gets (recursively) parent containers of this program item.ProgramItem
getParentProgramItem(ProgramItem programItem, AbstractProgram parentProgram)
Get the nearest program item parent into the given parentAbstractProgram
List<ProgramItem>
getParentProgramItems(ProgramItem programItem)
Get the parent program items of aProgramItem
Set<Program>
getParentPrograms(ProgramItem programItem)
Gets (recursively) parent programs of this program item.String
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 '/'.String
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 '/'.String
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 '/'.String
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 '/'.List<List<ProgramItem>>
getPathOfAncestors(ProgramItem item)
Get the full path to program item for highest ancestors.protected List<String>
getPaths(ProgramItem item, String separator)
Get all the paths of a ODF content.
The path is construct with the contents' title<T extends ProgramItem>
TgetProgramItem(T srcProgramItem, String catalogName, String lang)
Get the equivalentProgramItem
of the sourceProgramItem
in given catalog and language<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 argumentsList<Program>
getProgramsFromOrgUnit(OrgUnit orgUnit, String catalog, String lang)
Get the child programs of anOrgUnit
AmetysObjectCollection
getRootContent()
Gets the root for ODF contentsAmetysObjectCollection
getRootContent(boolean create)
Gets the root for ODF contentsMap<String,Object>
getStructureInfo(String programItemId)
Get information of the program item structure (type, if program has children)Map<String,Map<String,Object>>
getStructureInfo(List<String> programItemIds)
Get information of the program item structure (type, if program has children)List<String>
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
switchToLiveVersion(DefaultAmetysObject ao)
Switch the ametys object to Live version if it has onevoid
switchToLiveVersionIfNeeded(DefaultAmetysObject ao)
Switch to Live version if is required-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
REQUEST_ATTRIBUTE_VALID_LABEL
public static final String REQUEST_ATTRIBUTE_VALID_LABEL
Request attribute to get the "Live" version of contents- See Also:
- Constant Field Values
-
__INITIAL_WORKFLOW_ACTION_ID
protected static final int __INITIAL_WORKFLOW_ACTION_ID
The default id of initial workflow action- See Also:
- Constant Field Values
-
_resolver
protected AmetysObjectResolver _resolver
Ametys object resolver
-
_contentWorkflowHelper
protected ContentWorkflowHelper _contentWorkflowHelper
The content workflow helper
-
_cTypeEP
protected ContentTypeExtensionPoint _cTypeEP
The content types manager
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_ouRootProvider
protected RootOrgUnitProvider _ouRootProvider
Root orgunit
-
_externalizableDataProviderEP
protected ExternalizableDataProviderExtensionPoint _externalizableDataProviderEP
Provider for externalizable metadata
-
_shareableCourseHelper
protected ShareableCourseHelper _shareableCourseHelper
Helper for shareable course
-
-
Constructor Detail
-
ODFHelper
public ODFHelper()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
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
public AmetysObjectCollection getRootContent()
Gets the root for ODF contents- Returns:
- the root for ODF contents
-
getRootContent
public AmetysObjectCollection getRootContent(boolean create)
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
public CoursePart getCoursePart(CoursePart srcCoursePart, String catalogName, String lang)
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
public <T extends ProgramItem> T getProgramItem(T srcProgramItem, String catalogName, String lang)
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
public List<ProgramItem> getChildProgramItems(ProgramItem programItem)
Get the child program items of aProgramItem
- Parameters:
programItem
- The program item- Returns:
- The child program items
-
getChildSubPrograms
public Set<SubProgram> getChildSubPrograms(ProgramPart programPart)
Get the child subprograms of aProgramPart
- Parameters:
programPart
- The program part- Returns:
- The child subprograms
-
getParentContainers
public Set<Container> getParentContainers(ProgramItem programItem)
Gets (recursively) parent containers of this program item.- Parameters:
programItem
- The program item- Returns:
- parent containers of this program item.
-
getParentPrograms
public Set<Program> getParentPrograms(ProgramItem programItem)
Gets (recursively) parent programs of this program item.- Parameters:
programItem
- The program item- Returns:
- parent programs of this program item.
-
getParentAbstractPrograms
public Set<AbstractProgram> getParentAbstractPrograms(ProgramItem programItem)
Gets (recursively) parent abstract programs of this program item.- Parameters:
programItem
- The program item- Returns:
- parent abstract programs of this program item.
-
getProgramsFromOrgUnit
public List<Program> getProgramsFromOrgUnit(OrgUnit orgUnit, String catalog, String lang)
Get the child programs of anOrgUnit
- Parameters:
orgUnit
- the orgUnit, can be nullcatalog
- the cataloglang
- the lang- Returns:
- The child programs
-
getSubOrgUnitIds
public List<String> getSubOrgUnitIds(OrgUnit orgUnit)
Get the current orgunit and its suborgunits recursively identifiers.
-
hasParentProgramItems
public boolean hasParentProgramItems(ProgramItem programItem)
Determines if theProgramItem
has parent program items- Parameters:
programItem
- The program item- Returns:
- true if has parent program items
-
getParentProgramItems
public List<ProgramItem> getParentProgramItems(ProgramItem programItem)
Get the parent program items of aProgramItem
- Parameters:
programItem
- The program item- Returns:
- The parent program items
-
getParentProgramItem
public ProgramItem getParentProgramItem(ProgramItem programItem, AbstractProgram parentProgram)
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.
-
getStructureInfo
public Map<String,Object> getStructureInfo(String programItemId)
Get information of the program item structure (type, if program has children)- Parameters:
programItemId
- the program item id- Returns:
- a map of information
-
getStructureInfo
public Map<String,Map<String,Object>> getStructureInfo(List<String> programItemIds)
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
-
getPaths
protected List<String> getPaths(ProgramItem item, String separator)
Get all the paths of a ODF content.
The path is construct with the contents' title- Parameters:
separator
- The path separatoritem
- The program item- Returns:
- the paths in parent program items
-
getPathOfAncestors
public List<List<ProgramItem>> getPathOfAncestors(ProgramItem item)
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
public String 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 '/'.- 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
public String 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 '/'.- Parameters:
item
- The program itemparentProgram
- The parent root (sub)program. Can not be null.- Returns:
- the path from the parent program
-
getPathInCourse
public String 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 '/'.- 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
public String 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 '/'.- 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
public String 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 '/'.- 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
public String getOrgUnitPath(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 '/'.- 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
public boolean hasAncestor(ProgramPart part, String parentId)
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,String> copiedSubPrograms, Map<String,String> copiedContainers, Map<String,String> copiedCourseLists, Map<String,String> copiedCourses, Map<String,String> copiedCourseParts) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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,String> copiedSubPrograms, Map<String,String> copiedContainers, Map<String,String> copiedCourseLists, Map<String,String> copiedCourses, Map<String,String> copiedCourseParts) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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,String> copiedSubPrograms, Map<String,String> copiedContainers, Map<String,String> copiedCourseLists, Map<String,String> copiedCourses, Map<String,String> copiedCourseParts) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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,String> copiedSubPrograms, Map<String,String> copiedContainers, Map<String,String> copiedCourseLists, Map<String,String> copiedCourses, Map<String,String> copiedCourseParts) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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,String> copiedSubPrograms, Map<String,String> copiedContainers, Map<String,String> copiedCourseLists, Map<String,String> copiedCourses, Map<String,String> copiedCourseParts) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
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
protected void _cleanContentMetadata(ModifiableContent createdContent)
Clean the CONTENT metadata created after a copy but whose values reference the initial content' structure- Parameters:
createdContent
- The created content to clean
-
switchToLiveVersion
public void switchToLiveVersion(DefaultAmetysObject ao) throws NoLiveVersionException
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
public void switchToLiveVersionIfNeeded(DefaultAmetysObject ao) throws NoLiveVersionException
Switch to Live version if is required- Parameters:
ao
- the Ametys object- Throws:
NoLiveVersionException
- if the Live version is required but not exist
-
getCumulatedHours
public Double getCumulatedHours(ProgramItem programItem)
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
protected Request _getRequest()
Get the request- Returns:
- the request
-
getOrgUnitByUAICode
public OrgUnit getOrgUnitByUAICode(String uaiCode)
Get the first orgunit matching the given UAI code- Parameters:
uaiCode
- the UAI code- Returns:
- the orgunit or null if not found
-
-