de.esprit.appsuite.database.dbase

## Class ComposedRecord

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.common.util.TransferableObject
    - - de.esprit.appsuite.database.dbase.ComposedRecord

- All Implemented Interfaces:
    DBPersistent, DBRecord, Renderable, DeepCloneable, Dumpable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

      public abstract class ComposedRecord
      extends TransferableObject
      implements DBRecord

  This is the superclass for all composed records that are build up with DBObjects. It implements already most of the DBRecord interface, thus making all subclasses automatically GUI representable.
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ComposedRecord()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ComposedRecord` | `clone()` Performs a deep clone of this object.
    `void` | `copyRecordValues(DBRecord otherRecord, boolean isIncludePK)`
    `protected abstract DBRecord` | `createInstance(DBObject dbo)` Must be implemented by subclasses
    `protected abstract DBRecord` | `createInstance(java.lang.String[] primaryKey)` Must be implemented by subclasses
    `void` | `dbLoad(DBLoadMonitor monitor, SqlCondition condition)` Reads a set of objects from from the database according to the given condition.
    `void` | `dbLoad(DBLoadMonitor monitor, SqlCondition condition, SqlOrder order)` Performs a monitored load of records.
    `void` | `dbRehash()` Rehashes all DBObjects this record is composed of.
    `void` | `dbSearch(DBLoadMonitor monitor, SqlCondition condition)` Reads a set of objects from from the database according to the given condition.
    `void` | `dbSearch(DBLoadMonitor monitor, SqlCondition condition, SqlOrder order)` Reads a set of objects from from the database according to the given condition and order.
    `DBRecord[]` | `dbSearch(SqlCondition condition)` Reads a set of objects from from the database according to the given condition.
    `DBRecord[]` | `dbSearch(SqlCondition condition, SqlOrder order)` Reads a set of objects from from the database according to the given condition and order.
    `DBRecord[]` | `dbSelect(SqlCondition condition)` Reads a set of objects from from the database according to the given condition.
    `DBRecord[]` | `dbSelect(SqlCondition condition, SqlOrder order)` Reads ComposedRecord instances from the database.
    `<T> T` | `deepClone()` Returns a deep clone of this object
    `boolean` | `equals(java.lang.Object o)`
    `boolean` | `exists()` Checks the existance of all DBObjects this record is composed of.
    `boolean` | `existsField(java.lang.String fieldName)` Tells wasCancelled this field exists in this DBObject.
    `abstract DBRecord[]` | `getAvailableSubTypes()` Returns an array of instances of sub-types of this composed record type.
    `int` | `getFieldCount()` Returns the number columns of this DBObject including primary key columns
    `java.lang.String[]` | `getFieldFullNames()` Returns the full names of all columns in the format table.column
    `int` | `getFieldLength(java.lang.String fieldName)` Returns the length (in number or characters) of the given fieldname.
    `java.lang.String[]` | `getFieldNames()` Returns the names of all columns without the table prefix
    `java.lang.String` | `getForeignKeyRef(java.lang.String fieldName)` If the given field is a foreign key field then the referenced fieldname is returned in the format table.column.
    `java.lang.Class` | `getJavaType(java.lang.String fieldName)` Returns the java variable type of the given fieldname.
    `int` | `getJdbcType(java.lang.String fieldName)` Returns the jdbc-type of the given fieldname.
    `DBObject` | `getLastManagedDBObject()` Returns the bottom element in the list of managed DBObjects
    `abstract DBRecord` | `getParentType()` Returns the parent in inheritance hierarchy.
    `int` | `getPrimaryKeyCount()` Returns the number of fields that compose the primary key
    `java.lang.String[]` | `getPrimaryKeyValues()` Returns the values of the primary key as a String array.
    `java.lang.String` | `getRecordName()` Returns a unique name for this record, which is usually the tablename.
    `java.awt.Color` | `getRenderColor()`
    `javax.swing.Icon` | `getRenderIcon()`
    `java.lang.String` | `getTranslationAppKey()` Returns the main translation key for this record.
    `java.lang.Object` | `getValue(java.lang.String fieldName)` Returns the current value of the given fieldname.
    `int` | `hashCode()`
    `boolean` | `hasPrimaryKey()` Tells whether this object has a primary key at all
    `boolean` | `isDirty()` Tells whether any of the managed DBObjects has been changed and is not in sync with the database any more.
    `boolean` | `isFieldVirtual(java.lang.String fieldName)` Tells wasCancelled this field is supposed to be editable.
    `boolean` | `isForeignKey(java.lang.String fieldName)` Tells wasCancelled this field is a foreign key field.
    `boolean` | `isNotNullField(java.lang.String fieldName)` Tells wasCancelled this field is a not null field.
    `boolean` | `isPrimaryKey(java.lang.String fieldName)` Tells wasCancelled this field is or is part of the primary key.
    `void` | `setPrimaryKeyValues(java.lang.String... pkValues)` Sets the values of the primary key.
    `DumpString` | `toDumpString(DumpString s)` This method allows subclasses to add values to the existing DumpString of the superclass.
    `ToString` | `toString(ToString s)` This method allows subclasses to add values to the existing ToString of the superclass.

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface de.esprit.appsuite.database.dbase.DBRecord

      `getFieldIcon, getManagedDBObjects, getMasterRecord`

    - ### Methods inherited from interface de.esprit.appsuite.database.dbase.DBPersistent

      `dbDelete, dbInsert, dbUpdate`

    - ### Methods inherited from interface de.esprit.common.type.Dumpable

      `toDumpString, toString`

    - ### Methods inherited from interface java.lang.Comparable

      `compareTo`

    - ### Methods inherited from interface de.esprit.common.gui.Renderable

      `getRenderText`

- - ### Constructor Detail

    - #### ComposedRecord

          public ComposedRecord()

  - ### Method Detail

    - #### getTranslationAppKey

          public java.lang.String getTranslationAppKey()

      Description copied from interface: `DBRecord`
      Returns the main translation key for this record. This key is used as a prefix for all translations of this record.
      Specified by:
        `getTranslationAppKey` in interface `DBRecord`

    - #### hasPrimaryKey

          public boolean hasPrimaryKey()

      Description copied from interface: `DBPersistent`
      Tells whether this object has a primary key at all
      Specified by:
        `hasPrimaryKey` in interface `DBPersistent`

    - #### getRenderIcon

          public javax.swing.Icon getRenderIcon()

      Specified by:
        `getRenderIcon` in interface `Renderable`

    - #### getRenderColor

          public java.awt.Color getRenderColor()

      Specified by:
        `getRenderColor` in interface `Renderable`

    - #### dbSelect

          public DBRecord[] dbSelect(SqlCondition condition)
                              throws java.lang.Exception

      Description copied from interface: `DBPersistent`
      Reads a set of objects from from the database according to the given condition. The default ordering is by primary key.
      Specified by:
        `dbSelect` in interface `DBPersistent`
      Throws:
        `java.lang.Exception`

    - #### dbLoad

          public void dbLoad(DBLoadMonitor monitor,
                    SqlCondition condition)
                      throws java.lang.Exception

      Description copied from interface: `DBPersistent`
      Reads a set of objects from from the database according to the given condition. The default ordering is by primary key.
      Specified by:
        `dbLoad` in interface `DBPersistent`
      Throws:
        `java.lang.Exception`

    - #### dbSearch

          public DBRecord[] dbSearch(SqlCondition condition)
                              throws java.lang.Exception

      Description copied from interface: `DBPersistent`
      Reads a set of objects from from the database according to the given condition. The default ordering is by primary key.
      Specified by:
        `dbSearch` in interface `DBPersistent`
      Throws:
        `java.lang.Exception`

    - #### dbSearch

          public DBRecord[] dbSearch(SqlCondition condition,
                            SqlOrder order)
                              throws java.lang.Exception

      Description copied from interface: `DBPersistent`
      Reads a set of objects from from the database according to the given condition and order.
      Specified by:
        `dbSearch` in interface `DBPersistent`
      Throws:
        `java.lang.Exception`

    - #### dbSearch

          public void dbSearch(DBLoadMonitor monitor,
                      SqlCondition condition)
                        throws java.lang.Exception

      Description copied from interface: `DBPersistent`
      Reads a set of objects from from the database according to the given condition. The default ordering is by primary key.
      Specified by:
        `dbSearch` in interface `DBPersistent`
      Throws:
        `java.lang.Exception`

    - #### dbSearch

          public void dbSearch(DBLoadMonitor monitor,
                      SqlCondition condition,
                      SqlOrder order)
                        throws java.lang.Exception

      Description copied from interface: `DBPersistent`
      Reads a set of objects from from the database according to the given condition and order.
      Specified by:
        `dbSearch` in interface `DBPersistent`
      Throws:
        `java.lang.Exception`

    - #### clone

          public ComposedRecord clone()

      Performs a deep clone of this object. All internally managed DBObjects are cloned too.
      Overrides:
        `clone` in class `TransferableObject`

    - #### createInstance

          protected abstract DBRecord createInstance(java.lang.String[] primaryKey)
                                              throws java.lang.Exception

      Must be implemented by subclasses
      Throws:
        `java.lang.Exception`

    - #### createInstance

          protected abstract DBRecord createInstance(DBObject dbo)
                                              throws java.lang.Exception

      Must be implemented by subclasses
      Throws:
        `java.lang.Exception`

    - #### getPrimaryKeyCount

          public int getPrimaryKeyCount()

      Description copied from interface: `DBPersistent`
      Returns the number of fields that compose the primary key
      Specified by:
        `getPrimaryKeyCount` in interface `DBPersistent`

    - #### getPrimaryKeyValues

          public java.lang.String[] getPrimaryKeyValues()

      Description copied from interface: `DBPersistent`
      Returns the values of the primary key as a String array. Note that the primary key must consist of data types that are representable by a String!
      Specified by:
        `getPrimaryKeyValues` in interface `DBPersistent`

    - #### setPrimaryKeyValues

          public void setPrimaryKeyValues(java.lang.String... pkValues)

      Description copied from interface: `DBPersistent`
      Sets the values of the primary key. Note that the order of the array elements must match the primary key definition in the table.
      Specified by:
        `setPrimaryKeyValues` in interface `DBPersistent`

    - #### getForeignKeyRef

          public java.lang.String getForeignKeyRef(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      If the given field is a foreign key field then the referenced fieldname is returned in the format table.column.
      Specified by:
        `getForeignKeyRef` in interface `DBRecord`
      Parameters:
        `fieldName` - The name of the field in the format table.column - only the column name is checked!

    - #### isForeignKey

          public boolean isForeignKey(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      Tells wasCancelled this field is a foreign key field.
      Specified by:
        `isForeignKey` in interface `DBRecord`
      Parameters:
        `fieldName` - might be a pure column name or in the format table.column - only the column name is checked!
      See Also:
        `DBRecord.getForeignKeyRef(String)`

    - #### isPrimaryKey

          public boolean isPrimaryKey(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      Tells wasCancelled this field is or is part of the primary key.
      Specified by:
        `isPrimaryKey` in interface `DBRecord`
      Parameters:
        `fieldName` - might be a pure column name or in the format table.column - only the column name is checked!

    - #### getFieldCount

          public int getFieldCount()

      Description copied from interface: `DBRecord`
      Returns the number columns of this DBObject including primary key columns
      Specified by:
        `getFieldCount` in interface `DBRecord`

    - #### getRecordName

          public java.lang.String getRecordName()

      Description copied from interface: `DBPersistent`
      Returns a unique name for this record, which is usually the tablename. On more complex composed persistent objects this may be any other identifying name.
      Specified by:
        `getRecordName` in interface `DBPersistent`

    - #### getFieldFullNames

          public java.lang.String[] getFieldFullNames()

      Description copied from interface: `DBRecord`
      Returns the full names of all columns in the format table.column
      Specified by:
        `getFieldFullNames` in interface `DBRecord`

    - #### getFieldNames

          public java.lang.String[] getFieldNames()

      Description copied from interface: `DBRecord`
      Returns the names of all columns without the table prefix
      Specified by:
        `getFieldNames` in interface `DBRecord`

    - #### existsField

          public boolean existsField(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      Tells wasCancelled this field exists in this DBObject.
      Specified by:
        `existsField` in interface `DBRecord`
      Parameters:
        `fieldName` - might be a pure column name or in the format table.column - only the column name is checked!

    - #### getValue

          public java.lang.Object getValue(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      Returns the current value of the given fieldname.
      Specified by:
        `getValue` in interface `DBRecord`
      Parameters:
        `fieldName` - might be a pure column name or in the format table.column - only the column name is checked!

    - #### isNotNullField

          public boolean isNotNullField(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      Tells wasCancelled this field is a not null field.
      Specified by:
        `isNotNullField` in interface `DBRecord`
      Parameters:
        `fieldName` - might be a pure column name or in the format table.column - only the column name is checked!

    - #### isFieldVirtual

          public boolean isFieldVirtual(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      Tells wasCancelled this field is supposed to be editable. Composed objects might have fields that have no representation in the database (because they are calculated fields) and thus cannot be edited.
      Specified by:
        `isFieldVirtual` in interface `DBRecord`
      Parameters:
        `fieldName` - can be the pure column name or in the format table.column - only the column name is checked!

    - #### getJdbcType

          public int getJdbcType(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      Returns the jdbc-type of the given fieldname.
      Specified by:
        `getJdbcType` in interface `DBRecord`
      Parameters:
        `fieldName` - might be a pure column name or in the format table.column - only the column name is checked!
      See Also:
        `Types`

    - #### getFieldLength

          public int getFieldLength(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      Returns the length (in number or characters) of the given fieldname.
      Specified by:
        `getFieldLength` in interface `DBRecord`
      Parameters:
        `fieldName` - might be a pure column name or in the format table.column - only the column name is checked!

    - #### getJavaType

          public java.lang.Class getJavaType(java.lang.String fieldName)

      Description copied from interface: `DBRecord`
      Returns the java variable type of the given fieldname.
      Specified by:
        `getJavaType` in interface `DBRecord`
      Parameters:
        `fieldName` - might be a pure column name or in the format table.column - only the column name is checked!

    - #### toString

          public ToString toString(ToString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing ToString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toString` in interface `Dumpable`
      Overrides:
        `toString` in class `DumpableObject`

    - #### toDumpString

          public DumpString toDumpString(DumpString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing DumpString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toDumpString` in interface `Dumpable`
      Overrides:
        `toDumpString` in class `DumpableObject`

    - #### equals

          public boolean equals(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### dbRehash

          public void dbRehash()
                        throws java.lang.Exception

      Rehashes all DBObjects this record is composed of.
      Specified by:
        `dbRehash` in interface `DBPersistent`
      Throws:
        `java.lang.Exception`
      See Also:
        `DBPersistent.isDirty()`

    - #### exists

          public boolean exists()

      Checks the existance of all DBObjects this record is composed of. Returns true only if they all exist.
      Specified by:
        `exists` in interface `DBPersistent`

    - #### isDirty

          public boolean isDirty()

      Tells whether any of the managed DBObjects has been changed and is not in sync with the database any more. An dbUpdate() or a dbRehash() call will be needed to get them back in sync.
      Specified by:
        `isDirty` in interface `DBPersistent`

    - #### getLastManagedDBObject

          public DBObject getLastManagedDBObject()

      Returns the bottom element in the list of managed DBObjects

    - #### dbLoad

          public void dbLoad(DBLoadMonitor monitor,
                    SqlCondition condition,
                    SqlOrder order)
                      throws java.lang.Exception

      Performs a monitored load of records. The result contains sub-instances of ComposedRecords. In order to remain cancellable the load is done in 2 steps

      1st) read all DBO_xyy records with a cancellable RecordIterator
      2nd) in a canclelable loop create Xyy instances from the DBO_xyy records

      Note that the filter condition may only contain properties of the subclass at the very bottom of the hierarchy.

      Specified by:
        `dbLoad` in interface `DBPersistent`
      Throws:
        `java.lang.Exception`

    - #### dbSelect

          public DBRecord[] dbSelect(SqlCondition condition,
                            SqlOrder order)
                              throws java.lang.Exception

      Reads ComposedRecord instances from the database. The returned objects will be the type-specific subclasses of this class.

      Note that the filter condition may only contain properties of the subclass at the very bottom of the hierarchy.

      Specified by:
        `dbSelect` in interface `DBPersistent`
      Throws:
        `java.lang.Exception`

    - #### getAvailableSubTypes

          public abstract DBRecord[] getAvailableSubTypes()

      Returns an array of instances of sub-types of this composed record type. The array contains only sub-types that are direct derivations of the current type. This is needed when inserting new Records in order to give the user a choice which sub-type of record is going to be created.

    - #### getParentType

          public abstract DBRecord getParentType()

      Returns the parent in inheritance hierarchy. If the instance is the root component in the hierarchy tree, then it should return 'this' if it wants to be seen in a DBList or null if preferes to be invisible.

    - #### deepClone

          public <T> T deepClone()

      Description copied from interface: `DeepCloneable`
      Returns a deep clone of this object
      Specified by:
        `deepClone` in interface `DeepCloneable`
      Overrides:
        `deepClone` in class `TransferableObject`

    - #### copyRecordValues

          public void copyRecordValues(DBRecord otherRecord,
                              boolean isIncludePK)
                                throws java.lang.Exception

      Specified by:
        `copyRecordValues` in interface `DBRecord`
      Throws:
        `java.lang.Exception`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.