Package org.ametys.core.user.population
Class PopulationContextHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.user.population.PopulationContextHelper
- All Implemented Interfaces:
LogEnabled,Initializable,Component,Serviceable
- Direct Known Subclasses:
PopulationContextHelper,SitePopulationContextHelper
public class PopulationContextHelper
extends AbstractLogEnabled
implements Component, Serviceable, Initializable
Helper for associating
UserPopulations to contexts.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringThe id of right for administration accessprotected static final StringThe name of the JDBC table for user populations by contextprotected ServiceManagerThe service managerstatic final StringThe "admin" contextstatic final StringThe name of request attribute holding the current population contextsstatic final StringAvalon Role -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the cacheGet the cache as mapprotected CurrentUserProviderGet the current user providerprotected ObservationManagerGet the observation managerprotected RightManagerGet the right managerprotected ConnectionGet the connection to the databaseprotected UserPopulationDAOGet the DAO for user populationsgetUserPopulationsOnContext(String context, boolean withDisabled) Gets the populations linked to the given context (need the population to be enabled)getUserPopulationsOnContexts(Collection<String> contexts, boolean withDisabled) Gets the populations linked to at least one of the given contexts (need the population to be enabled)getUserPopulationsOnContexts(Collection<String> contexts, boolean withDisabled, boolean checkRights) Gets the populations linked to at least one of the given contexts (need the population to be enabled)voidbooleanReturns true if the user population is linked to a context.link(String context, Collection<String> ids) Links given populations to a context.voidservice(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon Role -
POPULATION_CONTEXTS_REQUEST_ATTR
The name of request attribute holding the current population contexts- See Also:
-
ADMIN_CONTEXT
The "admin" context- See Also:
-
__USER_POPULATIONS_TABLE
The name of the JDBC table for user populations by context- See Also:
-
__ADMIN_RIGHT_ACCESS
The id of right for administration access- See Also:
-
_manager
The service manager
-
-
Constructor Details
-
PopulationContextHelper
public PopulationContextHelper()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
getObservationManager
Get the observation manager- Returns:
- the
-
getUserPopulationDAO
Get the DAO for user populations- Returns:
- the DAO for user populations
-
getCurrentUserProvider
Get the current user provider- Returns:
- the current user provider
-
getRightManager
Get the right manager- Returns:
- the right manager
-
getSQLConnection
Get the connection to the database- Returns:
- the SQL connection
-
link
Links given populations to a context.- Parameters:
context- The contextids- The ids of the populations to link- Returns:
- The ids of the changed user populations (the ones unlinked and the ones linked)
-
getUserPopulationsOnContext
Gets the populations linked to the given context (need the population to be enabled)- Parameters:
context- The contextwithDisabled- True to also return disabled populations- Returns:
- The ids of populations linked to the context
-
getUserPopulationsOnContexts
public Set<String> getUserPopulationsOnContexts(Collection<String> contexts, boolean withDisabled, boolean checkRights) Gets the populations linked to at least one of the given contexts (need the population to be enabled)- Parameters:
contexts- The contextswithDisabled- True to also return disabled populationscheckRights- True to check that current user belongs to one of populations or is an administrator user- Returns:
- The ids of populations linked to the contexts
-
getUserPopulationsOnContexts
Gets the populations linked to at least one of the given contexts (need the population to be enabled)- Parameters:
contexts- The contextswithDisabled- True to also return disabled populations- Returns:
- The ids of populations linked to the contexts
-
_getCache
Get the cache- Returns:
- Non null cache
-
_getCacheAsMap
Get the cache as map- Returns:
- Non null cache
-
isLinked
Returns true if the user population is linked to a context.- Parameters:
upId- The id of the user population- Returns:
- True if the user population is currently linked to a context.
-