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
UserPopulation
s to contexts.-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
The id of right for administration accessprotected static final String
The name of the JDBC table for user populations by contextprotected ServiceManager
The service managerstatic final String
The "admin" contextstatic final String
The name of request attribute holding the current population contextsstatic final String
Avalon Role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the cacheGet the cache as mapprotected CurrentUserProvider
Get the current user providerprotected ObservationManager
Get the observation managerprotected RightManager
Get the right managerprotected Connection
Get the connection to the databaseprotected UserPopulationDAO
Get 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)void
boolean
Returns true if the user population is linked to a context.link
(String context, Collection<String> ids) Links given populations to a context.void
service
(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:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in 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.
-