Package org.cyclos.impl.users
Class GroupServiceImpl
-
- All Implemented Interfaces:
CRUDServiceLocal<BasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>,GroupServiceLocal,CRUDService<BasicGroupDTO,BasicGroupData,BasicGroupNature>,CRUDWithConfirmationPasswordService<BasicGroupDTO,BasicGroupData,BasicGroupNature>,Service,GroupService
@Service public class GroupServiceImpl extends CRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature> implements GroupServiceLocal
implementation forGroupService. Note that methods for retrieving collections of groups are to be placed inGroupsHandler.
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.CRUDServiceImpl
$, ATTR_CURRENT_COPY, dtoClass, entityClass, extensionPointService, idPath, internalNamePath, namePath, ownerEntityIdPath, ownerEntityPath, ownerEntityPropertyName, passwordHandler, richTextHandler, withConfirmationPassword
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description GroupServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanChangeEnabled(Group group)Returns true if the group enabled attribute can be changed.booleancanManage(BasicGroup group)Returns whether the group can be managed by the logged userbooleancanView(BasicGroup group)Returns whether the group can be viewed by the logged uservoidchangeConfiguration(BasicGroupVO basicGroupVO, ConfigurationVO configurationVO)Changes the configuration for the specified BasicGroup by assigning a new Configuration.AdminGroupcreateNetworkAdmins(Network network)Creates the network administrators group for the given networkprotected voiddoRemove(BasicGroup entity, boolean flush)May be overridden in order to perform logical removing, instead of physical removing, or to remove some extra relationships as wellGroupfindByName(String name)Find a group by nameActiveConfigurationForGroupsDatagetActiveConfiguration(BasicGroupVO basicGroupVO)Returns theActiveConfigurationForGroupsData, containing all the actual configuration for the given group or group setList<AdminGroup>getAdminGroups()Return all enabled admin groups.Set<BasicGroup>getBasicUserGroups()Returns all enabled groups (including GroupSets) but excluding admin in the system In case groupsets are included, all of the groups contained in that groupset are also automatically included.protected BasicGroupDatagetData(BasicGroup basicGroup)Returns details data for the given entityList<BasicGroup>getGroupsUsingConfiguration(Configuration configuration)Returns all groups which are associated with the given configurationList<BasicGroup>getGroupsUsingProduct(Product product)Returns all groups which are associated to the given productGroupSearchDatagetSearchData()Returns the data for searching groupsAdminGroupgetSystemAdmins()Returns the default admins group, that is, either global admins if in global mode, or the current network admins otherwiseBooleanhasUsers(BasicGroup basicGroup)returns true if there are users in the basic groupCollection<BasicGroup>listEntities(BasicGroupQuery params)List group entities that satisfy the given conditionsBasicGroupnewEntity(BasicGroupNature nature)Should be implemented in order to instantiate a new entity based on the given context parametersprotected voidonAfterRemove(BasicGroup entity)May be overridden in order to perform custom logic after removing an entityprotected voidonAfterSave(BasicGroup entity, BasicGroup currentCopy, Object dataFromOnBeforeSave)May be overridden in order to perform custom logic after saving an entityprotected voidonBeforeRemove(BasicGroup basicGroup)May be overridden in order to perform custom logic before removing an entityprotected ObjectonBeforeSave(BasicGroup group, BasicGroup currentCopy)May be overridden in order to perform custom logic before saving an entity.protected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkprotected ValidatorresolveValidator(BasicGroupDTO dto)Page<BasicGroupVO>search(BasicGroupQuery params)Searches for groups, returning results hierarchicallyprotected org.apache.commons.collections4.BidiMap<Class<? extends BasicGroup>,Class<? extends BasicGroupDTO>>subClassMappings()Should be overridden by subclasses which handle entity / dto hierarchies.BasicGroupDTOtoDTO(BasicGroup entity)Converts the given entity in a DTO, handling theCRUDServiceImpl.subClassMappings()mappings for subclassesBasicGrouptoEntity(BasicGroupDTO dto)Converts the given DTO in an entity, handling theCRUDServiceImpl.subClassMappings()mappings for subclasses-
Methods inherited from class org.cyclos.impl.CRUDServiceImpl
addCustomInternalNameValidations, addCustomNameValidations, checkConfirmationPassword, find, findAll, from, getConfirmationPasswordInput, getConfirmationPasswordInputForRemove, getData, getDataForNew, getDeviceConfirmationParams, getEntityClass, getEntityInternalNameKey, getExcludedPropertiesToDTO, getExcludedPropertiesToEntity, getNameLabel, getUniqueInternalNameQuery, getUniqueNameQuery, isEntityInternalNameRequired, isNameRequired, load, logEntity, preProcessCurrentCopy, remove, remove, removeAll, removeAll, removeAllWithConfirmationPassword, removeWithConfirmationPassword, resolveDTOType, resolveEntityType, resolveExtensionPointAccessor, save, saveOrder, saveSkippingEntityLog, saveWithConfirmationPassword, shouldCheckConfirmationPassword, validate
-
Methods inherited from class org.cyclos.impl.BaseServiceImpl
initializeNetworkMappings
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, delete, detach, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.services.CRUDService
getData, getDataForNew, load, remove, removeAll, save
-
Methods inherited from interface org.cyclos.impl.CRUDServiceLocal
find, findAll, getEntityClass, remove, removeAll, saveEntity, saveSkippingEntityLog, validate
-
-
-
-
Method Detail
-
canChangeEnabled
public boolean canChangeEnabled(Group group)
Description copied from interface:GroupServiceLocalReturns true if the group enabled attribute can be changed. It can be changed if all the users in the group are removed or the group has no users.- Specified by:
canChangeEnabledin interfaceGroupServiceLocal
-
canManage
public boolean canManage(BasicGroup group)
Description copied from interface:GroupServiceLocalReturns whether the group can be managed by the logged user- Specified by:
canManagein interfaceGroupServiceLocal
-
canView
public boolean canView(BasicGroup group)
Description copied from interface:GroupServiceLocalReturns whether the group can be viewed by the logged user- Specified by:
canViewin interfaceGroupServiceLocal
-
changeConfiguration
public void changeConfiguration(BasicGroupVO basicGroupVO, ConfigurationVO configurationVO)
Description copied from interface:GroupServiceChanges the configuration for the specified BasicGroup by assigning a new Configuration. As a result, the configuration formerly assigned is not assigned anymore to the group.- Specified by:
changeConfigurationin interfaceGroupService
-
createNetworkAdmins
public AdminGroup createNetworkAdmins(Network network) throws FrameworkException
Description copied from interface:GroupServiceLocalCreates the network administrators group for the given network- Specified by:
createNetworkAdminsin interfaceGroupServiceLocal- Throws:
FrameworkException
-
findByName
public Group findByName(String name)
Description copied from interface:GroupServiceLocalFind a group by name- Specified by:
findByNamein interfaceGroupServiceLocal
-
getActiveConfiguration
public ActiveConfigurationForGroupsData getActiveConfiguration(BasicGroupVO basicGroupVO) throws EntityNotFoundException
Description copied from interface:GroupServiceReturns theActiveConfigurationForGroupsData, containing all the actual configuration for the given group or group set- Specified by:
getActiveConfigurationin interfaceGroupService- Throws:
EntityNotFoundException
-
getAdminGroups
public List<AdminGroup> getAdminGroups()
Description copied from interface:GroupServiceLocalReturn all enabled admin groups.- Specified by:
getAdminGroupsin interfaceGroupServiceLocal
-
getBasicUserGroups
public Set<BasicGroup> getBasicUserGroups()
Description copied from interface:GroupServiceLocalReturns all enabled groups (including GroupSets) but excluding admin in the system In case groupsets are included, all of the groups contained in that groupset are also automatically included.- Specified by:
getBasicUserGroupsin interfaceGroupServiceLocal
-
getGroupsUsingConfiguration
public List<BasicGroup> getGroupsUsingConfiguration(Configuration configuration) throws FrameworkException
Description copied from interface:GroupServiceLocalReturns all groups which are associated with the given configuration- Specified by:
getGroupsUsingConfigurationin interfaceGroupServiceLocal- Throws:
FrameworkException
-
getGroupsUsingProduct
public List<BasicGroup> getGroupsUsingProduct(Product product)
Description copied from interface:GroupServiceLocalReturns all groups which are associated to the given product- Specified by:
getGroupsUsingProductin interfaceGroupServiceLocal
-
getSearchData
public GroupSearchData getSearchData()
Description copied from interface:GroupServiceReturns the data for searching groups- Specified by:
getSearchDatain interfaceGroupService
-
getSystemAdmins
public AdminGroup getSystemAdmins() throws FrameworkException
Description copied from interface:GroupServiceLocalReturns the default admins group, that is, either global admins if in global mode, or the current network admins otherwise- Specified by:
getSystemAdminsin interfaceGroupServiceLocal- Throws:
FrameworkException
-
hasUsers
public Boolean hasUsers(BasicGroup basicGroup)
Description copied from interface:GroupServiceLocalreturns true if there are users in the basic group- Specified by:
hasUsersin interfaceGroupServiceLocal
-
listEntities
public Collection<BasicGroup> listEntities(BasicGroupQuery params)
Description copied from interface:GroupServiceLocalList group entities that satisfy the given conditions- Specified by:
listEntitiesin interfaceGroupServiceLocal
-
newEntity
public BasicGroup newEntity(BasicGroupNature nature)
Description copied from class:CRUDServiceImplShould be implemented in order to instantiate a new entity based on the given context parameters- Specified by:
newEntityin interfaceCRUDServiceLocal<BasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>- Specified by:
newEntityin classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
search
public Page<BasicGroupVO> search(BasicGroupQuery params)
Description copied from interface:GroupServiceSearches for groups, returning results hierarchically- Specified by:
searchin interfaceGroupService
-
toDTO
public BasicGroupDTO toDTO(BasicGroup entity)
Converts the given entity in a DTO, handling theCRUDServiceImpl.subClassMappings()mappings for subclasses
Note that the method takes the entity's accessibleBasicGroups property, and divides this over the DTO's accessibleUserGroups property and the DTO's accessibleAdminGroups property. Also Note that the userGroups are flattened, so entities having only a GroupSet in accessibleBasicGroups turn out with a DTO having bothe the GroupSet and its containing groups in the accessibleBasicGroups.- Specified by:
toDTOin interfaceCRUDServiceLocal<BasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>- Overrides:
toDTOin classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
toEntity
public BasicGroup toEntity(BasicGroupDTO dto)
Description copied from class:CRUDServiceImplConverts the given DTO in an entity, handling theCRUDServiceImpl.subClassMappings()mappings for subclasses- Specified by:
toEntityin interfaceCRUDServiceLocal<BasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>- Overrides:
toEntityin classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
doRemove
protected void doRemove(BasicGroup entity, boolean flush)
Description copied from class:CRUDServiceImplMay be overridden in order to perform logical removing, instead of physical removing, or to remove some extra relationships as well- Overrides:
doRemovein classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
getData
protected BasicGroupData getData(BasicGroup basicGroup)
Description copied from class:CRUDServiceImplReturns details data for the given entity- Specified by:
getDatain classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
onAfterRemove
protected void onAfterRemove(BasicGroup entity)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic after removing an entity- Overrides:
onAfterRemovein classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
onAfterSave
protected void onAfterSave(BasicGroup entity, BasicGroup currentCopy, Object dataFromOnBeforeSave)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic after saving an entity- Overrides:
onAfterSavein classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
onBeforeRemove
protected void onBeforeRemove(BasicGroup basicGroup)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic before removing an entity- Overrides:
onBeforeRemovein classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
onBeforeSave
protected Object onBeforeSave(BasicGroup group, BasicGroup currentCopy)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic before saving an entity. Any returned value will be passed to theCRUDServiceImpl.onAfterSave(BaseEntity, BaseEntity, Object)method- Overrides:
onBeforeSavein classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
registerNetworkMappings
protected void registerNetworkMappings(NetworkPathRegistry networkPathRegistry)
Description copied from class:BaseServiceImplNeeds to be overridden by subclasses to register the path up to the network- Specified by:
registerNetworkMappingsin classBaseServiceImpl
-
resolveValidator
protected Validator resolveValidator(BasicGroupDTO dto)
- Specified by:
resolveValidatorin classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
subClassMappings
protected org.apache.commons.collections4.BidiMap<Class<? extends BasicGroup>,Class<? extends BasicGroupDTO>> subClassMappings()
Description copied from class:CRUDServiceImplShould be overridden by subclasses which handle entity / dto hierarchies. The map key should be the entity class, while the map value, the DTO class- Overrides:
subClassMappingsin classCRUDServiceImpl<BasicGroup,QBasicGroup,BasicGroupDTO,BasicGroupData,BasicGroupNature>
-
-