Class PersistentObjectClassVariables<T extends org.tentackle.pdo.PersistentDomainObject<T>,​P extends AbstractPersistentObject<T,​P>>

  • Type Parameters:
    T - the PDO class type
    P - the persistence class type

    public class PersistentObjectClassVariables<T extends org.tentackle.pdo.PersistentDomainObject<T>,​P extends AbstractPersistentObject<T,​P>>
    extends org.tentackle.dbms.DbObjectClassVariables<P>
    Extends DbObjectClassVariables for AbstractPersistentObjects.
    Author:
    harald
    • Constructor Detail

      • PersistentObjectClassVariables

        public PersistentObjectClassVariables​(java.lang.Class<T> pdoClass,
                                              java.lang.Class<P> poClass,
                                              java.lang.String tableAlias,
                                              PersistentObjectClassVariables<? super T,​? super P> superClassVariables,
                                              java.util.List<Join<T,​?>> eagerJoins)
        Constructs a classvariable.

        Notice: the superPoClass is necessary only in SINGLE and MULTI table inheritance configurations.

        Parameters:
        pdoClass - the PDO's class (i.e. interface)
        poClass - the class of the persistence implementation
        tableAlias - the table alias to be used in joined selects
        superClassVariables - the class variables of the superclass, null if not inherited
        eagerJoins - the optional eager joins, null of empty if none
      • PersistentObjectClassVariables

        public PersistentObjectClassVariables​(java.lang.Class<T> pdoClass,
                                              java.lang.Class<P> poClass,
                                              java.lang.String tableAlias)
        Constructs a classvariable.
        Parameters:
        pdoClass - the PDO's class (i.e. interface)
        poClass - the class of the persistence implementation
        tableAlias - the table alias to be used in joined selects
    • Method Detail

      • create

        public static <T extends org.tentackle.pdo.PersistentDomainObject<T>,​P extends AbstractPersistentObject<T,​P>> PersistentObjectClassVariables<T,​P> create​(java.lang.Class<T> pdoClass,
                                                                                                                                                                                   java.lang.Class<P> poClass,
                                                                                                                                                                                   java.lang.String tableAlias,
                                                                                                                                                                                   PersistentObjectClassVariables<? super T,​? super P> superClassVariables,
                                                                                                                                                                                   java.util.List<Join<T,​?>> eagerJoins)
        Creates a PDO classvariable.
        Type Parameters:
        T - the PDO class type
        P - the persistence class type
        Parameters:
        pdoClass - the PDO's class (i.e. interface)
        poClass - the class of the persistence implementation
        tableAlias - the table alias to be used in joined selects
        superClassVariables - the class variables of the superclass, null if not inherited
        eagerJoins - the optional eager joins, null of empty if none
      • create

        public static <T extends org.tentackle.pdo.PersistentDomainObject<T>,​P extends AbstractPersistentObject<T,​P>> PersistentObjectClassVariables<T,​P> create​(java.lang.Class<T> pdoClass,
                                                                                                                                                                                   java.lang.Class<P> poClass,
                                                                                                                                                                                   java.lang.String tableAlias)
        Creates a PDO classvariable.
        Type Parameters:
        T - the PDO class type
        P - the persistence class type
        Parameters:
        pdoClass - the PDO's class (i.e. interface)
        poClass - the class of the persistence implementation
        tableAlias - the table alias to be used in joined selects
      • getEagerJoins

        public java.util.List<Join<T,​?>> getEagerJoins()
        Gets the eager joins.
        Returns:
        the join, null or empty if none
      • getTableName

        public java.lang.String getTableName()
        Returns the tablename for this classvariable.

        If the class has no tablename, it is derived from its superclasses.

        Returns:
        the tablename, null if class does not map to any database table
      • getTableAlias

        public java.lang.String getTableAlias()
        Gets the table alias.

        If the class has no tablename, it is derived from its superclasses.

        Returns:
        the alias, null if class does not map to any database table
      • getColumnName

        public java.lang.String getColumnName​(java.lang.String name)
        Gets the full column name with optional table alias.
        Parameters:
        name - the short name
        Returns:
        the full name
      • getTopSuperClassVariables

        public PersistentObjectClassVariables<? super T,​? super P> getTopSuperClassVariables()
        Returns the topmost classvariables.
        Useful for multi-inheritance.
        Returns:
        the topmost variables, this if not inherited, never null
      • isSecurityEnabled

        public boolean isSecurityEnabled()
      • isReferenced

        public boolean isReferenced​(org.tentackle.dbms.Db db,
                                    long id)
        Overrides:
        isReferenced in class org.tentackle.dbms.DbObjectClassVariables<P extends AbstractPersistentObject<T,​P>>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class org.tentackle.dbms.DbObjectClassVariables<P extends AbstractPersistentObject<T,​P>>
      • isAbstract

        public boolean isAbstract()
        Returns whether the pdo class is abstract.
        Returns:
        true if abstract
      • isReadAllowed

        public boolean isReadAllowed​(org.tentackle.pdo.DomainContext context)
        Check the read security for this class. The implementation checks that the class rules will accept and that no object rule denies.

        Notice that SecurityPersistenceImpl objects are always readable!

        Parameters:
        context - the current domain context, null = all
        Returns:
        false if operation (select) is denied.
      • isReadAllowed

        public boolean isReadAllowed()
        Check the read security for this class in all contexts.
        Returns:
        false if operation (select) is denied.
      • isWriteAllowed

        public boolean isWriteAllowed​(org.tentackle.pdo.DomainContext context)
        Check the write security for this class. The implementation checks that the class rules will accept and that no object rule denies.
        Parameters:
        context - the current domain context, null = all
        Returns:
        false if operation (delete, update or insert) is denied.
      • isWriteAllowed

        public boolean isWriteAllowed()
        Check the write security for this class in all contexts.
        Returns:
        false if operation (delete, update or insert) is denied.
      • isReadAllowed

        public boolean isReadAllowed​(AbstractPersistentObject<?,​?> object)
        Check the read permission for a PDO.

        Components are readable if their root-entity is readable.

        Parameters:
        object - the object to check the security rules for.
        Returns:
        false if operation (select) is denied.
      • isWriteAllowed

        public boolean isWriteAllowed​(AbstractPersistentObject<?,​?> object)
        Check the write permission for a PDO.

        Only root-entities are writable. Components are not writable by default (because only the root can be persisted).

        Notice that the persistence layer will not invoke isWriteAllowed on components, because the root is already checked when saving or deleting a PDO. Remember that only root entities can be persisted by the application!

        Parameters:
        object - the object to check the security rules for.
        Returns:
        false if operation is denied
      • isViewAllowed

        public boolean isViewAllowed​(AbstractPersistentObject<?,​?> object)
        Check the view permission for a PDO.

        Components are viewable if their root-entity is viewable.

        Parameters:
        object - the object to check the security rules for.
        Returns:
        false if operation is denied
      • isEditAllowed

        public boolean isEditAllowed​(AbstractPersistentObject<?,​?> object)
        Check the edit permission for a PDO.

        Only root-entities are editable. Components are not editable by default (because only the root can be persisted).

        Parameters:
        object - the object to check the security rules for.
        Returns:
        false if operation is denied
      • getCreateAttributesInSnapshotMethod

        public java.lang.reflect.Method getCreateAttributesInSnapshotMethod()
                                                                     throws java.lang.NoSuchMethodException
        Gets the method createAttributesInSnapshot of the persistence object.
        Returns:
        the method
        Throws:
        java.lang.NoSuchMethodException - if not found
      • getRevertAttributesToSnapshotMethod

        public java.lang.reflect.Method getRevertAttributesToSnapshotMethod()
                                                                     throws java.lang.NoSuchMethodException
        Gets the method revertAttributesToSnapshot of the persistence object.
        Returns:
        the method
        Throws:
        java.lang.NoSuchMethodException - if not found
      • getCreateComponentsInSnapshotMethod

        public java.lang.reflect.Method getCreateComponentsInSnapshotMethod()
                                                                     throws java.lang.NoSuchMethodException
        Gets the method createComponentsInSnapshot of the persistence object.
        Returns:
        the method
        Throws:
        java.lang.NoSuchMethodException - if not found
      • getRevertComponentsToSnapshotMethod

        public java.lang.reflect.Method getRevertComponentsToSnapshotMethod()
                                                                     throws java.lang.NoSuchMethodException
        Gets the method revertComponentsToSnapshot of the persistence object.
        Returns:
        the method
        Throws:
        java.lang.NoSuchMethodException - if not found
      • determineReferencePriority

        protected int determineReferencePriority​(java.lang.Class<? extends org.tentackle.dbms.AbstractDbObject<?>> clazz)

        Overridden to determine the priority according to the presence of a cache:

        1. high: class provides a preloading cache (low volume data, usually master data)
        2. medium: class provides a non-preloading cache (medium volume data)
        3. low: class provides no cache (high volume, usually transaction data)
        Notice that the cache must be named "cache". This is the case for wurblet generated caches.
        Overrides:
        determineReferencePriority in class org.tentackle.dbms.DbObjectClassVariables<P extends AbstractPersistentObject<T,​P>>
      • checkClassPermission

        protected boolean checkClassPermission​(org.tentackle.pdo.DomainContext context,
                                               org.tentackle.security.Permission permission)
        Check security for this class.
        Parameters:
        context - the domain context
        permission - the permission
        Returns:
        true if accepted