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
Modifier and TypeFieldDescriptionprotected OdfReferenceTableHelper
The ODF Reference table helperprotected AmetysObjectResolver
The Ametys object resolverprotected ContentWorkflowHelper
The content workflow helperprotected WorkflowProvider
The workflowstatic final String
The component role. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected CoursePart
_createCoursePart
(Course course, OdfReferenceTableEntry nature, Double totalDurationOf, boolean isLive) Create a course part linked to the course.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._doAction
(WorkflowAwareContent content, Integer actionId) ContentWorkflowHelper
cannot be used in these conditions.List of the course parts nature categories.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
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 Details
-
ROLE
The component role. -
_resolver
The Ametys object resolver -
_odfRefTableHelper
The ODF Reference table helper -
_workflowHelper
The content workflow helper -
_workflowProvider
The workflow
-
-
Constructor Details
-
MigrateCoursePartComponent
public MigrateCoursePartComponent()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
migrateCourseParts
public void migrateCourseParts() throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException, javax.jcr.RepositoryExceptionMigrate the totalDurationOf to course parts.- Throws:
AmetysRepositoryException
- if an error occurscom.opensymphony.workflow.WorkflowException
- if an error occursjavax.jcr.RepositoryException
- if an error occurs
-
migrateCourseParts
public void migrateCourseParts(Map<String, Pair<String, throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowException, javax.jcr.RepositoryExceptionLong>> natureEnseignementCategories, Map<String, Pair<String, String>> natureEnseignements) 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 occursjavax.jcr.RepositoryException
- 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
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
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, throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionLong>> natureEnseignementCategories, Map<String, Pair<String, String>> natureEnseignements) 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, throws AmetysRepositoryException, com.opensymphony.workflow.WorkflowExceptionLong>> natureEnseignementCategories) 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, _getNaturesEnseignementListString>> (Map<String, Pair<String, String>> natureEnseignements) List of the course parts natures. -
_getNaturesEnseignementCategoryList
protected Map<String,Pair<String, _getNaturesEnseignementCategoryListLong>> (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
-