Package org.cyclos.impl.system
Class BaseOwnedImageServiceImpl<O extends BaseEntity & ImageOwner<O,I>,I extends OwnedImage<O>,A extends com.querydsl.core.types.EntityPath<I>,NP extends IEntity>
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.system.BaseImageServiceImpl<I,A,NP>
-
- org.cyclos.impl.system.BaseCategorizedImageServiceImpl<I,O,A,NP>
-
- org.cyclos.impl.system.BaseOwnedImageServiceImpl<O,I,A,NP>
-
- All Implemented Interfaces:
BaseCategorizedImageServiceLocal<I,O,NP>,BaseImageServiceLocal<I,NP>,BaseOwnedImageServiceLocal<O,I,NP>,Service,BaseCategorizedImageService<NP>,BaseImageService<NP>,BaseOwnedImageService<NP>
- Direct Known Subclasses:
AdImageServiceImpl,BaseSingleOwnedImageServiceImpl,ImportedImageServiceImpl,UserImageServiceImpl
public abstract class BaseOwnedImageServiceImpl<O extends BaseEntity & ImageOwner<O,I>,I extends OwnedImage<O>,A extends com.querydsl.core.types.EntityPath<I>,NP extends IEntity> extends BaseCategorizedImageServiceImpl<I,O,A,NP> implements BaseOwnedImageServiceLocal<O,I,NP>
Base service implementation for owned images. Owned images are categorized images whose category is the owner.
-
-
Field Summary
Fields Modifier and Type Field Description protected BeanHandlerbeanHandlerprotected TempImageServiceLocaltempImageService-
Fields inherited from class org.cyclos.impl.system.BaseCategorizedImageServiceImpl
categoryPath, categoryType
-
Fields inherited from class org.cyclos.impl.system.BaseImageServiceImpl
$, imageHandler, imageType, nature, storedFileHandler
-
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 BaseOwnedImageServiceImpl(ImageNature nature, Class<O> ownerType, Class<I> imageType, A $, com.querydsl.core.types.dsl.EntityPathBase<O> ownerPath)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcustomizeListByCategoryQuery(DBQuery<?> query, O category)Sub-classes can override this method to customize the query used to list the images by category.protected voiddoAddImage(O owner, I image)Common implementation for those owner having multiple images (users / ads)LongimportTempImage(O owner, TempImage tempImage)Imports the given temporary image, returning the new image identifierList<Long>importTempImages(O owner, List<TempImage> tempImages)Imports all the given temporary images, returning the new image identifiersprotected booleanisCategoryActive(O owner)The default implementation assumes the image category is active.protected abstract booleanisTempValid(O owner, TempImage temp)Must be implemented to return whether the given temporary image is valid for the given ownerInewImage(NP ownerVO)Returns a new image for the given parametersprotected intnewOrder(O owner)Returns the order an image should have when added to the given ownerprotected voidonAfterRemove(I image)May be overridden in order to take actions after remove an imageprotected voidonAfterSave(I image)May be overridden in order to take action after save an imageprotected voidonBeforeRemove(I image)May be overridden in order to take actions before remove an imageprotected voidonOrderChanged(O owner)Callback method called when images order has changedprotected voidphysicallyAddImage(O owner, I image)Physically add the given image to the ownerintremoveAll(O owner)Removes all images of the given categoryvoidsaveOrder(NP ownerVO, List<Long> imageIds)Saves the images orderprotected voidsetFirstImage(I image, O owner, Supplier<Boolean> mustSetGuard)This method MUST be used instead of directly set the image to the owner.-
Methods inherited from class org.cyclos.impl.system.BaseCategorizedImageServiceImpl
count, findCategory, getListData, isRequired, list, listByCategory, remove, resolveMaxImages, save, toCategory, validateMaxImages, validateMaxImages
-
Methods inherited from class org.cyclos.impl.system.BaseImageServiceImpl
find, findByKey, getImageNature, isKeepOriginalContent, readContent, readContentByKey, remove, removeAll, saveName, setDataAndPersist, setImageName
-
Methods inherited from class org.cyclos.impl.BaseServiceImpl
initializeNetworkMappings, registerNetworkMappings
-
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, 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.system.BaseCategorizedImageService
getListData, list
-
Methods inherited from interface org.cyclos.impl.system.BaseCategorizedImageServiceLocal
listByCategory
-
Methods inherited from interface org.cyclos.services.system.BaseImageService
remove, removeAll, save, saveName
-
Methods inherited from interface org.cyclos.impl.system.BaseImageServiceLocal
find, getImageNature, readContent, readContentByKey
-
-
-
-
Field Detail
-
beanHandler
@Autowired protected BeanHandler beanHandler
-
tempImageService
@Autowired protected TempImageServiceLocal tempImageService
-
-
Method Detail
-
importTempImage
public Long importTempImage(O owner, TempImage tempImage)
Description copied from interface:BaseOwnedImageServiceLocalImports the given temporary image, returning the new image identifier- Specified by:
importTempImagein interfaceBaseOwnedImageServiceLocal<O extends BaseEntity & ImageOwner<O,I>,I extends OwnedImage<O>,A extends com.querydsl.core.types.EntityPath<I>>
-
importTempImages
public List<Long> importTempImages(O owner, List<TempImage> tempImages)
Description copied from interface:BaseOwnedImageServiceLocalImports all the given temporary images, returning the new image identifiers- Specified by:
importTempImagesin interfaceBaseOwnedImageServiceLocal<O extends BaseEntity & ImageOwner<O,I>,I extends OwnedImage<O>,A extends com.querydsl.core.types.EntityPath<I>>
-
newImage
public I newImage(NP ownerVO)
Description copied from class:BaseImageServiceImplReturns a new image for the given parameters- Overrides:
newImagein classBaseCategorizedImageServiceImpl<I extends OwnedImage<O>,O extends BaseEntity & ImageOwner<O,I>,A extends com.querydsl.core.types.EntityPath<I>,NP extends IEntity>
-
removeAll
public int removeAll(O owner)
Description copied from interface:BaseCategorizedImageServiceLocalRemoves all images of the given category- Specified by:
removeAllin interfaceBaseCategorizedImageServiceLocal<O extends BaseEntity & ImageOwner<O,I>,I extends OwnedImage<O>,A extends com.querydsl.core.types.EntityPath<I>>- Overrides:
removeAllin classBaseCategorizedImageServiceImpl<I extends OwnedImage<O>,O extends BaseEntity & ImageOwner<O,I>,A extends com.querydsl.core.types.EntityPath<I>,NP extends IEntity>
-
saveOrder
public final void saveOrder(NP ownerVO, List<Long> imageIds) throws FrameworkException
Description copied from interface:BaseOwnedImageServiceSaves the images order- Specified by:
saveOrderin interfaceBaseOwnedImageService<O extends BaseEntity & ImageOwner<O,I>>- Throws:
FrameworkException
-
customizeListByCategoryQuery
protected void customizeListByCategoryQuery(DBQuery<?> query, O category)
Description copied from class:BaseCategorizedImageServiceImplSub-classes can override this method to customize the query used to list the images by category.- Overrides:
customizeListByCategoryQueryin classBaseCategorizedImageServiceImpl<I extends OwnedImage<O>,O extends BaseEntity & ImageOwner<O,I>,A extends com.querydsl.core.types.EntityPath<I>,NP extends IEntity>
-
doAddImage
protected void doAddImage(O owner, I image)
Common implementation for those owner having multiple images (users / ads)
-
isCategoryActive
protected boolean isCategoryActive(O owner)
The default implementation assumes the image category is active.- Specified by:
isCategoryActivein classBaseCategorizedImageServiceImpl<I extends OwnedImage<O>,O extends BaseEntity & ImageOwner<O,I>,A extends com.querydsl.core.types.EntityPath<I>,NP extends IEntity>
-
isTempValid
protected abstract boolean isTempValid(O owner, TempImage temp)
Must be implemented to return whether the given temporary image is valid for the given owner
-
newOrder
protected int newOrder(O owner)
Returns the order an image should have when added to the given owner
-
onAfterRemove
protected void onAfterRemove(I image)
Description copied from class:BaseImageServiceImplMay be overridden in order to take actions after remove an image- Overrides:
onAfterRemovein classBaseImageServiceImpl<I extends OwnedImage<O>,A extends com.querydsl.core.types.EntityPath<I>,NP extends IEntity>
-
onAfterSave
protected void onAfterSave(I image)
Description copied from class:BaseImageServiceImplMay be overridden in order to take action after save an image- Overrides:
onAfterSavein classBaseImageServiceImpl<I extends OwnedImage<O>,A extends com.querydsl.core.types.EntityPath<I>,NP extends IEntity>
-
onBeforeRemove
protected void onBeforeRemove(I image)
Description copied from class:BaseImageServiceImplMay be overridden in order to take actions before remove an image- Overrides:
onBeforeRemovein classBaseImageServiceImpl<I extends OwnedImage<O>,A extends com.querydsl.core.types.EntityPath<I>,NP extends IEntity>
-
onOrderChanged
protected void onOrderChanged(O owner)
Callback method called when images order has changed
-
physicallyAddImage
protected void physicallyAddImage(O owner, I image)
Physically add the given image to the owner
-
setFirstImage
protected void setFirstImage(I image, O owner, Supplier<Boolean> mustSetGuard)
This method MUST be used instead of directly set the image to the owner. It supports concurrent modification of the owner entity using a lock (LockType.IMAGE_OWNER). If the image is directly set using theImageOwner.setImage(OwnedImage)method then anOptimisticLockExceptioncould happens.- Parameters:
image- the image to be set. Could be null.mustSetGuard- The image will be set only if the given boolean supplier returns true. Take into account this guard will be invoked twice if the first time it returns true (one before entering the critical section and the other after the lock was acquired).
-
-