org.tentackle.appworx
Class AppDbObject

java.lang.Object
  extended by org.tentackle.db.DbObject
      extended by org.tentackle.appworx.AppDbObject
All Implemented Interfaces:
Serializable, Cloneable, Comparable<DbObject>, ContextDependable
Direct Known Subclasses:
AppDbPseudoObject, History, PartialAppDbObject, Security

public abstract class AppDbObject
extends DbObject
implements ContextDependable

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.

Author:
harald
See Also:
Serialized Form

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
<T extends AppDbObject>
T
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
<T extends AppDbObject>
T
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
<T extends AppDbObject>
List<T>
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
<T extends AppDbObject>
T
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
<T extends AppDbObject>
T
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
<T extends AppDbObject>
T
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 org.tentackle.db.DbObject
_delete, _save, alwaysPrepare, assertLazyNotWithinTX, attributesModified, beginTx, clone, compareTo, copyAllToDb, copyToDb, countModification, createModificationLog, delete, deleteLinkedObjects, deleteList, deleteMissingInList, deleteObject, deletePlain, dummyUpdate, equals, getClassBaseName, getClassName, getDb, getDeleteStatementId, getDummyUpdateStatementId, getExpirationBacklog, getExpiredTableSerials, getFieldCount, getFields, getIcon, getId, getIdSource, getInsertStatementId, getMultiName, getRemoteDelegateId, getSelectAllStatementId, getSelectExpiredTableSerials1StatementId, getSelectExpiredTableSerials2StatementId, getSelectLockedStatementId, getSelectSerialStatementId, getSelectStatementId, getSerial, getSingleName, getSqlAllFields, getSqlPrefix, getSqlPrefixWithDot, getSqlSelectAllFields, getTableName, getTableSerial, getUpdateSerialAndTableSerialStatementId, getUpdateSerialStatementId, getUpdateStatementId, getUpdateTableSerialStatementId, hashCode, insert, insertObject, insertPlain, isCountingModification, isDeleted, isEditable, isEditableLazy, isEntity, isGettingFieldCount, isIdValid, isLazyElapsed, isListModified, isLoggingModification, isModified, isNew, isPartial, isReferencedLazy, isRemovable, isRemovableLazy, isSaveable, isTableSerialValid, isTracked, isTxObject, isUpdatingSerialEvenIfNotModified, isVirgin, loadLinkedObjects, logModification, markDeleted, markListDeleted, newByClass, newByClass, newByClassWrapped, newId, prepareDeleteStatement, prepareDummyUpdateStatement, prepareInsertStatement, prepareSelectLockedStatement, prepareSelectSerialStatement, prepareSelectStatement, prepareUpdateSerialAndTableSerialStatement, prepareUpdateSerialStatement, prepareUpdateStatement, prepareUpdateTableSerialStatement, readFromResultSetWrapper, reload, reloadLocked, reserveId, saveLinkedObjects, saveList, saveList, select, select, selectAll, selectAll, selectAllCursor, selectAllCursor, selectAllResultSet, selectExpiredTableSerials, selectExpiredTableSerials, selectModification, selectNext, selectSerial, selectSerial, setAlwaysPrepare, setDeleteStatementId, setDummyUpdateStatementId, setFields, setId, setInsertStatementId, setModified, setSelectAllStatementId, setSelectExpiredTableSerials1StatementId, setSelectExpiredTableSerials2StatementId, setSelectLockedStatementId, setSelectSerialStatementId, setSelectStatementId, setSerial, setTableSerial, setUpdateSerialAndTableSerialStatementId, setUpdateSerialStatementId, setUpdateStatementId, setUpdateTableSerialStatementId, sync, syncObject, toGenericString, toString, update, updateFieldCount, updateFields, updatePlain, updateSerial, updateSerialAndTableSerial, updateTableSerial
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FIELD_EDITEDBY

public static final String FIELD_EDITEDBY
the object ID of the user currently editing this object

See Also:
Constant Field Values

FIELD_EDITEDSINCE

public static final String FIELD_EDITEDSINCE
time when editing started

See Also:
Constant Field Values

FIELD_EDITEDEXPIRY

public static final String FIELD_EDITEDEXPIRY
time when "lock token" will expire

See Also:
Constant Field Values

FIELD_NORMTEXT

public static final String FIELD_NORMTEXT
column name for the normtext

See Also:
Constant Field Values

TX_SAVE_COPY_IN_CONTEXT

public static final String TX_SAVE_COPY_IN_CONTEXT
save copy in context

See Also:
Constant Field Values

TX_DELETE_ALL_IN_CONTEXT

public static final String TX_DELETE_ALL_IN_CONTEXT
delete all in context

See Also:
Constant Field Values

TX_TRANSFER_EDITEDBY

public static final String TX_TRANSFER_EDITEDBY
transfer edited by

See Also:
Constant Field Values

VERIFIED_DUPLICATE

public static final int VERIFIED_DUPLICATE
saving this object will result in a unique violation

See Also:
Constant Field Values
Constructor Detail

AppDbObject

public AppDbObject(ContextDb contextDb)
Creates an application database object.

Parameters:
contextDb - the database context

AppDbObject

public AppDbObject()
Creates an application database object without a database context. Extendes classes must also implement the empty constructor!

Method Detail

setNormText

public void setNormText(String normText)
Sets the normtext.

Parameters:
normText - the normtext

getNormText

public String getNormText()
Gets the normtext.

Returns:
the normtext

setDb

public void setDb(Db db)
Sets the logical db connection for this object.

Overridden to set the Db in ContextDb as well.

Overrides:
setDb in class DbObject
Parameters:
db - the db connection

setContextDb

