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
FieldsModifier and TypeFieldDescriptionprotected CatalogsManagerThe catalog managerprotected CDMFrSyncExtensionPointExtension point to transform CDM-frprotected ContextThe Cocoon contextprotected StringThe prefix of the contentsprotected ContentTypeExtensionPointThe content type extension pointprotected ContentWorkflowHelperThe content workflow helperprotected CurrentUserProviderThe current user providerprotected DOMParserThe DOM parserList of imported contentsprotected intNumber of errors encounteredprotected ObservationManagerThe observation managerprotected ODFHelperThe ODF Helperprotected StringDefault language configured for ODFprotected OdfReferenceTableHelperThe ODF TableRef Helperprotected AmetysObjectResolverThe ametys object resolverprotected RootOrgUnitProviderThe root orgunit providerprotected SynchronizableContentsCollectionHelperThe SCC helperprotected ShareableCourseHelperThe shareable course helperSynchronized fields by content typeprotected static final intThe synchronize workflow action idList of synchronized contentsprotected static final StringTag to identify a containerprotected static final StringTag to identify a courseListprotected static final StringTag to identify a coursePartprotected static final StringTag to identify a programprotected static final StringTag to identify a subprogramprotected ImportCDMFrValuesExtractorFactorytheImportCDMFrValuesExtractorfactoryprotected XPathProcessorThe XPath processorFields inherited from interface org.ametys.plugins.odfsync.cdmfr.components.ImportCDMFrComponent
ROLE -
Constructor Summary
Constructors -
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 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 contentadditionalOperations(ModifiableContent content, Map<String, Object> additionalParameters, 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) 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 booleanIf true, bypass the rights check during the import processimportOrSynchronizeContent(Element contentElement, ContentWorkflowDescription wfDescription, String title, String syncCode, ImportCDMFrContext context) Import or synchronize the content.voidprotected abstract booleanWhen 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 DocumentTransform the document depending of it structure.protected abstract booleanTrue to validate the contents after importprotected voidvalidateContent(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
theImportCDMFrValuesExtractorfactory -
_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:
initializein interfaceInitializable- Throws:
Exception
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
configure
- Specified by:
configurein interfaceConfigurable- Throws:
ConfigurationException
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
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, Logger logger) throws ProcessingExceptionDescription 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
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: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.WorkflowExceptionSynchronize 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, 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
-
_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: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
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
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
-