Class FileEntityViewPersistenceAdapter<View extends IFileEntityView, File extends IFileEntity<?,Data> & IFileSizeProviding, Data extends IFileDataEntity<File>, Context>
java.lang.Object
de.xima.fc.logic.filesystem.FileEntityViewPersistenceAdapter<View,File,Data,Context>
- Type Parameters:
View- The type of the view.File- The type of the file entity.Data- The type of the file data entity.Context- The type of the context for the entities.
- All Implemented Interfaces:
ICrudPersistenceAdapter<IEntityContext, View>, IFileDataPersistenceAdapter<IEntityContext, View>, IScopedEntityPersistenceAdapter<IEntityContext, View, Context>, IEntityFileSystemPersistenceAdapter<IEntityContext, View, Context>, Serializable
- Direct Known Subclasses:
FormThemeFileViewPersistenceAdapter
public abstract class FileEntityViewPersistenceAdapter<View extends IFileEntityView, File extends IFileEntity<?,Data> & IFileSizeProviding, Data extends IFileDataEntity<File>, Context>
extends Object
implements IEntityFileSystemPersistenceAdapter<IEntityContext, View, Context>
A
file entity adapter for a view of a file entity.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedFileEntityViewPersistenceAdapter(Class<View> dtoClass, Class<File> fileEntityType, Class<Data> fileDataEntityType) Creates afile entity adapterfor a generalfile entity. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddSelectCriteria(de.xima.cmn.criteria.AttributeSelectCriteriaManager acm) Adds additional select criteria for extra attributes needed to construct the view.protected voidaddUpdateCriteria(IEntityContext ec, de.xima.cmn.criteria.UpdateCriteriaManager ucm, View view) Adds additional update criteria for extra attributes that need to be updated when updating the entity.final Viewcreate(IEntityContext ec, View view) Persists the file entity in the database and returns the persisted entity.protected abstract de.xima.cmn.criteria.FilterCriterioncreateContextualFilter(Context context) Creates the filter to limit the database query to the given context.final voiddelete(IEntityContext ec, View view) Deletes the file entity and all its children (such as file data).protected voidfillEmptyEntity(IEntityContext ec, File entity, View view) protected voidhydrateView(View view, javax.persistence.Tuple tuple) Hydrates the view with additional attributes from the loaded tuple.protected booleanWhen set to true, the locking version is ignored.list(IEntityContext ec, Context context) Reads all file entities that exist in the given context.protected FileCreates a new empty instance of the entity.protected ViewnewView()Creates a new empty instance of the view.final InputStreamopenForRead(Supplier<IEntityContext> ec, View view) Opens an input stream to the content of a file entity.final OutputStreamopenForWrite(Supplier<IEntityContext> ec, View view) Opens an output stream for changing the content of a file entity.final Viewread(IEntityContext ec, View view) Reads the entity from the persistence layer, returning a fresh version of the entity.final Viewupdate(IEntityContext ec, View view) Updates the file entity in the persistence layer and returns the updated entity.
-
Constructor Details
-
FileEntityViewPersistenceAdapter
protected FileEntityViewPersistenceAdapter(Class<View> dtoClass, Class<File> fileEntityType, Class<Data> fileDataEntityType) Creates afile entity adapterfor a generalfile entity.- Parameters:
fileEntityType- The type of the file entity.fileDataEntityType- The type of the file data entity.
-
-
Method Details
-
create
Description copied from interface:ICrudPersistenceAdapterPersists the file entity in the database and returns the persisted entity.- Specified by:
createin interfaceICrudPersistenceAdapter<View extends IFileEntityView, File extends IFileEntity<?,Data> & IFileSizeProviding> - Parameters:
ec- Persistence context to use for accessing the database.view- The entity to create.- Returns:
- The persisted entity.
-
delete
Description copied from interface:ICrudPersistenceAdapterDeletes the file entity and all its children (such as file data).- Specified by:
deletein interfaceICrudPersistenceAdapter<View extends IFileEntityView, File extends IFileEntity<?,Data> & IFileSizeProviding> - Parameters:
ec- Persistence context to use for accessing the persistence layer.view- The entity to delete.
-
list
Description copied from interface:IScopedEntityPersistenceAdapterReads all file entities that exist in the given context.- Specified by:
listin interfaceIScopedEntityPersistenceAdapter<View extends IFileEntityView, File extends IFileEntity<?,Data> & IFileSizeProviding, Data extends IFileDataEntity<File>> - Parameters:
ec- Persistence context to use for accessing the persistence layer.context- The context in which to read the entities, such as a client or project.- Returns:
- A list of all file entities in the context.
-
openForRead
Description copied from interface:IFileDataPersistenceAdapterOpens an input stream to the content of a file entity.- Specified by:
openForReadin interfaceIFileDataPersistenceAdapter<View extends IFileEntityView, File extends IFileEntity<?,Data> & IFileSizeProviding> - Parameters:
ec- Persistence context factory to use for accessing the persistence layer.view- The entity to open.- Returns:
- An input stream to the file content.
- Throws:
IOException- If an error occurs while opening the file.
-
openForWrite
Description copied from interface:IFileDataPersistenceAdapterOpens an output stream for changing the content of a file entity. This should also update the file metadata, such as the user who last modified the file and the last modified time.- Specified by:
openForWritein interfaceIFileDataPersistenceAdapter<View extends IFileEntityView, File extends IFileEntity<?,Data> & IFileSizeProviding> - Parameters:
ec- Persistence context factory to use for accessing the persistence layer.view- The entity to open.- Returns:
- An output stream to the file content.
- Throws:
IOException- If an error occurs while opening the file.
-
read
Description copied from interface:ICrudPersistenceAdapterReads the entity from the persistence layer, returning a fresh version of the entity.- Specified by:
readin interfaceICrudPersistenceAdapter<View extends IFileEntityView, File extends IFileEntity<?,Data> & IFileSizeProviding> - Parameters:
ec- Persistence context to use for accessing the persistence layer.view- The entity to read.- Returns:
- The entity read from the persistence layer.
-
update
Description copied from interface:ICrudPersistenceAdapterUpdates the file entity in the persistence layer and returns the updated entity.- Specified by:
updatein interfaceICrudPersistenceAdapter<View extends IFileEntityView, File extends IFileEntity<?,Data> & IFileSizeProviding> - Parameters:
ec- Persistence context to use for accessing the database.view- The entity to update.- Returns:
- The updated entity.
-
addSelectCriteria
protected void addSelectCriteria(de.xima.cmn.criteria.AttributeSelectCriteriaManager acm) Adds additional select criteria for extra attributes needed to construct the view. The default implementation does not add any additional criteria.- Parameters:
acm- The attribute select criteria manager to which to add the criteria.
-
addUpdateCriteria
protected void addUpdateCriteria(IEntityContext ec, de.xima.cmn.criteria.UpdateCriteriaManager ucm, View view) Adds additional update criteria for extra attributes that need to be updated when updating the entity. The default implementation does not add any additional criteria.- Parameters:
ucm- The update criteria manager to which to add the criteria.view- The view from which to take the values.
-
createContextualFilter
Creates the filter to limit the database query to the given context.- Parameters:
context- The context to which to limit the query.- Returns:
- The contextual filter.
-
fillEmptyEntity
-
hydrateView
Hydrates the view with additional attributes from the loaded tuple. Should be compatible withaddSelectCriteria. The default implementation does not hydrate any additional attributes.- Parameters:
view- The view to hydrate.tuple- The tuple from which to take the values.
-
ignoreLockingVersion
protected boolean ignoreLockingVersion()When set to true, the locking version is ignored. When set to false, an exception is thrown when the locking version does not match.- Returns:
- Whether to ignore the locking version.
-
newEntity
Creates a new empty instance of the entity. The default implementation uses reflection to create a new instance via the default constructor. You may override this method if the class does not have a default constructor or to provide a more efficient way to create a new instance.- Returns:
- A new instance of the entity.
-
newView
Creates a new empty instance of the view. The default implementation uses reflection to create a new instance via the default constructor. You may override this method if the class does not have a default constructor or to provide a more efficient way to create a new instance.- Returns:
- A new instance of the view.
-