public void setContextDb(ContextDb contextDb)
Sets this object's database application context.

Setting the context will also DbObject.setDb(org.tentackle.db.Db) and setContextId()

Specified by:
setContextDb in interface ContextDependable

getContextDb

public ContextDb getContextDb()
Gets the database application context this object belongs to.

The default implementation just returns the context. Subclasses may override this with a covariant method.

Specified by:
getContextDb in interface ContextDependable
Returns:
the context

setContextId

public void setContextId()
Determines the object-ID(s) of the root object(s) of the context and sets the attributes of the database object accordingly.

The default implementation does nothing (object living in a context not depending on another object).

Specified by:
setContextId in interface ContextDependable

getContextId

public long getContextId()
Gets the ID of the root object describing the context of this object.

The default implementation returns 0.

Specified by:
getContextId in interface ContextDependable
Returns:
the ID of the root object, 0 if in default context (no context)

getSqlContextCondition

public String getSqlContextCondition()
Gets the additional condition to be used in the WHERE clause describing the context.
 Example: return " AND " + FIELD_TENANTID + "=?";
 

The default implementation returns null.

Specified by:
getSqlContextCondition in interface ContextDependable
Returns:
the condition, null if none necessary

getBaseContext

public ContextDb getBaseContext()
Gets the minimum context, i.e. the one that is sufficient for this object. Objects may have a "higher" context they live in.

The default implementation returns a new ContextDb.

Specified by:
getBaseContext in interface ContextDependable
Returns:
the base context, never null

makeValidContext

public 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.

The default implementation just returns a new ContextDb.
Notice that the Db must be valid!

Specified by:
makeValidContext in interface ContextDependable
Returns:
the new context, never null

getAppDbObjectClassVariables

public 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.

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"

Returns:
the class variables
See Also:
DbObject.getDbObjectClassVariables()

getDbObjectClassVariables

public DbObjectClassVariables getDbObjectClassVariables()
Gets the some attributes and variables common to all objects of the same class. Class variables for classes derived from DbObject are kept in an instance of DbObjectClassVariables.

In fact, AppDbObjectClassVariables is an extension of DbObjectClassVariables. So this fullfills the requirements for DbObject

Specified by:
getDbObjectClassVariables in class DbObject
Returns:
the class variables

isComposite

public boolean isComposite()
Tells whether this object is composite (i.e. has composite relations).
The method is overridden by the AppDbRelations-wurblet if at least one relation is flagged as "composite". The default implementation returns false.

Returns:
true if object is composite, false if not.

loadComposites

public boolean loadComposites()
Loads all composites.
The method is used to transfer a copy of an object between tiers including all composite object relations recursively. By default the method throws a DbRuntimeException telling that it is not implemented if isComposite() returns true. The --loadcomposites option of the AppDbRelations wurblet will generate the method. Applications should not override this method if AppDbRelations is used.

Returns:
true if composites loaded or object is not composite, false if loading composites failed

findDuplicate

public AppDbObject findDuplicate()
Checks whether this object (if saved) would violate any unique constraints.

The method is usually used by the presentation layer to check for duplicates. The default implementation does nothing and returns null.

Returns:
the duplicate object, null if no duplicated

verify

public List<InteractiveError> verify()
Verifies the consistency and constraints of this object.

The method is usually invoked by the presentation layer before save(). The default implementation checks for duplicates via findDuplicate().

Returns:
a list of InteractiveErrors, never null.
See Also:
VERIFIED_DUPLICATE

isCacheable

public boolean isCacheable()
Determines whether object is cacheable or not. The default implementation always returns true, but apps can use this as a filter.

Returns:
true if object is cacheable

isExpired

public boolean isExpired()
Checks whether object has been marked expired. Expired objects will be reloaded from the database by the cache when the object is retrieved again.

Returns:
true if object is expired (in cache)

setExpired

public void setExpired(boolean expired)
Sets this object's expiration flag.

Parameters:
expired - true if object is expired

setCacheAccessTime

public void setCacheAccessTime(long millis)
Set the last cache access time.

Parameters:
millis - is the system time in ms.

getCacheAccessTime

public long getCacheAccessTime()
Gets the last cache access time.

Returns:
the last cache access time

countCacheAccess

public void countCacheAccess()
Count cache access


setCacheAccessCount

public void setCacheAccessCount(long count)
Sets the cache access count.

Parameters:
count - new access count

getCacheAccessCount

public long getCacheAccessCount()
Gets the cache access count.

Returns:
the access count

markCacheAccess

public void markCacheAccess()
mark cache access (count and set current system-time)


isCached

public boolean isCached()
Returns:
true if object is cached

getSecurityManager

public SecurityManager getSecurityManager()
Gets the SecurityManager for this object.

Returns:
the manager. Never null.

getSecurityResult

public SecurityResult getSecurityResult(int permission)
Creates the SecurityResult for a given permission.

Parameters:
permission - the permission type
Returns:
the security result (never null)

isPermissionDenied

public boolean isPermissionDenied(int permission)
Checks if the privilege for a given permission is denied.

Parameters:
permission - the permission type
Returns:
true if privilege is denied

isPermissionAccepted

public boolean isPermissionAccepted(int permission)
Checks if the privilege for a given permission is accepted.

Parameters:
permission - the permission type
Returns:
true if privilege is accepted

isPermissionDefault

public boolean isPermissionDefault(int permission)
Checks if the privilege for a given permission is the default privilege. The default privilege is returned if there were no rules found.

Parameters:
permission - the permission type
Returns:
true if privilege is default (no rule found)

createCopyInContextDb

public 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. Subclasses must override this method if they contain links to other objects (via IDs) that may have changed too (depending on the context).
The default implementation just clones the object, sets the context and sets the original object (see getCopiedObject()).

