Package ch.tocco.nice2.businessunit.impl
Class BusinessUnitManagerImpl
java.lang.Object
ch.tocco.nice2.businessunit.impl.BusinessUnitManagerImpl
- All Implemented Interfaces:
BusinessUnitManager
-
Constructor Summary
ConstructorsConstructorDescriptionBusinessUnitManagerImpl(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 BusinessUnitgetBusinessUnitById(String buId) Returns the business unit of the specified unique_id.@Nullable BusinessUnitHoldergetBusinessUnitEntity(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_UNITif none exists.Returns the Business_unit entity that is corresponding to the current BusinessUnit if the current BusinessUnit contains a PrimaryKey.booleanhasBusinessUnit(Entity entity) voidSets the specified business unit to the current thread overwriting any existing one! It does NOT re-login the principal.voidvoidsetDefaultBusinessUnit(String principal, BusinessUnit preferredBusinessUnit) Sets the default business unit for the specified principal only if no current business unit is found.voidsetListeners(List<BusinessUnitChangeListener> listeners) voidswitchBusinessUnit(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:BusinessUnitManagerSets 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:
setDefaultBusinessUnitin interfaceBusinessUnitManager- Parameters:
principal- the username of the principal
-
withBusinessUnit
Description copied from interface:BusinessUnitManagerGet an invoker to execute something with a certain business unit.- Specified by:
withBusinessUnitin interfaceBusinessUnitManager- Parameters:
buChange- the desired business unit.- Returns:
- the invoker.
- See Also:
-
withBusinessUnitOfEntity
Description copied from interface:BusinessUnitManagerGet an invoker to execute something with the business unit of the given entity.- Specified by:
withBusinessUnitOfEntityin interfaceBusinessUnitManager- Parameters:
entity- the business unit dependent entity.- Returns:
- the invoker.
-
withNullBusinessUnit
Description copied from interface:BusinessUnitManagerGet an invoker to execute something with theBusinessUnit.NULL_BUSINESS_UNIT.- Specified by:
withNullBusinessUnitin interfaceBusinessUnitManager- Returns:
- the invoker.
-
withoutBusinessUnitInterceptor
- Specified by:
withoutBusinessUnitInterceptorin 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:BusinessUnitManagerSets 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:
switchBusinessUnitin interfaceBusinessUnitManager
-
hasBusinessUnit
- Specified by:
hasBusinessUnitin interfaceBusinessUnitManager- Parameters:
entity- entity- Returns:
- true if the entity-model has a business unit
-
getBusinessUnit
Description copied from interface:BusinessUnitManagerReturns the business unit of the provided entity. Throws aIllegalArgumentExceptionif the provided entity is not business-unit dependent.- Specified by:
getBusinessUnitin interfaceBusinessUnitManager- Parameters:
entity- a entity- Returns:
- the business unit of the provided entity
-
getBusinessUnits
Description copied from interface:BusinessUnitManagerReturns all business units that the principal is associated to.- Specified by:
getBusinessUnitsin interfaceBusinessUnitManager
-
getBusinessUnits
Description copied from interface:BusinessUnitManagerReturns all business units that the principal is associated to by the specified roleId.- Specified by:
getBusinessUnitsin interfaceBusinessUnitManager- Parameters:
principal- thePrincipalroleId- theunique_idof the role
-
getAllBusinessUnits
- Specified by:
getAllBusinessUnitsin interfaceBusinessUnitManager- Returns:
- all business units (except the
BusinessUnit.NULL_BUSINESS_UNIT)
-
getBusinessUnitById
Description copied from interface:BusinessUnitManagerReturns the business unit of the specified unique_id.- Specified by:
getBusinessUnitByIdin interfaceBusinessUnitManager
-
setBusinessUnit
Description copied from interface:BusinessUnitManagerSets the specified business unit to the current thread overwriting any existing one! It does NOT re-login the principal.- Specified by:
setBusinessUnitin interfaceBusinessUnitManager- Parameters:
bu- new business unit to set
-
getCurrentBusinessUnit
Description copied from interface:BusinessUnitManagerReturns the business unit of the current thread orBusinessUnit.NULL_BUSINESS_UNITif none exists.- Specified by:
getCurrentBusinessUnitin interfaceBusinessUnitManager
-
getBusinessUnitEntity
Description copied from interface:BusinessUnitManagerReturns the Business_unit entity that is corresponding to a given BusinessUnit object if it contains a PrimaryKey- Specified by:
getBusinessUnitEntityin interfaceBusinessUnitManager- Returns:
- Business_unit entity
-
getCurrentBusinessUnitEntity
Description copied from interface:BusinessUnitManagerReturns the Business_unit entity that is corresponding to the current BusinessUnit if the current BusinessUnit contains a PrimaryKey.- Specified by:
getCurrentBusinessUnitEntityin interfaceBusinessUnitManager- Returns:
- Business_unit entity
-
getBusinessUnitContext
- Specified by:
getBusinessUnitContextin interfaceBusinessUnitManager
-
setBusinessUnitContext
- Specified by:
setBusinessUnitContextin interfaceBusinessUnitManager
-