|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.tentackle.db.DbObject
org.tentackle.appworx.AppDbObject
public abstract class AppDbObject
Application database object.
Extends DbObject with features necessary in nearly all
desktop enterprise applications.
In contrast to DbObject, which is associated to a Db,
an AppDbObject is associated to a ContextDb.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.tentackle.db.DbObject |
|---|
DbObject.CopyAllToDbLogger, DbObject.IdComparator<T extends DbObject>, DbObject.NameComparator<T extends DbObject>, DbObject.NameIdComparator<T extends DbObject> |
| Field Summary | |
|---|---|
static String |
FIELD_EDITEDBY
the object ID of the user currently editing this object |
static String |
FIELD_EDITEDEXPIRY
time when "lock token" will expire |
static String |
FIELD_EDITEDSINCE
time when editing started |
static String |
FIELD_NORMTEXT
column name for the normtext |
static String |
TX_DELETE_ALL_IN_CONTEXT
delete all in context |
static String |
TX_SAVE_COPY_IN_CONTEXT
save copy in context |
static String |
TX_TRANSFER_EDITEDBY
transfer edited by |
static int |
VERIFIED_DUPLICATE
saving this object will result in a unique violation |
| Fields inherited from class org.tentackle.db.DbObject |
|---|
BEGIN, COMMIT, DELETE, DELETEALL, FIELD_ID, FIELD_SERIAL, FIELD_TABLESERIAL, idComparator, INSERT, lazyMethodInterval, nameComparator, nameIdComparator, TX_DELETE_LIST, TX_DELETE_MISSING_IN_LIST, TX_DELETE_OBJECT, TX_DUMMY_UPDATE, TX_INSERT_OBJECT, TX_INSERT_PLAIN, TX_SAVE, TX_SAVE_LIST, TX_UPDATE_OBJECT, TX_UPDATE_PLAIN, TX_UPDATE_SERIAL, TX_UPDATE_SERIAL_AND_TABLESERIAL, TX_UPDATE_TABLESERIAL, UPDATE |
| Constructor Summary | |
|---|---|
AppDbObject()
Creates an application database object without a database context. |
|
AppDbObject(ContextDb contextDb)
Creates an application database object. |
|
| Method Summary | ||
|---|---|---|
boolean |
allowsHistory()
Determines whether this object (or class) provides a field level history. This controls the history-menuitem in trees. |
|
boolean |
allowsTreeChildObjects()
Determines whether this object may have child objects that should be visible in a navigatable tree. The default implementation returns true. |
|
boolean |
allowsTreeParentObjects()
Determines whether the navigatable object tree should show the parents of this object. Objects may be childs of different parents in terms of "being referenced from" or any other relation, for example: the warehouses this customer visited. |
|
void |
clearEditedBy()
Clears the editedBy token. The operation is only done in memory, not in persistent storage. |
|
boolean |
containsPattern(String pattern)
Searches for a "pattern" in this object. The default implementation looks for the pattern in the normtext. |
|
AppDbObject |
copy()
Creates a "fast copy" of this object. |
|
static Collection<? extends AppDbObject> |
copyCollection(Collection<? extends AppDbObject> col)
Creates a cloned copy of a collection in such a way that all operations on the copied collection or its objects will not modify the orginal collection or any of its objects. |
|
void |
copyLazyValues(DbObject obj)
Copies the lazy values from one object to another. |
|
void |
countCacheAccess()
Count cache access |
|
long |
countModification(boolean optimize)
Counts a modification for the class of this object. |
|
AppDbObject |
createCopyInContextDb(ContextDb otherDb)
Creates a new object as a copy of the current object in another (or the same) database context. The new context must be of the same class as the old one. |
|
boolean |
dropTransferable(Transferable transferable)
Drops a transferable on this object. The default implementation does nothing and returns false (drop failed). |
|
boolean |
expireCache(long maxSerial)
Expires the cache according to the serial numbers. If objects of this class are cached, the cache must be expired on updates, etc... |
|
static List<AppDbObject> |
extractTreePath(Collection objects,
Class[] clazz)
Extracts from a list of objects the tree-hierarchy at a given depth. The last class in the array clazz[] is the desired one. |
|
List<AppDbObject> |
extractTreePathObjects(Class clazz)
Extracts tree childs with a given class. The method provides a hint and an optimization method for extractTreePath(java.util.Collection, java.lang.Class[]). |
|
static List<AppDbObject> |
filterAppDbObjects(Collection col)
Filters a collection of Objects, returning only those that are AppDbObjects. |
|
AppDbObject |
findDuplicate()
Checks whether this object (if saved) would violate any unique constraints. |
|
boolean |
finishModification(char modType)
Does any postprocessing after delete, insert or update. |
|
boolean |
finishNotUpdated()
Does any update postprocessing for objects not being updated (because not modified for some reason, e.g. |
|
abstract AppDbObjectClassVariables |
getAppDbObjectClassVariables()
Gets the application oriented class variables for this object. Class variables for classes derived from AppDbObject are kept in an instance of AppDbObjectClassVariables. |
|
ContextDb |
getBaseContext()
Gets the minimum context, i.e. |
|
AppDbObjectCache |
getCache()
Gets the cache. |
|
long |
getCacheAccessCount()
Gets the cache access count. |
|
long |
getCacheAccessTime()
Gets the last cache access time. |
|
static String[] |
getClassPath()
Gets the current classpath for loading classes by basename. |
|
ContextDb |
getContextDb()
Gets the database application context this object belongs to. |
|
long |
getContextId()
Gets the ID of the root object describing the context of this object. |
|
AppDbObject |
getCopiedObject()
Gets the original object if this object was created by createCopyInContextDb(org.tentackle.appworx.ContextDb). |
|
DbObjectClassVariables |
getDbObjectClassVariables()
Gets the some attributes and variables common to all objects of the same class. |
|
long |
getEditedBy()
Gets the id of the user currently editing this object. |
|
AppDbObject |
getEditedByObject()
Gets the object associated to the id of the editedBy-attribute. This is usually the id of an AppDbObject implementing the concept of a user, group, role or whatever. |
|
Timestamp |
getEditedExpiry()
Gets the time since when this object is being edited. |
|
Timestamp |
getEditedSince()
Gets the time since when this object is being edited. |
|
FormTableEntry |
getFormTableEntry()
Gets the table entry for viewing lists of this object in a FormTable.The default implementation returns an AppDbObjectDefaultTableEntry. |
|
String |
getFormTableName()
Gets the tablename used in to initialize the table's gui (columns, sizes, etc...). |
|
History |
getHistory()
Gets the history object for this object. The default implementation returns null. |
|
static String |
getMultiName(Class<? extends AppDbObject> clazz)
Gets the human readable name for multiple objects of given class. |
|
String |
getNormText()
Gets the normtext. |
|
AppDbObject |
getPanelObject()
Gets the object that should be edited or viewed in a panel. |
|
AppDbObjectRemoteDelegate |
getRemoteDelegate()
Gets the delegate for remote connections. Each class has its own delegate. |
|
SecurityManager |
getSecurityManager()
Gets the SecurityManager for this object. |
|
SecurityResult |
getSecurityResult(int permission)
Creates the SecurityResult for a given permission. |
|
protected int |
getSelectAllInContextCursorStatementId()
Gets the statememt id for selectAllInContextCursor(). |
|
protected int |
getSelectAllInContextStatementId()
Gets the statememt id for selectAllInContext(). |
|
protected int |
getSelectByNormTextCursorStatementId()
Gets the statememt id for selectByNormTextCursor(java.lang.String). |
|
protected int |
getSelectByNormTextStatementId()
Gets the statememt id for selectByNormText(java.lang.String). |
|
protected int |
getSelectEditedByStatementId()
Gets the statement id for select in updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp). |
|
static String |
getSingleName(Class<? extends AppDbObject> clazz)
Gets the human readable name for a single object of given class. |
|
String |
getSqlContextCondition()
Gets the additional condition to be used in the WHERE clause describing the context. |
|
String |
getToolTipText()
Gets the tooltip to be displayed for an object in a tree. |
|
String |
getToolTipText(Object parent)
Gets the tooltip text with respect to the parent object this object is displayed in a tree. The default implementation just invokes getToolTipText(). |
|
Transferable |
getTransferable()
Gets the Transferable for this object.Used for drag and drop. |
|
protected int |
getTransferEditedByStatementId()
Gets the statement id for transferEditedBy(long). |
|
Object |
getTransientData()
Gets the optional transient data object. The default implementation does nothing. |
|
List<Object> |
getTreeChildObjects()
Gets all childs of this objects that should be visible to the user in a navigatable object tree. The default implementation returns an empty ArrayList. |
|
List<Object> |
getTreeChildObjects(Object parentObject)
Gets the childs with respect to the parent object this object is displayed in the current tree. The default implementation just invokes getTreeChildObjects(). |
|
int |
getTreeExpandMaxDepth()
Gets the maximum level of expansion allowed in a navigatable object tree. |
|
List<Object> |
getTreeParentObjects()
Gets the parents of this object. |
|
List<Object> |
getTreeParentObjects(Object parentObject)
Gets the parents with respect to the parent object this object is displayed in the current tree. Override if the parents vary according to this object's parent. |
|
AppDbObject |
getTreeRoot()
Gets the object to be displayed in trees in place of this object. |
|
String |
getTreeText()
Gets the text to be displayed in trees for this object. |
|
String |
getTreeText(Object parent)
Gets the tree text with respect to the parent object this object is displayed in a tree. The default implementation just invokes getTreeText(). |
|
protected int |
getUpdateEditedByOnlyStatementId()
Gets the statement id for updateEditedByOnly(). |
|
protected int |
getUpdateEditedByStatementId()
Gets the statement id for updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp). |
|
long |
getUpdateEditedByTimeout()
Gets the expiration in milliseconds of the "being-edited-token" if this object should request such a token when being edited. The default implementation returns 0. |
|
boolean |
initModification(char modType)
Does any preprocessing before delete, insert or update. |
|
void |
invalidateLazyValues()
Clears the lazy values. Makes it safe to invoke the lazy method and being sure to invoke the non-lazy too. |
|
boolean |
isCacheable()
Determines whether object is cacheable or not. |
|
boolean |
isCached()
|
|
boolean |
isComposite()
Tells whether this object is composite (i.e. |
|
boolean |
isEditedLocked()
Checks whether this object is token locked (editedBy != 0) and the lock is not expired. |
|
boolean |
isExpired()
Checks whether object has been marked expired. |
|
boolean |
isInstantiatable()
Determines whether the user allowed to create a new object. The default is true. |
|
boolean |
isLoggingHistory()
Determines whether the history is implemented by Tentackle. History tables can be easily achieved by triggers directly within the database backend. |
|
boolean |
isPermissionAccepted(int permission)
Checks if the privilege for a given permission is accepted. |
|
boolean |
isPermissionDefault(int permission)
Checks if the privilege for a given permission is the default privilege. |
|
boolean |
isPermissionDenied(int permission)
Checks if the privilege for a given permission is denied. |
|
boolean |
isReferenced()
Checks whether this object is referenced by other objects. |
|
boolean |
isShowable()
Checks whether this object can be viewed by the user. |
|
boolean |
isShowableLazy()
Gets the showable state which has been valid for at least the last lazyMethodInterval milliseconds. |
|
static Class<? extends AppDbObject> |
loadClass(String className)
Loads an AppDbObject-class by its classname. If the classname is fully qualifiedthe class will simply be loaded via Class.forName(java.lang.String). |
|
boolean |
loadComposites()
Loads all composites. The method is used to transfer a copy of an object between tiers including all composite object relations recursively. |
|
static int |
loadComposites(Collection<? extends AppDbObject> objects)
Loads all composites of a collection. |
|
boolean |
logHistory(char historyType)
Performs the history logging. |
|
QbfPlugin |
makeQbfPlugin()
Creates the qbf plugin for the search dialog. The default implementation returns DefaultQbfPlugin. |
|
static QbfPlugin |
makeQbfPlugin(Class<? extends AppDbObject> clazz,
ContextDb db)
Invokes makeQbfPlugin in abstract classes. Searches for a static method "makeQbfPlugin(ContextDb)" and invokes it. |
|
ContextDb |
makeValidContext()
Creates a valid context for this object. Useful if the object has been loaded without a context or to make the least significant context the object can live in. |
|
void |
markCacheAccess()
mark cache access (count and set current system-time) |
|
static
|
newByClass(ContextDb contextDb,
Class<T> clazz)
Instantiates a new object for a given class and context. |
|
static AppDbObject |
newByClassBaseName(ContextDb contextDb,
String classBaseName)
Instantiates a new object for a given classname and context. |
|
AppDbObject |
newObject()
Creates an instance of the same class as this object, initialized in the same contextDb. |
|
FormContainer |
newPanel()
Creates a panel to edit or view this object. |
|
String |
orderBy()
Gets the natural ordering to be added in WHERE-clauses following "ORDER BY ". |
|
boolean |
panelExists()
Determines whether a panel exists to edit or view this object. |
|
int |
permissionType()
Determines the permission-type for this object. Can also be some application specific type. |
|
protected int |
prepareSelectEditedByStatement()
Prepares the select in updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp) statement. |
|
boolean |
prepareSetFields()
Prepares the object's attributes before the object is saved to the database. |
|
protected int |
prepareTransferEditedByStatement()
Prepares the transferEditedBy(long) statement. |
|
protected int |
prepareUpdateEditedByOnlyStatement()
Prepares the updateEditedByOnly() statement. |
|
protected int |
prepareUpdateEditedByStatement()
Prepares the updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp) statement. |
|
void |
presetQbfParameter(QbfParameter qbfPar)
Presets the qbf parameter with default values from this object. The default implementation does nothing. |
|
boolean |
readFromResultSetWrapper(ResultSetWrapper rs,
boolean withLinkedObjects)
Reads the values from a result-set into this object. |
|
ResultSetWrapper |
resultAllInContext()
Gets the result set for all objects in the current context for use in lists. |
|
ResultSetWrapper |
resultAllInContextCursor()
Gets the result set for all objects in the current context for use in cursors. Cursors differ from lists because they need ResultSet.TYPE_SCROLL_INSENSITIVE
set. |
|
ResultSetWrapper |
resultByNormText(String normText)
Gets the result set for the normtext query (where normtext like ?) for use in lists. If the given normtext is null or just "%" the method falls back to resultAllInContext(). |
|
ResultSetWrapper |
resultByNormTextCursor(String normText)
Gets the result set for the normtext query (where normtext like ?) for use in cursors. Cursors differ from lists because they need ResultSet.TYPE_SCROLL_INSENSITIVE
set. |
|
boolean |
save()
Saves this object. This is the standard method applications should use to insert or update objects. |
|
AppDbObject |
saveCopyInContextDb(ContextDb otherDb)
Same as createCopyInContextDb(org.tentackle.appworx.ContextDb) but saves the new object within a transaction.The default implementation also creates the Security-rules for the new object |
|
boolean |
saveInContextDb(ContextDb newDb)
speichert ein Object in einem anderen Db-Context. |
|
List<? extends AppDbObject> |
searchQbf(QbfParameter par)
Runs a QBF-Search returning a list. |
|
AppDbCursor<? extends AppDbObject> |
searchQbfCursor(QbfParameter par)
Runs a QBF-Search returning a cursor. |
|
static
|
select(ContextDb contextDb,
Class<T> clazz,
long id)
Selects an object for a given context, class and object ID. If the class is abstract reflection is used to invoke a static method with the signature: |
|
static AppDbObject |
select(ContextDb contextDb,
String classBaseName,
long id)
Selects an object for a given context, class and object ID. |
|
AppDbObject |
select(long id)
Loads an object from the database by its unique ID. |
|
AppDbObject |
select(long id,
boolean withLinkedObjects)
Loads an object from the database by its unique ID. |
|
List<? extends AppDbObject> |
selectAll(boolean withLinkedObjects)
Selects all objects in their corresponding context. Because objects of the same table may live in different ContextDb makeValidContext is invoked for each object. |
|
List<? extends AppDbObject> |
selectAllInContext()
Selects all records in current context as a list. |
|
static
|
selectAllInContext(ContextDb contextDb,
Class<T> clazz)
Selects all objects for a given context and class. |
|
List<? extends AppDbObject> |
selectAllInContextCached()
Gets all objects in context via cache. |
|
AppDbCursor<? extends AppDbObject> |
selectAllInContextCursor()
Selects all records in current context as a cursor |
|
List<? extends AppDbObject> |
selectAllInValidContext()
Selects all objects in their corresponding context (with linked objects). |
|
List<? extends AppDbObject> |
selectAllInValidContext(boolean withLinkedObjects)
The method selectAll(boolean) should get the suffix "InValidContext"
but it must override DbObject.selectAll(boolean). |
|
List<? extends AppDbObject> |
selectByNormText(String normText)
Selects all objects with a given normtext as a list. |
|
AppDbCursor<? extends AppDbObject> |
selectByNormTextCursor(String normText)
Selects all objects with a given normtext as a cursor. |
|
AppDbObject |
selectByTemplate(AppDbObject template)
Selects an object according to a template object. |
|
static
|
selectCached(ContextDb contextDb,
Class<T> clazz,
long id)
Selects an object via cache for a given context, class and object ID. If there is no cache, the object is selected uncached. |
|
static AppDbObject |
selectCached(ContextDb contextDb,
String classBaseName,
long id)
Selects an object via cache for a given context, class and object ID. If there is no cache the object will be loaded uncached. |
|
AppDbObject |
selectCached(long id)
Gets the object via cache. If there is no cache (i.e. |
|
static
|
selectInValidContext(Db db,
Class<T> clazz,
long id)
Selects an object for a given db connection and class by its unique ID in a newly created context (with linked objects). |
|
AppDbObject |
selectInValidContext(Db db,
long id)
Selects an object for a given db connection by its unique ID in a newly created context (with linked objects). |
|
AppDbObject |
selectInValidContext(Db db,
long id,
boolean withLinkedObjects)
Selects an object for a given db connection by its unique ID in a newly created context. |
|
static AppDbObject |
selectInValidContext(Db db,
String classBaseName,
long id)
Selects an object for a given db connection and class by its unique ID in a newly created context (with linked objects). |
|
AppDbObject |
selectInValidContext(long id)
Selects an object by its unique ID in a newly created context (with linked objects). |
|
AppDbObject |
selectInValidContext(long id,
boolean withLinkedObjects)
Selects an object by its unique ID in a newly created context. Notice that DbObject.loadLinkedObjects() is invoked _after_ makeValidContext()!
Furthermore, this method does not work well with multi-table objects (see PartialAppDbObject)
and eager loading because it invokes DbObject.getFields(org.tentackle.db.ResultSetWrapper) directly instead of
readFromResultSetWrapper(org.tentackle.db.ResultSetWrapper, boolean). |
|
static
|
selectLocked(ContextDb contextDb,
Class<T> clazz,
long id)
Selects and write-locks an object for a given context, class and object ID. If the class is abstract reflection is used to invoke a static method with the signature: |
|
static AppDbObject |
selectLocked(ContextDb contextDb,
String classBaseName,
long id)
Selects and write-locks an object for a given context, class and object ID. |
|
AppDbObject |
selectLocked(long id)
Load the object from the database with exclusive lock (aka write lock). |
|
AppDbObject |
selectLocked(long id,
boolean withLinkedObjects)
Load the object from the database with exclusive lock (aka write lock). |
|
void |
setCacheAccessCount(long count)
Sets the cache access count. |
|
void |
setCacheAccessTime(long millis)
Set the last cache access time. |
|
static void |
setClassPath(String[] path)
Sets the classpath for loading classes by basename. Database object classes may be loaded by their basename (see DbObject.getClassBaseName()). |
|
void |
setContextDb(ContextDb contextDb)
Sets this object's database application context. |
|
void |
setContextId()
Determines the object-ID(s) of the root object(s) of the context and sets the attributes of the database object accordingly. |
|
void |
setDb(Db db)
Sets the logical db connection for this object. |
|
void |
setEditedBy(long editedBy)
Sets the user editing this object. |
|
void |
setEditedByObject(AppDbObject obj)
Sets the user/group/role-object editing this object. |
|
void |
setEditedExpiry(Timestamp editedExpiry)
Sets the time when the token should expire. |
|
void |
setEditedSince(Timestamp editedSince)
Sets the time since when this object is being edited. |
|
void |
setExpired(boolean expired)
Sets this object's expiration flag. |
|
void |
setNormText(String normText)
Sets the normtext. |
|
protected void |
setSelectAllInContextCursorStatementId(int id)
Sets the statememt id for selectAllInContextCursor(). |
|
protected void |
setSelectAllInContextStatementId(int id)
Sets the statememt id for selectAllInContext(). |
|
protected void |
setSelectByNormTextCursorStatementId(int id)
Sets the statememt id for selectByNormTextCursor(java.lang.String). |
|
protected void |
setSelectByNormTextStatementId(int id)
Sets the statememt id for selectByNormText(java.lang.String). |
|
protected void |
setSelectEditedByStatementId(int id)
Sets the statement id for select in updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp). |
|
protected void |
setTransferEditedByStatementId(int id)
Sets the statement id for transferEditedBy(long). |
|
void |
setTransientData(Object data)
Sets the optional transient data object. Sometimes, e.g. |
|
protected void |
setUpdateEditedByOnlyStatementId(int id)
Sets the statement id for updateEditedByOnly(). |
|
protected void |
setUpdateEditedByStatementId(int id)
Sets the statement id for updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp). |
|
boolean |
stopTreeExpansion()
Determines whether tree explansion should stop at this object. Sometimes treechilds should not be expanded if in a recursive "expand all". |
|
boolean |
transferEditedBy(long userId)
Transfers the editing info in db-record (if feature enabled) to another user. Necessary to hand-over a token without releasing it. |
|
boolean |
updateEditedBy(Timestamp tokenExpiry)
Updates editing info in db-record (if feature enabled). Will *NOT* log modification and *NOT* update the serial-counter! Must be called from within application where appropriate. |
|
boolean |
updateEditedBy(Timestamp tokenExpiry,
long userId,
Timestamp curTime)
Updates editing info in db-record (if feature enabled). Will *NOT* log modification and *NOT* update the serial-counter! Must be called from within application where appropriate. |
|
boolean |
updateEditedByOnly()
Update the editedBy-attributes to persistent storage. No check is done whether locked or not and there is no serial update and no modlog. |
|
boolean |
updateObject(boolean withLinkedObjects)
Updates this object to the database. The modified attribute gets cleared if insert was successful. |
|
List<InteractiveError> |
verify()
Verifies the consistency and constraints of this object. |
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String FIELD_EDITEDBY
public static final String FIELD_EDITEDSINCE
public static final String FIELD_EDITEDEXPIRY
public static final String FIELD_NORMTEXT
public static final String TX_SAVE_COPY_IN_CONTEXT
public static final String TX_DELETE_ALL_IN_CONTEXT
public static final String TX_TRANSFER_EDITEDBY
public static final int VERIFIED_DUPLICATE
| Constructor Detail |
|---|
public AppDbObject(ContextDb contextDb)
contextDb - the database contextpublic AppDbObject()
| Method Detail |
|---|
public void setNormText(String normText)
normText - the normtextpublic String getNormText()
public void setDb(Db db)
Overridden to set the Db in ContextDb as well.
setDb in class DbObjectdb - the db connectionpublic void setContextDb(ContextDb contextDb)
Setting the context will also DbObject.setDb(org.tentackle.db.Db) and setContextId()
setContextDb in interface ContextDependablepublic ContextDb getContextDb()
The default implementation just returns the context. Subclasses may override this with a covariant method.
getContextDb in interface ContextDependablepublic void setContextId()
The default implementation does nothing (object living in a context not depending on another object).
setContextId in interface ContextDependablepublic long getContextId()
The default implementation returns 0.
getContextId in interface ContextDependablepublic String getSqlContextCondition()
Example: return " AND " + FIELD_TENANTID + "=?";
The default implementation returns null.
getSqlContextCondition in interface ContextDependablepublic ContextDb getBaseContext()
The default implementation returns a new ContextDb.
getBaseContext in interface ContextDependablepublic ContextDb makeValidContext()
The default implementation just returns a new ContextDb.
Notice that the Db must be valid!
makeValidContext in interface ContextDependablepublic abstract AppDbObjectClassVariables getAppDbObjectClassVariables()
AppDbObjectClassVariables.Notice: we cannot use a covariant method getDbObjectClassVariables() returning AppDbObjectClassVariables because super.getDbObjectClassVariables() is abstract and in that case covariance does not work. You will get the compiler error: "abstract method getDbObjectClassVariables() in org.tentackle.db.DbObject cannot be accessed directly"
DbObject.getDbObjectClassVariables()public DbObjectClassVariables getDbObjectClassVariables()
DbObjectClassVariables.
In fact, AppDbObjectClassVariables is an extension of DbObjectClassVariables.
So this fullfills the requirements for DbObject
getDbObjectClassVariables in class DbObjectpublic boolean isComposite()
public boolean loadComposites()
public AppDbObject findDuplicate()
The method is usually used by the presentation layer to check for duplicates. The default implementation does nothing and returns null.
public List<InteractiveError> verify()
The method is usually invoked by the presentation layer
before save().
The default implementation checks for duplicates via findDuplicate().
InteractiveErrors, never null.VERIFIED_DUPLICATEpublic boolean isCacheable()
public boolean isExpired()
public void setExpired(boolean expired)
expired - true if object is expiredpublic void setCacheAccessTime(long millis)
millis - is the system time in ms.public long getCacheAccessTime()
public void countCacheAccess()
public void setCacheAccessCount(long count)
count - new access countpublic long getCacheAccessCount()
public void markCacheAccess()
public boolean isCached()
public SecurityManager getSecurityManager()
SecurityManager for this object.
public SecurityResult getSecurityResult(int permission)
SecurityResult for a given permission.
permission - the permission type
public boolean isPermissionDenied(int permission)
permission - the permission type
public boolean isPermissionAccepted(int permission)
permission - the permission type
public boolean isPermissionDefault(int permission)
permission - the permission type
public AppDbObject createCopyInContextDb(ContextDb otherDb)
getCopiedObject()).
otherDb - the database context
public AppDbObject getCopiedObject()
createCopyInContextDb(org.tentackle.appworx.ContextDb).
public AppDbObject saveCopyInContextDb(ContextDb otherDb)
throws ApplicationException
createCopyInContextDb(org.tentackle.appworx.ContextDb) but saves the new object within a transaction.Security-rules for the new object
otherDb - the database context
ApplicationException - if save failedpublic AppDbObject selectByTemplate(AppDbObject template)
template - the template object
public AppDbObject newObject()
newObject in class DbObjectpublic AppDbObject copy()
The method is provided as a fast alternative to deep cloning via reflection or serialization.
All database-attributes are copied in such a way that each attribute of the new object can be changed without modifying the state of the original object. This also applies to all related AppDbObjects along the object graph. Non-AppDbObjects or any other non-database attributes are initialized according to the object's constructor (i.e. will usually be initialized to false, 0 or null, respectively).
The method will create a new object (no clone!) and set all attributes the same way as if the object has been loaded from storage.
Notice that it differs semantically from createCopyInContextDb() as copy() will copy the identity (ID) from the source object as well and will retain the contextDb. Thus, upon return we're talking about another instance of the "same" object with respect to what the database considers as "same".
A copied object is always not modified and not deleted, as it is when loaded from the database.
The default implementation throws a DbRuntimeException, i.e. must be overridden. See the AppDbCopy wurblet for an implementation.
copyCollection(java.util.Collection extends org.tentackle.appworx.AppDbObject>)
public AppDbObject selectInValidContext(long id,
boolean withLinkedObjects)
DbObject.loadLinkedObjects() is invoked _after_ makeValidContext()!
Furthermore, this method does not work well with multi-table objects (see PartialAppDbObject)
and eager loading because it invokes DbObject.getFields(org.tentackle.db.ResultSetWrapper) directly instead of
readFromResultSetWrapper(org.tentackle.db.ResultSetWrapper, boolean).
selectInValidContext in class DbObjectid - is the object idwithLinkedObjects - is true if load linked objects too
public AppDbObject selectInValidContext(long id)
id - the object id
selectInValidContext(long, boolean)
public AppDbObject selectInValidContext(Db db,
long id,
boolean withLinkedObjects)
db - the db connectionid - the object idwithLinkedObjects - true if load linked objects too
selectInValidContext(long, boolean)
public AppDbObject selectInValidContext(Db db,
long id)
db - the db connectionid - the object id
selectInValidContext(Db, long, boolean)
public boolean readFromResultSetWrapper(ResultSetWrapper rs,
boolean withLinkedObjects)
Overridden due to security check whether reading this object is allowed. If not, false is returned as if reading some values failed.
readFromResultSetWrapper in class DbObjectrs - is the result set (wrapper)withLinkedObjects - is true if load linked objects too
public AppDbObject select(long id,
boolean withLinkedObjects)
For local db connections the current object's attributes will be replaced by the database values (i.e. this object is returned). For remote connections, a copy of the object in the server is returned. Hence, applications should always create a new object and invoke select and don't make any further assumptions. This applies to all select methods returning an object! Example:
Customer customer = new Customer(db).select(customerId);
Since Java 1.5 covariance is supported and you should consider
overriding the method and cast the return value to the appropriate class.
Overridden because we need to set the contextDb in remote connections.
select in class DbObjectid - is the object idwithLinkedObjects - is true if load linked objects too
public AppDbObject select(long id)
For local db connections the current object's attributes will be replaced by the database values (i.e. this object is returned). For remote connections, a copy of the object in the server is returned. Hence, applications should always create a new object and invoke select and don't make any further assumptions. This applies to all select methods returning an object! Example:
Customer customer = new Customer(db).select(customerId);
Since Java 1.5 covariance is supported and you should consider
overriding the method and cast the return value to the appropriate class.
Overridden because we need to set the contextDb in remote connections.
select in class DbObjectid - is the object id
public AppDbObject selectLocked(long id,
boolean withLinkedObjects)
Overridden because we need to set the contextDb in remote connections.
selectLocked in class DbObjectid - is the object idwithLinkedObjects - is true if load linked objects too
public AppDbObject selectLocked(long id)
Overridden because we need to set the contextDb in remote connections.
selectLocked in class DbObjectid - is the object id
public List<? extends AppDbObject> selectAll(boolean withLinkedObjects)
DbObject.loadLinkedObjects() is invoked _after_ makeValidContext().
The method overrides DbObject.selectAll(boolean).
selectAll in class DbObjectwithLinkedObjects - is true if load linked objects too
selectAllInValidContext(boolean)public List<? extends AppDbObject> selectAllInValidContext(boolean withLinkedObjects)
selectAll(boolean) should get the suffix "InValidContext"
but it must override DbObject.selectAll(boolean). This method just
fixes the naming convention and invokes selectAll.
withLinkedObjects - true if load linked objects too
public List<? extends AppDbObject> selectAllInValidContext()
selectAll(boolean)public ResultSetWrapper resultByNormText(String normText)
resultAllInContext().
normText - the normtext to search for
resultByNormTextCursor(java.lang.String)public ResultSetWrapper resultByNormTextCursor(String normText)
ResultSet.TYPE_SCROLL_INSENSITIVE
set.
If the given normtext is null or just "%" the method falls back
to resultAllInContext().
normText - the normtext to search for
resultByNormText(java.lang.String)public List<? extends AppDbObject> selectByNormText(String normText)
normText - the normtext
resultByNormText(java.lang.String)public AppDbCursor<? extends AppDbObject> selectByNormTextCursor(String normText)
normText - the normtext
resultByNormTextCursor(java.lang.String)public ResultSetWrapper resultAllInContext()
resultAllInContextCursor()public ResultSetWrapper resultAllInContextCursor()
ResultSet.TYPE_SCROLL_INSENSITIVE
set.
resultAllInContext()public List<? extends AppDbObject> selectAllInContext()
resultAllInContext()public AppDbCursor<? extends AppDbObject> selectAllInContextCursor()
resultAllInContextCursor()public AppDbCursor<? extends AppDbObject> searchQbfCursor(QbfParameter par)
par - the qbf parameter
public List<? extends AppDbObject> searchQbf(QbfParameter par)
par - the QbfParameter
public boolean saveInContextDb(ContextDb newDb)
newDb - is the new ContextDb
public AppDbObjectCache getCache()
public boolean expireCache(long maxSerial)
cache.expire(maxSerial);
while "cache" has been declared by the wurblet AppDbCache.
maxSerial - is the new tableSerial this object will get
AppDbObjectCachepublic AppDbObject selectCached(long id)
id - the uniue object ID
select(long)public List<? extends AppDbObject> selectAllInContextCached()
selectAllInContext()public long countModification(boolean optimize)
Overridden to expire the cache if object is using the tableserial.
countModification in class DbObjectoptimize - is true if optimize modcounting within transaction
ModificationCounterpublic boolean prepareSetFields()
Overridden to set the normtext from DbObject.toString().
prepareSetFields in class DbObjectpublic boolean panelExists()
newPanel()public FormContainer newPanel()
panelExists()public AppDbObject getPanelObject()
public boolean isShowable()
The default implementation returns true. Does not refer to the SecurityManager!
The application can assume a lazy context (invoked from is...Lazy) if invoked outside a transaction. This is just an optimization hint.
isShowableLazy()public boolean isShowableLazy()
isShowable()public void copyLazyValues(DbObject obj)
Ovewritten due to isShowableLazy().
copyLazyValues in class DbObjectobj - the object to copy the values frompublic void invalidateLazyValues()
Ovewritten due to isShowableLazy().
invalidateLazyValues in class DbObjectpublic boolean isInstantiatable()
public boolean isReferenced()
It is invoked before operations that may have an impact on the referential integrity. The default implementation returns false.
The application can assume a lazy context (invoked from is...Lazy) if invoked outside a transaction. This is just an optimization hint.
Overridden because remote method requires a contextDb instead of just the db-connection.
isReferenced in class DbObjectpublic boolean allowsTreeChildObjects()
AppDbObjectTreepublic List<Object> getTreeChildObjects()
ArrayList.
Notice that these objects need not necessarily be AppDbObjects.
AppDbObjectTreepublic List<Object> getTreeChildObjects(Object parentObject)
getTreeChildObjects().
Override if the childs vary according to this object's parent.
parentObject - the parent object of this object in the tree, null = no parent
AppDbObjectTreepublic int getTreeExpandMaxDepth()
AppDbObjectTreepublic boolean allowsTreeParentObjects()
AppDbObjectTreepublic List<Object> getTreeParentObjects()
ArrayList.
AppDbObjectTree,
allowsTreeParentObjects()public List<Object> getTreeParentObjects(Object parentObject)
parentObject - the parent object, null if no parent
AppDbObjectTreepublic AppDbObject getTreeRoot()
AppDbObjectTreepublic String getTreeText()
DbObject.toString().
AppDbObjectTreepublic String getTreeText(Object parent)
getTreeText().
Override this method if the object's treetext varies according
to its parent.
parent - is the parent object, null if no parent
AppDbObjectTreepublic String getToolTipText()
DbObject.toString().
AppDbObjectTreepublic String getToolTipText(Object parent)
getToolTipText().
Override this method if the objects tooltip varies according
to its parent.
parent - is the parent object, null if no parent
AppDbObjectTreepublic boolean stopTreeExpansion()
AppDbObjectTreepublic List<AppDbObject> extractTreePathObjects(Class clazz)
extractTreePath(java.util.Collection, java.lang.Class[]).
The default implementation simply invokes getTreeChildObjects().
clazz - is the class of the childs to get
public Transferable getTransferable()
Transferable for this object.
AppDbObjectTransferablepublic boolean dropTransferable(Transferable transferable)
transferable - the Transferable
public boolean containsPattern(String pattern)
pattern - the pattern to search for
AppDbObjectSearchDialogpublic boolean allowsHistory()
AppDbObjectTreepublic History getHistory()
public boolean isLoggingHistory()
public boolean logHistory(char historyType)
historyType - is one of History.INSERT|UPDATE|DELETE
isLoggingHistory()public String orderBy()
return FIELD_ID + "," + FIELD_PRINTED + " DESC";For a single field with sort ascending returning the fieldname is sufficient. The default is null, i.e. no order-by-clause will be added.
public QbfPlugin makeQbfPlugin()
DefaultQbfPlugin.
public void presetQbfParameter(QbfParameter qbfPar)
qbfPar - the qbf parameterpublic int permissionType()
Security.TYPE_DATA
public boolean initModification(char modType)
Overridden due to security check.
initModification in class DbObjectmodType - is the modification type: DELETE, INSERT or UPDATE
public boolean finishModification(char modType)
Overridden to log history, remove security rules and clear the editedby-token.
finishModification in class DbObjectmodType - is the modification type: DELETE, INSERT or UPDATE
public boolean finishNotUpdated()
AppDbObject.
Ovewritten to get the editedBy token removed, if any.
finishNotUpdated in class DbObjectpublic void clearEditedBy()
public boolean updateObject(boolean withLinkedObjects)
DbObject.save() instead!
Overridden to clear editedBy if remote db.
updateObject in class DbObjectwithLinkedObjects - true if update also linked objects
public boolean save()
If the ID is 0, a new ID is obtained and this object inserted. Otherwise this object is updated. The modified attribute gets cleared if save() was successful.
Overridden to clear editedBy if remote db.
save in class DbObjectpublic long getUpdateEditedByTimeout()
AppDbObjectDialogprotected int getUpdateEditedByStatementId()
updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp).
protected void setUpdateEditedByStatementId(int id)
updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp).
id - the statement idprotected int getUpdateEditedByOnlyStatementId()
updateEditedByOnly().
protected void setUpdateEditedByOnlyStatementId(int id)
updateEditedByOnly().
id - the statement idprotected int getSelectEditedByStatementId()
updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp).
protected void setSelectEditedByStatementId(int id)
updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp).
id - the statement idprotected int getTransferEditedByStatementId()
transferEditedBy(long).
protected void setTransferEditedByStatementId(int id)
transferEditedBy(long).
id - the statement idprotected int prepareUpdateEditedByStatement()
updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp) statement.
protected int prepareUpdateEditedByOnlyStatement()
updateEditedByOnly() statement.
protected int prepareSelectEditedByStatement()
updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp) statement.
protected int prepareTransferEditedByStatement()
transferEditedBy(long) statement.
public long getEditedBy()
public void setEditedBy(long editedBy)
editedBy - the id of the user, 0 to clear.public boolean isEditedLocked()
public Timestamp getEditedSince()
public void setEditedSince(Timestamp editedSince)
editedSince - the time, null to clear.public Timestamp getEditedExpiry()
public void setEditedExpiry(Timestamp editedExpiry)
editedExpiry - the expiration time, null to clear.public AppDbObject getEditedByObject()
AbstractApplication.getUser(long).
public void setEditedByObject(AppDbObject obj)
obj - the object, null to clear.
public boolean updateEditedBy(Timestamp tokenExpiry,
long userId,
Timestamp curTime)
2 cases:
If expiry == 0, the "token" is released. True is returned if operation was successful and editedBy will hold 0 while editedSince holds the current (release) time. False is returned if token could not be released and nothing is changed. This usually is the case when another user holds the token (and indicates some logic errors in the application, btw.) EditedBy and editedSince are updated in the object to reflect the current values in the database. Notice: releasing an already released token is not considered to be an error. This will simply update the release timestamp.
If expiry > 0, a new token for the current user is requested. True is returned if the token could be exclusively acquired. EditedBy and editedSince are updated accordingly. If false: the object is in use by another user and editedSince and editedId holds this user and his timestamp. Notice: requesting an already requested token will simply renew the token.
The method does not check getUpdateEditedByTimeout()! This is due to the application. Applications should use updateEditedBy(tokenExpiry). This is an internal implementation only.
tokenExpiry - holds the time the token will expire. Null to release token.userId - is the current user (unused if tokenExpiry is null)curTime - is the current system time
public boolean updateEditedBy(Timestamp tokenExpiry)
2 cases:
If expiry == 0, the "token" is released. True is returned if operation was successful and editedBy will hold 0 while editedSince holds the current (release) time. False is returned if token could not be released and nothing is changed. This usually is the case when another user holds the token (and indicates some logic errors in the application, btw.) EditedBy and editedSince are updated in the object to reflect the current values in the database. Notice: releasing an already released token is not considered to be an error. This will simply update the release timestamp.
If expiry > 0, a new token for the current user is requested. True is returned if the token could be exclusively acquired. EditedBy and editedSince are updated accordingly. If false: the object is in use by another user and editedSince and editedId holds this user and his timestamp. Notice: requesting an already requested token will simply renew the token.
The method does not check getUpdateEditedByTimeout()! This is due to the application.
tokenExpiry - holds the time the token will expire. Null to release token.
public boolean updateEditedByOnly()
public boolean transferEditedBy(long userId)
userId - is the new user Id. (special 0 = free token, even if we are not the owner)
public FormTableEntry getFormTableEntry()
FormTable.AppDbObjectDefaultTableEntry.
Should be overridden in subclasses.
getFormTableName()public String getFormTableName()
formTableName.
Should be overridden.
getFormTableEntry()public Object getTransientData()
public void setTransientData(Object data)
data - the transient datapublic AppDbObjectRemoteDelegate getRemoteDelegate()
Overridden due to covariance.
getRemoteDelegate in class DbObjectprotected int getSelectByNormTextStatementId()
selectByNormText(java.lang.String).
protected void setSelectByNormTextStatementId(int id)
selectByNormText(java.lang.String).
id - the statement idprotected int getSelectAllInContextStatementId()
selectAllInContext().
protected void setSelectAllInContextStatementId(int id)
selectAllInContext().
id - the statement idprotected int getSelectByNormTextCursorStatementId()
selectByNormTextCursor(java.lang.String).
protected void setSelectByNormTextCursorStatementId(int id)
selectByNormTextCursor(java.lang.String).
id - the statement idprotected int getSelectAllInContextCursorStatementId()
selectAllInContextCursor().
protected void setSelectAllInContextCursorStatementId(int id)
selectAllInContextCursor().
id - the statement idpublic static Collection<? extends AppDbObject> copyCollection(Collection<? extends AppDbObject> col)
col - the original collection
copy()public static void setClassPath(String[] path)
DbObject.getClassBaseName()).
For this to work a classpath must be defined.
This is simply an array of package names.
The default classpath contains only the empty string.
path - the classpathpublic static String[] getClassPath()
public static Class<? extends AppDbObject> loadClass(String className)
throws ClassNotFoundException
Class.forName(java.lang.String).
If the classname does not contain a dot '.' the class is loaded by prepending the
classpath set by setClassPath(java.lang.String[]), one by one.
className -
ClassNotFoundException - if the class is not an extension of AppDbObject
public static <T extends AppDbObject> T newByClass(ContextDb contextDb,
Class<T> clazz)
throws InstantiationException,
IllegalAccessException
T - the classcontextDb - the database contextclazz - the class to create a new object for
InstantiationException
IllegalAccessException
public static AppDbObject newByClassBaseName(ContextDb contextDb,
String classBaseName)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
contextDb - the database contextclassBaseName - is the class basename
ClassNotFoundException
InstantiationException
IllegalAccessExceptionloadClass(java.lang.String)
public static String getSingleName(Class<? extends AppDbObject> clazz)
throws InstantiationException,
IllegalAccessException
clazz - the class
InstantiationException
IllegalAccessExceptionDbObject.getSingleName()
public static String getMultiName(Class<? extends AppDbObject> clazz)
throws InstantiationException,
IllegalAccessException
clazz - the class
InstantiationException
IllegalAccessExceptionDbObject.getMultiName()
public static <T extends AppDbObject> T selectInValidContext(Db db,
Class<T> clazz,
long id)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
T - the classdb - the db connectionclazz - the classid - the object id
ClassNotFoundException
InstantiationException
IllegalAccessExceptionselectInValidContext(long)
public static AppDbObject selectInValidContext(Db db,
String classBaseName,
long id)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
db - the db connectionclassBaseName - the class basenameid - the object id
ClassNotFoundException
InstantiationException
IllegalAccessExceptionselectInValidContext(long)
public static <T extends AppDbObject> List<T> selectAllInContext(ContextDb contextDb,
Class<T> clazz)
throws InstantiationException,
IllegalAccessException
T - the classcontextDb - the database contextclazz - the class
InstantiationException
IllegalAccessExceptionselectAllInContext()
public static <T extends AppDbObject> T select(ContextDb contextDb,
Class<T> clazz,
long id)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
static T select(ContextDb, Class, long) while T extends AppDbObjectIf the class does not provide such a method an InstantationException is thrown.
T - the classcontextDb - the database contextclazz - the classid - the object ID
ClassNotFoundException
InstantiationException
IllegalAccessException
public static <T extends AppDbObject> T selectCached(ContextDb contextDb,
Class<T> clazz,
long id)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
static T selectCached(ContextDb, Class, long) while T extends AppDbObjectIf the class does not provide such a method an InstantationException is thrown.
T - the classcontextDb - the database contextclazz - the classid - the object ID
ClassNotFoundException
InstantiationException
IllegalAccessException
public static <T extends AppDbObject> T selectLocked(ContextDb contextDb,
Class<T> clazz,
long id)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
static T selectLocked(ContextDb, Class, long) while T extends AppDbObjectIf the class does not provide such a method an InstantationException is thrown.
T - the classcontextDb - the database contextclazz - the classid - the object ID
ClassNotFoundException
InstantiationException
IllegalAccessException
public static AppDbObject select(ContextDb contextDb,
String classBaseName,
long id)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
contextDb - the database contextclassBaseName - the basename or full name of the classid - the object ID
ClassNotFoundException
InstantiationException
IllegalAccessExceptionnewByClassBaseName(org.tentackle.appworx.ContextDb, java.lang.String)
public static AppDbObject selectCached(ContextDb contextDb,
String classBaseName,
long id)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
contextDb - the database contextclassBaseName - the basename or full name of the classid - the object ID
ClassNotFoundException
InstantiationException
IllegalAccessExceptionnewByClassBaseName(org.tentackle.appworx.ContextDb, java.lang.String)
public static AppDbObject selectLocked(ContextDb contextDb,
String classBaseName,
long id)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
contextDb - the database contextclassBaseName - the basename or full name of the classid - the object ID
ClassNotFoundException
InstantiationException
IllegalAccessExceptionnewByClassBaseName(org.tentackle.appworx.ContextDb, java.lang.String)public static int loadComposites(Collection<? extends AppDbObject> objects)
objects - the collection of AppDbObjects
DbRuntimeException - if some object did not implement loadComposites()public static List<AppDbObject> filterAppDbObjects(Collection col)
col - the collection of objects
public static List<AppDbObject> extractTreePath(Collection objects,
Class[] clazz)
objects - the root-objects to walk along the clazz[]-path. Non-AppDbObjects will be skipped.clazz - the classes to pass along
AppDbObjectTree
public static QbfPlugin makeQbfPlugin(Class<? extends AppDbObject> clazz,
ContextDb db)
throws NoSuchMethodException,
IllegalAccessException,
InvocationTargetException
clazz - is the abstract classdb - is the db-context
NoSuchMethodException
IllegalAccessException
InvocationTargetException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||