Parameters:
otherDb - the database context
Returns:
the created object

getCopiedObject

public AppDbObject getCopiedObject()
Gets the original object if this object was created by createCopyInContextDb(org.tentackle.appworx.ContextDb).

Returns:
the object or null if this object is not a copy

saveCopyInContextDb

public AppDbObject saveCopyInContextDb(ContextDb otherDb)
                                throws ApplicationException
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

Parameters:
otherDb - the database context
Returns:
the created object
Throws:
ApplicationException - if save failed

selectByTemplate

public AppDbObject selectByTemplate(AppDbObject template)
Selects an object according to a template object. Useful to find corresponding objects in another context. The default implementation loads the same object by its ID. Should be overwridden to select by some other unique key.

Parameters:
template - the template object
Returns:
the object if found, else null.

newObject

public AppDbObject newObject()
Creates an instance of the same class as this object, initialized in the same contextDb.

Overrides:
newObject in class DbObject
Returns:
the new object

copy

public AppDbObject copy()
Creates a "fast copy" of this object.

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.

Returns:
the copied object
See Also:
copyCollection(java.util.Collection)

selectInValidContext

public 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).

Overrides:
selectInValidContext in class DbObject
Parameters:
id - is the object id
withLinkedObjects - is true if load linked objects too
Returns:
object if loaded, null if no such object

selectInValidContext

public AppDbObject selectInValidContext(long id)
Selects an object by its unique ID in a newly created context (with linked objects).

Parameters:
id - the object id
Returns:
the object, null if no such object
See Also:
selectInValidContext(long, boolean)

selectInValidContext

public 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.

Parameters:
db - the db connection
id - the object id
withLinkedObjects - true if load linked objects too
Returns:
the object, null if no such object
See Also:
selectInValidContext(long, boolean)

selectInValidContext

public 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).

Parameters:
db - the db connection
id - the object id
Returns:
the object, null if no such object
See Also:
selectInValidContext(Db, long, boolean)

readFromResultSetWrapper

public boolean readFromResultSetWrapper(ResultSetWrapper rs,
                                        boolean withLinkedObjects)
Reads the values from a result-set into this object.

Overridden due to security check whether reading this object is allowed. If not, false is returned as if reading some values failed.

Overrides:
readFromResultSetWrapper in class DbObject
Parameters:
rs - is the result set (wrapper)
withLinkedObjects - is true if load linked objects too
Returns:
true if values read, false if some error

select

public AppDbObject select(long id,
                          boolean withLinkedObjects)
Loads an object from the database by its unique 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.

Overrides:
select in class DbObject
Parameters:
id - is the object id
withLinkedObjects - is true if load linked objects too
Returns:
object if loaded, null if no such object

select

public AppDbObject select(long id)
Loads an object from the database by its unique 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.

Overrides:
select in class DbObject
Parameters:
id - is the object id
Returns:
object if loaded, null if no such object

selectLocked

public AppDbObject selectLocked(long id,
                                boolean withLinkedObjects)
Load the object from the database with exclusive lock (aka write lock). This is implemented via "SELECT FOR UPDATE".

Overridden because we need to set the contextDb in remote connections.

Overrides:
selectLocked in class DbObject
Parameters:
id - is the object id
withLinkedObjects - is true if load linked objects too
Returns:
object if loaded, null if no such object

selectLocked

public AppDbObject selectLocked(long id)
Load the object from the database with exclusive lock (aka write lock). This is implemented via "SELECT FOR UPDATE". The linked objects are loaded as well.

Overridden because we need to set the contextDb in remote connections.

Overrides:
selectLocked in class DbObject
Parameters:
id - is the object id
Returns:
object if loaded, null if no such object

selectAll

public 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. Notice that DbObject.loadLinkedObjects() is invoked _after_ makeValidContext(). The method overrides DbObject.selectAll(boolean).

Overrides:
selectAll in class DbObject
Parameters:
withLinkedObjects - is true if load linked objects too
Returns:
the list of objects
See Also:
selectAllInValidContext(boolean)

selectAllInValidContext

public List<? extends AppDbObject> selectAllInValidContext(boolean withLinkedObjects)
The method selectAll(boolean) should get the suffix "InValidContext" but it must override DbObject.selectAll(boolean). This method just fixes the naming convention and invokes selectAll.

Parameters:
withLinkedObjects - true if load linked objects too
Returns:
the list of objects

selectAllInValidContext

public List<? extends AppDbObject> selectAllInValidContext()
Selects all objects in their corresponding context (with linked objects).

Returns:
the list of objects
See Also:
selectAll(boolean)

resultByNormText

public 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().

Parameters:
normText - the normtext to search for
Returns:
the result set
See Also:
resultByNormTextCursor(java.lang.String)

resultByNormTextCursor

public 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. If the given normtext is null or just "%" the method falls back to resultAllInContext().

Parameters:
normText - the normtext to search for
Returns:
the result set
See Also:
resultByNormText(java.lang.String)

selectByNormText

public List<? extends AppDbObject> selectByNormText(String normText)
Selects all objects with a given normtext as a list.

Parameters:
normText - the normtext
Returns:
the list of objects, never null
See Also:
resultByNormText(java.lang.String)

selectByNormTextCursor

public AppDbCursor<? extends AppDbObject> selectByNormTextCursor(String normText)
Selects all objects with a given normtext as a cursor.

Parameters:
normText - the normtext
Returns:
the cursor
See Also:
resultByNormTextCursor(java.lang.String)

resultAllInContext

public ResultSetWrapper resultAllInContext()
Gets the result set for all objects in the current context for use in lists.

