Package org.ametys.odf.migration
Class MigrateCoursePartComponent
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.odf.migration.MigrateCoursePartComponent
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
- Direct Known Subclasses:
MigrateNatureEnseignementComponent
public class MigrateCoursePartComponent extends AbstractLogEnabled implements Serviceable, Component
Component class to migrate totalDurationOf* metadata.
-
-
Field Summary
Fields Modifier and Type Field Description protected OdfReferenceTableHelper
_odfRefTableHelper
The ODF Reference table helperprotected AmetysObjectResolver
_resolver
The Ametys object resolverprotected ContentWorkflowHelper
_workflowHelper
The content workflow helperprotected WorkflowProvider
_workflowProvider
The workflowstatic String
ROLE
The component role.
-
Constructor Summary
Constructors Constructor Description MigrateCoursePartComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CoursePart
_createCoursePart(Course course, OdfReferenceTableEntry nature, Double totalDurationOf, boolean isLive)
Create a course part linked to the course.protected Map<String,String>
_createNatureEnseignementCategories(Map<String,Pair<String,Long>> natureEnseignementCategories)
Create entries into the reference table EnseignementNature if they don't exist.protected Map<String,OdfReferenceTableEntry>
_createNaturesEnseignement(Map<String,Pair<String,Long>> natureEnseignementCategories, Map<String,Pair<String,String>> natureEnseignements)
Create entries into the reference table EnseignementNature if they don't exist.protected Map<String,Object>
_doAction(WorkflowAwareContent content, Integer actionId)
ContentWorkflowHelper
cannot be used in these conditions.protected Map<String,Pair<String,Long>>
_getNaturesEnseignementCategoryList(Map<String,Pair<String,Long>> natureEnseignementCategories)
List of the course parts nature categories.protected Map<String,Pair<String,String>>
_getNaturesEnseignementList(Map<String,Pair<String,String>> natureEnseignements)
List of the course parts natures.protected OdfReferenceTableEntry
_getOrCreateNatureEnseignement(String title, String code, Long order)
Get or create the nature enseignement if it doesn't exist.protected Map<String,CoursePart>
_migrateCoursePart(Course course, Map<String,OdfReferenceTableEntry> natureByCode, boolean isLive)
Create a course part linked to the course.protected void
_setAdditionalValues(CoursePart coursePart, Course course)
Set additional values to theCoursePart
from theCourse
.protected void
_updateCoursePart(Course course, Map<String,OdfReferenceTableEntry> natureByCode, Map<String,CoursePart> createdCourseParts)
Update theCoursePart
and the course parts list of theCourse
with the values of the current version.void
migrateCourseParts()
Migrate the totalDurationOf to course parts.void
migrateCourseParts(Map<String,Pair<String,Long>> natureEnseignementCategories, Map<String,Pair<String,String>> natureEnseignements)
Migrate the totalDurationOf to course parts.protected void
removeExternalizableData(JCRRepositoryData repositoryData, String dataName)
Remove a data and its externalizable datavoid
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_resolver
protected AmetysObjectResolver _resolver
The Ametys object resolver
-
_odfRefTableHelper
protected OdfReferenceTableHelper _odfRefTableHelper
The ODF Reference table helper
-
_workflowHelper
protected ContentWorkflowHelper _workflowHelper
The content workflow helper
-
_workflowProvider
protected WorkflowProvider _workflowProvider
The workflow
-
-
Constructor Detail
-
MigrateCoursePartComponent
public MigrateCoursePartComponent()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
migrateCourseParts
public void migrateCourseParts() throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException, RepositoryException
Migrate the totalDurationOf to course parts.- Throws:
AmetysRepositoryException
- if an error occurscom.opensymphony.workflow.WorkflowException
- if an error occursRepositoryException
- if an error occurs
-
migrateCourseParts
public void migrateCourseParts(Map<String,Pair<String,Long>> natureEnseignementCategories, Map<String,Pair<String,String>> natureEnseignements) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException, RepositoryException
Migrate the totalDurationOf to course parts.- Parameters:
natureEnseignementCategories
- the map of nature enseignement categoriesnatureEnseignements
- the map of nature enseignement- Throws:
AmetysRepositoryException
- if an error occurscom.opensymphony.workflow.WorkflowException
- if an error occursRepositoryException
- if an error occurs
-
_updateCoursePart
protected void _updateCoursePart(Course course, Map<String,OdfReferenceTableEntry> natureByCode, Map<String,CoursePart> createdCourseParts)
Update theCoursePart
and the course parts list of theCourse
with the values of the current version.- Parameters:
course
- TheCourse
to migratenatureByCode
- The course part naturescreatedCourseParts
- TheMap
of the createdCoursePart
previously
-
_migrateCoursePart
protected Map<String,CoursePart> _migrateCoursePart(Course course, Map<String,OdfReferenceTableEntry> natureByCode, boolean isLive)
Create a course part linked to the course.- Parameters:
course
- TheCourse
to migratenatureByCode
- The course part naturesisLive
- Set the Live label iftrue
- Returns:
- The created course parts
-
removeExternalizableData
protected void removeExternalizableData(JCRRepositoryData repositoryData, String dataName)
Remove a data and its externalizable data- Parameters:
repositoryData
- the repository data containing the datadataName
- name of the data to remove
-
_createCoursePart
protected CoursePart _createCoursePart(Course course, OdfReferenceTableEntry nature, Double totalDurationOf, boolean isLive)
Create a course part linked to the course.- Parameters:
course
- TheCourse
holdernature
- The nature of the course parttotalDurationOf
- The number of hoursisLive
- Set the Live label iftrue
- Returns:
- The
CoursePart
id
-
_setAdditionalValues
protected void _setAdditionalValues(CoursePart coursePart, Course course)
Set additional values to theCoursePart
from theCourse
.- Parameters:
coursePart
- The course part to modifycourse
- The original course
-
_createNaturesEnseignement
protected Map<String,OdfReferenceTableEntry> _createNaturesEnseignement(Map<String,Pair<String,Long>> natureEnseignementCategories, Map<String,Pair<String,String>> natureEnseignements) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
Create entries into the reference table EnseignementNature if they don't exist.- Parameters:
natureEnseignementCategories
- the map of nature enseignement categoriesnatureEnseignements
- the map of nature enseignement- Returns:
- The list of natures with their code and associated ID.
- Throws:
AmetysRepositoryException
- if an error occurscom.opensymphony.workflow.WorkflowException
- if an error occurs
-
_createNatureEnseignementCategories
protected Map<String,String> _createNatureEnseignementCategories(Map<String,Pair<String,Long>> natureEnseignementCategories) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
Create entries into the reference table EnseignementNature if they don't exist.- Parameters:
natureEnseignementCategories
- the map of nature enseignement categories- Returns:
- The list of natures with their code and associated ID.
- Throws:
AmetysRepositoryException
- if an error occurscom.opensymphony.workflow.WorkflowException
- if an error occurs
-
_getNaturesEnseignementList
protected Map<String,Pair<String,String>> _getNaturesEnseignementList(Map<String,Pair<String,String>> natureEnseignements)
List of the course parts natures.
-
_getNaturesEnseignementCategoryList
protected Map<String,Pair<String,Long>> _getNaturesEnseignementCategoryList(Map<String,Pair<String,Long>> natureEnseignementCategories)
List of the course parts nature categories.- Parameters:
natureEnseignementCategories
- the map of nature enseignement categories- Returns:
- A
Map
with the code as a key, and the title as a value
-
_doAction
protected Map<String,Object> _doAction(WorkflowAwareContent content, Integer actionId) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
ContentWorkflowHelper
cannot be used in these conditions.- Parameters:
content
- The contentactionId
- Action to perform- Returns:
- The result map
- Throws:
com.opensymphony.workflow.WorkflowException
- if an error occursAmetysRepositoryException
- if an error occurs
-
_getOrCreateNatureEnseignement
protected OdfReferenceTableEntry _getOrCreateNatureEnseignement(String title, String code, Long order) throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException
Get or create the nature enseignement if it doesn't exist. The code is tested.- Parameters:
title
- The title of the naturecode
- The code of the natureorder
- The order to set.- Returns:
- The corresponding entry
- Throws:
AmetysRepositoryException
- if an error occurscom.opensymphony.workflow.WorkflowException
- if an error occurs
-
-