public class ODFHelper extends AbstractLogEnabled implements Component, Serviceable, PluginAware
Modifier and Type | Field and Description |
---|---|
protected static int |
__INITIAL_WORKFLOW_ACTION_ID
The default id of initial workflow action
|
protected ContentWorkflowHelper |
_contentWorkflowHelper
The content workflow helper
|
protected ContentTypeExtensionPoint |
_cTypeEP
The content types manager
|
protected CurrentUserProvider |
_currentUserProvider
The current user provider
|
protected ExternalizableMetadataProviderExtensionPoint |
_externalizableMetadataProviderEP
Provider for externalizable metadata
|
protected ObservationManager |
_observationManager
The observation manager
|
protected RootOrgUnitProvider |
_ouRootProvider
Root orgunit
|
private String |
_pluginName |
protected AmetysObjectResolver |
_resolver
Ametys object resolver
|
protected ShareableCourseHelper |
_shareableCourseHelper
Helper for shareable course
|
static String |
ROLE
The component role.
|
Constructor and Description |
---|
ODFHelper() |
Modifier and Type | Method and Description |
---|---|
private void |
_addFormValues(Map<Pair<String,String>,List<String>> values,
String childMetadataPath,
String parentMetadataPath,
List<String> refChildIds) |
protected void |
_cleanContentMetadata(ModifiableContent createdContent)
Clean the CONTENT metadata created after a copy but whose values reference the initial content' structure
|
private <C extends ModifiableContent> |
_copyODFContent(Content srcContent,
String catalog,
String code,
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 a
ProgramItem |
private void |
_editChildRelation(WorkflowAwareContent parentContent,
Map<Pair<String,String>,List<String>> values) |
private List<String> |
_getContentParameters(Content srcContent,
Content targetContent) |
private <T> Set<T> |
_getParentsOfType(ProgramItem programItem,
Class<T> classToTest) |
private <T> Set<T> |
_getParentsOfType(ProgramItem programItem,
Set<ProgramItem> visitedProgramItems,
Class<T> classToTest) |
private String |
_getPathInCourse(Content content,
Content parentContent) |
private boolean |
_isContentTypeCompatible(Content srcContent,
Content targetContent) |
private void |
_putInCopiedMap(Content srcContent,
ModifiableContent createdContent,
Map<String,String> copiedPrograms,
Map<String,String> copiedSubPrograms,
Map<String,String> copiedContainers,
Map<String,String> copiedCourseLists,
Map<String,String> copiedCourses,
Map<String,String> copiedCourseParts) |
<C extends ModifiableContent> |
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)
Copy a
CoursePart |
<C extends ModifiableContent> |
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)
Copy a
ProgramItem |
<C extends ModifiableContent> |
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)
Copy a
ProgramItem |
<C extends ModifiableContent> |
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)
Copy a
ProgramItem |
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 a
ProgramItem |
List<ProgramItem> |
getChildProgramItems(ProgramItem programItem)
Get the child program items of a
ProgramItem |
Set<SubProgram> |
getChildSubPrograms(ProgramPart programPart)
Get the child subprograms of a
ProgramPart |
CoursePart |
getCoursePart(CoursePart srcCoursePart,
String catalogName,
String lang)
Get the equivalent
CoursePart of the source CoursePart in given catalog and language |
<T extends AmetysObject> |
getODFContent(String contentType,
String odfContentCode,
String catalogName,
String lang)
Get the equivalent
Content having the same code in given catalog and language |
String |
getOrgUnitPath(String orgUnitId)
Get the hierarchical path of a
OrgUnit 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 a
OrgUnit 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 parent
AbstractProgram |
List<ProgramItem> |
getParentProgramItems(ProgramItem programItem)
Get the parent program items of a
ProgramItem |
Set<Program> |
getParentPrograms(ProgramItem programItem)
Gets (recursively) parent programs of this program item.
|
String |
getPathInCourse(Content courseOrList,
Course parentCourse)
Get the path of a
Course or a CourseList into a Course The path is construct with the contents' names and the used separator is '/'. |
String |
getPathInCourse(String contentId,
String parentCourseId)
Get the path of a
Course or a CourseList into a Course 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 a
Program .The path is construct with the contents' names and the used separator is '/'. |
String |
getPathInProgram(String programItemId,
String programId)
Get the path of a
ProgramItem into a Program The path is construct with the contents' names and the used separator is '/'. |
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> |
getProgramItem(T srcProgramItem,
String catalogName,
String lang)
Get the equivalent
ProgramItem of the source ProgramItem in given catalog and language |
<C extends Content> |
getProgramItems(String cTypeId,
String code,
String catalogName,
String lang)
Get the
ProgramItem s matching the given arguments |
<C extends Content> |
getProgramItems(String cTypeId,
String code,
String catalogName,
String lang,
Expression additionnalExpr,
SortCriteria sortCriteria)
Get the
ProgramItem s matching the given arguments |
AmetysObjectCollection |
getRootContent()
Gets the root for ODF contents
|
AmetysObjectCollection |
getRootContent(boolean create)
Gets the root for ODF contents
|
Map<String,Object> |
getStructureInfo(String programItemId)
Get information of the program item structure (type, if program has children)
|
boolean |
hasAncestor(ProgramPart part,
String parentId)
Return true if the given
ProgramPart has in its hierarchy a parent of given id |
boolean |
isRelationCompatible(Content srcContent,
Content targetContent,
List<I18nizableText> errors,
Map<String,Object> contextualParameters)
Check if a relation can be establish between two ODF contents
|
void |
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. |
getLogger, setLogger
protected static final int __INITIAL_WORKFLOW_ACTION_ID
protected AmetysObjectResolver _resolver
protected ContentWorkflowHelper _contentWorkflowHelper
protected ContentTypeExtensionPoint _cTypeEP
protected ObservationManager _observationManager
protected CurrentUserProvider _currentUserProvider
protected RootOrgUnitProvider _ouRootProvider
protected ExternalizableMetadataProviderExtensionPoint _externalizableMetadataProviderEP
protected ShareableCourseHelper _shareableCourseHelper
private String _pluginName
public ODFHelper()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void setPluginInfo(String pluginName, String featureName, String id)
PluginAware
setPluginInfo
in interface PluginAware
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this componentpublic AmetysObjectCollection getRootContent()
public AmetysObjectCollection getRootContent(boolean create)
create
- true
to create automatically the root when missing.public <C extends Content> AmetysObjectIterable<C> getProgramItems(String cTypeId, String code, String catalogName, String lang)
ProgramItem
s matching the given argumentsC
- The content return typecTypeId
- 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 languagepublic <C extends Content> AmetysObjectIterable<C> getProgramItems(String cTypeId, String code, String catalogName, String lang, Expression additionnalExpr, SortCriteria sortCriteria)
ProgramItem
s matching the given argumentsC
- The content return typecTypeId
- 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 resultspublic CoursePart getCoursePart(CoursePart srcCoursePart, String catalogName, String lang)
CoursePart
of the source CoursePart
in given catalog and languagesrcCoursePart
- The source course partcatalogName
- The name of catalog to search intolang
- The search languagenull
if not existspublic <T extends ProgramItem> T getProgramItem(T srcProgramItem, String catalogName, String lang)
ProgramItem
of the source ProgramItem
in given catalog and languageT
- The type of returned object, it have to be a subclass of ProgramItem
srcProgramItem
- The source program itemcatalogName
- The name of catalog to search intolang
- The search languagenull
if not existspublic <T extends AmetysObject> T getODFContent(String contentType, String odfContentCode, String catalogName, String lang)
Content
having the same code in given catalog and languageT
- The type of returned object, it have to be a subclass of AmetysObject
contentType
- The content type to search forodfContentCode
- The code of the ODF contentcatalogName
- The name of catalog to search intolang
- The search languagenull
if not existspublic List<ProgramItem> getChildProgramItems(ProgramItem programItem)
ProgramItem
programItem
- The program itempublic Set<SubProgram> getChildSubPrograms(ProgramPart programPart)
ProgramPart
programPart
- The program partpublic Set<Container> getParentContainers(ProgramItem programItem)
programItem
- The program itempublic Set<Program> getParentPrograms(ProgramItem programItem)
programItem
- The program itempublic Set<AbstractProgram> getParentAbstractPrograms(ProgramItem programItem)
programItem
- The program itemprivate <T> Set<T> _getParentsOfType(ProgramItem programItem, Class<T> classToTest)
private <T> Set<T> _getParentsOfType(ProgramItem programItem, Set<ProgramItem> visitedProgramItems, Class<T> classToTest)
public List<ProgramItem> getParentProgramItems(ProgramItem programItem)
ProgramItem
programItem
- The program itempublic ProgramItem getParentProgramItem(ProgramItem programItem, AbstractProgram parentProgram)
AbstractProgram
programItem
- The program itemparentProgram
- The parent program or subprogram. If null, the nearest abstract program will be returned.public Map<String,Object> getStructureInfo(String programItemId)
programItemId
- the program item idprotected List<String> getPaths(ProgramItem item, String separator)
separator
- The path separatoritem
- The program itempublic String getPathInProgram(String programItemId, String programId)
ProgramItem
into a Program
programItemId
- The id of the program itemprogramId
- The id of program. Can not be null.public String getPathInProgram(ProgramItem item, Program parentProgram)
Program
.item
- The program itemparentProgram
- The parent root (sub)program. Can not be null.public String getPathInCourse(String contentId, String parentCourseId)
Course
or a CourseList
into a Course
contentId
- The id of the contentparentCourseId
- The id of parent course. Can not be null.public String getPathInCourse(Content courseOrList, Course parentCourse)
Course
or a CourseList
into a Course
courseOrList
- The course or the course listparentCourse
- The parent course. Can not be null.private String _getPathInCourse(Content content, Content parentContent)
public String getOrgUnitPath(String orgUnitId, String rootOrgUnitId)
OrgUnit
from the root orgunit id.orgUnitId
- The id of the orgunitrootOrgUnitId
- The root orgunit idpublic String getOrgUnitPath(String orgUnitId)
OrgUnit
from the root orgunit.orgUnitId
- The id of the orgunitpublic boolean hasAncestor(ProgramPart part, String parentId)
ProgramPart
has in its hierarchy a parent of given idpart
- The program partparentId
- The ancestor idProgramPart
has in its hierarchy a parent of given idpublic boolean isRelationCompatible(Content srcContent, Content targetContent, List<I18nizableText> errors, Map<String,Object> contextualParameters)
srcContent
- The source content (copied or moved)targetContent
- The target contenterrors
- The list of error messagescontextualParameters
- the contextual parametersprivate boolean _isContentTypeCompatible(Content srcContent, Content targetContent)
private List<String> _getContentParameters(Content srcContent, Content targetContent)
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
ProgramItem
C
- The modifiable content return typesrcContent
- The program item to copytargetCatalog
- The target catalog. Can be null. The target catalog will be the catalog of the source object.fullCopy
- Set to true
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 contentAmetysRepositoryException
- If an error occurred during copycom.opensymphony.workflow.WorkflowException
- If an error occurred during copypublic <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
ProgramItem
C
- The modifiable content return typesrcContent
- 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 to true
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 contentAmetysObjectExistsException
- If a program item with same code, catalog and language already existsAmetysRepositoryException
- If an error occurredcom.opensymphony.workflow.WorkflowException
- If an error occurredpublic <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
CoursePart
C
- The modifiable content return typesrcContent
- 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 to true
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 contentAmetysObjectExistsException
- If a program item with same code, catalog and language already existsAmetysRepositoryException
- If an error occurredcom.opensymphony.workflow.WorkflowException
- If an error occurredpublic <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
ProgramItem
C
- The modifiable content return typesrcContent
- 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 to true
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 contentAmetysObjectExistsException
- If a program item with same code, catalog and language already existsAmetysRepositoryException
- If an error occurredcom.opensymphony.workflow.WorkflowException
- If an error occurredprivate <C extends ModifiableContent> C _copyODFContent(Content srcContent, String catalog, String code, 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
ProgramItem
C
- The modifiable content return typesrcContent
- The program item to copycatalog
- The catalogcode
- The odf content codetargetContentName
- 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 to true
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 contentAmetysObjectExistsException
- If a program item with same code, catalog and language already existsAmetysRepositoryException
- If an error occurredcom.opensymphony.workflow.WorkflowException
- If an error occurredprivate void _putInCopiedMap(Content srcContent, ModifiableContent createdContent, Map<String,String> copiedPrograms, Map<String,String> copiedSubPrograms, Map<String,String> copiedContainers, Map<String,String> copiedCourseLists, Map<String,String> copiedCourses, Map<String,String> copiedCourseParts)
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
ProgramItem
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 contentAmetysRepositoryException
- If an error occurred during copycom.opensymphony.workflow.WorkflowException
- If an error occurred during copyprivate void _addFormValues(Map<Pair<String,String>,List<String>> values, String childMetadataPath, String parentMetadataPath, List<String> refChildIds)
private void _editChildRelation(WorkflowAwareContent parentContent, Map<Pair<String,String>,List<String>> values) throws AmetysRepositoryException
AmetysRepositoryException
protected void _cleanContentMetadata(ModifiableContent createdContent)
createdContent
- The created content to clean