Returns:
the result set
See Also:
resultAllInContextCursor()

resultAllInContextCursor

public 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.

Returns:
the result set
See Also:
resultAllInContext()

selectAllInContext

public List<? extends AppDbObject> selectAllInContext()
Selects all records in current context as a list.

Returns:
the list of objects, never null
See Also:
resultAllInContext()

selectAllInContextCursor

public AppDbCursor<? extends AppDbObject> selectAllInContextCursor()
Selects all records in current context as a cursor

Returns:
the cursor
See Also:
resultAllInContextCursor()

searchQbfCursor

public AppDbCursor<? extends AppDbObject> searchQbfCursor(QbfParameter par)
Runs a QBF-Search returning a cursor. Will prompt the user if too much data received. The method is provided to be overridden in the concrete classes. The default implementation just queries the normtext for the default qbf parameter.

Parameters:
par - the qbf parameter
Returns:
the cursor

searchQbf

public List<? extends AppDbObject> searchQbf(QbfParameter par)
Runs a QBF-Search returning a list. The implementation simply invokes searchQbfCursor().toListAndClose().

Parameters:
par - the QbfParameter
Returns:
the list, never null

saveInContextDb

public boolean saveInContextDb(ContextDb newDb)
speichert ein Object in einem anderen Db-Context. Wird z.B. verwendet um Stammdaten in einen anderen Mandant/Jahr zu kopieren. Das Objekt wird NICHT(!) clone()'d, sondern bekommt lediglich eine neue Object-ID und einen neuen Context. Es werden auch keine linked Objects gespeichert, sondern nur das nackte Objekt.

Parameters:
newDb - is the new ContextDb
Returns:
true if done, false if error

getCache

public AppDbObjectCache getCache()
Gets the cache. The default implementation returns null. Must be overridden to enable optimization features with RMI servers.

Returns:
the cache, null if uncached

expireCache

public 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... Furthermore, if there is a cache, isCountingModification() MUST return true, in order for countModification() to invalidate the cache for the local JVM. Classes with a cache must override this method! The implementation with the AppDbObjectCache should look like this:
    cache.expire(maxSerial);
 
while "cache" has been declared by the wurblet AppDbCache.

Parameters:
maxSerial - is the new tableSerial this object will get
Returns:
true if cache invalidated, false if there is no cache
See Also:
AppDbObjectCache

selectCached

public AppDbObject selectCached(long id)
Gets the object via cache.
If there is no cache (i.e. the method is not overridden), the default implementation just loads from the db.

Parameters:
id - the uniue object ID
Returns:
the object, null if no such object
See Also:
select(long)

selectAllInContextCached

public List<? extends AppDbObject> selectAllInContextCached()
Gets all objects in context via cache. If there is no cache (i.e. the method is not overridden), the default implementation gets it from the db.

Returns:
the list, never null
See Also:
selectAllInContext()

countModification

public long countModification(boolean optimize)
Counts a modification for the class of this object.

Overridden to expire the cache if object is using the tableserial.

Overrides:
countModification in class DbObject
Parameters:
optimize - is true if optimize modcounting within transaction
Returns:
the table serial if isTableSerialValid()==true, -1 if isCountModificationAllowed() == false
See Also:
ModificationCounter

prepareSetFields

public boolean prepareSetFields()
Prepares the object's attributes before the object is saved to the database. Should be overridden. The default implementation does nothing. Used to setup, check and align values.

Overridden to set the normtext from DbObject.toString().

Overrides:
prepareSetFields in class DbObject
Returns:
true if proceed with save/insert/update, false if some error.

panelExists

public boolean panelExists()
Determines whether a panel exists to edit or view this object. The default is false.

Returns:
true if a panel exists
See Also:
newPanel()

newPanel

public FormContainer newPanel()
Creates a panel to edit or view this object. The default implementation returns null.

Returns:
the panel, null if none
See Also:
panelExists()

getPanelObject

public AppDbObject getPanelObject()
Gets the object that should be edited or viewed in a panel. The default implementation returns this object.

Returns:
the object to be edited or viewed in a panel

isShowable

public boolean isShowable()
Checks whether this object can be viewed by the user.

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.

Returns:
true if showable
See Also:
isShowableLazy()

isShowableLazy

public boolean isShowableLazy()
Gets the showable state which has been valid for at least the last lazyMethodInterval milliseconds.

Returns:
true if showable
See Also:
isShowable()

copyLazyValues

public void copyLazyValues(DbObject obj)
Copies the lazy values from one object to another.

Ovewritten due to isShowableLazy().

Overrides:
copyLazyValues in class DbObject
Parameters:
obj - the object to copy the values from

invalidateLazyValues

public void invalidateLazyValues()
Clears the lazy values.
Makes it safe to invoke the lazy method and being sure to invoke the non-lazy too.

Ovewritten due to isShowableLazy().

Overrides:
invalidateLazyValues in class DbObject

isInstantiatable

public boolean isInstantiatable()
Determines whether the user allowed to create a new object.
The default is true. 'false' usually means that objects of this class are created (and removed) by the application logic and the user has no control over that.

Returns:
true if user is allowed to create (and delete)

isReferenced

public boolean isReferenced()
Checks whether this object is referenced by other objects.

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.

Overrides:
isReferenced in class DbObject
Returns:
true if referenced

allowsTreeChildObjects

public boolean allowsTreeChildObjects()
Determines whether this object may have child objects that should be visible in a navigatable tree.
The default implementation returns true.

Returns:
true if object may have childs
See Also:
AppDbObjectTree

getTreeChildObjects

public 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. Notice that these objects need not necessarily be AppDbObjects.

Returns:
the childs
See Also:
AppDbObjectTree

getTreeChildObjects

