Package org.cyclos.impl.users
Class UserAddressServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.CRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
- org.cyclos.impl.users.UserAddressServiceImpl
-
- All Implemented Interfaces:
CRUDServiceLocal<UserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>,UserAddressServiceLocal,CRUDService<UserAddressDTO,UserAddressData,UserAddressDataParams>,CRUDWithConfirmationPasswordService<UserAddressDTO,UserAddressData,UserAddressDataParams>,Service,UserAddressService
@Service public class UserAddressServiceImpl extends CRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams> implements UserAddressServiceLocal
Implementation forUserAddressService
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.CRUDServiceImpl
$, ATTR_CURRENT_COPY, cacheHandler, 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, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description UserAddressServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddCustomNameValidations(Property name, UserAddressDTO namedDTO)This method may be overridden to add custom validations for the NAME property.voidappendValidations(Validator validator, AddressDTO address, ConfigurationAccessor configuration, boolean nameRequired)Append validation of address fields to the given validatorvoidcleanDisabledAddressFields(IAddress address, ConfigurationAccessor configuration)Sets null to the disabled address fields according to the given configurationprotected voiddoRemove(UserAddress address, boolean flush)May be overridden in order to perform logical removing, instead of physical removing, or to remove some extra relationships as wellList<UserAddressVO>getAddresses(User user, boolean visibleOnly, boolean locatedOnly)Returns all the user addresses or only the visible or located onesUserAddressListDatagetAddressListData(UserLocatorVO locator)Returns all the user addresses.protected UserAddressDatagetData(UserAddress address)Returns details data for the given entityUserAddressgetDefaultUserAddress(User user)Returns the user default address or null if none existsprotected CreateDeviceConfirmationParamsgetDeviceConfirmationParams(UserAddressDTO dto, UserAddress entity, CRUDOperation operation)If the confirmation password must be checked then subclasses must overwrite this method to return a no-nullCreateDeviceConfirmationParamsobject.protected Object[]getExcludedPropertiesToEntity(UserAddressDTO dto)May be overridden in order to exclude properties when converting the given DTO to entitySearchByDistanceDatagetSearchByDistanceData()Returns data for the logged user to search by distanceValidatorgetValidator(AddressDTO address, Group group, boolean nameRequired)Validate a userAddressDTO instance when a userAddress is being validated outside this service (for examplePublicRegistrationRemoteServiceImplList<UserAddress>listByUser(User user)Returns all user addresses for the given uservoidmarkAsDefault(Long id)Marks the given address as default for it's ownerbooleanmaxAddressesReached(User user)Returns whether the given has reached the limit of allowed addressesUserAddressnewEntity(UserAddressDataParams params)Should be implemented in order to instantiate a new entity based on the given context parametersprotected voidonAfterRemove(UserAddress address)May be overridden in order to perform custom logic after removing an entityprotected voidonAfterSave(UserAddress address, UserAddress currentCopy, Object dataFromOnBeforeSave)May be overridden in order to perform custom logic after saving an entityprotected voidonBeforeRemove(UserAddress address)May be overridden in order to perform custom logic before removing an entityprotected ObjectonBeforeSave(UserAddress address, UserAddress currentCopy)May be overridden in order to perform custom logic before saving an entity.protected voidpreProcessCurrentCopy(UserAddressDTO dto, UserAddress currentCopy)This method is invoked before saving the entity and also, if the log is enabled, before removing.protected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkvoidremoveAll(User user)Removes all addresses of the given userprotected ExtensionPointAccessorresolveExtensionPointAccessor(CRUDOperation operation, UserAddress address)Should be overridden by subclasses which have extension pointsprotected ValidatorresolveValidator(UserAddressDTO dto)protected booleanshouldCheckConfirmationPassword(UserAddress entity, CRUDOperation operation)Controls whether confirmation password should be checked for the given entity and operation.UserAddresstoEntity(UserAddressDTO dto)Converts the given DTO in an entity, handling theCRUDServiceImpl.subClassMappings()mappings for subclasses-
Methods inherited from class org.cyclos.impl.CRUDServiceImpl
addCustomInternalNameValidations, checkConfirmationPassword, find, findAll, from, getConfirmationPasswordInput, getConfirmationPasswordInputForRemove, getData, getDataForNew, getEntityClass, getEntityInternalNameKey, getExcludedPropertiesToDTO, getNameLabel, getUniqueInternalNameQuery, getUniqueNameQuery, isEntityInternalNameRequired, isNameRequired, load, logEntity, remove, remove, removeAll, removeAll, removeAllWithConfirmationPassword, removeWithConfirmationPassword, resolveDTOType, resolveEntityType, save, saveOrder, saveSkippingEntityLog, saveWithConfirmationPassword, subClassMappings, toDTO, 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, toDTO, validate
-
Methods inherited from interface org.cyclos.services.CRUDWithConfirmationPasswordService
getConfirmationPasswordInputForRemove, removeAllWithConfirmationPassword, removeWithConfirmationPassword, saveWithConfirmationPassword
-
-
-
-
Method Detail
-
appendValidations
public void appendValidations(Validator validator, AddressDTO address, ConfigurationAccessor configuration, boolean nameRequired)
Description copied from interface:UserAddressServiceLocalAppend validation of address fields to the given validator- Specified by:
appendValidationsin interfaceUserAddressServiceLocal
-
cleanDisabledAddressFields
public void cleanDisabledAddressFields(IAddress address, ConfigurationAccessor configuration)
Description copied from interface:UserAddressServiceLocalSets null to the disabled address fields according to the given configuration- Specified by:
cleanDisabledAddressFieldsin interfaceUserAddressServiceLocal
-
getAddresses
public List<UserAddressVO> getAddresses(User user, boolean visibleOnly, boolean locatedOnly)
Description copied from interface:UserAddressServiceLocalReturns all the user addresses or only the visible or located ones- Specified by:
getAddressesin interfaceUserAddressServiceLocal
-
getAddressListData
public UserAddressListData getAddressListData(UserLocatorVO locator)
Description copied from interface:UserAddressServiceReturns all the user addresses. If the logged user manages the given user, the hidden addresses will be also returned.- Specified by:
getAddressListDatain interfaceUserAddressService
-
getDefaultUserAddress
public UserAddress getDefaultUserAddress(User user) throws FrameworkException
Description copied from interface:UserAddressServiceLocalReturns the user default address or null if none exists- Specified by:
getDefaultUserAddressin interfaceUserAddressServiceLocal- Throws:
FrameworkException
-
getSearchByDistanceData
public SearchByDistanceData getSearchByDistanceData() throws FrameworkException
Description copied from interface:UserAddressServiceLocalReturns data for the logged user to search by distance- Specified by:
getSearchByDistanceDatain interfaceUserAddressServiceLocal- Throws:
FrameworkException
-
getValidator
public Validator getValidator(AddressDTO address, Group group, boolean nameRequired)
Validate a userAddressDTO instance when a userAddress is being validated outside this service (for examplePublicRegistrationRemoteServiceImpl- Specified by:
getValidatorin interfaceUserAddressServiceLocal
-
listByUser
public List<UserAddress> listByUser(User user)
Description copied from interface:UserAddressServiceLocalReturns all user addresses for the given user- Specified by:
listByUserin interfaceUserAddressServiceLocal
-
markAsDefault
public void markAsDefault(Long id) throws FrameworkException
Description copied from interface:UserAddressServiceMarks the given address as default for it's owner- Specified by:
markAsDefaultin interfaceUserAddressService- Throws:
FrameworkException
-
maxAddressesReached
public boolean maxAddressesReached(User user) throws FrameworkException
Description copied from interface:UserAddressServiceLocalReturns whether the given has reached the limit of allowed addresses- Specified by:
maxAddressesReachedin interfaceUserAddressServiceLocal- Throws:
FrameworkException
-
newEntity
public UserAddress newEntity(UserAddressDataParams params)
Description copied from class:CRUDServiceImplShould be implemented in order to instantiate a new entity based on the given context parameters- Specified by:
newEntityin interfaceCRUDServiceLocal<UserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>- Specified by:
newEntityin classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
removeAll
public void removeAll(User user)
Description copied from interface:UserAddressServiceLocalRemoves all addresses of the given user- Specified by:
removeAllin interfaceUserAddressServiceLocal
-
toEntity
public UserAddress toEntity(UserAddressDTO dto)
Description copied from class:CRUDServiceImplConverts the given DTO in an entity, handling theCRUDServiceImpl.subClassMappings()mappings for subclasses- Specified by:
toEntityin interfaceCRUDServiceLocal<UserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>- Overrides:
toEntityin classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
addCustomNameValidations
protected void addCustomNameValidations(Property name, UserAddressDTO namedDTO)
Description copied from class:CRUDServiceImplThis method may be overridden to add custom validations for the NAME property.- Overrides:
addCustomNameValidationsin classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
doRemove
protected void doRemove(UserAddress address, 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<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
getData
protected UserAddressData getData(UserAddress address)
Description copied from class:CRUDServiceImplReturns details data for the given entity- Specified by:
getDatain classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
getDeviceConfirmationParams
protected CreateDeviceConfirmationParams getDeviceConfirmationParams(UserAddressDTO dto, UserAddress entity, CRUDOperation operation)
Description copied from class:CRUDServiceImplIf the confirmation password must be checked then subclasses must overwrite this method to return a no-nullCreateDeviceConfirmationParamsobject. This object is required to validate the confirmation when the operation was confirmed with a device.- Overrides:
getDeviceConfirmationParamsin classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>- Parameters:
dto- , it can be null, subclasses must take it into account. E.g: to disable a mobile phone for SMS, the confirmation password must be check and for this case there is no DTO instance.entity- never null, represents the current value (i.e before apply the dto).
-
getExcludedPropertiesToEntity
protected Object[] getExcludedPropertiesToEntity(UserAddressDTO dto)
Description copied from class:CRUDServiceImplMay be overridden in order to exclude properties when converting the given DTO to entity- Overrides:
getExcludedPropertiesToEntityin classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
onAfterRemove
protected void onAfterRemove(UserAddress address)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic after removing an entity- Overrides:
onAfterRemovein classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
onAfterSave
protected void onAfterSave(UserAddress address, UserAddress currentCopy, Object dataFromOnBeforeSave)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic after saving an entity- Overrides:
onAfterSavein classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
onBeforeRemove
protected void onBeforeRemove(UserAddress address)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic before removing an entity- Overrides:
onBeforeRemovein classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
onBeforeSave
protected Object onBeforeSave(UserAddress address, UserAddress 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<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
preProcessCurrentCopy
protected void preProcessCurrentCopy(UserAddressDTO dto, UserAddress currentCopy)
Description copied from class:CRUDServiceImplThis method is invoked before saving the entity and also, if the log is enabled, before removing. Subclasses can override it to fetch lazy relationships, etc as the current copy will be detached. In case of removing (i.e the log is enabled for this entity) the dto parameter will be null.- Overrides:
preProcessCurrentCopyin classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
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
-
resolveExtensionPointAccessor
protected ExtensionPointAccessor resolveExtensionPointAccessor(CRUDOperation operation, UserAddress address)
Description copied from class:CRUDServiceImplShould be overridden by subclasses which have extension points- Overrides:
resolveExtensionPointAccessorin classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
resolveValidator
protected Validator resolveValidator(UserAddressDTO dto)
- Specified by:
resolveValidatorin classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
shouldCheckConfirmationPassword
protected boolean shouldCheckConfirmationPassword(UserAddress entity, CRUDOperation operation)
Description copied from class:CRUDServiceImplControls whether confirmation password should be checked for the given entity and operation. By default returns true if this service indirectly implementsCRUDWithConfirmationPasswordService(for example, if the remote service interface extends it).- Overrides:
shouldCheckConfirmationPasswordin classCRUDServiceImpl<UserAddress,QUserAddress,UserAddressDTO,UserAddressData,UserAddressDataParams>
-
-