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
FieldsModifier and TypeFieldDescriptionprotected OdfReferenceTableHelperThe ODF Reference table helperprotected AmetysObjectResolverThe Ametys object resolverprotected ContentWorkflowHelperThe content workflow helperprotected WorkflowProviderThe workflowstatic final StringThe component role. -
Constructor Summary
Constructors -
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) ContentWorkflowHelpercannot 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 theCoursePartfrom theCourse.protected void_updateCoursePart(Course course, Map<String, OdfReferenceTableEntry> natureByCode, Map<String, CoursePart> createdCourseParts) Update theCoursePartand the course parts list of theCoursewith the values of the current version.voidMigrate the totalDurationOf to course parts.voidmigrateCourseParts(Map<String, Pair<String, Long>> natureEnseignementCategories, Map<String, Pair<String, String>> natureEnseignements) Migrate the totalDurationOf to course parts.protected voidremoveExternalizableData(JCRRepositoryData repositoryData, String dataName) Remove a data and its externalizable datavoidservice(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:
servicein 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 theCoursePartand the course parts list of theCoursewith the values of the current version.- Parameters:
course- TheCourseto migratenatureByCode- The course part naturescreatedCourseParts- TheMapof the createdCoursePartpreviously
-
_migrateCoursePart
protected Map<String,CoursePart> _migrateCoursePart(Course course, Map<String, OdfReferenceTableEntry> natureByCode, boolean isLive) Create a course part linked to the course.- Parameters:
course- TheCourseto 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- TheCourseholdernature- The nature of the course parttotalDurationOf- The number of hoursisLive- Set the Live label iftrue- Returns:
- The
CoursePartid
-
_setAdditionalValues
Set additional values to theCoursePartfrom 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
Mapwith 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 ContentWorkflowHelpercannot 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
-