public 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(). Override if the childs vary according to this object's parent.

Parameters:
parentObject - the parent object of this object in the tree, null = no parent
Returns:
the list of childs
See Also:
AppDbObjectTree

getTreeExpandMaxDepth

public int getTreeExpandMaxDepth()
Gets the maximum level of expansion allowed in a navigatable object tree. The default is 0, i.e. no limit. Override this method to limit the load if node is expanded.

Returns:
the maximum depth of a subtree of this object, 0 = no limit (default)
See Also:
AppDbObjectTree

allowsTreeParentObjects

public 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. Trees may provide a button to make these parents visible. The default implementation returns false.

Returns:
true if showing parents is enabled
See Also:
AppDbObjectTree

getTreeParentObjects

public List<Object> getTreeParentObjects()
Gets the parents of this object. The default implementation returns an empty ArrayList.

Returns:
the parent objects
See Also:
AppDbObjectTree, allowsTreeParentObjects()

getTreeParentObjects

public 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.

Parameters:
parentObject - the parent object, null if no parent
Returns:
the parents
See Also:
AppDbObjectTree

getTreeRoot

public AppDbObject getTreeRoot()
Gets the object to be displayed in trees in place of this object. The default implementation returns "this". Override if necessary.

Returns:
the object to be displayed in a tree instead of this.
See Also:
AppDbObjectTree

getTreeText

public String getTreeText()
Gets the text to be displayed in trees for this object. The default returns DbObject.toString().

Returns:
the tree text
See Also:
AppDbObjectTree

getTreeText

public 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(). Override this method if the object's treetext varies according to its parent.

Parameters:
parent - is the parent object, null if no parent
Returns:
the tree text
See Also:
AppDbObjectTree

getToolTipText

public String getToolTipText()
Gets the tooltip to be displayed for an object in a tree. The default implementation returns DbObject.toString().

Returns:
the tooltip text
See Also:
AppDbObjectTree

getToolTipText

public 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(). Override this method if the objects tooltip varies according to its parent.

Parameters:
parent - is the parent object, null if no parent
Returns:
the tooltip text
See Also:
AppDbObjectTree

stopTreeExpansion

public boolean stopTreeExpansion()
Determines whether tree explansion should stop at this object.
Sometimes treechilds should not be expanded if in a recursive "expand all". However they should expand if the user explicitly wants to. If this method returns true, the tree will not further expand this node automatically (only on demand).
The default implementation returns false.

Returns:
true if expansion should stop.
See Also:
AppDbObjectTree

extractTreePathObjects

public 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[]). The default implementation simply invokes getTreeChildObjects().

Parameters:
clazz - is the class of the childs to get
Returns:
a list of childs which may be of *ANY* class, not clazz only.

getTransferable

public Transferable getTransferable()
Gets the Transferable for this object.
Used for drag and drop. If the object is new, null is returned because the object has no ID yet.

Returns:
the transferable, null if none
See Also:
AppDbObjectTransferable

dropTransferable

public boolean dropTransferable(Transferable transferable)
Drops a transferable on this object.
The default implementation does nothing and returns false (drop failed).

Parameters:
transferable - the Transferable
Returns:
true if drop succeeded, else false

containsPattern

public boolean containsPattern(String pattern)
Searches for a "pattern" in this object.
The default implementation looks for the pattern in the normtext.

Parameters:
pattern - the pattern to search for
Returns:
true if this object "contains" the pattern
See Also:
AppDbObjectSearchDialog

allowsHistory

public boolean allowsHistory()
Determines whether this object (or class) provides a field level history.
This controls the history-menuitem in trees. It does *not* tell whether the history is implemented by db-triggers or by tentackle!

Returns:
true if history is available
See Also:
AppDbObjectTree

getHistory

public History getHistory()
Gets the history object for this object.
The default implementation returns null.

Returns:
the history object, null if no history

isLoggingHistory

public boolean isLoggingHistory()
Determines whether the history is implemented by Tentackle.
History tables can be easily achieved by triggers directly within the database backend. However, sometimes it's better to let the application generate the history records. Furthermore, tentackle history logging *ONLY* logs ordinary inserts, updates, saves and deletes! No editedBy, updateSerial, dummyUpdate, etc...
The default implementation returns false.

Returns:
true if the application generates the history for this object (or class)

logHistory

public boolean logHistory(char historyType)
Performs the history logging.

Parameters:
historyType - is one of History.INSERT|UPDATE|DELETE
Returns:
true if history log could be created (and saved to the database)
See Also:
isLoggingHistory()

orderBy

public String orderBy()
Gets the natural ordering to be added in WHERE-clauses following "ORDER BY ". The wurblets will use it if --sort option set. Example:
  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.

Returns:
the order by appendix string, null if no order by

makeQbfPlugin

public QbfPlugin makeQbfPlugin()
Creates the qbf plugin for the search dialog.
The default implementation returns DefaultQbfPlugin.

Returns:
the plugin

presetQbfParameter

public void presetQbfParameter(QbfParameter qbfPar)
Presets the qbf parameter with default values from this object.
The default implementation does nothing.

Parameters:
qbfPar - the qbf parameter

permissionType

public int permissionType()
Determines the permission-type for this object.
Can also be some application specific type. The default implementation returns Security.TYPE_DATA

Returns:
the permission type

initModification

public boolean initModification(char modType)
Does any preprocessing before delete, insert or update.

Overridden due to security check.

Overrides:
initModification in class DbObject
Parameters:
modType - is the modification type: DELETE, INSERT or UPDATE
Returns:
true if preprocessing ok, false if not

finishModification

public boolean finishModification(char modType)
Does any postprocessing after delete, insert or update.

