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 |
Modifier and Type | Field and Description |
---|---|
protected CatalogsManager |
_catalogsManager
The catalog manager
|
protected CDMFrSyncExtensionPoint |
_cdmFrSyncExtensionPoint
Extension point to transform CDM-fr
|
protected Context |
_cocoonContext
The Cocoon context
|
private static AbstractImportCDMFrComponent.ContentWorkflowDescription |
_CONTAINER_WF_DESCRIPTION |
protected String |
_contentPrefix
The prefix of the contents
|
protected ContentTypeExtensionPoint |
_contentTypeEP
The content type extension point
|
private static AbstractImportCDMFrComponent.ContentWorkflowDescription |
_COURSE_WF_DESCRIPTION |
private static AbstractImportCDMFrComponent.ContentWorkflowDescription |
_COURSELIST_WF_DESCRIPTION |
protected CurrentUserProvider |
_currentUserProvider
The current user provider
|
protected DOMParser |
_domParser
The DOM parser
|
protected Map<String,Integer> |
_importedContents
List of synchronized contents
|
protected int |
_nbCreatedContents
Number of created contents
|
protected int |
_nbError
Number of errors encountered
|
protected int |
_nbNotChangedContents
Number of unchanged contents
|
protected int |
_nbSynchronizedContents
Number of synchronized contents
|
protected ObservationManager |
_observationManager
The observation manager
|
protected String |
_odfLang
Default language configured for ODF
|
protected OdfReferenceTableHelper |
_odfRefTableHelper
The ODF TableRef Helper
|
private static AbstractImportCDMFrComponent.ContentWorkflowDescription |
_ORGUNIT_WF_DESCRIPTION |
private static AbstractImportCDMFrComponent.ContentWorkflowDescription |
_PERSON_WF_DESCRIPTION |
private static PrefixResolver |
_PREFIX_RESOLVER |
private static AbstractImportCDMFrComponent.ContentWorkflowDescription |
_PROGRAM_WF_DESCRIPTION |
protected AmetysObjectResolver |
_resolver
The ametys object resolver
|
protected RootOrgUnitProvider |
_rootOUProvider
The root orgunit provider
|
private static AbstractImportCDMFrComponent.ContentWorkflowDescription |
_SUBPROGRAM_WF_DESCRIPTION |
protected Map<String,Set<String>> |
_syncFieldsByContentType
Synchronized fields by content type
|
protected BaseSynchroComponent |
_synchroComponent
The base SCC component
|
protected Set<String> |
_synchronizedContents
List of synchronized contents having differences
|
protected static String |
_TAG_CONTAINER
Tag to identify a container
|
protected static String |
_TAG_COURSELIST
Tag to identify a courseList
|
protected static String |
_TAG_PROGRAM
Tag to identify a program
|
protected static String |
_TAG_SUBPROGRAM
Tag to identify a subprogram
|
protected Set<String> |
_updatedContents
List of synchronized contents (to avoid a treatment twice or more)
|
protected XPathProcessor |
_xPathProcessor
The XPath processor
|
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 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) |
private boolean |
_handleBinaryMetadata(Node metadataNode,
ModifiableDefaultContent content,
String completeMetadataPath,
boolean synchronize,
Logger logger) |
private boolean |
_handleCompositeMetadata(Document doc,
Node metadataNode,
ModifiableDefaultContent content,
String logicalMetadataPath,
String completeMetadataPath,
ContentType contentType,
String lang,
Logger logger) |
private boolean |
_handleFileMetadata(Node metadataNode,
ModifiableDefaultContent content,
String logicalMetadataPath,
String completeMetadataPath,
boolean synchronize,
ContentType contentType,
Logger logger) |
private boolean |
_handleGeocodeMetadata(Node metadataNode,
ModifiableDefaultContent content,
String completeMetadataPath,
boolean synchronize) |
private List<Object> |
_handleMetadataValues(Document doc,
ModifiableDefaultContent content,
MetadataDefinition metadataDef,
List<String> metadataValues,
String lang,
Logger logger) |
private boolean |
_handleRepeaterMetadata(Document doc,
Node metadataNode,
ModifiableDefaultContent content,
String logicalMetadataPath,
String completeMetadataPath,
ContentType contentType,
String lang,
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,
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,
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 |
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.
|
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
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 _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 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 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, 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 langlogger
- The loggertrue
if changes occursprivate boolean _handleGeocodeMetadata(Node metadataNode, ModifiableDefaultContent content, String completeMetadataPath, boolean synchronize)
private boolean _handleFileMetadata(Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, boolean synchronize, ContentType contentType, Logger logger)
private boolean _handleBinaryMetadata(Node metadataNode, ModifiableDefaultContent content, String completeMetadataPath, boolean synchronize, Logger logger)
private boolean _handleRepeaterMetadata(Document doc, Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, ContentType contentType, String lang, Logger logger)
private boolean _handleCompositeMetadata(Document doc, Node metadataNode, ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, ContentType contentType, String lang, Logger logger)
private boolean _handleRichTextMetadata(ModifiableDefaultContent content, String logicalMetadataPath, String completeMetadataPath, Node metadataNode, boolean synchronize, Logger logger)
private List<Object> _handleMetadataValues(Document doc, ModifiableDefaultContent content, MetadataDefinition metadataDef, List<String> metadataValues, String lang, 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, Logger logger)
content
- The content to updatechildren
- Children to setlogger
- 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 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 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