Package org.cyclos.impl.users
Class ProductServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.CRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
- org.cyclos.impl.users.ProductServiceImpl
-
- All Implemented Interfaces:
CRUDServiceLocal<Product,ProductDTO,ProductData,ProductNature>,ProductServiceLocal,CRUDService<ProductDTO,ProductData,ProductNature>,CRUDWithConfirmationPasswordService<ProductDTO,ProductData,ProductNature>,Service,ProductService
@Service public class ProductServiceImpl extends CRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature> implements ProductServiceLocal
implementation forProductService
-
-
Field Summary
Fields Modifier and Type Field Description protected GroupsHandlerInternalgroupsHandlerInternal-
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 ProductServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanViewProducts()Returns true if the logged user can view productsAdminProductcreateAdminProduct(AdminGroup group)Creates an administrator product which will be default for the given (still transient) adminitrator groupvoidcreateRelationship(Product product, Property<?,?> dtoProperty, SimpleEntity entity)Make sure the given value is related to the given product via a DTO property.protected voidfixPasswordActions(Set<? extends ProductPasswordAction> passwordActions)protected ProductDatagetData(Product product)Returns details data for the given entity<DTO extends ProductDTO>
ProductConversionHandler<? extends Product,DTO,? extends ActiveProductsData>getProductConverter(DTO dto)Returns theProductConversionHandlerfor the given product<P extends Product,DTO extends ProductDTO,AD extends ActiveProductsData>
ProductConversionHandler<P,DTO,AD>getProductConverter(P product)Returns theProductConversionHandlerfor the given productProductSearchDatagetSearchData()Gets data used on the search pageList<MemberProduct>listByAccount(UserAccountType accountType)Returns the products which define the given account typeList<Product>listByRoles(Collection<Role> roles)Lists products by rolesList<Product>listEntities()Returns a list of product entities.ProductnewEntity(ProductNature nature)Should be implemented in order to instantiate a new entity based on the given context parametersprotected voidonAfterRemove(Product entity)May be overridden in order to perform custom logic after removing an entityprotected voidonAfterSave(Product product, Product currentCopy, Object dataFromOnBeforeSave)May be overridden in order to perform custom logic after saving an entityprotected voidonBeforeRemove(Product product)May be overridden in order to perform custom logic before removing an entityprotected ObjectonBeforeSave(Product product, Product currentCopy)May be overridden in order to perform custom logic before saving an entity.UserProductsQueryResultpermissionQuery(Permission... permissions)Returns an object that can apply to a query of users that have one of the given permissionsprotected voidpreProcessCurrentCopy(ProductDTO dto, Product currentCopy)This method is invoked before saving the entity and also, if the log is enabled, before removing.UserProductsQueryResultproductQuery(Collection<? extends Product> products)Returns an object that can apply to a query of users that have one of the given productsprotected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkvoidremoveAllRelationships(Property<?,?> dtoProperty, SimpleEntity entity)For each product related to the given value via DTO path, remove the value from the collection, and, if the collection is empty, remove the corresponding permissionprotected ValidatorresolveValidator(ProductDTO dto)Page<ProductWithUserAccountVO>search(ProductQuery params)Search products according to the specified query parametersprotected org.apache.commons.collections4.BidiMap<Class<? extends Product>,Class<? extends ProductDTO>>subClassMappings()Should be overridden by subclasses which handle entity / dto hierarchies.ActiveProductsDatatoActiveProduct(ProductsAccessor accessor)Converts the given products accessor into anActiveProductsDataProductDTOtoDTO(Product entity)Converts the given entity in a DTO, handling theCRUDServiceImpl.subClassMappings()mappings for subclassesProducttoEntity(ProductDTO dto)Converts the given DTO in an entity, handling theCRUDServiceImpl.subClassMappings()mappings for subclassesvoidupdateProductPasswordActions(PasswordType passwordType)Creates password actions for global admin products when a new password type is created-
Methods inherited from class org.cyclos.impl.CRUDServiceImpl
addCustomInternalNameValidations, addCustomNameValidations, checkConfirmationPassword, doRemove, find, findAll, from, getConfirmationPasswordInput, getConfirmationPasswordInputForRemove, getData, getDataForNew, getDeviceConfirmationParams, getEntityClass, getEntityInternalNameKey, getExcludedPropertiesToDTO, getExcludedPropertiesToEntity, getNameLabel, getUniqueInternalNameQuery, getUniqueNameQuery, isEntityInternalNameRequired, isNameRequired, load, logEntity, 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, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, 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
-
-
-
-
Field Detail
-
groupsHandlerInternal
@Autowired protected GroupsHandlerInternal groupsHandlerInternal
-
-
Method Detail
-
canViewProducts
public boolean canViewProducts()
Description copied from interface:ProductServiceLocalReturns true if the logged user can view products- Specified by:
canViewProductsin interfaceProductServiceLocal
-
createAdminProduct
public AdminProduct createAdminProduct(AdminGroup group)
Description copied from interface:ProductServiceLocalCreates an administrator product which will be default for the given (still transient) adminitrator group- Specified by:
createAdminProductin interfaceProductServiceLocal
-
createRelationship
public void createRelationship(Product product, Property<?,?> dtoProperty, SimpleEntity entity)
Description copied from interface:ProductServiceLocalMake sure the given value is related to the given product via a DTO property. Also makes sure the corresponding permission is set- Specified by:
createRelationshipin interfaceProductServiceLocal
-
getProductConverter
public <DTO extends ProductDTO> ProductConversionHandler<? extends Product,DTO,? extends ActiveProductsData> getProductConverter(DTO dto)
Returns theProductConversionHandlerfor the given product- Specified by:
getProductConverterin interfaceProductServiceLocal
-
getProductConverter
public <P extends Product,DTO extends ProductDTO,AD extends ActiveProductsData> ProductConversionHandler<P,DTO,AD> getProductConverter(P product)
Returns theProductConversionHandlerfor the given product- Specified by:
getProductConverterin interfaceProductServiceLocal
-
getSearchData
public ProductSearchData getSearchData()
Description copied from interface:ProductServiceGets data used on the search page- Specified by:
getSearchDatain interfaceProductService
-
listByAccount
public List<MemberProduct> listByAccount(UserAccountType accountType)
Description copied from interface:ProductServiceLocalReturns the products which define the given account type- Specified by:
listByAccountin interfaceProductServiceLocal
-
listByRoles
public List<Product> listByRoles(Collection<Role> roles)
Description copied from interface:ProductServiceLocalLists products by roles- Specified by:
listByRolesin interfaceProductServiceLocal
-
listEntities
public List<Product> listEntities()
Description copied from interface:ProductServiceLocalReturns a list of product entities.- Specified by:
listEntitiesin interfaceProductServiceLocal
-
newEntity
public Product newEntity(ProductNature 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<Product,ProductDTO,ProductData,ProductNature>- Specified by:
newEntityin classCRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
permissionQuery
public UserProductsQueryResult permissionQuery(Permission... permissions)
Description copied from interface:ProductServiceLocalReturns an object that can apply to a query of users that have one of the given permissions- Specified by:
permissionQueryin interfaceProductServiceLocal
-
productQuery
public UserProductsQueryResult productQuery(Collection<? extends Product> products)
Description copied from interface:ProductServiceLocalReturns an object that can apply to a query of users that have one of the given products- Specified by:
productQueryin interfaceProductServiceLocal
-
removeAllRelationships
public void removeAllRelationships(Property<?,?> dtoProperty, SimpleEntity entity)
Description copied from interface:ProductServiceLocalFor each product related to the given value via DTO path, remove the value from the collection, and, if the collection is empty, remove the corresponding permission- Specified by:
removeAllRelationshipsin interfaceProductServiceLocal
-
search
public Page<ProductWithUserAccountVO> search(ProductQuery params)
Description copied from interface:ProductServiceSearch products according to the specified query parameters- Specified by:
searchin interfaceProductService
-
toActiveProduct
public ActiveProductsData toActiveProduct(ProductsAccessor accessor)
Description copied from interface:ProductServiceLocalConverts the given products accessor into anActiveProductsData- Specified by:
toActiveProductin interfaceProductServiceLocal
-
toDTO
public ProductDTO toDTO(Product entity)
Description copied from class:CRUDServiceImplConverts the given entity in a DTO, handling theCRUDServiceImpl.subClassMappings()mappings for subclasses- Specified by:
toDTOin interfaceCRUDServiceLocal<Product,ProductDTO,ProductData,ProductNature>- Overrides:
toDTOin classCRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
toEntity
public Product toEntity(ProductDTO dto)
Description copied from class:CRUDServiceImplConverts the given DTO in an entity, handling theCRUDServiceImpl.subClassMappings()mappings for subclasses- Specified by:
toEntityin interfaceCRUDServiceLocal<Product,ProductDTO,ProductData,ProductNature>- Overrides:
toEntityin classCRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
updateProductPasswordActions
public void updateProductPasswordActions(PasswordType passwordType)
Description copied from interface:ProductServiceLocalCreates password actions for global admin products when a new password type is created- Specified by:
updateProductPasswordActionsin interfaceProductServiceLocal
-
fixPasswordActions
protected void fixPasswordActions(Set<? extends ProductPasswordAction> passwordActions)
-
getData
protected ProductData getData(Product product)
Description copied from class:CRUDServiceImplReturns details data for the given entity- Specified by:
getDatain classCRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
onAfterRemove
protected void onAfterRemove(Product entity)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic after removing an entity- Overrides:
onAfterRemovein classCRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
onAfterSave
protected void onAfterSave(Product product, Product currentCopy, Object dataFromOnBeforeSave)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic after saving an entity- Overrides:
onAfterSavein classCRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
onBeforeRemove
protected void onBeforeRemove(Product product)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic before removing an entity- Overrides:
onBeforeRemovein classCRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
onBeforeSave
protected Object onBeforeSave(Product product, Product 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<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
preProcessCurrentCopy
protected void preProcessCurrentCopy(ProductDTO dto, Product 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<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
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(ProductDTO dto)
- Specified by:
resolveValidatorin classCRUDServiceImpl<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
subClassMappings
protected org.apache.commons.collections4.BidiMap<Class<? extends Product>,Class<? extends ProductDTO>> 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<Product,QProduct,ProductDTO,ProductData,ProductNature>
-
-