Overridden to log history, remove security rules and clear the editedby-token.

Overrides:
finishModification in class DbObject
Parameters:
modType - is the modification type: DELETE, INSERT or UPDATE
Returns:
true if postprocessing ok, false if not

finishNotUpdated

public boolean finishNotUpdated()
Does any update postprocessing for objects not being updated (because not modified for some reason, e.g. only composites modified). The default implementation does nothing. See AppDbObject.

Ovewritten to get the editedBy token removed, if any.

Overrides:
finishNotUpdated in class DbObject
Returns:
true if done, false if failed

clearEditedBy

public void clearEditedBy()
Clears the editedBy token.
The operation is only done in memory, not in persistent storage.


updateObject

public boolean updateObject(boolean withLinkedObjects)
Updates this object to the database.
The modified attribute gets cleared if insert was successful. Note: this method should be used by the application with great care! Use DbObject.save() instead!

Overridden to clear editedBy if remote db.

Overrides:
updateObject in class DbObject
Parameters:
withLinkedObjects - true if update also linked objects
Returns:
true if done, false if duplicate

save

public boolean save()
Saves this object.
This is the standard method applications should use to insert or update objects.

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.

Overrides:
save in class DbObject
Returns:
true of done, false if duplicate

getUpdateEditedByTimeout

public 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.

Returns:
the timespan in ms, 0 = no token required.
See Also:
AppDbObjectDialog

getUpdateEditedByStatementId

protected int getUpdateEditedByStatementId()
Gets the statement id for updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp).

Returns:
the statement id

setUpdateEditedByStatementId

protected void setUpdateEditedByStatementId(int id)
Sets the statement id for updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp).

Parameters:
id - the statement id

getUpdateEditedByOnlyStatementId

protected int getUpdateEditedByOnlyStatementId()
Gets the statement id for updateEditedByOnly().

Returns:
the statement id

setUpdateEditedByOnlyStatementId

protected void setUpdateEditedByOnlyStatementId(int id)
Sets the statement id for updateEditedByOnly().

Parameters:
id - the statement id

getSelectEditedByStatementId

protected int getSelectEditedByStatementId()
Gets the statement id for select in updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp).

Returns:
the statement id

setSelectEditedByStatementId

protected void setSelectEditedByStatementId(int id)
Sets the statement id for select in updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp).

Parameters:
id - the statement id

getTransferEditedByStatementId

protected int getTransferEditedByStatementId()
Gets the statement id for transferEditedBy(long).

Returns:
the statement id

setTransferEditedByStatementId

protected void setTransferEditedByStatementId(int id)
Sets the statement id for transferEditedBy(long).

Parameters:
id - the statement id

prepareUpdateEditedByStatement

protected int prepareUpdateEditedByStatement()
Prepares the updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp) statement.

Returns:
the statement id

prepareUpdateEditedByOnlyStatement

protected int prepareUpdateEditedByOnlyStatement()
Prepares the updateEditedByOnly() statement.

Returns:
the statement id

prepareSelectEditedByStatement

protected int prepareSelectEditedByStatement()
Prepares the select in updateEditedBy(java.sql.Timestamp, long, java.sql.Timestamp) statement.

Returns:
the statement id

prepareTransferEditedByStatement

protected int prepareTransferEditedByStatement()
Prepares the transferEditedBy(long) statement.

Returns:
the statement id

getEditedBy

public long getEditedBy()
Gets the id of the user currently editing this object.

Returns:
the id or 0 if not being edited currently.

setEditedBy

public void setEditedBy(long editedBy)
Sets the user editing this object. Does *NOT* alter isModified().

Parameters:
editedBy - the id of the user, 0 to clear.

isEditedLocked

public boolean isEditedLocked()
Checks whether this object is token locked (editedBy != 0) and the lock is not expired.

Returns:
true if locked by another user

getEditedSince

public Timestamp getEditedSince()
Gets the time since when this object is being edited.

Returns:
the time, null if not being edited.

setEditedSince

public void setEditedSince(Timestamp editedSince)
Sets the time since when this object is being edited. Does *NOT* alter isModified().

Parameters:
editedSince - the time, null to clear.

getEditedExpiry

public Timestamp getEditedExpiry()
Gets the time since when this object is being edited.

Returns:
the time, null if not being edited.

setEditedExpiry

public void setEditedExpiry(Timestamp editedExpiry)
Sets the time when the token should expire. Does *NOT* alter isModified().

Parameters:
editedExpiry - the expiration time, null to clear.

getEditedByObject

public 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. The default implementation invokes AbstractApplication.getUser(long).

Returns:
the user object, null if no user or id was 0

setEditedByObject

public void setEditedByObject(AppDbObject obj)
Sets the user/group/role-object editing this object.

Parameters:
obj - the object, null to clear.

updateEditedBy

public 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. See AppDbObjectDialog.

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.

Parameters:
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
Returns:
true if operation done, false if couldn't set/unset token

updateEditedBy

public 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. See AppDbObjectDialog.

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.

Parameters:
tokenExpiry - holds the time the token will expire. Null to release token.
Returns:
true if operation done, false if couldn't set/unset token

updateEditedByOnly

public 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. Used by daemons to cleanup.

Returns:
true if updated

transferEditedBy

public 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. Eliminates the time-gap when object is token-free. Furthermore allows taking over the token WITHOUT possessing it! This method should be used with great care as it does not check who owns the token and if there is a token at all. The serial will be increased, so the old user gets an error if trying to update. Furthermore, the current object does *NOT* get the serial increased thus preventing any update without reloading the object again! As opposed to updateEditedBy the modtable is updated (countModification) because the serial is increased and thus all caches must be invalidated.

