Class AbstractDefaultSynchronizableContentsCollection
java.lang.Object
org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
org.ametys.plugins.contentio.synchronize.impl.AbstractDefaultSynchronizableContentsCollection
- All Implemented Interfaces:
SynchronizableContentsCollection
,Configurable
,Serviceable
public abstract class AbstractDefaultSynchronizableContentsCollection
extends AbstractSimpleSynchronizableContentsCollection
Abstract for default and simplified implementation of SCC.
Mandatory methods are:
SynchronizableContentsCollection.getIdField()
to define the content field which is the synchronization identifier.AbstractSimpleSynchronizableContentsCollection.internalSearch(Map, int, int, List, Logger)
to search data. It supports pagination but on single search and global synchronization, pagination is set to 0 andInteger.MAX_VALUE
. Also, on an import or synchronization (single search), the search parameters are filled with theSynchronizableContentsCollection.getIdField()
as a parameter and its associated value. The values are organized by ID field then name and value, the value can be aCollection
. May not return null.
It may be useful to override the following methods too:
getLocalAndExternalFields(Map)
to set the values from synchronization into remote values. These attributes name will have the synchronization toggle on edition._getMapping(Map)
to modify the default mapping, default mapping consider the field name from results as the final attribute name. The mapping can receive data from several fields.
You have to declare your now SCC model into a plugin.xml through the following extension:
<extension id="fr.ametys.myproject.scc.static" class="org.ametys.plugins.contentio.synchronize.impl.DefaultSynchronizableContentsCollectionModel" point="org.ametys.plugins.contentio.synchronize.SynchronizeContentsCollectionModelExtensionPoint"> <class name="org.ametys.plugins.contentio.synchronize.impl.StaticSynchronizableContentsCollection"/> <label i18n="false">Static SCC</label> <description i18n="false">Static SCC</description> </extension>
And it's also possible to declare a synchronization button on the content:
<extension id="fr.ametys.myproject.scc.static.SynchronizePerson" point="org.ametys.core.ui.RibbonControlsManager" class="org.ametys.plugins.contentio.synchronize.clientsideelement.SCCSmartContentClientSideElement"> <class name="Ametys.plugins.cms.content.controller.SmartContentController"> <action>Ametys.plugins.contentio.search.SynchronizeContentAction.act</action> <sccModelId>fr.ametys.myproject.scc.static</sccModelId> <label type="false">Synchroniser le contenu</label> <description type="false">Synchronisation du contenu</description> <field-label>Login</field-label> <selection-target-id>^content$</selection-target-id> <selection-target-parameter> <name>^types$</name> <value>^org.ametys.plugins.odf.Content.person$</value> </selection-target-parameter> <selection-enable-multiselection>false</selection-enable-multiselection> <icon-glyph>ametysicon-arrow123</icon-glyph> <selection-description-empty type="i18n">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_NOCONTENT</selection-description-empty> <selection-description-nomatch type="i18n">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_NOCONTENT</selection-description-nomatch> <selection-description-multiselectionforbidden type="i18n">plugin.cms:CONTENT_EDIT_DESCRIPTION_MANYCONTENT</selection-description-multiselectionforbidden> <allright-start-description type="i18n">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_START</allright-start-description> <allright-end-description type="i18n">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_CONTENT_END</allright-end-description> <allright-content-description type="i18n">plugin.contentio:PLUGINS_CONTENTIO_BUTTON_SYNCHRONIZE_CONTENT</allright-content-description> <error-description type="i18n">plugin.cms:CONTENT_EDIT_DESCRIPTION_ERROR</error-description> <enabled-on-unlock-only>true</enabled-on-unlock-only> <locked-start-description type="i18n">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_START</locked-start-description> <locked-end-description type="i18n">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_END</locked-end-description> <locked-content-description type="i18n">plugin.cms:CONTENT_EDIT_DESCRIPTION_LOCKED_CONTENT</locked-content-description> </class> <scripts> <file plugin="cms">js/Ametys/plugins/cms/content/controller/SmartContentController.js</file> <file plugin="contentio">js/Ametys/plugins/contentio/search/SynchronizeContentAction.js</file> </scripts> <depends> <org.ametys.core.ui.UIToolsFactoriesManager>uitool-server-logs</org.ametys.core.ui.UIToolsFactoriesManager> </depends> </extension>
And a tool to search and import a single content:
<extension id="fr.ametys.myproject.scc.static.Import" point="org.ametys.core.ui.RibbonControlsManager" class="org.ametys.plugins.contentio.synchronize.clientsideelement.SCCClientSideElement"> <class name="Ametys.ribbon.element.ui.button.OpenToolButtonController"> <opentool-id>uitool-scc-import</opentool-id> <sccModelId>fr.ametys.myproject.scc.static</sccModelId> <label type="false">Importer un contenu</label> <description type="false">Import d'un contenu</description> <icon-glyph>ametysicon-body-people</icon-glyph> <icon-decorator>decorator-ametysicon-upload119</icon-decorator> <icon-decorator-type>action-create</icon-decorator-type> </class> <depends> <org.ametys.core.ui.UIToolsFactoriesManager>uitool-scc-import</org.ametys.core.ui.UIToolsFactoriesManager> </depends> </extension>
-
Field Summary
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_contentHelper, _synchronizingContentOperatorEP
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_contentWorkflowHelper, _currentUserProvider, _hasGlobalError, _i18nUtils, _nbCreatedContents, _nbDeletedContents, _nbError, _nbNotChangedContents, _nbSynchronizedContents, _observationManager, SCC_UNIQUE_ID
Fields inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_checkCollection, _compatibleSCC, _contentDAO, _contentPrefix, _contentType, _contentTypeEP, _id, _ignoreRestrictions, _initialActionId, _label, _languages, _modelId, _modelParamValues, _removalSync, _reportMails, _resolver, _restrictedField, _sccHelper, _searchModelConfiguration, _synchronizeActionId, _synchronizeExistingContentsOnly, _synchronizingContentOperator, _validateActionId, _validateAfterImport, _workflowName
Fields inherited from interface org.ametys.plugins.contentio.synchronize.SynchronizableContentsCollection
COLLECTION_ID_DATA_NAME, LAST_SYNCHRONIZATION_DATA_NAME, LAST_SYNCHRONIZATION_USER_DATA_NAME, RESULT_NB_CREATED_CONTENTS, RESULT_NB_DELETED_CONTENTS, RESULT_NB_NOT_CHANGED_CONTENTS, RESULT_NB_SYNCHRONIZED_CONTENTS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the mapping of the current SCC based on results.protected void
configureDataSource
(Configuration configuration) Configure the data source parameters.protected void
Configure the search model used by SCCSearchTool.getLocalAndExternalFields
(Map<String, Object> additionalParameters) Get the path of tri-state fields (with local and external values)getRemoteValues
(Map<String, Object> searchParameters, Logger logger) Search values and return the result organized by attributesputIdParameter
(String syncCode) Set search parameters for the ID value.search
(Map<String, Object> searchParameters, int offset, int limit, List<Object> sort, Logger logger) Search the data to import from parameters.Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_addEditInputsForSCC, _editContent, _fillContent, _getContentsToRemove, _getEditInputs, _getEditInputsContextParameters, _handleContent, _importContent, _importOrSynchronizeContent, _importOrSynchronizeContent, _importOrSynchronizeContents, _importOrSynchronizeContents, _internalPopulate, _isHandled, _synchronizeContent, _transformRemoteValues, configure, createContentAction, getAdditionalAttributeValues, getContent, getNotSynchronizedRelatedContentIds, getTotalCount, getTransformedRemoteValues, importContent, internalSearch, populate, service, synchronizeContent, updateSyncInformations, validateContent
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_deleteContents, _getAdditionalInputsForContentCreation, _getContentPathQuery, _getExpressionsList, _hasSomethingChanged, _internalPopulate, _isParamNotEmpty, _logSynchronizationResult, _removeEmptyParameters, _removeSCCOrDeleteContents, createContentAction, deleteUnexistingContents, empty, getSynchronizationResult, sendErrorMail, validateContent
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_parseMultipleValuesConf, _parseParameters, _transformRemoteValuesCardinality, checkCollection, configureStaticParams, getCompatibleSCC, getContentPrefix, getContentType, getId, getInitialActionId, getLabel, getLanguages, getParameterValues, getReportMails, getRestrictedField, getSearchModelConfiguration, getSynchronizeActionId, getSynchronizeCollectionModelId, getSynchronizingContentOperator, getValidateActionId, getWorkflowName, ignoreRestrictions, removalSync, synchronizeExistingContentsOnly, validateAfterImport
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.plugins.contentio.synchronize.SynchronizableContentsCollection
additionalCommonOperations, additionalImportOperations, additionalSynchronizeOperations, getIdField, handleRightAssignmentContext
-
Constructor Details
-
AbstractDefaultSynchronizableContentsCollection
-
-
Method Details
-
getLocalAndExternalFields
Description copied from interface:SynchronizableContentsCollection
Get the path of tri-state fields (with local and external values)- Parameters:
additionalParameters
- Additional parameters- Returns:
- the synchronized fields
-
putIdParameter
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Set search parameters for the ID value.- Specified by:
putIdParameter
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
syncCode
- Value to search- Returns:
- Map with the search parameters
-
getRemoteValues
protected Map<String,Map<String, getRemoteValuesList<Object>>> (Map<String, Object> searchParameters, Logger logger) Description copied from class:AbstractSimpleSynchronizableContentsCollection
Search values and return the result organized by attributes- Specified by:
getRemoteValues
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
searchParameters
- Search parameters to restrict the searchlogger
- The logger- Returns:
- Map of results organized by attributes.
-
search
public Map<String,Map<String, searchObject>> (Map<String, Object> searchParameters, int offset, int limit, List<Object> sort, Logger logger) Description copied from interface:SynchronizableContentsCollection
Search the data to import from parameters.- Specified by:
search
in interfaceSynchronizableContentsCollection
- Overrides:
search
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
searchParameters
- Parameters for the searchoffset
- Begin of the searchlimit
- Number of resultssort
- Sort of results (ignored for LDAP results)logger
- The logger- Returns:
- A map of remote values by content
-
configureDataSource
Description copied from class:AbstractStaticSynchronizableContentsCollection
Configure the data source parameters.- Specified by:
configureDataSource
in classAbstractStaticSynchronizableContentsCollection
- Parameters:
configuration
- Configuration to read- Throws:
ConfigurationException
- If an error occurs
-
configureSearchModel
Description copied from class:AbstractStaticSynchronizableContentsCollection
Configure the search model used by SCCSearchTool.- Specified by:
configureSearchModel
in classAbstractStaticSynchronizableContentsCollection
-
_getMapping
Get the mapping of the current SCC based on results. Default implementation is key -> List.of(key).- Parameters:
results
- The results- Returns:
- the mapping based on results (if needed)
-