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 Details

    • FileEntityViewPersistenceAdapter

      protected FileEntityViewPersistenceAdapter(Class<View> dtoClass, Class<File> fileEntityType, Class<Data> fileDataEntityType)
      Creates a file entity adapter for a general file entity.
      Parameters:
      fileEntityType - The type of the file entity.
      fileDataEntityType - The type of the file data entity.
  • Method Details

    • create

      public final View create(IEntityContext ec, View view)
      Description copied from interface: ICrudPersistenceAdapter
      Persists the file entity in the database and returns the persisted entity.
      Specified by:
      create in interface ICrudPersistenceAdapter<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

      public final void delete(IEntityContext ec, View view)
      Description copied from interface: ICrudPersistenceAdapter
      Deletes the file entity and all its children (such as file data).
      Specified by:
      delete in interface ICrudPersistenceAdapter<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

      public final List<View> list(IEntityContext ec, Context context)
      Description copied from interface: IScopedEntityPersistenceAdapter
      Reads all file entities that exist in the given context.
      Specified by:
      list in interface IScopedEntityPersistenceAdapter<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

      public final InputStream openForRead(Supplier<IEntityContext> ec, View view) throws IOException
      Description copied from interface: IFileDataPersistenceAdapter
      Opens an input stream to the content of a file entity.
      Specified by:
      openForRead in interface IFileDataPersistenceAdapter<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

      public final OutputStream openForWrite(Supplier<IEntityContext> ec, View view) throws IOException
      Description copied from interface: IFileDataPersistenceAdapter
      Opens 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:
      openForWrite in interface IFileDataPersistenceAdapter<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

      public final View read(IEntityContext ec, View view)
      Description copied from interface: ICrudPersistenceAdapter
      Reads the entity from the persistence layer, returning a fresh version of the entity.
      Specified by:
      read in interface ICrudPersistenceAdapter<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

      public final View update(IEntityContext ec, View view)
      Description copied from interface: ICrudPersistenceAdapter
      Updates the file entity in the persistence layer and returns the updated entity.
      Specified by:
      update in interface ICrudPersistenceAdapter<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

      protected abstract de.xima.cmn.criteria.FilterCriterion createContextualFilter(Context context)
      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

      protected void fillEmptyEntity(IEntityContext ec, File entity, View view)
    • hydrateView

      protected void hydrateView(View view, javax.persistence.Tuple tuple)
      Hydrates the view with additional attributes from the loaded tuple. Should be compatible with addSelectCriteria. 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

      protected File 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

      protected View 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.