Package ch.tocco.nice2.businessunit.impl
Class BusinessUnitManagerImpl
java.lang.Object
ch.tocco.nice2.businessunit.impl.BusinessUnitManagerImpl
- All Implemented Interfaces:
BusinessUnitManager
-
Constructor Summary
ConstructorDescriptionBusinessUnitManagerImpl
(org.slf4j.Logger log, Context context, SecurityManager securityManager, PrincipalManager principalManager, CommandExecutor executor) -
Method Summary
Modifier and TypeMethodDescriptiongetBusinessUnit
(Entity entity) Returns the business unit of the provided entity.@Nullable BusinessUnit
getBusinessUnitById
(String buId) Returns the business unit of the specified unique_id.@Nullable BusinessUnitHolder
getBusinessUnitEntity
(BusinessUnit businessUnit) Returns the Business_unit entity that is corresponding to a given BusinessUnit object if it contains a PrimaryKeygetBusinessUnits
(Principal principal) Returns all business units that the principal is associated to.getBusinessUnits
(Principal principal, String roleId) Returns all business units that the principal is associated to by the specified roleId.Returns the business unit of the current thread orBusinessUnit.NULL_BUSINESS_UNIT
if none exists.Returns the Business_unit entity that is corresponding to the current BusinessUnit if the current BusinessUnit contains a PrimaryKey.boolean
hasBusinessUnit
(Entity entity) void
Sets the specified business unit to the current thread overwriting any existing one! It does NOT re-login the principal.void
void
setDefaultBusinessUnit
(String principal, BusinessUnit preferredBusinessUnit) Sets the default business unit for the specified principal only if no current business unit is found.void
setListeners
(List<BusinessUnitChangeListener> listeners) void
switchBusinessUnit
(BusinessUnit bu, boolean saveChange) Sets the specified business unit to the current thread and triggers all necessary updates (re-login).withBusinessUnit
(BusinessUnitChange buChange) Get an invoker to execute something with a certain business unit.withBusinessUnitOfEntity
(Entity entity) Get an invoker to execute something with the business unit of the given entity.Get an invoker to execute something with theBusinessUnit.NULL_BUSINESS_UNIT
.
-
Constructor Details
-
BusinessUnitManagerImpl
public BusinessUnitManagerImpl(org.slf4j.Logger log, @Lazy Context context, @Lazy SecurityManager securityManager, @Lazy PrincipalManager principalManager, @Lazy CommandExecutor executor)
-
-
Method Details
-
setListeners
-
setDefaultBusinessUnit
Description copied from interface:BusinessUnitManager
Sets the default business unit for the specified principal only if no current business unit is found. The business unit is retrieved from the user settings. If not available some business-unit for the principal is set. The default implementation sets the business unit with the lowest primary key. Used after login to apply an initial business unit.- Specified by:
setDefaultBusinessUnit
in interfaceBusinessUnitManager
- Parameters:
principal
- the username of the principal
-
withBusinessUnit
Description copied from interface:BusinessUnitManager
Get an invoker to execute something with a certain business unit.- Specified by:
withBusinessUnit
in interfaceBusinessUnitManager
- Parameters:
buChange
- the desired business unit.- Returns:
- the invoker.
- See Also:
-
withBusinessUnitOfEntity
Description copied from interface:BusinessUnitManager
Get an invoker to execute something with the business unit of the given entity.- Specified by:
withBusinessUnitOfEntity
in interfaceBusinessUnitManager
- Parameters:
entity
- the business unit dependent entity.- Returns:
- the invoker.
-
withNullBusinessUnit
Description copied from interface:BusinessUnitManager
Get an invoker to execute something with theBusinessUnit.NULL_BUSINESS_UNIT
.- Specified by:
withNullBusinessUnit
in interfaceBusinessUnitManager
- Returns:
- the invoker.
-
withoutBusinessUnitInterceptor
- Specified by:
withoutBusinessUnitInterceptor
in interfaceBusinessUnitManager
- Returns:
- an invoker that disables the business unit query interceptor. This means that results from queries always contain results from all business units.
- See Also:
-
switchBusinessUnit
Description copied from interface:BusinessUnitManager
Sets the specified business unit to the current thread and triggers all necessary updates (re-login). This is a permanent change to the given business unit. The `saveChange` parameter controls whether the new business unit is saved in the usersettings.- Specified by:
switchBusinessUnit
in interfaceBusinessUnitManager
-
hasBusinessUnit
- Specified by:
hasBusinessUnit
in interfaceBusinessUnitManager
- Parameters:
entity
- entity- Returns:
- true if the entity-model has a business unit
-
getBusinessUnit
Description copied from interface:BusinessUnitManager
Returns the business unit of the provided entity. Throws aIllegalArgumentException
if the provided entity is not business-unit dependent.- Specified by:
getBusinessUnit
in interfaceBusinessUnitManager
- Parameters:
entity
- a entity- Returns:
- the business unit of the provided entity
-
getBusinessUnits
Description copied from interface:BusinessUnitManager
Returns all business units that the principal is associated to.- Specified by:
getBusinessUnits
in interfaceBusinessUnitManager
-
getBusinessUnits
Description copied from interface:BusinessUnitManager
Returns all business units that the principal is associated to by the specified roleId.- Specified by:
getBusinessUnits
in interfaceBusinessUnitManager
- Parameters:
principal
- thePrincipal
roleId
- theunique_id
of the role
-
getAllBusinessUnits
- Specified by:
getAllBusinessUnits
in interfaceBusinessUnitManager
- Returns:
- all business units (except the
BusinessUnit.NULL_BUSINESS_UNIT
)
-
getBusinessUnitById
Description copied from interface:BusinessUnitManager
Returns the business unit of the specified unique_id.- Specified by:
getBusinessUnitById
in interfaceBusinessUnitManager
-
setBusinessUnit
Description copied from interface:BusinessUnitManager
Sets the specified business unit to the current thread overwriting any existing one! It does NOT re-login the principal.- Specified by:
setBusinessUnit
in interfaceBusinessUnitManager
- Parameters:
bu
- new business unit to set
-
getCurrentBusinessUnit
Description copied from interface:BusinessUnitManager
Returns the business unit of the current thread orBusinessUnit.NULL_BUSINESS_UNIT
if none exists.- Specified by:
getCurrentBusinessUnit
in interfaceBusinessUnitManager
-
getBusinessUnitEntity
Description copied from interface:BusinessUnitManager
Returns the Business_unit entity that is corresponding to a given BusinessUnit object if it contains a PrimaryKey- Specified by:
getBusinessUnitEntity
in interfaceBusinessUnitManager
- Returns:
- Business_unit entity
-
getCurrentBusinessUnitEntity
Description copied from interface:BusinessUnitManager
Returns the Business_unit entity that is corresponding to the current BusinessUnit if the current BusinessUnit contains a PrimaryKey.- Specified by:
getCurrentBusinessUnitEntity
in interfaceBusinessUnitManager
- Returns:
- Business_unit entity
-
getBusinessUnitContext
- Specified by:
getBusinessUnitContext
in interfaceBusinessUnitManager
-
setBusinessUnitContext
- Specified by:
setBusinessUnitContext
in interfaceBusinessUnitManager
-