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
Modifier and TypeFieldDescriptionprotected CatalogsManager
The catalog managerprotected CDMFrSyncExtensionPoint
Extension point to transform CDM-frprotected Context
The Cocoon contextprotected String
The prefix of the contentsprotected ContentTypeExtensionPoint
The content type extension pointprotected ContentWorkflowHelper
The content workflow helperprotected CurrentUserProvider
The current user providerprotected DOMParser
The DOM parserList of imported contentsprotected int
Number of errors encounteredprotected ObservationManager
The observation managerprotected ODFHelper
The ODF Helperprotected String
Default language configured for ODFprotected OdfReferenceTableHelper
The ODF TableRef Helperprotected AmetysObjectResolver
The ametys object resolverprotected RootOrgUnitProvider
The root orgunit providerprotected SynchronizableContentsCollectionHelper
The SCC helperprotected ShareableCourseHelper
The shareable course helperSynchronized fields by content typeprotected static final int
The synchronize workflow action idList of synchronized contentsprotected static final String
Tag to identify a containerprotected static final String
Tag to identify a courseListprotected static final String
Tag to identify a coursePartprotected static final String
Tag to identify a programprotected static final String
Tag to identify a subprogramprotected ImportCDMFrValuesExtractorFactory
theImportCDMFrValuesExtractor
factoryprotected XPathProcessor
The XPath processorFields inherited from interface org.ametys.plugins.odfsync.cdmfr.components.ImportCDMFrComponent
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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._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._getInputsForContentCreation
(ContentWorkflowDescription wfDescription, ImportCDMFrContext context) Retrieves the inputs to give for content creation_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 givenProgramItem
protected 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 contentadditionalOperations
(ModifiableContent content, Map<String, Object> additionalParameters, Logger logger) Add specific fields to the content during import or synchronization.protected abstract void
additionalParameters
(Map<String, Object> parameters) Additional parameters for specific treatments.void
configure
(Configuration configuration) void
contextualize
(Context context) getCatalogName
(Element contentElement) Get the name of catalog to use for importgetContent
(String contentType, String syncCode, ImportCDMFrContext context) Get the content from the synchronization code, the content type and the context.Return the attribute identifier for CDM-fr synchronization.getIdFromCDMThenCode
(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.getLocalAndExternalFields
(Map<String, Object> additionalParameters) Get the path of tri-state fields (with local and external values)handleInputStream
(InputStream input, Map<String, Object> parameters, SynchronizableContentsCollection scc, Logger logger) Handle the CDM-fr input stream to import all the programs and its dependencies containing into it.protected boolean
If true, bypass the rights check during the import processimportOrSynchronizeContent
(Element contentElement, ContentWorkflowDescription wfDescription, String title, String syncCode, ImportCDMFrContext context) Import or synchronize the content.void
protected abstract boolean
When returns true, a content created by a previous synchro will be removed if it does not exist anymore during the current synchro.void
service
(ServiceManager manager) protected Document
Transform the document depending of it structure.protected abstract boolean
True to validate the contents after importprotected void
validateContent
(WorkflowAwareContent content, int validationActionId, Logger logger) Validates a content after import
-
Field Details
-
_TAG_PROGRAM
Tag to identify a program- See Also:
-
_TAG_SUBPROGRAM
Tag to identify a subprogram- See Also:
-
_TAG_CONTAINER
Tag to identify a container- See Also:
-
_TAG_COURSELIST
Tag to identify a courseList- See Also:
-
_TAG_COURSEPART
Tag to identify a coursePart- See Also:
-
_SYNCHRONIZE_WORKFLOW_ACTION_ID
The synchronize workflow action id- See Also:
-
_cocoonContext
The Cocoon context -
_domParser
The DOM parser -
_xPathProcessor
The XPath processor -
_cdmFrSyncExtensionPoint
Extension point to transform CDM-fr -
_odfLang
Default language configured for ODF -
_catalogsManager
The catalog manager -
_resolver
The ametys object resolver -
_odfRefTableHelper
The ODF TableRef Helper -
_contentTypeEP
The content type extension point -
_currentUserProvider
The current user provider -
_observationManager
The observation manager -
_rootOUProvider
The root orgunit provider -
_odfHelper
The ODF Helper -
_sccHelper
The SCC helper -
_contentWorkflowHelper
The content workflow helper -
_valuesExtractorFactory
theImportCDMFrValuesExtractor
factory -
_importedContents
List of imported contents -
_synchronizedContents
List of synchronized contents -
_nbError
Number of errors encountered -
_contentPrefix
The prefix of the contents -
_syncFieldsByContentType
Synchronized fields by content type
-
-
Constructor Details
-
AbstractImportCDMFrComponent
public AbstractImportCDMFrComponent()
-
-
Method Details
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getIdField
Description copied from interface:ImportCDMFrComponent
Return the attribute identifier for CDM-fr synchronization.- Specified by:
getIdField
in interfaceImportCDMFrComponent
- Returns:
- The attribute name (cdmfrSyncCode)
-
handleInputStream
public Map<String,Object> handleInputStream(InputStream input, Map<String, Object> parameters, SynchronizableContentsCollection scc, Logger logger) throws ProcessingExceptionDescription copied from interface:ImportCDMFrComponent
Handle the CDM-fr input stream to import all the programs and its dependencies containing into it.- Specified by:
handleInputStream
in interfaceImportCDMFrComponent
- Parameters:
input
- The CDM-fr input streamparameters
- The parameters useful for the operationscc
- TheSynchronizableContentsCollection
calling this componentlogger
- The logger- Returns:
- The list of imported/synchronized programs
- Throws:
ProcessingException
- If an error occurs
-
validateAfterImport
True to validate the contents after import- Returns:
- True to validate the contents after import
-
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
Additional parameters for specific treatments.- Parameters:
parameters
- The parameters map to get
-
transformDocument
protected Document transformDocument(Document document, Map<String, Object> parameters, Logger logger) throws IOException, SAXException, ProcessingExceptionTransform 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
Description copied from interface:ImportCDMFrComponent
Get the name of catalog to use for import- Specified by:
getCatalogName
in 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:ImportCDMFrComponent
Import or synchronize the content.- Specified by:
importOrSynchronizeContent
in 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:ImportCDMFrComponent
Get the content from the synchronization code, the content type and the context.- Specified by:
getContent
in 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.WorkflowExceptionSynchronize the content with given values.- Parameters:
content
- The content to synchronizeview
- the view containing the item to editvalues
- the valuescreate
-true
if 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, Logger logger) Description copied from interface:ImportCDMFrComponent
Add specific fields to the content during import or synchronization.- Specified by:
additionalOperations
in interfaceImportCDMFrComponent
- Parameters:
content
- Content to updateadditionalParameters
- Additional parameterslogger
- The logger- Returns:
- The synchronization result of the additional operations
-
_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
Validates a content after import- Parameters:
content
- The content to validatevalidationActionId
- Validation action ID to use for this contentlogger
- The logger
-
getIdFromCDMThenCode
Description copied from interface:ImportCDMFrComponent
Get 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:
getIdFromCDMThenCode
in interfaceImportCDMFrComponent
- Parameters:
tableRefId
- The reference table IDcdmCode
- The CDM code- Returns:
- A content ID or
null
-
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
List
ofExpression
-
getLocalAndExternalFields
Description copied from interface:ImportCDMFrComponent
Get the path of tri-state fields (with local and external values)- Specified by:
getLocalAndExternalFields
in interfaceImportCDMFrComponent
- Parameters:
additionalParameters
- Additional parameters- Returns:
- the synchronized fields
-