Class PersistentObjectClassVariables<T extends PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>>

java.lang.Object
org.tentackle.dbms.DbObjectClassVariables<P>
org.tentackle.persist.PersistentObjectClassVariables<T,P>
Type Parameters:
T - the PDO class type
P - the persistence class type

public class PersistentObjectClassVariables<T extends PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>> extends DbObjectClassVariables<P>
Author:
harald
  • Field Details

  • Constructor Details

    • PersistentObjectClassVariables

      public PersistentObjectClassVariables(Class<T> pdoClass, Class<P> poClass, String tableAlias, PersistentObjectClassVariables<? super T,? super P> superClassVariables, 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(Class<T> pdoClass, Class<P> poClass, 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 Details

    • create

      public static <T extends PersistentDomainObject<T>, P extends AbstractPersistentObject<T, P>> PersistentObjectClassVariables<T,P> create(Class<T> pdoClass, Class<P> poClass, String tableAlias, PersistentObjectClassVariables<? super T,? super P> superClassVariables, 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 PersistentDomainObject<T>, P extends AbstractPersistentObject<T, P>> PersistentObjectClassVariables<T,P> create(Class<T> pdoClass, Class<P> poClass, 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 List<Join<? super T,?>> getEagerJoins()
      Gets the effective eager joins.
      Returns:
      the joins, null if none
    • getTableName

      public 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 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 String getColumnName(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(Db db, long id)
      Overrides:
      isReferenced in class DbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
    • toString

      public String toString()
      Overrides:
      toString in class 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(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(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 Method getCreateAttributesInSnapshotMethod() throws NoSuchMethodException
      Gets the method createAttributesInSnapshot of the persistence object.
      Returns:
      the method
      Throws:
      NoSuchMethodException - if not found
    • getRevertAttributesToSnapshotMethod

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

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

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

      protected Method findSnapshotMethod(String methodName, Class<?> clazz) throws NoSuchMethodException
      Finds a snapshot method.
      Snapshot methods (AbstractPersistentObject.createAttributesInSnapshot(AbstractPersistentObject), AbstractPersistentObject.createComponentsInSnapshot(AbstractPersistentObject), AbstractPersistentObject.revertAttributesToSnapshot(AbstractPersistentObject) and AbstractPersistentObject.revertComponentsToSnapshot(AbstractPersistentObject)) take the snapshot object with the correct implementation type and are implemented at some implementation class. This method finds the most specific snapshot-method along the inheritance hierarchy.
      Parameters:
      methodName - the snapshot method name
      clazz - the implementation class
      Returns:
      the method
      Throws:
      NoSuchMethodException - if no such method found
    • determineReferencePriority

      protected int determineReferencePriority(Class<? extends 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 DbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
    • checkClassPermission

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