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.
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Internal object to describe content workflow elements. -
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 CurrentUserProvider
The current user providerprotected DOMParser
The DOM parserList of synchronized contentsprotected int
Number of created contentsprotected int
Number of errors encounteredprotected int
Number of unchanged contentsprotected int
Number of synchronized contentsprotected ObservationManager
The observation managerprotected String
Default language configured for ODFprotected OdfReferenceTableHelper
The ODF TableRef Helperprotected AmetysObjectResolver
The ametys object resolverprotected RootOrgUnitProvider
The root orgunit providerprotected ShareableCourseHelper
The shareable course helperSynchronized fields by content typeprotected BaseSynchroComponent
The base SCC componentList of synchronized contents having differencesprotected 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 subprogramList of synchronized contents (to avoid a treatment twice or more)protected XPathProcessor
The XPath processorFields inherited from interface org.ametys.plugins.odfsync.cdmfr.components.ImportCDMFrComponent
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ModifiableDefaultContent
_getContent
(String lang, String catalog, String syncCode, AbstractImportCDMFrComponent.ContentWorkflowDescription wfDescription) Get the content from the synchronization code, the lang, the catalog and the content type.protected String
_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.protected ModifiableDefaultContent
_getOrCreateContent
(String title, String lang, String catalog, String syncCode, AbstractImportCDMFrComponent.ContentWorkflowDescription wfDescription, Logger logger) Get or create the content from the synchronization code, the lang, the catalog and the content type.protected boolean
_handleBinaryMetadata
(Node metadataNode, ModifiableDefaultContent content, String completeMetadataPath, boolean synchronize, Logger logger) Synchronize binary metadataprotected boolean
_handleBinaryMetadata
(Node metadataNode, ModifiableDefaultContent content, ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize, Logger logger) Synchronize binary metadataprotected boolean
_handleFileMetadata
(Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, boolean synchronize, ContentType contentType, Logger logger) Synchronize file metadataprotected boolean
_handleFileMetadata
(Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize, ContentType contentType, Logger logger) Synchronize file metadataprotected boolean
_handleGeocodeMetadata
(Node metadataNode, ModifiableDefaultContent content, String completeMetadataPath, boolean synchronize) Synchronize geocode metadataprotected boolean
_handleGeocodeMetadata
(Node metadataNode, ModifiableDefaultContent content, ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize) Synchronize geocode metadata_handleMetadataValues
(Document doc, ModifiableDefaultContent content, MetadataDefinition metadataDef, List<String> untypedValues, String lang, String catalog, Logger logger) Handle metadata valuesprotected ModifiableDefaultContent
_importOrSynchronizeContent
(Document doc, Node contentNode, AbstractImportCDMFrComponent.ContentWorkflowDescription wfDescription, String title, String lang, String catalog, String syncCode, Logger logger) Import or synchronize the content.protected void
_linkTranslationsIfExist
(ModifiableContent importedContent, String contentType) Search for translated contentsprotected void
_saveContentChanges
(ModifiableDefaultContent content, String contentTypeId, boolean hasChanges, Logger logger) Save the changes of the content.protected boolean
_setChildren
(ModifiableDefaultContent content, List<ModifiableDefaultContent> children, Logger logger) Set children for the given content.protected boolean
_setOrgUnitParent
(ModifiableDefaultContent orgUnit, Logger logger) Set the orgUnit parent to rootOrgUnit.protected boolean
_setRelations
(ModifiableDefaultContent content, List<ModifiableDefaultContent> children, List<ModifiableDefaultContent> courseParts, boolean removeOldCourseParts, Logger logger) Set relations for the content.protected void
_synchronizeContent
(Document doc, Node contentNode, ModifiableDefaultContent content, String contentTypeId, String lang, String catalog, String syncCode, Logger logger) Synchronize contentprotected void
_synchronizeCourseList
(Document doc, Node courseListNode, ModifiableDefaultContent courseList, String lang, String catalog, Logger logger) Synchronize a course list, it has attributes to synchronize.protected boolean
_synchronizeMetadata
(Document doc, Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, ContentType contentType, String lang, String catalog, Logger logger) Synchronize a metadata (can be a composite or a repeater).protected abstract void
additionalOperationsBeforeSave
(ModifiableDefaultContent content, Logger logger) Additional operation to do on the content before saving it.protected abstract void
additionalParameters
(Map<String, Object> parameters) Additional parameters for specific treatments.void
configure
(Configuration configuration) void
contextualize
(Context context) protected String
getCatalogName
(Node contentNode) Get the name of catalog to use for importGet the container workflow description.Get the course list workflow description.Get the course part workflow description.Get the course workflow description.getExpressionsList
(String lang, String idValue, String contentType, String catalog) Construct the query to retrieve the content.Return the metadata identifier for CDM-fr synchronization.getLocalAndExternalFields
(Map<String, Object> additionalParameters) Get the path of tri-state fields (with local and external values)Get the orgunit workflow description.Get the person workflow description.Get the program workflow description.Get the subprogram workflow description.handleInputStream
(InputStream input, Map<String, Object> parameters, 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 processvoid
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 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:
-
_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 -
_synchroComponent
The base SCC component -
_importedContents
List of synchronized contents -
_synchronizedContents
List of synchronized contents having differences -
_updatedContents
List of synchronized contents (to avoid a treatment twice or more) -
_nbError
Number of errors encountered -
_nbCreatedContents
Number of created contents -
_nbSynchronizedContents
Number of synchronized contents -
_nbNotChangedContents
Number of unchanged contents -
_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 metadata identifier for CDM-fr synchronization.- Specified by:
getIdField
in interfaceImportCDMFrComponent
- Returns:
- The metadata name (cdmfrSyncCode)
-
handleInputStream
public Map<String,Object> handleInputStream(InputStream input, Map<String, Object> parameters, 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 operationlogger
- 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.
-
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
Get the name of catalog to use for import- Parameters:
contentNode
- The node of program- Returns:
- The catalog to used
-
_getOrCreateContent
protected ModifiableDefaultContent _getOrCreateContent(String title, String lang, String catalog, String syncCode, AbstractImportCDMFrComponent.ContentWorkflowDescription wfDescription, Logger logger) throws RepositoryException Get or create the content from the synchronization code, the lang, the catalog and the content type.- Parameters:
title
- The titlelang
- The langcatalog
- The catalogsyncCode
- The synchronization codewfDescription
- The workflow descriptionlogger
- The logger- Returns:
- the retrieved or created content
- Throws:
RepositoryException
- if an error occurs
-
_getContent
protected ModifiableDefaultContent _getContent(String lang, String catalog, String syncCode, AbstractImportCDMFrComponent.ContentWorkflowDescription wfDescription) Get the content from the synchronization code, the lang, the catalog and the content type.- Parameters:
lang
- The langcatalog
- The catalogsyncCode
- The synchronization codewfDescription
- The workflow description- Returns:
- the retrieved content
-
additionalParameters
Additional parameters for specific treatments.- Parameters:
parameters
- The parameters map to get
-
additionalOperationsBeforeSave
protected abstract void additionalOperationsBeforeSave(ModifiableDefaultContent content, Logger logger) throws RepositoryException Additional operation to do on the content before saving it.- Parameters:
content
- The contentlogger
- The logger- Throws:
RepositoryException
- if an error occurs
-
_importOrSynchronizeContent
protected ModifiableDefaultContent _importOrSynchronizeContent(Document doc, Node contentNode, AbstractImportCDMFrComponent.ContentWorkflowDescription wfDescription, String title, String lang, String catalog, String syncCode, Logger logger) Import or synchronize the content.- Parameters:
doc
- XML documentcontentNode
- Node of the contentwfDescription
- The workflow descriptiontitle
- The titlelang
- The langcatalog
- The catalogsyncCode
- The synchronization codelogger
- The logger- Returns:
- The imported or synchronized content
-
_synchronizeContent
protected void _synchronizeContent(Document doc, Node contentNode, ModifiableDefaultContent content, String contentTypeId, String lang, String catalog, String syncCode, Logger logger) Synchronize content- Parameters:
doc
- The root documentcontentNode
- the DOM content nodecontent
- The content to synchronizecontentTypeId
- The content type IDlang
- Parent program language (to select the good courses in the CDM-FR file)catalog
- The catalog of parent programsyncCode
- The synchronization codelogger
- The logger
-
_synchronizeCourseList
protected void _synchronizeCourseList(Document doc, Node courseListNode, ModifiableDefaultContent courseList, String lang, String catalog, Logger logger) Synchronize a course list, it has attributes to synchronize.- Parameters:
doc
- The XML documentcourseListNode
- The XML node of the course listcourseList
- The course list contentlang
- The langcatalog
- The cataloglogger
- The logger
-
_synchronizeMetadata
protected boolean _synchronizeMetadata(Document doc, Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, ContentType contentType, String lang, String catalog, Logger logger) Synchronize a metadata (can be a composite or a repeater).- Parameters:
doc
- The XML documentmetadataNode
- The metadata nodecontent
- The contentlogicalMetadataPath
- The logical metadata path (to retrieve the definition)completeMetadataPath
- The complete metadata path (to retrieve the metadata holder)contentType
- The content typelang
- The langcatalog
- The cataloglogger
- The logger- Returns:
true
if changes occurs
-
_handleGeocodeMetadata
protected boolean _handleGeocodeMetadata(Node metadataNode, ModifiableDefaultContent content, String completeMetadataPath, boolean synchronize) Synchronize geocode metadata- Parameters:
metadataNode
- The metadata nodecontent
- The contentcompleteMetadataPath
- The complete metadata path (to retrieve the metadata holder)synchronize
- true if the data is external- Returns:
- true if some changes has been made
-
_handleGeocodeMetadata
protected boolean _handleGeocodeMetadata(Node metadataNode, ModifiableDefaultContent content, ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize) Synchronize geocode metadata- Parameters:
metadataNode
- The metadata nodecontent
- The contentmetadataHolder
- the metadata holdermetadataName
- the metadata namesynchronize
- true if the data is external- Returns:
- true if some changes has been made
-
_handleFileMetadata
protected boolean _handleFileMetadata(Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, boolean synchronize, ContentType contentType, Logger logger) Synchronize file metadata- Parameters:
metadataNode
- The metadata nodecontent
- The contentlogicalMetadataPath
- The logical metadata path (to retrieve the definition)completeMetadataPath
- The complete metadata path (to retrieve the metadata holder)synchronize
- true if the data is externalcontentType
- the content typelogger
- the logger- Returns:
- true if some changes has been made
-
_handleFileMetadata
protected boolean _handleFileMetadata(Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize, ContentType contentType, Logger logger) Synchronize file metadata- Parameters:
metadataNode
- The metadata nodecontent
- The contentlogicalMetadataPath
- The logical metadata path (to retrieve the definition)metadataHolder
- the metadata holdermetadataName
- the metadata namesynchronize
- true if the data is externalcontentType
- the content typelogger
- the logger- Returns:
- true if some changes has been made
-
_handleBinaryMetadata
protected boolean _handleBinaryMetadata(Node metadataNode, ModifiableDefaultContent content, String completeMetadataPath, boolean synchronize, Logger logger) Synchronize binary metadata- Parameters:
metadataNode
- The metadata nodecontent
- The contentcompleteMetadataPath
- The complete metadata path (to retrieve the metadata holder)synchronize
- true if the data is externallogger
- the logger- Returns:
- true if some changes has been made
-
_handleBinaryMetadata
protected boolean _handleBinaryMetadata(Node metadataNode, ModifiableDefaultContent content, ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize, Logger logger) Synchronize binary metadata- Parameters:
metadataNode
- The metadata nodecontent
- The contentmetadataHolder
- the metadata holdermetadataName
- the metadata namesynchronize
- true if the data is externallogger
- the logger- Returns:
- true if some changes has been made
-
_handleMetadataValues
protected List<Object> _handleMetadataValues(Document doc, ModifiableDefaultContent content, MetadataDefinition metadataDef, List<String> untypedValues, String lang, String catalog, Logger logger) Handle metadata values- Parameters:
doc
- the documentcontent
- the contentmetadataDef
- the metadata definitionuntypedValues
- the metadata values, untypedlang
- the languagecatalog
- the cataloglogger
- the logger- Returns:
- the list of handle value, typed
-
_linkTranslationsIfExist
Search for translated contents- Parameters:
importedContent
- The imported contentcontentType
- The content type
-
_saveContentChanges
protected void _saveContentChanges(ModifiableDefaultContent content, String contentTypeId, boolean hasChanges, Logger logger) Save the changes of the content.- Parameters:
content
- Content to savecontentTypeId
- The content type (for logs)hasChanges
- If there are changes to savelogger
- The logger
-
_setRelations
protected boolean _setRelations(ModifiableDefaultContent content, List<ModifiableDefaultContent> children, List<ModifiableDefaultContent> courseParts, boolean removeOldCourseParts, Logger logger) Set relations for the content.- Parameters:
content
- The content to updatechildren
- Children to setcourseParts
-List
ofCoursePart
to set forCourse
contentremoveOldCourseParts
- If the course parts doesn't have a code, we remove all the oldCoursePart
s before adding the new oneslogger
- The logger- Returns:
true
if changes occurs
-
_setChildren
protected boolean _setChildren(ModifiableDefaultContent content, List<ModifiableDefaultContent> children, Logger logger) Set children for the given content.- Parameters:
content
- Content to add the childrenchildren
- Children to addlogger
- The logger- Returns:
true
if changes occurs
-
_setOrgUnitParent
Set the orgUnit parent to rootOrgUnit.- Parameters:
orgUnit
- The orgunit to linklogger
- The logger- Returns:
true
if changes occurs
-
_getIdFromCDMThenCode
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.- 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
-
getProgramWfDescription
Get the program workflow description.- Returns:
- A
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the program workflow
-
getSubProgramWfDescription
Get the subprogram workflow description.- Returns:
- A
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the subprogram workflow
-
getContainerWfDescription
Get the container workflow description.- Returns:
- A
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the container workflow
-
getCourseListWfDescription
Get the course list workflow description.- Returns:
- A
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the course list workflow
-
getCourseWfDescription
Get the course workflow description.- Returns:
- A
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the course workflow
-
getCoursePartWfDescription
Get the course part workflow description.- Returns:
- A
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the course part workflow
-
getOrgUnitWfDescription
Get the orgunit workflow description.- Returns:
- A
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the orgunit workflow
-
getPersonWfDescription
Get the person workflow description.- Returns:
- A
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the person workflow
-
getExpressionsList
public List<Expression> getExpressionsList(String lang, String idValue, String contentType, String catalog) Description copied from interface:ImportCDMFrComponent
Construct the query to retrieve the content.- Specified by:
getExpressionsList
in interfaceImportCDMFrComponent
- Parameters:
lang
- LangidValue
- Synchronization valuecontentType
- Content typecatalog
- The catalog- 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
-