Class SQLSynchronizableUDOrgunitCollection
- 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.AbstractDataSourceSynchronizableContentsCollection
-
- org.ametys.plugins.contentio.synchronize.impl.SQLSynchronizableContentsCollection
-
- org.ametys.plugins.userdirectory.synchronize.SQLSynchronizableUDOrgunitCollection
-
- All Implemented Interfaces:
SynchronizableContentsCollection
,Component
,Configurable
,Serviceable
public class SQLSynchronizableUDOrgunitCollection extends SQLSynchronizableContentsCollection
Synchronizable collection for UD Orgunits
-
-
Field Summary
Fields Modifier and Type Field Description protected DeleteOrgUnitComponent
_deleteOrgUnitComponent
The delete orgUnit componentprotected Integer
_nbSynchronizedOrgUnit
Number of updated contents for parent-child org unit relationprotected OrganisationChartPageHandler
_orgChartPageHandler
The organisation chart page handlerprotected Map<String,String>
_orgUnitParents
The map which link orgunit with this parentprotected Map<String,String>
_orgUnitRemoteIds
The map which link orgunit with sql remote idsprotected OutgoingReferencesExtractor
_outgoingReferencesExtractor
The OutgoingReferences extractorprotected SQLUserSearchDAO
_sqlUserDAO
The sql user search DAOprotected CurrentUserProvider
_userProvider
The current user providerprotected Map<String,Map<String,String>>
_usersByOrgUnitId
The map which link users (userId and role) to their orgunitsstatic String
ORGUNIT_REMOTE_ID_INTERNAL_DATA
The internal data name for orgUnit remote sql idstatic String
RESULT_NB_SYNCHRONIZED_ORGUNITS_RELATIONS
The result map key for number of deleted contents-
Fields inherited from class org.ametys.plugins.contentio.synchronize.impl.SQLSynchronizableContentsCollection
_sqlCollectionDAO
-
Fields inherited from class org.ametys.plugins.contentio.synchronize.impl.AbstractDataSourceSynchronizableContentsCollection
__PARAM_DATASOURCE_ID, __PARAM_FIELD_ID, __PARAM_MAPPING, __PARAM_MAPPING_ATTRIBUTE, __PARAM_MAPPING_METADATA_REF, __PARAM_MAPPING_SYNCHRO, _columnsAndCriteria, _jsonUtils, _mapping, _syncFields
-
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
_contentDAO, _contentPrefix, _contentType, _contentTypeEP, _id, _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, RESULT_NB_CREATED_CONTENTS, RESULT_NB_DELETED_CONTENTS, RESULT_NB_NOT_CHANGED_CONTENTS, RESULT_NB_SYNCHRONIZED_CONTENTS
-
-
Constructor Summary
Constructors Constructor Description SQLSynchronizableUDOrgunitCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
_deleteContents(List<Content> contentsToRemove, org.slf4j.Logger logger)
Delete contents.protected Content
_getOrgUnitContentFromRemoteId(String remoteId, String lang, org.slf4j.Logger logger)
Get orgunit content from the remote Idprotected List<Map<String,Object>>
_getOrgUnitUsers(String orgUnitId, String lang)
Retrieves the users of the given orgunitprotected Map<String,Object>
_getSearchParameters(Map<String,Object> parameters, int offset, int limit, List<Object> sort, List<String> columns)
Get the parameters map for mybatis searchprotected Map<String,Object>
_getSearchUserParameters(String orgUnitColumnKey, org.slf4j.Logger logger)
Get the parameters map for user mybatis searchprotected Optional<Triple<String,String,String>>
_getUserByOrgUnit(String orgUnitKey, String loginColumnName, String roleColumnName, Map<String,Object> normalizedUser, org.slf4j.Logger logger)
Retrieves aTriple
containing the orgunit id, and the user's login and role for the given normalized userprotected Content
_getUserContent(String loginValue, String lang)
Get user content from login valueprotected Map<String,Map<String,String>>
_getUsersByOrgUnit(org.slf4j.Logger logger)
Retrieves the user attributes for all org unitsprotected boolean
_hasSomethingChanged()
Checks if some content have changed during the synchronizationprotected Optional<ModifiableContent>
_importOrSynchronizeContent(String idValue, String lang, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)
Imports or synchronizes a content for a given languageprotected List<ModifiableContent>
_internalPopulate(org.slf4j.Logger logger)
Internal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)
protected void
_logSynchronizationResult(org.slf4j.Logger logger)
Logs the result of the synchronization, containing The number of created contents The number of synchronized contents The number of unchanged contents The number of deleted contentsprotected void
_setContentsRelationWithParentOrgunit(List<ModifiableContent> orgUnitContents, org.slf4j.Logger logger)
Set all orgunit parents relation for each synchronized contentContentSynchronizationResult
additionalCommonOperations(ModifiableContent content, Map<String,Object> additionalParameters, org.slf4j.Logger logger)
Add specific fields to the content during import or synchronization.protected Map<String,Object>
getAdditionalAttributeValues(String idValue, Content content, Map<String,Object> additionalParameters, boolean create, org.slf4j.Logger logger)
Retrieves additional values to synchronize for a contentString
getLoginUserAttributeName()
Get the login user attribute nameString
getLoginUserColumnName()
Get the login user column nameString
getOrgunitJoinColumnNameForUser()
Get the name of the orgunit join column name of the user tableString
getOrgUnitRemoteIdColumnName()
Get the orgunit remote id column nameString
getRoleUserColumnName()
Get the role user column nameMap<String,Integer>
getSynchronizationResult()
Retrieves the result of the synchronization as a map of key / content count containing The number of created contents The number of synchronized contents The number of unchanged contents The number of deleted contentsString
getUserSortColumnName()
Get the user sort column nameString
getUserTableName()
Get the name of user SQL tableboolean
handleRightAssignmentContext()
Return true if aRightAssignmentContext
should be automatically generated for the contents of this SCCprotected Map<String,Map<String,Object>>
internalSearch(Map<String,Object> searchParameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Search values and return the result without any treatment.boolean
isUserSortPrevail()
True if the SQL sort for users prevailvoid
service(ServiceManager smanager)
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.impl.SQLSynchronizableContentsCollection
_checkIdObjectValue, _getNormalizedSearchResult, _getTotalCounParameters, _normalizeSearchResult, getTableName, getTotalCount
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.impl.AbstractDataSourceSynchronizableContentsCollection
configureDataSource, configureSearchModel, getDataSourceId, getIdField, getLocalAndExternalFields, getMapping, getRemoteValues, putIdParameter
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSimpleSynchronizableContentsCollection
_editContent, _fillContent, _getContentsToRemove, _handleContent, _importContent, _importOrSynchronizeContent, _importOrSynchronizeContents, _isHandled, _synchronizeContent, _transformRemoteValues, configure, createContentAction, getContent, getNotSynchronizedRelatedContentIds, getTransformedRemoteValues, importContent, populate, search, synchronizeContent, updateSyncInformations, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractSynchronizableContentsCollection
_getAdditionalInputsForContentCreation, _getContentPathQuery, _getExpressionsList, _isParamNotEmpty, _removeEmptyParameters, createContentAction, deleteUnexistingContents, empty, sendErrorMail, validateContent
-
Methods inherited from class org.ametys.plugins.contentio.synchronize.AbstractStaticSynchronizableContentsCollection
_parseLanguages, _parseParameters, _transformRemoteValuesCardinality, configureStaticParams, getContentPrefix, getContentType, getId, getInitialActionId, getLabel, getLanguages, getParameterValues, getReportMails, getRestrictedField, getSearchModelConfiguration, getSynchronizeActionId, getSynchronizeCollectionModelId, getSynchronizingContentOperator, getValidateActionId, getWorkflowName, 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
additionalImportOperations, additionalSynchronizeOperations
-
-
-
-
Field Detail
-
ORGUNIT_REMOTE_ID_INTERNAL_DATA
public static final String ORGUNIT_REMOTE_ID_INTERNAL_DATA
The internal data name for orgUnit remote sql id- See Also:
- Constant Field Values
-
RESULT_NB_SYNCHRONIZED_ORGUNITS_RELATIONS
public static final String RESULT_NB_SYNCHRONIZED_ORGUNITS_RELATIONS
The result map key for number of deleted contents- See Also:
- Constant Field Values
-
_orgUnitParents
protected Map<String,String> _orgUnitParents
The map which link orgunit with this parent
-
_usersByOrgUnitId
protected Map<String,Map<String,String>> _usersByOrgUnitId
The map which link users (userId and role) to their orgunits
-
_orgUnitRemoteIds
protected Map<String,String> _orgUnitRemoteIds
The map which link orgunit with sql remote ids
-
_nbSynchronizedOrgUnit
protected Integer _nbSynchronizedOrgUnit
Number of updated contents for parent-child org unit relation
-
_sqlUserDAO
protected SQLUserSearchDAO _sqlUserDAO
The sql user search DAO
-
_orgChartPageHandler
protected OrganisationChartPageHandler _orgChartPageHandler
The organisation chart page handler
-
_userProvider
protected CurrentUserProvider _userProvider
The current user provider
-
_outgoingReferencesExtractor
protected OutgoingReferencesExtractor _outgoingReferencesExtractor
The OutgoingReferences extractor
-
_deleteOrgUnitComponent
protected DeleteOrgUnitComponent _deleteOrgUnitComponent
The delete orgUnit component
-
-
Constructor Detail
-
SQLSynchronizableUDOrgunitCollection
public SQLSynchronizableUDOrgunitCollection()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classSQLSynchronizableContentsCollection
- Throws:
ServiceException
-
handleRightAssignmentContext
public boolean handleRightAssignmentContext()
Description copied from interface:SynchronizableContentsCollection
Return true if aRightAssignmentContext
should be automatically generated for the contents of this SCC- Returns:
- true to automatically generate a
RightAssignmentContext
. Return false if the rights of contents of this SCC are handle by its ownRightAssignmentContext
-
getUserTableName
public String getUserTableName()
Get the name of user SQL table- Returns:
- The user SQL table name
-
getOrgunitJoinColumnNameForUser
public String getOrgunitJoinColumnNameForUser()
Get the name of the orgunit join column name of the user table- Returns:
- The name of the orgunit join column name
-
getLoginUserAttributeName
public String getLoginUserAttributeName()
Get the login user attribute name- Returns:
- The login user attribute name
-
getLoginUserColumnName
public String getLoginUserColumnName()
Get the login user column name- Returns:
- The login user column name
-
getRoleUserColumnName
public String getRoleUserColumnName()
Get the role user column name- Returns:
- The role user column name
-
getUserSortColumnName
public String getUserSortColumnName()
Get the user sort column name- Returns:
- The user sort column name
-
getOrgUnitRemoteIdColumnName
public String getOrgUnitRemoteIdColumnName()
Get the orgunit remote id column name- Returns:
- The orgunit remote id column name
-
isUserSortPrevail
public boolean isUserSortPrevail()
True if the SQL sort for users prevail- Returns:
- true if the SQL sort for users prevail
-
_getSearchParameters
protected Map<String,Object> _getSearchParameters(Map<String,Object> parameters, int offset, int limit, List<Object> sort, List<String> columns)
Description copied from class:SQLSynchronizableContentsCollection
Get the parameters map for mybatis search- Overrides:
_getSearchParameters
in classSQLSynchronizableContentsCollection
- Parameters:
parameters
- the filter parameteroffset
- the offsetlimit
- the limitsort
- the sort mapcolumns
- the list of columns- Returns:
- the parameter map
-
internalSearch
protected Map<String,Map<String,Object>> internalSearch(Map<String,Object> searchParameters, int offset, int limit, List<Object> sort, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Search values and return the result without any treatment.- Overrides:
internalSearch
in classSQLSynchronizableContentsCollection
- Parameters:
searchParameters
- Search parameters to restrict the searchoffset
- Begin of the searchlimit
- Number of resultssort
- Sort of results (ignored for LDAP results)logger
- The logger- Returns:
- Map of results without any treatment.
-
_logSynchronizationResult
protected void _logSynchronizationResult(org.slf4j.Logger logger)
Description copied from class:AbstractSynchronizableContentsCollection
Logs the result of the synchronization, containing- The number of created contents
- The number of synchronized contents
- The number of unchanged contents
- The number of deleted contents
- Overrides:
_logSynchronizationResult
in classAbstractSynchronizableContentsCollection
- Parameters:
logger
- the logger
-
_hasSomethingChanged
protected boolean _hasSomethingChanged()
Description copied from class:AbstractSynchronizableContentsCollection
Checks if some content have changed during the synchronization- Overrides:
_hasSomethingChanged
in classAbstractSynchronizableContentsCollection
- Returns:
true
if some contents have changed,false
otherwise
-
_internalPopulate
protected List<ModifiableContent> _internalPopulate(org.slf4j.Logger logger)
Description copied from class:AbstractSynchronizableContentsCollection
Internal implementation ofAbstractSynchronizableContentsCollection.populate(Logger)
- Overrides:
_internalPopulate
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
logger
- The logger- Returns:
- The list of created/synchronized contents
-
_getUsersByOrgUnit
protected Map<String,Map<String,String>> _getUsersByOrgUnit(org.slf4j.Logger logger)
Retrieves the user attributes for all org units- Parameters:
logger
- The logger- Returns:
- the org units' users
-
_getUserByOrgUnit
protected Optional<Triple<String,String,String>> _getUserByOrgUnit(String orgUnitKey, String loginColumnName, String roleColumnName, Map<String,Object> normalizedUser, org.slf4j.Logger logger)
Retrieves aTriple
containing the orgunit id, and the user's login and role for the given normalized user- Parameters:
orgUnitKey
- the orgUnit keyloginColumnName
- the login column nameroleColumnName
- the role column namenormalizedUser
- the normalized userlogger
- the logger- Returns:
- the user info as a
Triple
-
_importOrSynchronizeContent
protected Optional<ModifiableContent> _importOrSynchronizeContent(String idValue, String lang, Map<String,List<Object>> remoteValues, boolean forceImport, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Imports or synchronizes a content for a given language- Overrides:
_importOrSynchronizeContent
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
idValue
- The unique identifier of the contentlang
- The language of content to import or synchronizeremoteValues
- The remote valuesforceImport
- To force import and ignoring the synchronize existing contents only optionlogger
- The logger- Returns:
- The imported or synchronized content
-
additionalCommonOperations
public ContentSynchronizationResult additionalCommonOperations(ModifiableContent content, Map<String,Object> additionalParameters, org.slf4j.Logger logger)
Description copied from interface:SynchronizableContentsCollection
Add specific fields to the content during import or synchronization.- Parameters:
content
- Content to updateadditionalParameters
- Additional parameterslogger
- The logger- Returns:
- The synchronization result of the additional operations
-
getAdditionalAttributeValues
protected Map<String,Object> getAdditionalAttributeValues(String idValue, Content content, Map<String,Object> additionalParameters, boolean create, org.slf4j.Logger logger)
Description copied from class:AbstractSimpleSynchronizableContentsCollection
Retrieves additional values to synchronize for a content- Overrides:
getAdditionalAttributeValues
in classAbstractSimpleSynchronizableContentsCollection
- Parameters:
idValue
- id value of the contentcontent
- The contentadditionalParameters
- Additional parameterscreate
-true
if the content has been newly created,false
otherwiselogger
- The logger- Returns:
- the values to add
-
_getOrgUnitUsers
protected List<Map<String,Object>> _getOrgUnitUsers(String orgUnitId, String lang)
Retrieves the users of the given orgunit- Parameters:
orgUnitId
- the orgunit identifierlang
- the language of the orgunit- Returns:
- the users linked to the given orgunit
-
_setContentsRelationWithParentOrgunit
protected void _setContentsRelationWithParentOrgunit(List<ModifiableContent> orgUnitContents, org.slf4j.Logger logger)
Set all orgunit parents relation for each synchronized content- Parameters:
orgUnitContents
- the synchronized contentlogger
- the logger
-
_getUserContent
protected Content _getUserContent(String loginValue, String lang)
Get user content from login value- Parameters:
loginValue
- the login valuelang
- the language- Returns:
- the user content
-
_getOrgUnitContentFromRemoteId
protected Content _getOrgUnitContentFromRemoteId(String remoteId, String lang, org.slf4j.Logger logger)
Get orgunit content from the remote Id- Parameters:
remoteId
- the remote Idlang
- the languagelogger
- the logger- Returns:
- the orgunit content
-
_getSearchUserParameters
protected Map<String,Object> _getSearchUserParameters(String orgUnitColumnKey, org.slf4j.Logger logger)
Get the parameters map for user mybatis search- Parameters:
orgUnitColumnKey
- the column name of the orgunit keylogger
- the logger- Returns:
- the parameter map
-
_deleteContents
protected int _deleteContents(List<Content> contentsToRemove, org.slf4j.Logger logger)
Description copied from class:AbstractSynchronizableContentsCollection
Delete contents.- Overrides:
_deleteContents
in classAbstractSynchronizableContentsCollection
- Parameters:
contentsToRemove
- List of contents to removelogger
- The logger- Returns:
- the number of deleted contents
-
getSynchronizationResult
public Map<String,Integer> getSynchronizationResult()
Description copied from interface:SynchronizableContentsCollection
Retrieves the result of the synchronization as a map of key / content count containing- The number of created contents
- The number of synchronized contents
- The number of unchanged contents
- The number of deleted contents
- Specified by:
getSynchronizationResult
in interfaceSynchronizableContentsCollection
- Overrides:
getSynchronizationResult
in classAbstractSynchronizableContentsCollection
- Returns:
- the result of the synchronization
-
-