Parameters:
userId - is the new user Id. (special 0 = free token, even if we are not the owner)
Returns:
true if operation done, false if couldn't transfer token

getFormTableEntry

public FormTableEntry getFormTableEntry()
Gets the table entry for viewing lists of this object in a FormTable.
The default implementation returns an AppDbObjectDefaultTableEntry. Should be overridden in subclasses.

Returns:
the formtable entry
See Also:
getFormTableName()

getFormTableName

public String getFormTableName()
Gets the tablename used in to initialize the table's gui (columns, sizes, etc...). The default implementation returns formTableName. Should be overridden.

Returns:
the table name
See Also:
getFormTableEntry()

getTransientData

public Object getTransientData()
Gets the optional transient data object.
The default implementation does nothing.

Returns:
the transient data, null if none.

setTransientData

public void setTransientData(Object data)
Sets the optional transient data object.
Sometimes, e.g. when objects need to be reloaded from storage, all non-persistent data attached to the object would be lost. In such cases the framework invokes getTransientData() and setTransientData() to keep the non-persistent attributes.
The default implementation does nothing.

Parameters:
data - the transient data

getRemoteDelegate

public AppDbObjectRemoteDelegate getRemoteDelegate()
Gets the delegate for remote connections.
Each class has its own delegate.

Overridden due to covariance.

Overrides:
getRemoteDelegate in class DbObject
Returns:
the delegate for this object

getSelectByNormTextStatementId

protected int getSelectByNormTextStatementId()
Gets the statememt id for selectByNormText(java.lang.String).

Returns:
the statement id

setSelectByNormTextStatementId

protected void setSelectByNormTextStatementId(int id)
Sets the statememt id for selectByNormText(java.lang.String).

Parameters:
id - the statement id

getSelectAllInContextStatementId

protected int getSelectAllInContextStatementId()
Gets the statememt id for selectAllInContext().

Returns:
the statement id

setSelectAllInContextStatementId

protected void setSelectAllInContextStatementId(int id)
Sets the statememt id for selectAllInContext().

Parameters:
id - the statement id

getSelectByNormTextCursorStatementId

protected int getSelectByNormTextCursorStatementId()
Gets the statememt id for selectByNormTextCursor(java.lang.String).

Returns:
the statement id

setSelectByNormTextCursorStatementId

protected void setSelectByNormTextCursorStatementId(int id)
Sets the statememt id for selectByNormTextCursor(java.lang.String).

Parameters:
id - the statement id

getSelectAllInContextCursorStatementId

protected int getSelectAllInContextCursorStatementId()
Gets the statememt id for selectAllInContextCursor().

Returns:
the statement id

setSelectAllInContextCursorStatementId

protected void setSelectAllInContextCursorStatementId(int id)
Sets the statememt id for selectAllInContextCursor().

Parameters:
id - the statement id

copyCollection

public 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.

Parameters:
col - the original collection
Returns:
the copied collection
See Also:
copy()

setClassPath

public 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()). 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.

Parameters:
path - the classpath

getClassPath

public static String[] getClassPath()
Gets the current classpath for loading classes by basename.

Returns:
the classpath

loadClass

public static Class<? extends AppDbObject> loadClass(String className)
                                              throws ClassNotFoundException
Loads an AppDbObject-class by its classname.
If the classname is fully qualifiedthe class will simply be loaded via 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.
This method allows storing shorter classnames in db-tables without the need to install a new classloader for the whole application.

Parameters:
className -
Returns:
the class
Throws:
ClassNotFoundException - if the class is not an extension of AppDbObject

newByClass

public static <T extends AppDbObject> T newByClass(ContextDb contextDb,
                                                   Class<T> clazz)
                                        throws InstantiationException,
                                               IllegalAccessException
Instantiates a new object for a given class and context.

Type Parameters:
T - the class
Parameters:
contextDb - the database context
clazz - the class to create a new object for
Returns:
the object
Throws:
InstantiationException
IllegalAccessException

newByClassBaseName

public static AppDbObject newByClassBaseName(ContextDb contextDb,
                                             String classBaseName)
                                      throws ClassNotFoundException,
                                             InstantiationException,
                                             IllegalAccessException
Instantiates a new object for a given classname and context. The classname may be full qualified or a basename.

Parameters:
contextDb - the database context
classBaseName - is the class basename
Returns:
the new object
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
See Also:
loadClass(java.lang.String)

getSingleName

public static String getSingleName(Class<? extends AppDbObject> clazz)
                            throws InstantiationException,
                                   IllegalAccessException
Gets the human readable name for a single object of given class.

Parameters:
clazz - the class
Returns:
the name
Throws:
InstantiationException
IllegalAccessException
See Also:
DbObject.getSingleName()

getMultiName

public static String getMultiName(Class<? extends AppDbObject> clazz)
                           throws InstantiationException,
                                  IllegalAccessException
Gets the human readable name for multiple objects of given class.

Parameters:
clazz - the class
Returns:
the name
Throws:
InstantiationException
IllegalAccessException
See Also:
DbObject.getMultiName()

selectInValidContext

public static <T extends AppDbObject> T selectInValidContext(Db db,
                                                             Class<T> clazz,
                                                             long id)
                                                  throws ClassNotFoundException,
                                                         InstantiationException,
                                                         IllegalAccessException
Selects an object for a given db connection and class by its unique ID in a newly created context (with linked objects).

Type Parameters:
T - the class
Parameters:
db - the db connection
clazz - the class
id - the object id
Returns:
the object, null if no such object
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
See Also:
selectInValidContext(long)

selectInValidContext

public static AppDbObject selectInValidContext(Db db,
                                               String classBaseName,
                                               long id)
                                        throws ClassNotFoundException,
                                               InstantiationException,
                                               IllegalAccessException
