Class CoAccreditedRemoteImportCDMFrComponent
- java.lang.Object
-
- org.ametys.plugins.odfsync.cdmfr.components.AbstractImportCDMFrComponent
-
- org.ametys.plugins.odfsync.cdmfr.components.impl.RemoteImportCDMFrComponent
-
- org.ametys.plugins.odfsync.cdmfr.components.impl.CoAccreditedRemoteImportCDMFrComponent
-
- All Implemented Interfaces:
ImportCDMFrComponent
,Initializable
,Component
,Configurable
,Contextualizable
,Serviceable
public class CoAccreditedRemoteImportCDMFrComponent extends RemoteImportCDMFrComponent
Component to import a CDM-fr input stream from a remote server with co-accredited mode.
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<String>
_attributePathsToMerge
The list of attributes to mergeprotected DeleteODFContentHelper
_deleteODFContent
The delete ODF content helperprotected Set<String>
_mentionAttributePaths
The list of attributes to copy for mention programprotected static String
SHARED_PROGRAMS_NODE_NAME
The name of the JCR node holding the shared metadata-
Fields inherited from class org.ametys.plugins.odfsync.cdmfr.components.impl.RemoteImportCDMFrComponent
_forcedCatalog, _validateAfterImport, ROLE
-
Fields inherited from class org.ametys.plugins.odfsync.cdmfr.components.AbstractImportCDMFrComponent
_catalogsManager, _cdmFrSyncExtensionPoint, _cocoonContext, _contentPrefix, _contentTypeEP, _contentWorkflowHelper, _currentUserProvider, _domParser, _importedContents, _nbError, _observationManager, _odfHelper, _odfLang, _odfRefTableHelper, _resolver, _rootOUProvider, _sccHelper, _shareableCourseHelper, _syncFieldsByContentType, _SYNCHRONIZE_WORKFLOW_ACTION_ID, _synchronizedContents, _TAG_CONTAINER, _TAG_COURSELIST, _TAG_COURSEPART, _TAG_PROGRAM, _TAG_SUBPROGRAM, _valuesExtractorFactory, _xPathProcessor
-
-
Constructor Summary
Constructors Constructor Description CoAccreditedRemoteImportCDMFrComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_configureCoAccreditedParams(Configuration configuration)
Configure the co-accredited paramsprotected Program
_createMention(Element contentElement, String mentionId, String syncCode, ImportCDMFrContext context)
Create the mentionprotected View
_createMentionView()
Create the view to use to extract values for mention creationprotected View
_createMergeView(Set<String> attributePathsToMerge, ImportCDMFrContext context)
Creates a view with attributes to mergeprotected Map<String,Object>
_extractValuesToMerge(Element contentElement, View mergeView, String sharedSubProgramCode, ImportCDMFrContext context)
Extract the values to merge with the main programprotected Map<String,Object>
_getAdditionalValuesToSynchronize(ModifiableContent content, String syncCode, ImportCDMFrContext context)
Retrieves additional values to synchronize for the contentprotected Program
_getMention(String mentionId, String degreeId, ImportCDMFrContext context)
Get the mention programprotected Map<String,Object>
_getMergedAttributes(SubProgram mainSubProgram, View mergeView)
Retrieves the merged attributes of all sub programs shared with the given main sub programprotected Set<String>
_getNotSynchronizedRelatedContentIds(ModifiableContent content, String syncCode, ImportCDMFrContext context)
Retrieves the ids of the contents related to the given content but that are not part of the synchronizationprotected Program
_getOrCreateMention(Element contentElement, String mentionCode, String syncCode, ImportCDMFrContext context)
Get of create the mention programprotected SubProgram
_getSameSubProgram(Program mentionProgram, Element contentElement, ImportCDMFrContext context)
Search for a sub program corresponding to the one represented by the content elementprotected ModifiableModelAwareDataHolder
_getSharedSubProgramDataHolder(ModifiableRepositoryData rootRepositoryData, String subProgramCode)
Get the data holder for the shared attributes for subprogram of given codeprotected ModifiableRepositoryData
_getSharedSubProgramRootRepositoryData(SubProgram mainSubProgram)
Get the shared program repository data holding the shared subprogram dataprotected ModifiableContent
_importOrSynchronizeSharedSubProgram(Program mentionProgram, Element contentElement, String title, String syncCode, ImportCDMFrContext context)
Import or synchronized shared subProgramsprotected void
_synchronizeAttributesToMergeOnSharedSubProgramNode(SubProgram mainSubProgram, String sharedSubProgramCode, View mergeView, Map<String,Object> valuesToMerge, ImportCDMFrContext context)
Synchronize the attributes to merge on the shared sub program dataprotected void
_updateMentionAttributes(Program mention, SubProgram subProgram, ImportCDMFrContext context)
Update mention attributes depending on the sub programprotected void
additionalParameters(Map<String,Object> parameters)
Additional parameters for specific treatments.void
configure(Configuration configuration)
ModifiableContent
importOrSynchronizeContent(Element contentElement, ContentWorkflowDescription wfDescription, String title, String syncCode, ImportCDMFrContext context)
Import or synchronize the content.void
initialize()
protected boolean
isValidAttributePath(ContentType contentType, String attributePath, ImportCDMFrContext context)
Determines if the attribute path is a valid path from the given content type and eligible to merge An attribute is considered as valid if it is part of the content type it is multiple (to be able to merge all data from main and shared subprograms)void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.plugins.odfsync.cdmfr.components.impl.RemoteImportCDMFrComponent
getCatalogName, ignoreRights, removalSync, transformDocument, validateAfterImport
-
Methods inherited from class org.ametys.plugins.odfsync.cdmfr.components.AbstractImportCDMFrComponent
_createContent, _editContent, _getExpressionsList, _getInputsForContentCreation, _getOrCreateContent, _initializeShareableCoursesFields, _linkTranslationsIfExist, _setOrgUnitParent, _synchronizeContent, additionalOperations, contextualize, getContent, getIdField, getIdFromCDMThenCode, getLocalAndExternalFields, handleInputStream, validateContent
-
-
-
-
Field Detail
-
SHARED_PROGRAMS_NODE_NAME
protected static final String SHARED_PROGRAMS_NODE_NAME
The name of the JCR node holding the shared metadata- See Also:
- Constant Field Values
-
_deleteODFContent
protected DeleteODFContentHelper _deleteODFContent
The delete ODF content helper
-
_mentionAttributePaths
protected Set<String> _mentionAttributePaths
The list of attributes to copy for mention program
-
_attributePathsToMerge
protected Set<String> _attributePathsToMerge
The list of attributes to merge
-
-
Constructor Detail
-
CoAccreditedRemoteImportCDMFrComponent
public CoAccreditedRemoteImportCDMFrComponent()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractImportCDMFrComponent
- Throws:
ServiceException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classAbstractImportCDMFrComponent
- Throws:
ConfigurationException
-
_configureCoAccreditedParams
protected void _configureCoAccreditedParams(Configuration configuration) throws ConfigurationException
Configure the co-accredited params- Parameters:
configuration
- the configuration- Throws:
ConfigurationException
- if an error occurred
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAbstractImportCDMFrComponent
- Throws:
Exception
-
additionalParameters
protected void additionalParameters(Map<String,Object> parameters)
Description copied from class:AbstractImportCDMFrComponent
Additional parameters for specific treatments.- Overrides:
additionalParameters
in classRemoteImportCDMFrComponent
- Parameters:
parameters
- The parameters map to get
-
importOrSynchronizeContent
public ModifiableContent importOrSynchronizeContent(Element contentElement, ContentWorkflowDescription wfDescription, String title, String syncCode, ImportCDMFrContext context)
Description copied from interface:ImportCDMFrComponent
Import or synchronize the content.- Specified by:
importOrSynchronizeContent
in interfaceImportCDMFrComponent
- Overrides:
importOrSynchronizeContent
in classAbstractImportCDMFrComponent
- Parameters:
contentElement
- Element of the contentwfDescription
- The workflow descriptiontitle
- The titlesyncCode
- The synchronization codecontext
- the import context- Returns:
- The imported or synchronized content
-
_getOrCreateMention
protected Program _getOrCreateMention(Element contentElement, String mentionCode, String syncCode, ImportCDMFrContext context)
Get of create the mention program- Parameters:
contentElement
- the content elementmentionCode
- the mention codesyncCode
- the content synchronization codecontext
- the import context- Returns:
- the mention program
-
_getMention
protected Program _getMention(String mentionId, String degreeId, ImportCDMFrContext context)
Get the mention program- Parameters:
mentionId
- the mention content iddegreeId
- the degree content idcontext
- the import context- Returns:
- the mention program or
null
if it doesn't exist
-
_createMention
protected Program _createMention(Element contentElement, String mentionId, String syncCode, ImportCDMFrContext context)
Create the mention- Parameters:
contentElement
- the content elementmentionId
- the mention idsyncCode
- the content synchronization codecontext
- the import context- Returns:
- the created mention
-
_createMentionView
protected View _createMentionView()
Create the view to use to extract values for mention creation- Returns:
- the created view
-
_importOrSynchronizeSharedSubProgram
protected ModifiableContent _importOrSynchronizeSharedSubProgram(Program mentionProgram, Element contentElement, String title, String syncCode, ImportCDMFrContext context)
Import or synchronized shared subPrograms- Parameters:
mentionProgram
- the mention programcontentElement
- the content elementtitle
- the title of the subprogramsyncCode
- the synchronisation codecontext
- the import context- Returns:
- the imported of synchronized content
-
_getSameSubProgram
protected SubProgram _getSameSubProgram(Program mentionProgram, Element contentElement, ImportCDMFrContext context)
Search for a sub program corresponding to the one represented by the content element- Parameters:
mentionProgram
- the mention programcontentElement
- the content elementcontext
- the import context- Returns:
- the corresponding subProgram, or
null
if none is found
-
_getAdditionalValuesToSynchronize
protected Map<String,Object> _getAdditionalValuesToSynchronize(ModifiableContent content, String syncCode, ImportCDMFrContext context)
Description copied from class:AbstractImportCDMFrComponent
Retrieves additional values to synchronize for the content- Overrides:
_getAdditionalValuesToSynchronize
in classAbstractImportCDMFrComponent
- Parameters:
content
- the contentsyncCode
- the content synchronization codecontext
- the import context- Returns:
- the additional values
-
_getNotSynchronizedRelatedContentIds
protected Set<String> _getNotSynchronizedRelatedContentIds(ModifiableContent content, String syncCode, ImportCDMFrContext context)
Description copied from class:AbstractImportCDMFrComponent
Retrieves the ids of the contents related to the given content but that are not part of the synchronization- Overrides:
_getNotSynchronizedRelatedContentIds
in classAbstractImportCDMFrComponent
- Parameters:
content
- the contentsyncCode
- the content synchronization codecontext
- the import context- Returns:
- the not synchronized content ids
-
_createMergeView
protected View _createMergeView(Set<String> attributePathsToMerge, ImportCDMFrContext context)
Creates a view with attributes to merge- Parameters:
attributePathsToMerge
- the attributes to put in the viewcontext
- the import context- Returns:
- the created view
-
isValidAttributePath
protected boolean isValidAttributePath(ContentType contentType, String attributePath, ImportCDMFrContext context)
Determines if the attribute path is a valid path from the given content type and eligible to merge An attribute is considered as valid if- it is part of the content type
- it is multiple (to be able to merge all data from main and shared subprograms)
- Parameters:
contentType
- The content typeattributePath
- The attribute pathcontext
- the import context- Returns:
true
if the attribute can be merged,false
otherwise
-
_extractValuesToMerge
protected Map<String,Object> _extractValuesToMerge(Element contentElement, View mergeView, String sharedSubProgramCode, ImportCDMFrContext context)
Extract the values to merge with the main program- Parameters:
contentElement
- the content elementmergeView
- the view containing the attributes to mergesharedSubProgramCode
- the shared sub program codecontext
- the import context- Returns:
- the extracted values
-
_synchronizeAttributesToMergeOnSharedSubProgramNode
protected void _synchronizeAttributesToMergeOnSharedSubProgramNode(SubProgram mainSubProgram, String sharedSubProgramCode, View mergeView, Map<String,Object> valuesToMerge, ImportCDMFrContext context)
Synchronize the attributes to merge on the shared sub program data- Parameters:
mainSubProgram
- the main sub programsharedSubProgramCode
- the code of the shared sub programmergeView
- the view containing the attributes to mergevaluesToMerge
- the values to mergecontext
- the import context
-
_getMergedAttributes
protected Map<String,Object> _getMergedAttributes(SubProgram mainSubProgram, View mergeView)
Retrieves the merged attributes of all sub programs shared with the given main sub program- Parameters:
mainSubProgram
- the main sub programmergeView
- the view containing the attributes to merge- Returns:
- the merged values
-
_getSharedSubProgramRootRepositoryData
protected ModifiableRepositoryData _getSharedSubProgramRootRepositoryData(SubProgram mainSubProgram)
Get the shared program repository data holding the shared subprogram data- Parameters:
mainSubProgram
- the main program- Returns:
- root repository data
-
_getSharedSubProgramDataHolder
protected ModifiableModelAwareDataHolder _getSharedSubProgramDataHolder(ModifiableRepositoryData rootRepositoryData, String subProgramCode)
Get the data holder for the shared attributes for subprogram of given code- Parameters:
rootRepositoryData
- the repository data containing the values of all shared sub programssubProgramCode
- the sub program code- Returns:
- the shared data holder
-
_updateMentionAttributes
protected void _updateMentionAttributes(Program mention, SubProgram subProgram, ImportCDMFrContext context)
Update mention attributes depending on the sub program- Parameters:
mention
- the mentionsubProgram
- the subProgramcontext
- the import context
-
-