public class ODFHelper extends AbstractLogEnabled implements Component, Serviceable, PluginAware
Modifier and Type | Field and Description |
---|---|
protected static int |
__EDIT_WORKFLOW_ACTION_ID
The default id of edit workflow action
|
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 ObservationManager |
_observationManager
The observation manager
|
protected RootOrgUnitProvider |
_ouRootProvider
Root orgunit
|
private String |
_pluginName |
protected AmetysObjectResolver |
_resolver
Ametys object resolver
|
static String |
ROLE
The component role.
|
Constructor and Description |
---|
ODFHelper() |
Modifier and Type | Method and Description |
---|---|
protected void |
_cleanContentMetadata(ModifiableContent createdContent)
Clean the CONTENT metadata created after a copy but whose values reference the initial content' structure
|
private void |
_editChildRelation(WorkflowAwareContent parentContent,
List<String> refChildIds,
int actionId,
String childMetadataPath) |
private Set<AbstractProgram> |
_getParentAbstractPrograms(ProgramItem programItem,
Set<ProgramItem> visitedProgramItems) |
private String |
_getPathInCourse(Content content,
Content parentContent) |
<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)
Copy a
ProgramItem |
<C extends ModifiableContent> |
copyProgramItem(ProgramItem srcContent,
String targetContentName,
String targetContentLanguage,
int initWorkflowActionId,
int editWorkflowActionId,
String targetCatalog,
boolean fullCopy,
Map<String,String> copiedPrograms,
Map<String,String> copiedSubPrograms,
Map<String,String> copiedContainers,
Map<String,String> copiedCourseLists,
Map<String,String> copiedCourses)
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)
Copy a
ProgramItem |
protected void |
copyProgramItemStructure(ProgramItem srcContent,
ModifiableContent targetContent,
String targetContentLanguage,
int initWorkflowActionId,
int editWorkflowActionId,
String targetCatalogName,
Map<String,String> copiedPrograms,
Map<String,String> copiedSubPrograms,
Map<String,String> copiedContainers,
Map<String,String> copiedCourseLists,
Map<String,String> copiedCourses)
Copy the structure of a
ProgramItem |
List<ProgramItem> |
getChildProgramItems(ProgramItem programItem)
Get the child program items of a
ProgramItem |
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.
|
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 |
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 |
Content |
getProgramItem(ProgramItem 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 |
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 static final int __EDIT_WORKFLOW_ACTION_ID
protected AmetysObjectResolver _resolver
protected ContentWorkflowHelper _contentWorkflowHelper
protected ContentTypeExtensionPoint _cTypeEP
protected ObservationManager _observationManager
protected CurrentUserProvider _currentUserProvider
protected RootOrgUnitProvider _ouRootProvider
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 Content getProgramItem(ProgramItem srcProgramItem, String catalogName, String lang)
ProgramItem
of the source ProgramItem
in given catalog and languagesrcProgramItem
- The source program itemcatalogName
- The name of catalog to search intolang
- The search languagenull
if not existspublic List<ProgramItem> getChildProgramItems(ProgramItem programItem)
ProgramItem
programItem
- The program itempublic Set<AbstractProgram> getParentAbstractPrograms(ProgramItem programItem)
programItem
- The program itemprivate Set<AbstractProgram> _getParentAbstractPrograms(ProgramItem programItem, Set<ProgramItem> visitedProgramItems)
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 <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) 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 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) 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 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, int editWorkflowActionId, String targetCatalog, boolean fullCopy, Map<String,String> copiedPrograms, Map<String,String> copiedSubPrograms, Map<String,String> copiedContainers, Map<String,String> copiedCourseLists, Map<String,String> copiedCourses) 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 ideditWorkflowActionId
- The workflow action id to edit the relationshipfullCopy
- 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 contentAmetysObjectExistsException
- If a program item with same code, catalog and language already existsAmetysRepositoryException
- If an error occurredcom.opensymphony.workflow.WorkflowException
- If an error occurredprotected void copyProgramItemStructure(ProgramItem srcContent, ModifiableContent targetContent, String targetContentLanguage, int initWorkflowActionId, int editWorkflowActionId, String targetCatalogName, Map<String,String> copiedPrograms, Map<String,String> copiedSubPrograms, Map<String,String> copiedContainers, Map<String,String> copiedCourseLists, Map<String,String> copiedCourses) 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 ideditWorkflowActionId
- The workflow action id to edit the relationshiptargetCatalogName
- 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 contentAmetysRepositoryException
- If an error occurred during copycom.opensymphony.workflow.WorkflowException
- If an error occurred during copyprivate void _editChildRelation(WorkflowAwareContent parentContent, List<String> refChildIds, int actionId, String childMetadataPath) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
AmetysRepositoryException
com.opensymphony.workflow.WorkflowException
protected void _cleanContentMetadata(ModifiableContent createdContent)
createdContent
- The created content to clean