Selects an object for a given db connection and class by its unique ID in a newly created context (with linked objects).

Parameters:
db - the db connection
classBaseName - the class basename
id - the object id
Returns:
the object, null if no such object
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
See Also:
selectInValidContext(long)

selectAllInContext

public static <T extends AppDbObject> List<T> selectAllInContext(ContextDb contextDb,
                                                                 Class<T> clazz)
                                                      throws InstantiationException,
                                                             IllegalAccessException
Selects all objects for a given context and class.

Type Parameters:
T - the class
Parameters:
contextDb - the database context
clazz - the class
Returns:
the list of objects
Throws:
InstantiationException
IllegalAccessException
See Also:
selectAllInContext()

select

public static <T extends AppDbObject> T select(ContextDb contextDb,
                                               Class<T> clazz,
                                               long id)
                                    throws ClassNotFoundException,
                                           InstantiationException,
                                           IllegalAccessException
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 T select(ContextDb, Class, long)
 
 while T extends AppDbObject
 
If the class does not provide such a method an InstantationException is thrown.

Type Parameters:
T - the class
Parameters:
contextDb - the database context
clazz - the class
id - the object ID
Returns:
the object, null if no such object
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

selectCached

public static <T extends AppDbObject> T selectCached(ContextDb contextDb,
                                                     Class<T> clazz,
                                                     long id)
                                          throws ClassNotFoundException,
                                                 InstantiationException,
                                                 IllegalAccessException
Selects an object via cache for a given context, class and object ID.
If there is no cache, the object is selected uncached. If the class is abstract reflection is used to invoke a static method with the signature:
 static T selectCached(ContextDb, Class, long)
 
 while T extends AppDbObject
 
If the class does not provide such a method an InstantationException is thrown.

Type Parameters:
T - the class
Parameters:
contextDb - the database context
clazz - the class
id - the object ID
Returns:
the object, null if no such object
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

selectLocked

public static <T extends AppDbObject> T selectLocked(ContextDb contextDb,
                                                     Class<T> clazz,
                                                     long id)
                                          throws ClassNotFoundException,
                                                 InstantiationException,
                                                 IllegalAccessException
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 T selectLocked(ContextDb, Class, long)
 
 while T extends AppDbObject
 
If the class does not provide such a method an InstantationException is thrown.

Type Parameters:
T - the class
Parameters:
contextDb - the database context
clazz - the class
id - the object ID
Returns:
the object, null if no such object
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException

select

public static AppDbObject select(ContextDb contextDb,
                                 String classBaseName,
                                 long id)
                          throws ClassNotFoundException,
                                 InstantiationException,
                                 IllegalAccessException
Selects an object for a given context, class and object ID.

Parameters:
contextDb - the database context
classBaseName - the basename or full name of the class
id - the object ID
Returns:
the object, null if no such object
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
See Also:
newByClassBaseName(org.tentackle.appworx.ContextDb, java.lang.String)

selectCached

public static AppDbObject selectCached(ContextDb contextDb,
                                       String classBaseName,
                                       long id)
                                throws ClassNotFoundException,
                                       InstantiationException,
                                       IllegalAccessException
Selects an object via cache for a given context, class and object ID.
If there is no cache the object will be loaded uncached.

Parameters:
contextDb - the database context
classBaseName - the basename or full name of the class
id - the object ID
Returns:
the object, null if no such object
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
See Also:
newByClassBaseName(org.tentackle.appworx.ContextDb, java.lang.String)

selectLocked

public static AppDbObject selectLocked(ContextDb contextDb,
                                       String classBaseName,
                                       long id)
                                throws ClassNotFoundException,
                                       InstantiationException,
                                       IllegalAccessException
Selects and write-locks an object for a given context, class and object ID.

Parameters:
contextDb - the database context
classBaseName - the basename or full name of the class
id - the object ID
Returns:
the object, null if no such object
Throws:
ClassNotFoundException
InstantiationException
IllegalAccessException
See Also:
newByClassBaseName(org.tentackle.appworx.ContextDb, java.lang.String)

loadComposites

public static int loadComposites(Collection<? extends AppDbObject> objects)
Loads all composites of a collection.

Parameters:
objects - the collection of AppDbObjects
Returns:
the number of objects processed, < 0 if failed (number*(-1)-1)
Throws:
DbRuntimeException - if some object did not implement loadComposites()

filterAppDbObjects

public static List<AppDbObject> filterAppDbObjects(Collection col)
Filters a collection of Objects, returning only those that are AppDbObjects.

Parameters:
col - the collection of objects
Returns:
a list of AppDbObjects, the rest is ignored. Never null.

extractTreePath

public 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. The objects will usually displayed as a list in a table.

Parameters:
objects - the root-objects to walk along the clazz[]-path. Non-AppDbObjects will be skipped.
clazz - the classes to pass along
Returns:
the list of objects (of the last Class in clazz[])
See Also:
AppDbObjectTree

makeQbfPlugin

public static QbfPlugin makeQbfPlugin(Class<? extends AppDbObject> clazz,
                                      ContextDb db)
                               throws NoSuchMethodException,
                                      IllegalAccessException,
                                      InvocationTargetException
Invokes makeQbfPlugin in abstract classes.
Searches for a static method "makeQbfPlugin(ContextDb)" and invokes it.

Parameters:
clazz - is the abstract class
db - is the db-context
Returns:
the plugin
Throws:
NoSuchMethodException
IllegalAccessException
InvocationTargetException


Copyright © 2001-2008 Harald Krake, Bergstr. 48, 78098 Triberg, Germany, harald@krake.de