de.esprit.appsuite.database.dbase

## Class InsertDefaultFactory

- java.lang.Object
- - de.esprit.appsuite.database.dbase.InsertDefaultFactory

- All Implemented Interfaces:
    InsertFactory

      public class InsertDefaultFactory
      extends java.lang.Object
      implements InsertFactory

  This class may provide insert default values for any DBObject field. Use `DBObject.setInsertFactory(InsertFactory)` to activate this class. The insert default values are applied when the `DBObject.dbInsert()` method is called on a DBObject.

  Note that you can change the latter behavior using `setApplyValuesInDialog(boolean)` which causes the apply of default values at the time when the RecordEdit dialog is applied.

  Note that for Date/Time/Timestamp values you may set the special constant InsertDefaultFactory.CURRENT, which is evaluated to the current time value at runtime.

  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `InsertDefaultFactory(DBRecord anyMasterInPackage)`
    `InsertDefaultFactory(java.lang.String dboPackageName)` You must provide the name of the package where the `DBObject`s are.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `get(Field inputField)` Gets the value for the given table-column or null if none is specified.
    `java.lang.Object` | `get(NlsDatabaseKey nlsKey)` Gets the value for the given table-column or null if none is specified.
    `java.lang.Class` | `getDataTypeFor(java.lang.String tableColumn)` Returns the data type of the given table-column of an `DBObject`.
    `boolean` | `isApplyValuesInDialog()` Defines whether the insert-default values should be applied to a DBObject when the record editor dialog is applied.
    `int` | `loadFromDatabase()` Loads the insert default definitions from the insert_def database table.
    `void` | `put(DBColumnKey columnKey, PersistentId insertValue)`
    `void` | `put(Field inputField, java.lang.Object insertValue)` Strores an insert default value for the given table-column.
    `void` | `put(NlsDatabaseKey nlsKey, java.lang.Object insertValue)` Strores an insert default value for the given table-column.
    `void` | `setApplyValuesInDialog(boolean isApplyValuesInDialog)` Tells whether the insert-default values should be applied to a DBObject when the record editor dialog is applied.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### InsertDefaultFactory

          public InsertDefaultFactory(java.lang.String dboPackageName)

      You must provide the name of the package where the `DBObject`s are. This is needed in order to find out from the DBO classes (by introspection) what data types the various table-column have got.
      Parameters:
        `dboPackageName` - name of the package where the DBObjects are

    - #### InsertDefaultFactory

          public InsertDefaultFactory(DBRecord anyMasterInPackage)

  - ### Method Detail

    - #### isApplyValuesInDialog

          public boolean isApplyValuesInDialog()

      Description copied from interface: `InsertFactory`
      Defines whether the insert-default values should be applied to a DBObject when the record editor dialog is applied. By default the values are applied when dbInsert() is called.
      Specified by:
        `isApplyValuesInDialog` in interface `InsertFactory`

    - #### setApplyValuesInDialog

          public void setApplyValuesInDialog(boolean isApplyValuesInDialog)

      Description copied from interface: `InsertFactory`
      Tells whether the insert-default values should be applied to a DBObject when the record editor dialog is applied. By default the values are applied when dbInsert() is called.
      Specified by:
        `setApplyValuesInDialog` in interface `InsertFactory`

    - #### get

          public java.lang.Object get(Field inputField)

      Description copied from interface: `InsertFactory`
      Gets the value for the given table-column or null if none is specified. The value will be converted to the data type of the particular table-column.
      Specified by:
        `get` in interface `InsertFactory`

    - #### get

          public java.lang.Object get(NlsDatabaseKey nlsKey)

      Description copied from interface: `InsertFactory`
      Gets the value for the given table-column or null if none is specified. The value will be converted to the data type of the particular table-column.
      Specified by:
        `get` in interface `InsertFactory`

    - #### put

          public void put(DBColumnKey columnKey,
                 PersistentId insertValue)

    - #### put

          public void put(NlsDatabaseKey nlsKey,
                 java.lang.Object insertValue)

      Description copied from interface: `InsertFactory`
      Strores an insert default value for the given table-column. Note that the data type of the value must match the real data type of the table-column.
      Specified by:
        `put` in interface `InsertFactory`

    - #### put

          public void put(Field inputField,
                 java.lang.Object insertValue)

      Description copied from interface: `InsertFactory`
      Strores an insert default value for the given table-column. Note that the data type of the value must match the real data type of the table-column.
      Specified by:
        `put` in interface `InsertFactory`

    - #### getDataTypeFor

          public java.lang.Class getDataTypeFor(java.lang.String tableColumn)

      Returns the data type of the given table-column of an `DBObject`. This type is determined by introspecting the according DBObject class.

    - #### loadFromDatabase

          public int loadFromDatabase()
                               throws java.lang.Exception

      Loads the insert default definitions from the insert_def database table.
      Throws:
        `java.lang.Exception`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.