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 typeP- the persistence class type
public class PersistentObjectClassVariables<T extends PersistentDomainObject<T>,P extends AbstractPersistentObject<T,P>> extends DbObjectClassVariables<P>
ExtendsDbObjectClassVariablesforAbstractPersistentObjects.- Author:
- harald
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.tentackle.dbms.DbObjectClassVariables
DbObjectClassVariables.ForeignReference
-
-
Field Summary
-
Fields inherited from class org.tentackle.dbms.DbObjectClassVariables
alwaysPrepare, classBaseName, classId, clazz, columnCount, deleteStatementId, dummyUpdateStatementId, expirationBacklog, foreignReferences, idSource, insertStatementId, remoteDelegateId, selectAllIdSerialStatementId, selectAllObjectsStatementId, selectExpiredTableSerials1StatementId, selectExpiredTableSerials2StatementId, selectForUpdateStatementId, selectMaxIdStatementId, selectMaxTableSerialStatementId, selectObjectStatementId, selectObjectsWithExpiredTableSerialsStatementId, selectSerialStatementId, tableName, updateAndSetSerialStatementId, updateSerialAndTableSerialStatementId, updateSerialStatementId, updateStatementId, updateTableSerialStatementId
-
-
Constructor Summary
Constructors Constructor Description PersistentObjectClassVariables(Class<T> pdoClass, Class<P> poClass, String tableAlias)Constructs a classvariable.PersistentObjectClassVariables(Class<T> pdoClass, Class<P> poClass, String tableAlias, PersistentObjectClassVariables<? super T,? super P> superClassVariables, List<Join<T,?>> eagerJoins)Constructs a classvariable.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckClassPermission(DomainContext context, Permission permission)Check security for this class.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.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.protected intdetermineReferencePriority(Class<? extends AbstractDbObject<?>> clazz)protected MethodfindSnapshotMethod(String methodName, Class<?> clazz)Finds a snapshot method.
Snapshot methods (AbstractPersistentObject.createAttributesInSnapshot(org.tentackle.persist.AbstractPersistentObject),AbstractPersistentObject.createComponentsInSnapshot(org.tentackle.persist.AbstractPersistentObject),AbstractPersistentObject.revertAttributesToSnapshot(org.tentackle.persist.AbstractPersistentObject)andAbstractPersistentObject.revertComponentsToSnapshot(org.tentackle.persist.AbstractPersistentObject)) take the snapshot object with the correct implementation type and are implemented at some implementation class.StringgetColumnName(String name)Gets the full column name with optional table alias.MethodgetCreateAttributesInSnapshotMethod()Gets the method createAttributesInSnapshot of the persistence object.MethodgetCreateComponentsInSnapshotMethod()Gets the method createComponentsInSnapshot of the persistence object.List<Join<T,?>>getEagerJoins()Gets the eager joins.MethodgetRevertAttributesToSnapshotMethod()Gets the method revertAttributesToSnapshot of the persistence object.MethodgetRevertComponentsToSnapshotMethod()Gets the method revertComponentsToSnapshot of the persistence object.StringgetTableAlias()Gets the table alias.StringgetTableName()Returns the tablename for this classvariable.PersistentObjectClassVariables<? super T,? super P>getTopSuperClassVariables()Returns the topmost classvariables.
Useful for multi-inheritance.booleanisAbstract()Returns whether the pdo class is abstract.booleanisEditAllowed(AbstractPersistentObject<?,?> object)Check the edit permission for a PDO.booleanisReadAllowed()Check the read security for this class in all contexts.booleanisReadAllowed(DomainContext context)Check the read security for this class.booleanisReadAllowed(AbstractPersistentObject<?,?> object)Check the read permission for a PDO.booleanisReferenced(Db db, long id)booleanisSecurityEnabled()booleanisViewAllowed(AbstractPersistentObject<?,?> object)Check the view permission for a PDO.booleanisWriteAllowed()Check the write security for this class in all contexts.booleanisWriteAllowed(DomainContext context)Check the write security for this class.booleanisWriteAllowed(AbstractPersistentObject<?,?> object)Check the write permission for a PDO.StringtoString()-
Methods inherited from class org.tentackle.dbms.DbObjectClassVariables
addReferencingClass, create, create, createBacklog, getIdSource, getProperties, getProperty, getRemoteDelegate, getRemoteDelegateId, getVariables, isReferencedImpl, putProperty, putVariables, removeReferencingClass
-
-
-
-
Field Detail
-
PROPERTY_CHECKSECURITY
public static final String PROPERTY_CHECKSECURITY
property key for the check security.- See Also:
- Constant Field Values
-
CLASSVARIABLES_NAME
public static final String CLASSVARIABLES_NAME
the declared name of the static class variables.- See Also:
- Constant Field Values
-
pdoClass
public final Class<T extends PersistentDomainObject<T>> pdoClass
The associated PDO class (i.e. the interface)
-
methodCache
public final PdoMethodCache<T extends PersistentDomainObject<T>> methodCache
The PDO method invocation cache.
-
eagerJoins
public final List<Join<T extends PersistentDomainObject<T>,?>> eagerJoins
The optional eager join.
-
pdoClassBaseName
public final String pdoClassBaseName
the pdo base-classname.
-
tableAlias
public String tableAlias
The table alias to be used in joined selects.
-
superClassVariables
public final PersistentObjectClassVariables<? super T extends PersistentDomainObject<T>,? super P extends AbstractPersistentObject<T,P>> superClassVariables
The classvariables of the parent class.
null if not inherited.
-
topSuperClassVariables
public PersistentObjectClassVariables<? super T extends PersistentDomainObject<T>,? super P extends AbstractPersistentObject<T,P>> topSuperClassVariables
The classvariables of the topmost parent class.
"this" if not inherited.
-
selectByNormTextStatementId
public final StatementId selectByNormTextStatementId
prepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String).
-
selectByInvertedNormTextStatementId
public final StatementId selectByInvertedNormTextStatementId
prepared statement ID forAbstractPersistentObject.selectByNormText(java.lang.String).
-
selectByNormTextCursorStatementId
public final StatementId selectByNormTextCursorStatementId
prepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String).
-
selectByInvertedNormTextCursorStatementId
public final StatementId selectByInvertedNormTextCursorStatementId
prepared statement ID forAbstractPersistentObject.selectByNormTextAsCursor(java.lang.String).
-
selectAllStatementId
public final StatementId selectAllStatementId
prepared statement ID forAbstractPersistentObject.selectAll().
-
selectAllWithExpiredTableSerialsStatementId
public final StatementId selectAllWithExpiredTableSerialsStatementId
prepared statement ID forAbstractPersistentObject.selectAllWithExpiredTableSerials(long).
-
selectAllCursorStatementId
public final StatementId selectAllCursorStatementId
prepared statement ID forAbstractPersistentObject.selectAllAsCursor().
-
updateTokenLockStatementId
public final StatementId updateTokenLockStatementId
-
updateTokenLockOnlyStatementId
public final StatementId updateTokenLockOnlyStatementId
prepared statement ID forAbstractPersistentObject.updateTokenLockOnly().
-
selectTokenLockStatementId
public final StatementId selectTokenLockStatementId
prepared statement ID for select inAbstractPersistentObject.updateTokenLock(org.tentackle.common.Timestamp, long, org.tentackle.common.Timestamp).
-
transferTokenLockStatementId
public final StatementId transferTokenLockStatementId
prepared statement ID forAbstractPersistentObject.transferTokenLock(long).
-
-
Constructor Detail
-
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 implementationtableAlias- the table alias to be used in joined selectssuperClassVariables- the class variables of the superclass, null if not inheritedeagerJoins- 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 implementationtableAlias- the table alias to be used in joined selects
-
-
Method Detail
-
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 typeP- the persistence class type- Parameters:
pdoClass- the PDO's class (i.e. interface)poClass- the class of the persistence implementationtableAlias- the table alias to be used in joined selectssuperClassVariables- the class variables of the superclass, null if not inheritedeagerJoins- 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 typeP- the persistence class type- Parameters:
pdoClass- the PDO's class (i.e. interface)poClass- the class of the persistence implementationtableAlias- the table alias to be used in joined selects
-
getEagerJoins
public List<Join<T,?>> getEagerJoins()
Gets the eager joins.- Returns:
- the join, null or empty 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:
isReferencedin classDbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
-
toString
public String toString()
- Overrides:
toStringin classDbObjectClassVariables<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
SecurityPersistenceImplobjects 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(org.tentackle.persist.AbstractPersistentObject),AbstractPersistentObject.createComponentsInSnapshot(org.tentackle.persist.AbstractPersistentObject),AbstractPersistentObject.revertAttributesToSnapshot(org.tentackle.persist.AbstractPersistentObject)andAbstractPersistentObject.revertComponentsToSnapshot(org.tentackle.persist.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 nameclazz- 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:
- high: class provides a preloading cache (low volume data, usually master data)
- medium: class provides a non-preloading cache (medium volume data)
- low: class provides no cache (high volume, usually transaction data)
- Overrides:
determineReferencePriorityin classDbObjectClassVariables<P extends AbstractPersistentObject<T,P>>
-
checkClassPermission
protected boolean checkClassPermission(DomainContext context, Permission permission)
Check security for this class.- Parameters:
context- the domain contextpermission- the permission- Returns:
- true if accepted
-
-