public abstract class AbstractImportCDMFrComponent extends Object implements ImportCDMFrComponent, Serviceable, Initializable, Contextualizable, Configurable, Component
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractImportCDMFrComponent.ContentWorkflowDescription
Internal object to describe content workflow elements.
|
private static class |
AbstractImportCDMFrComponent.DocbookPrefixResolver |
ROLE
Constructor and Description |
---|
AbstractImportCDMFrComponent() |
Modifier and Type | Method and Description |
---|---|
private Set<String> |
_configureSynchronizedFields(Configuration configuration,
String prefix) |
private void |
_fetchImages(Node docbookNode,
ModifiableDefaultContent content,
ModifiableRichText richText,
String metadataPath,
Logger logger) |
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.
|
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.
|
private String |
_getXPathString(Node metadataNode,
String xPath,
String defaultValue) |
protected boolean |
_handleBinaryMetadata(Node metadataNode,
ModifiableDefaultContent content,
ModifiableCompositeMetadata metadataHolder,
String metadataName,
boolean synchronize,
Logger logger)
Synchronize binary metadata
|
protected boolean |
_handleBinaryMetadata(Node metadataNode,
ModifiableDefaultContent content,
String completeMetadataPath,
boolean synchronize,
Logger logger)
Synchronize binary metadata
|
private boolean |
_handleCompositeMetadata(Document doc,
Node metadataNode,
ModifiableDefaultContent content,
String logicalMetadataPath,
String completeMetadataPath,
ContentType contentType,
String lang,
String catalog,
Logger logger) |
protected boolean |
_handleFileMetadata(Node metadataNode,
ModifiableDefaultContent content,
String logicalMetadataPath,
ModifiableCompositeMetadata metadataHolder,
String metadataName,
boolean synchronize,
ContentType contentType,
Logger logger)
Synchronize file metadata
|
protected boolean |
_handleFileMetadata(Node metadataNode,
ModifiableDefaultContent content,
String logicalMetadataPath,
String completeMetadataPath,
boolean synchronize,
ContentType contentType,
Logger logger)
Synchronize file metadata
|
protected boolean |
_handleGeocodeMetadata(Node metadataNode,
ModifiableDefaultContent content,
ModifiableCompositeMetadata metadataHolder,
String metadataName,
boolean synchronize)
Synchronize geocode metadata
|
protected boolean |
_handleGeocodeMetadata(Node metadataNode,
ModifiableDefaultContent content,
String completeMetadataPath,
boolean synchronize)
Synchronize geocode metadata
|
protected List<Object> |
_handleMetadataValues(Document doc,
ModifiableDefaultContent content,
MetadataDefinition metadataDef,
List<String> metadataValues,
String lang,
String catalog,
Logger logger)
Handle metadata values
|
private Object |
_handleMetadataValuesAsContent(Document doc,
MetadataDefinition metadataDef,
String metadataValue,
String lang,
String catalog,
Logger logger) |
private boolean |
_handleRepeaterMetadata(Document doc,
Node metadataNode,
ModifiableDefaultContent content,
String logicalMetadataPath,
String completeMetadataPath,
ContentType contentType,
String lang,
String catalog,
Logger logger) |
private boolean |
_handleRichTextMetadata(ModifiableDefaultContent content,
String logicalMetadataPath,
String completeMetadataPath,
Node metadataNode,
boolean synchronize,
Logger logger) |
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.
|
protected void |
_linkTranslationsIfExist(ModifiableContent importedContent,
String contentType)
Search for translated contents
|
private void |
_parseSynchronizedFields()
Get the synchronized metadata from the configuration file
|
protected 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 content
|
protected 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).
|
private boolean |
_updateDoubleRelation(ModifiableDefaultContent content,
List<ModifiableDefaultContent> children,
String metadataName,
String invertMetadataName,
Logger logger) |
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 import
|
protected AbstractImportCDMFrComponent.ContentWorkflowDescription |
getContainerWfDescription()
Get the container workflow description.
|
protected AbstractImportCDMFrComponent.ContentWorkflowDescription |
getCourseListWfDescription()
Get the course list workflow description.
|
protected AbstractImportCDMFrComponent.ContentWorkflowDescription |
getCoursePartWfDescription()
Get the course part workflow description.
|
protected AbstractImportCDMFrComponent.ContentWorkflowDescription |
getCourseWfDescription()
Get the course workflow description.
|
List<Expression> |
getExpressionsList(String lang,
String idValue,
String contentType,
String catalog)
Construct the query to retrieve the content.
|
String |
getIdField()
Return the metadata identifier for CDM-fr synchronization.
|
Set<String> |
getLocalAndExternalFields(Map<String,Object> additionalParameters)
Get the path of tri-state fields (with local and external values)
|
protected AbstractImportCDMFrComponent.ContentWorkflowDescription |
getOrgUnitWfDescription()
Get the orgunit workflow description.
|
protected AbstractImportCDMFrComponent.ContentWorkflowDescription |
getPersonWfDescription()
Get the person workflow description.
|
protected AbstractImportCDMFrComponent.ContentWorkflowDescription |
getProgramWfDescription()
Get the program workflow description.
|
protected AbstractImportCDMFrComponent.ContentWorkflowDescription |
getSubProgramWfDescription()
Get the subprogram workflow description.
|
Map<String,Object> |
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 |
ignoreRights()
If true, bypass the rights check during the import process
|
void |
initialize() |
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.
|
void |
service(ServiceManager manager) |
protected Document |
transformDocument(Document document,
Map<String,Object> parameters,
Logger logger)
Transform the document depending of it structure.
|
protected abstract boolean |
validateAfterImport()
True to validate the contents after import
|
protected static final String _TAG_PROGRAM
protected static final String _TAG_SUBPROGRAM
protected static final String _TAG_CONTAINER
protected static final String _TAG_COURSELIST
protected static final String _TAG_COURSEPART
private static final int SYNCHRONIZE_WORKFLOW_ACTION_ID
private static final AbstractImportCDMFrComponent.ContentWorkflowDescription _PROGRAM_WF_DESCRIPTION
private static final AbstractImportCDMFrComponent.ContentWorkflowDescription _SUBPROGRAM_WF_DESCRIPTION
private static final AbstractImportCDMFrComponent.ContentWorkflowDescription _CONTAINER_WF_DESCRIPTION
private static final AbstractImportCDMFrComponent.ContentWorkflowDescription _COURSELIST_WF_DESCRIPTION
private static final AbstractImportCDMFrComponent.ContentWorkflowDescription _COURSE_WF_DESCRIPTION
private static final AbstractImportCDMFrComponent.ContentWorkflowDescription _COURSEPART_WF_DESCRIPTION
private static final AbstractImportCDMFrComponent.ContentWorkflowDescription _ORGUNIT_WF_DESCRIPTION
private static final AbstractImportCDMFrComponent.ContentWorkflowDescription _PERSON_WF_DESCRIPTION
private static final PrefixResolver _PREFIX_RESOLVER
protected Context _cocoonContext
protected DOMParser _domParser
protected XPathProcessor _xPathProcessor
protected CDMFrSyncExtensionPoint _cdmFrSyncExtensionPoint
protected CatalogsManager _catalogsManager
protected AmetysObjectResolver _resolver
protected OdfReferenceTableHelper _odfRefTableHelper
protected ContentTypeExtensionPoint _contentTypeEP
protected CurrentUserProvider _currentUserProvider
protected ObservationManager _observationManager
protected RootOrgUnitProvider _rootOUProvider
protected BaseSynchroComponent _synchroComponent
protected ShareableCourseHelper _shareableCourseHelper
protected Map<String,Integer> _importedContents
protected Set<String> _synchronizedContents
protected Set<String> _updatedContents
protected int _nbError
protected int _nbCreatedContents
protected int _nbSynchronizedContents
protected int _nbNotChangedContents
protected String _contentPrefix
protected Map<String,Set<String>> _syncFieldsByContentType
public AbstractImportCDMFrComponent()
public void initialize() throws Exception
initialize
in interface Initializable
Exception
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public String getIdField()
ImportCDMFrComponent
getIdField
in interface ImportCDMFrComponent
private void _parseSynchronizedFields() throws ConfigurationException
ConfigurationException
- if the configuration is not valid.private Set<String> _configureSynchronizedFields(Configuration configuration, String prefix) throws ConfigurationException
ConfigurationException
public Map<String,Object> handleInputStream(InputStream input, Map<String,Object> parameters, Logger logger) throws ProcessingException
ImportCDMFrComponent
handleInputStream
in interface ImportCDMFrComponent
input
- The CDM-fr input streamparameters
- The parameters useful for the operationlogger
- The loggerProcessingException
- If an error occursprotected abstract boolean validateAfterImport()
protected abstract boolean removalSync()
protected Document transformDocument(Document document, Map<String,Object> parameters, Logger logger) throws IOException, SAXException, ProcessingException
document
- Document to transform.parameters
- Optional parameters for transformationlogger
- The loggerIOException
- if an error occurs.SAXException
- if an error occurs.ProcessingException
- if an error occurs.protected String getCatalogName(Node contentNode)
contentNode
- The node of programprotected ModifiableDefaultContent _getOrCreateContent(String title, String lang, String catalog, String syncCode, AbstractImportCDMFrComponent.ContentWorkflowDescription wfDescription, Logger logger) throws RepositoryException
title
- The titlelang
- The langcatalog
- The catalogsyncCode
- The synchronization codewfDescription
- The workflow descriptionlogger
- The loggerRepositoryException
- if an error occursprotected ModifiableDefaultContent _getContent(String lang, String catalog, String syncCode, AbstractImportCDMFrComponent.ContentWorkflowDescription wfDescription)
lang
- The langcatalog
- The catalogsyncCode
- The synchronization codewfDescription
- The workflow descriptionprotected abstract void additionalParameters(Map<String,Object> parameters)
parameters
- The parameters map to getprotected abstract void additionalOperationsBeforeSave(ModifiableDefaultContent content, Logger logger) throws RepositoryException
content
- The contentlogger
- The loggerRepositoryException
- if an error occursprotected ModifiableDefaultContent _importOrSynchronizeContent(Document doc, Node contentNode, AbstractImportCDMFrComponent.ContentWorkflowDescription wfDescription, String title, String lang, String catalog, String syncCode, Logger logger)
doc
- XML documentcontentNode
- Node of the contentwfDescription
- The workflow descriptiontitle
- The titlelang
- The langcatalog
- The catalogsyncCode
- The synchronization codelogger
- The loggerprotected void _synchronizeContent(Document doc, Node contentNode, ModifiableDefaultContent content, String contentTypeId, String lang, String catalog, String syncCode, Logger logger)
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 loggerprotected void _synchronizeCourseList(Document doc, Node courseListNode, ModifiableDefaultContent courseList, String lang, String catalog, Logger logger)
doc
- The XML documentcourseListNode
- The XML node of the course listcourseList
- The course list contentlang
- The langcatalog
- The cataloglogger
- The loggerprivate void _fetchImages(Node docbookNode, ModifiableDefaultContent content, ModifiableRichText richText, String metadataPath, Logger logger)
protected boolean _synchronizeMetadata(Document doc, Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, ContentType contentType, String lang, String catalog, Logger logger)
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 loggertrue
if changes occursprotected boolean _handleGeocodeMetadata(Node metadataNode, ModifiableDefaultContent content, String completeMetadataPath, boolean synchronize)
metadataNode
- The metadata nodecontent
- The contentcompleteMetadataPath
- The complete metadata path (to retrieve the metadata holder)synchronize
- true if the data is externalprotected boolean _handleGeocodeMetadata(Node metadataNode, ModifiableDefaultContent content, ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize)
metadataNode
- The metadata nodecontent
- The contentmetadataHolder
- the metadata holdermetadataName
- the metadata namesynchronize
- true if the data is externalprotected boolean _handleFileMetadata(Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, boolean synchronize, ContentType contentType, Logger logger)
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 loggerprotected boolean _handleFileMetadata(Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize, ContentType contentType, Logger logger)
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 loggerprotected boolean _handleBinaryMetadata(Node metadataNode, ModifiableDefaultContent content, String completeMetadataPath, boolean synchronize, Logger logger)
metadataNode
- The metadata nodecontent
- The contentcompleteMetadataPath
- The complete metadata path (to retrieve the metadata holder)synchronize
- true if the data is externallogger
- the loggerprotected boolean _handleBinaryMetadata(Node metadataNode, ModifiableDefaultContent content, ModifiableCompositeMetadata metadataHolder, String metadataName, boolean synchronize, Logger logger)
metadataNode
- The metadata nodecontent
- The contentmetadataHolder
- the metadata holdermetadataName
- the metadata namesynchronize
- true if the data is externallogger
- the loggerprivate boolean _handleRepeaterMetadata(Document doc, Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, ContentType contentType, String lang, String catalog, Logger logger)
private boolean _handleCompositeMetadata(Document doc, Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, ContentType contentType, String lang, String catalog, Logger logger)
private boolean _handleRichTextMetadata(ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, Node metadataNode, boolean synchronize, Logger logger)
protected List<Object> _handleMetadataValues(Document doc, ModifiableDefaultContent content, MetadataDefinition metadataDef, List<String> metadataValues, String lang, String catalog, Logger logger)
doc
- the documentcontent
- the contentmetadataDef
- the metadata definitionmetadataValues
- the metadata valueslang
- the languagecatalog
- the cataloglogger
- the loggerprivate Object _handleMetadataValuesAsContent(Document doc, MetadataDefinition metadataDef, String metadataValue, String lang, String catalog, Logger logger)
protected void _linkTranslationsIfExist(ModifiableContent importedContent, String contentType)
importedContent
- The imported contentcontentType
- The content typeprotected void _saveContentChanges(ModifiableDefaultContent content, String contentTypeId, boolean hasChanges, Logger logger)
content
- Content to savecontentTypeId
- The content type (for logs)hasChanges
- If there are changes to savelogger
- The loggerprotected boolean _setRelations(ModifiableDefaultContent content, List<ModifiableDefaultContent> children, List<ModifiableDefaultContent> courseParts, boolean removeOldCourseParts, Logger logger)
content
- The content to updatechildren
- Children to setcourseParts
- List
of CoursePart
to set for Course
contentremoveOldCourseParts
- If the course parts doesn't have a code, we remove all the old CoursePart
s before adding the new oneslogger
- The loggertrue
if changes occursprotected boolean _setChildren(ModifiableDefaultContent content, List<ModifiableDefaultContent> children, Logger logger)
content
- Content to add the childrenchildren
- Children to addlogger
- The loggertrue
if changes occursprotected boolean _setOrgUnitParent(ModifiableDefaultContent orgUnit, Logger logger)
orgUnit
- The orgunit to linklogger
- The loggertrue
if changes occursprotected String _getIdFromCDMThenCode(String tableRefId, String cdmCode)
tableRefId
- The reference table IDcdmCode
- The CDM codenull
private boolean _updateDoubleRelation(ModifiableDefaultContent content, List<ModifiableDefaultContent> children, String metadataName, String invertMetadataName, Logger logger)
private String _getXPathString(Node metadataNode, String xPath, String defaultValue)
protected boolean ignoreRights()
protected AbstractImportCDMFrComponent.ContentWorkflowDescription getProgramWfDescription()
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the program workflowprotected AbstractImportCDMFrComponent.ContentWorkflowDescription getSubProgramWfDescription()
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the subprogram workflowprotected AbstractImportCDMFrComponent.ContentWorkflowDescription getContainerWfDescription()
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the container workflowprotected AbstractImportCDMFrComponent.ContentWorkflowDescription getCourseListWfDescription()
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the course list workflowprotected AbstractImportCDMFrComponent.ContentWorkflowDescription getCourseWfDescription()
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the course workflowprotected AbstractImportCDMFrComponent.ContentWorkflowDescription getCoursePartWfDescription()
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the course part workflowprotected AbstractImportCDMFrComponent.ContentWorkflowDescription getOrgUnitWfDescription()
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the orgunit workflowprotected AbstractImportCDMFrComponent.ContentWorkflowDescription getPersonWfDescription()
AbstractImportCDMFrComponent.ContentWorkflowDescription
containing informations about the person workflowpublic List<Expression> getExpressionsList(String lang, String idValue, String contentType, String catalog)
ImportCDMFrComponent
getExpressionsList
in interface ImportCDMFrComponent
lang
- LangidValue
- Synchronization valuecontentType
- Content typecatalog
- The catalogList
of Expression
public Set<String> getLocalAndExternalFields(Map<String,Object> additionalParameters)
ImportCDMFrComponent
getLocalAndExternalFields
in interface ImportCDMFrComponent
additionalParameters
- Additional parameters