Package ch.tocco.nice2.businessunit.api
Interface BusinessUnitManager
- All Known Implementing Classes:
BusinessUnitManagerImpl
public interface BusinessUnitManager
-
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
Deprecated.void
void
setDefaultBusinessUnit
(String principal, @Nullable BusinessUnit preferredBusinessUnit) Sets the default business unit for the specified principal only if no current business unit is found.void
switchBusinessUnit
(BusinessUnit bu, boolean saveChange) Sets the specified business unit to the current thread and triggers all necessary updates (re-login).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
.
-
Method Details
-
setDefaultBusinessUnit
void setDefaultBusinessUnit(String principal, @Nullable @Nullable BusinessUnit preferredBusinessUnit) 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.- Parameters:
principal
- the username of the principal
-
withBusinessUnit
Get an invoker to execute something with a certain business unit.- Parameters:
bu
- the desired business unit.- Returns:
- the invoker.
- See Also:
-
withBusinessUnitOfEntity
Get an invoker to execute something with the business unit of the given entity.- Parameters:
entity
- the business unit dependent entity.- Returns:
- the invoker.
-
withNullBusinessUnit
Invoker withNullBusinessUnit()Get an invoker to execute something with theBusinessUnit.NULL_BUSINESS_UNIT
.- Returns:
- the invoker.
-
withoutBusinessUnitInterceptor
Invoker withoutBusinessUnitInterceptor()- 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
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. -
hasBusinessUnit
- Parameters:
entity
- entity- Returns:
- true if the entity-model has a business unit
-
getBusinessUnit
Returns the business unit of the provided entity. Throws aIllegalArgumentException
if the provided entity is not business-unit dependent.- Parameters:
entity
- a entity- Returns:
- the business unit of the provided entity
-
getBusinessUnits
Returns all business units that the principal is associated to. -
getBusinessUnits
Returns all business units that the principal is associated to by the specified roleId.- Parameters:
principal
- thePrincipal
roleId
- theunique_id
of the role
-
getAllBusinessUnits
List<BusinessUnit> getAllBusinessUnits()- Returns:
- all business units (except the
BusinessUnit.NULL_BUSINESS_UNIT
)
-
getBusinessUnitById
Returns the business unit of the specified unique_id. -
setBusinessUnit
Deprecated.usewithBusinessUnit(BusinessUnitChange)
instead, enabling the `noLogin` optionSets the specified business unit to the current thread overwriting any existing one! It does NOT re-login the principal.- Parameters:
bu
- new business unit to set
-
getCurrentBusinessUnit
BusinessUnit getCurrentBusinessUnit()Returns the business unit of the current thread orBusinessUnit.NULL_BUSINESS_UNIT
if none exists. -
getBusinessUnitEntity
Returns the Business_unit entity that is corresponding to a given BusinessUnit object if it contains a PrimaryKey- Returns:
- Business_unit entity
-
getCurrentBusinessUnitEntity
Returns the Business_unit entity that is corresponding to the current BusinessUnit if the current BusinessUnit contains a PrimaryKey.- Returns:
- Business_unit entity
-
setBusinessUnitContext
-
getBusinessUnitContext
-
withBusinessUnit(BusinessUnitChange)
instead, enabling the `noLogin` option