Class AbstractImportCDMFrComponent
- java.lang.Object
-
- org.ametys.plugins.odfsync.cdmfr.components.AbstractImportCDMFrComponent
-
- All Implemented Interfaces:
ImportCDMFrComponent,Initializable,Component,Configurable,Contextualizable,Serviceable
- Direct Known Subclasses:
RemoteImportCDMFrComponent,SCCImportCDMFrComponent
public abstract class AbstractImportCDMFrComponent extends Object implements ImportCDMFrComponent, Serviceable, Initializable, Contextualizable, Configurable, Component
Abstract class of a component to import a CDM-fr input stream.
-
-
Field Summary
Fields Modifier and Type Field Description protected CatalogsManager_catalogsManagerThe catalog managerprotected CDMFrSyncExtensionPoint_cdmFrSyncExtensionPointExtension point to transform CDM-frprotected Context_cocoonContextThe Cocoon contextprotected String_contentPrefixThe prefix of the contentsprotected ContentTypeExtensionPoint_contentTypeEPThe content type extension pointprotected ContentWorkflowHelper_contentWorkflowHelperThe content workflow helperprotected CurrentUserProvider_currentUserProviderThe current user providerprotected DOMParser_domParserThe DOM parserprotected Map<String,Integer>_importedContentsList of imported contentsprotected int_nbErrorNumber of errors encounteredprotected ObservationManager_observationManagerThe observation managerprotected ODFHelper_odfHelperThe ODF Helperprotected String_odfLangDefault language configured for ODFprotected OdfReferenceTableHelper_odfRefTableHelperThe ODF TableRef Helperprotected AmetysObjectResolver_resolverThe ametys object resolverprotected RootOrgUnitProvider_rootOUProviderThe root orgunit providerprotected SynchronizableContentsCollectionHelper_sccHelperThe SCC helperprotected ShareableCourseHelper_shareableCourseHelperThe shareable course helperprotected Map<String,Set<String>>_syncFieldsByContentTypeSynchronized fields by content typeprotected static int_SYNCHRONIZE_WORKFLOW_ACTION_IDThe synchronize workflow action idprotected Set<String>_synchronizedContentsList of synchronized contentsprotected static String_TAG_CONTAINERTag to identify a containerprotected static String_TAG_COURSELISTTag to identify a courseListprotected static String_TAG_COURSEPARTTag to identify a coursePartprotected static String_TAG_PROGRAMTag to identify a programprotected static String_TAG_SUBPROGRAMTag to identify a subprogramprotected ImportCDMFrValuesExtractorFactory_valuesExtractorFactorytheImportCDMFrValuesExtractorfactoryprotected XPathProcessor_xPathProcessorThe XPath processor-
Fields inherited from interface org.ametys.plugins.odfsync.cdmfr.components.ImportCDMFrComponent
ROLE
-
-
Constructor Summary
Constructors Constructor Description AbstractImportCDMFrComponent()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ModifiableContent_createContent(ContentWorkflowDescription wfDescription, String title, ImportCDMFrContext context)Create the content from the workflow description and the import context.protected void_editContent(WorkflowAwareContent content, Optional<View> view, Map<String,Object> values, boolean create, Set<String> notSynchronizedContentIds, ImportCDMFrContext context)Synchronize the content with given values.protected Map<String,Object>_getAdditionalValuesToSynchronize(ModifiableContent content, String syncCode, ImportCDMFrContext context)Retrieves additional values to synchronize for the contentprotected List<Expression>_getExpressionsList(String contentTypeId, String syncCode, ImportCDMFrContext context)Construct the query to retrieve the content.protected Map<String,Object>_getInputsForContentCreation(ContentWorkflowDescription wfDescription, ImportCDMFrContext context)Retrieves the inputs to give for content creationprotected 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 ModifiableContent_getOrCreateContent(ContentWorkflowDescription wfDescription, String title, String syncCode, ImportCDMFrContext context)Get or create the content from the workflow description, the synchronization code and the import context.protected List<ModifiableContent>_initializeShareableCoursesFields(ProgramItem programItem)Initialize shareable fields for the courses under the givenProgramItemprotected void_linkTranslationsIfExist(ModifiableContent importedContent, String contentType, ImportCDMFrContext context)Search for translated contentsprotected void_setOrgUnitParent(WorkflowAwareContent orgUnit, ImportCDMFrContext context)Set the orgUnit parent to rootOrgUnit.protected void_synchronizeContent(Element contentElement, ModifiableContent content, String contentTypeId, String syncCode, ImportCDMFrContext context)Synchronize contentContentSynchronizationResultadditionalOperations(ModifiableContent content, Map<String,Object> additionalParameters, org.slf4j.Logger logger)Add specific fields to the content during import or synchronization.protected abstract voidadditionalParameters(Map<String,Object> parameters)Additional parameters for specific treatments.voidconfigure(Configuration configuration)voidcontextualize(Context context)StringgetCatalogName(Element contentElement)Get the name of catalog to use for importModifiableContentgetContent(String contentType, String syncCode, ImportCDMFrContext context)Get the content from the synchronization code, the content type and the context.StringgetIdField()Return the attribute identifier for CDM-fr synchronization.StringgetIdFromCDMThenCode(String tableRefId, String cdmCode)Get the content ID from the CDM code, if there is no match with the CDM code, then we search with the code.Set<String>getLocalAndExternalFields(Map<String,Object> additionalParameters)Get the path of tri-state fields (with local and external values)Map<String,Object>handleInputStream(InputStream input, Map<String,Object> parameters, SynchronizableContentsCollection scc, org.slf4j.Logger logger)Handle the CDM-fr input stream to import all the programs and its dependencies containing into it.protected booleanignoreRights()If true, bypass the rights check during the import processModifiableContentimportOrSynchronizeContent(Element contentElement, ContentWorkflowDescription wfDescription, String title, String syncCode, ImportCDMFrContext context)Import or synchronize the content.voidinitialize()protected abstract booleanremovalSync()When returns true, a content created by a previous synchro will be removed if it does not exist anymore during the current synchro.voidservice(ServiceManager manager)protected DocumenttransformDocument(Document document, Map<String,Object> parameters, org.slf4j.Logger logger)Transform the document depending of it structure.protected abstract booleanvalidateAfterImport()True to validate the contents after importprotected voidvalidateContent(WorkflowAwareContent content, int validationActionId, org.slf4j.Logger logger)Validates a content after import
-
-
-
Field Detail
-
_TAG_PROGRAM
protected static final String _TAG_PROGRAM
Tag to identify a program- See Also:
- Constant Field Values
-
_TAG_SUBPROGRAM
protected static final String _TAG_SUBPROGRAM
Tag to identify a subprogram- See Also:
- Constant Field Values
-
_TAG_CONTAINER
protected static final String _TAG_CONTAINER
Tag to identify a container- See Also:
- Constant Field Values
-
_TAG_COURSELIST
protected static final String _TAG_COURSELIST
Tag to identify a courseList- See Also:
- Constant Field Values
-
_TAG_COURSEPART
protected static final String _TAG_COURSEPART
Tag to identify a coursePart- See Also:
- Constant Field Values
-
_SYNCHRONIZE_WORKFLOW_ACTION_ID
protected static final int _SYNCHRONIZE_WORKFLOW_ACTION_ID
The synchronize workflow action id- See Also:
- Constant Field Values
-
_cocoonContext
protected Context _cocoonContext
The Cocoon context
-
_domParser
protected DOMParser _domParser
The DOM parser
-
_xPathProcessor
protected XPathProcessor _xPathProcessor
The XPath processor
-
_cdmFrSyncExtensionPoint
protected CDMFrSyncExtensionPoint _cdmFrSyncExtensionPoint
Extension point to transform CDM-fr
-
_catalogsManager
protected CatalogsManager _catalogsManager
The catalog manager
-
_resolver
protected AmetysObjectResolver _resolver
The ametys object resolver
-
_odfRefTableHelper
protected OdfReferenceTableHelper _odfRefTableHelper
The ODF TableRef Helper
-
_contentTypeEP
protected ContentTypeExtensionPoint _contentTypeEP
The content type extension point
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
_rootOUProvider
protected RootOrgUnitProvider _rootOUProvider
The root orgunit provider
-
_odfHelper
protected ODFHelper _odfHelper
The ODF Helper
-
_sccHelper
protected SynchronizableContentsCollectionHelper _sccHelper
The SCC helper
-
_contentWorkflowHelper
protected ContentWorkflowHelper _contentWorkflowHelper
The content workflow helper
-
_shareableCourseHelper
protected ShareableCourseHelper _shareableCourseHelper
The shareable course helper
-
_valuesExtractorFactory
protected ImportCDMFrValuesExtractorFactory _valuesExtractorFactory
theImportCDMFrValuesExtractorfactory
-
_importedContents
protected Map<String,Integer> _importedContents
List of imported contents
-
_synchronizedContents
protected Set<String> _synchronizedContents
List of synchronized contents
-
_nbError
protected int _nbError
Number of errors encountered
-
_contentPrefix
protected String _contentPrefix
The prefix of the contents
-
_syncFieldsByContentType
protected Map<String,Set<String>> _syncFieldsByContentType
Synchronized fields by content type
-
-
Constructor Detail
-
AbstractImportCDMFrComponent
public AbstractImportCDMFrComponent()
-
-
Method Detail
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
configure
public void configure(Configuration configuration) throws ConfigurationException
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
getIdField
public String getIdField()
Description copied from interface:ImportCDMFrComponentReturn the attribute identifier for CDM-fr synchronization.- Specified by:
getIdFieldin interfaceImportCDMFrComponent- Returns:
- The attribute name (cdmfrSyncCode)
-
handleInputStream
public Map<String,Object> handleInputStream(InputStream input, Map<String,Object> parameters, SynchronizableContentsCollection scc, org.slf4j.Logger logger) throws ProcessingException
Description copied from interface:ImportCDMFrComponentHandle the CDM-fr input stream to import all the programs and its dependencies containing into it.- Specified by:
handleInputStreamin interfaceImportCDMFrComponent- Parameters:
input- The CDM-fr input streamparameters- The parameters useful for the operationscc- TheSynchronizableContentsCollectioncalling this componentlogger- The logger- Returns:
- The list of imported/synchronized programs
- Throws:
ProcessingException- If an error occurs
-
validateAfterImport
protected abstract boolean validateAfterImport()
True to validate the contents after import- Returns:
- True to validate the contents after import
-
removalSync
protected abstract boolean removalSync()
When returns true, a content created by a previous synchro will be removed if it does not exist anymore during the current synchro.- Returns:
- true if a content created by a previous synchro has to be removed if it does not exist anymore during the current synchro.
-
additionalParameters
protected abstract void additionalParameters(Map<String,Object> parameters)
Additional parameters for specific treatments.- Parameters:
parameters- The parameters map to get
-
transformDocument
protected Document transformDocument(Document document, Map<String,Object> parameters, org.slf4j.Logger logger) throws IOException, SAXException, ProcessingException
Transform the document depending of it structure.- Parameters:
document- Document to transform.parameters- Optional parameters for transformationlogger- The logger- Returns:
- The transformed document.
- Throws:
IOException- if an error occurs.SAXException- if an error occurs.ProcessingException- if an error occurs.
-
getCatalogName
public String getCatalogName(Element contentElement)
Description copied from interface:ImportCDMFrComponentGet the name of catalog to use for import- Specified by:
getCatalogNamein interfaceImportCDMFrComponent- Parameters:
contentElement- Element of the content- Returns:
- The catalog to used
-
importOrSynchronizeContent
public ModifiableContent importOrSynchronizeContent(Element contentElement, ContentWorkflowDescription wfDescription, String title, String syncCode, ImportCDMFrContext context)
Description copied from interface:ImportCDMFrComponentImport or synchronize the content.- Specified by:
importOrSynchronizeContentin interfaceImportCDMFrComponent- Parameters:
contentElement- Element of the contentwfDescription- The workflow descriptiontitle- The titlesyncCode- The synchronization codecontext- the import context- Returns:
- The imported or synchronized content
-
_getOrCreateContent
protected ModifiableContent _getOrCreateContent(ContentWorkflowDescription wfDescription, String title, String syncCode, ImportCDMFrContext context)
Get or create the content from the workflow description, the synchronization code and the import context.- Parameters:
wfDescription- The workflow descriptiontitle- The titlesyncCode- The synchronization codecontext- The import context- Returns:
- the retrieved or created content
-
getContent
public ModifiableContent getContent(String contentType, String syncCode, ImportCDMFrContext context)
Description copied from interface:ImportCDMFrComponentGet the content from the synchronization code, the content type and the context.- Specified by:
getContentin interfaceImportCDMFrComponent- Parameters:
contentType- The content typesyncCode- The synchronization codecontext- the import context- Returns:
- the retrieved content
-
_createContent
protected ModifiableContent _createContent(ContentWorkflowDescription wfDescription, String title, ImportCDMFrContext context) throws com.opensymphony.workflow.WorkflowException
Create the content from the workflow description and the import context.- Parameters:
wfDescription- The workflow descriptiontitle- The titlecontext- The import context- Returns:
- the created content
- Throws:
com.opensymphony.workflow.WorkflowException- if an error occurs while creating the content
-
_getInputsForContentCreation
protected Map<String,Object> _getInputsForContentCreation(ContentWorkflowDescription wfDescription, ImportCDMFrContext context)
Retrieves the inputs to give for content creation- Parameters:
wfDescription- The workflow descriptioncontext- The import context- Returns:
- the inputs to give for content creation
-
_synchronizeContent
protected void _synchronizeContent(Element contentElement, ModifiableContent content, String contentTypeId, String syncCode, ImportCDMFrContext context) throws Exception
Synchronize content- Parameters:
contentElement- the DOM content elementcontent- The content to synchronizecontentTypeId- The content type IDsyncCode- The synchronization codecontext- the import context- Throws:
Exception- if an error occurs while synchronizing the content values
-
_getAdditionalValuesToSynchronize
protected Map<String,Object> _getAdditionalValuesToSynchronize(ModifiableContent content, String syncCode, ImportCDMFrContext context)
Retrieves additional values to synchronize for the content- 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)
Retrieves the ids of the contents related to the given content but that are not part of the synchronization- Parameters:
content- the contentsyncCode- the content synchronization codecontext- the import context- Returns:
- the not synchronized content ids
-
_editContent
protected void _editContent(WorkflowAwareContent content, Optional<View> view, Map<String,Object> values, boolean create, Set<String> notSynchronizedContentIds, ImportCDMFrContext context) throws com.opensymphony.workflow.WorkflowException
Synchronize the content with given values.- Parameters:
content- The content to synchronizeview- the view containing the item to editvalues- the valuescreate-trueif content is creating, false if it is updatednotSynchronizedContentIds- the ids of the contents related to the given content but that are not part of the synchronizationcontext- the import context- Throws:
com.opensymphony.workflow.WorkflowException- if an error occurs
-
additionalOperations
public ContentSynchronizationResult additionalOperations(ModifiableContent content, Map<String,Object> additionalParameters, org.slf4j.Logger logger)
Description copied from interface:ImportCDMFrComponentAdd specific fields to the content during import or synchronization.- Specified by:
additionalOperationsin interfaceImportCDMFrComponent- Parameters:
content- Content to updateadditionalParameters- Additional parameterslogger- The logger- Returns:
- The synchronization result of the additional operations
-
_initializeShareableCoursesFields
protected List<ModifiableContent> _initializeShareableCoursesFields(ProgramItem programItem)
Initialize shareable fields for the courses under the givenProgramItem- Parameters:
programItem- the program item- Returns:
- the list of contents that have been modified during the initialization
-
_linkTranslationsIfExist
protected void _linkTranslationsIfExist(ModifiableContent importedContent, String contentType, ImportCDMFrContext context)
Search for translated contents- Parameters:
importedContent- The imported contentcontentType- The content typecontext- the import context
-
_setOrgUnitParent
protected void _setOrgUnitParent(WorkflowAwareContent orgUnit, ImportCDMFrContext context) throws Exception
Set the orgUnit parent to rootOrgUnit.- Parameters:
orgUnit- The orgunit to linkcontext- the import context- Throws:
Exception- if an error occurs while synchronizing the content values
-
validateContent
protected void validateContent(WorkflowAwareContent content, int validationActionId, org.slf4j.Logger logger)
Validates a content after import- Parameters:
content- The content to validatevalidationActionId- Validation action ID to use for this contentlogger- The logger
-
getIdFromCDMThenCode
public String getIdFromCDMThenCode(String tableRefId, String cdmCode)
Description copied from interface:ImportCDMFrComponentGet the content ID from the CDM code, if there is no match with the CDM code, then we search with the code. If nothing is found we return null.- Specified by:
getIdFromCDMThenCodein interfaceImportCDMFrComponent- Parameters:
tableRefId- The reference table IDcdmCode- The CDM code- Returns:
- A content ID or
null
-
ignoreRights
protected boolean ignoreRights()
If true, bypass the rights check during the import process- Returns:
- True if the rights check are bypassed during the import process
-
_getExpressionsList
protected List<Expression> _getExpressionsList(String contentTypeId, String syncCode, ImportCDMFrContext context)
Construct the query to retrieve the content.- Parameters:
contentTypeId- The content typesyncCode- The synchronization codecontext- the import context- Returns:
- The
ListofExpression
-
getLocalAndExternalFields
public Set<String> getLocalAndExternalFields(Map<String,Object> additionalParameters)
Description copied from interface:ImportCDMFrComponentGet the path of tri-state fields (with local and external values)- Specified by:
getLocalAndExternalFieldsin interfaceImportCDMFrComponent- Parameters:
additionalParameters- Additional parameters- Returns:
- the synchronized fields
-
-