Class PersistentObject

java.lang.Object
com.groiss.store.PersistentObject
All Implemented Interfaces:
KeyValuePair<String,String>, Persistent, Serializable, Cloneable
Direct Known Subclasses:
BasicEvent, ExportablePersistentObject, Lock, Partner, ProcessInstanceView, ProcessRelation

public abstract class PersistentObject extends Object implements Persistent, Cloneable
This is a default implementation of the Persistent interface. All methods apart from Persistent.getTableName() are implemented with default behaviour.

This abstract class also implements the KeyValuePair interface. So persistent objects become key value pairs, where the object's OID is the key and the object's String representation is the value.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected long
     

    Fields inherited from interface com.groiss.store.Persistent

    emptyKeys
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method is called after the persistent object has been deleted.
    void
    This method is called after the persistent object has been inserted into the store.
    void
    This method is called after the persistent object has been read.
    void
    This method is called after the persistent object has been updated in the store.
    void
    This method is called before the persistent object is deleted.
    void
    This method is called before the persistent object is inserted into the store.
    void
    This method is called before the persistent object is updated in the store (the existing object in the store will be overwritten with the values of this object).
     
    Returns the persistent fields of this object in a List containing java.lang.reflect.Field objects.
    boolean
    Compares two persistent objects and returns true if they are equal (i.e., they must have the same OID and the same class).
    Returns the key (className:OID) of this KeyValuePair.
    String[][]
    A class may return key field groups in order to identify already existing objects of that class.
     
    Get the object name in localized form.
    long
    Getter method for the persistent object's OID.
    Returns the value (String representation) of this KeyValuePair.
    int
    Returns a hash code for this persistent object.
    boolean
    With this method you check if this persistent object is filled with persistent data or not.
    void
    Overwrite this method to check ids, etc.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use beforeDelete() instead.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use beforeInsert() instead.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use afterRead() instead.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use beforeUpdate() instead.
    void
    setFilled(boolean f)
    This method can change the filled status of this persistent object.
    void
    Setter method for the persistent object's OID.
    void
    setOid(long oid)
    Setter method for the persistent object's OID.
    Returns a special string representation of the object.

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.groiss.store.Persistent

    getStore, getTableName
  • Field Details

    • oid

      protected long oid
    • filled

      protected boolean filled
  • Constructor Details

    • PersistentObject

      public PersistentObject()
  • Method Details

    • getOid

      public long getOid()
      Description copied from interface: Persistent
      Getter method for the persistent object's OID.
      Specified by:
      getOid in interface Persistent
      Returns:
      The OID of the persistent object.
    • setOid

      public void setOid(long oid)
      Description copied from interface: Persistent
      Setter method for the persistent object's OID. Usually you will never need to set the OID of an object directly, because OIDs are assigned automatically.
      Specified by:
      setOid in interface Persistent
      Parameters:
      oid - The new OID for the object.
    • setOid

      public void setOid()
      Description copied from interface: Persistent
      Setter method for the persistent object's OID. Usually you will never need to set the OID of an object directly, because OIDs are assigned automatically when the object is inserted into the database. Sometimes it may be necessary to set the OID earlier in order to reference the object.
      Specified by:
      setOid in interface Persistent
    • setFilled

      public void setFilled(boolean f)
      Description copied from interface: Persistent
      This method can change the filled status of this persistent object. See Persistent.isFilled() for more details.
      Specified by:
      setFilled in interface Persistent
      Parameters:
      f - The new value for the filled status.
    • isFilled

      public boolean isFilled()
      Description copied from interface: Persistent
      With this method you check if this persistent object is filled with persistent data or not. If it is not filled, you can use the Store to fill it.
      Specified by:
      isFilled in interface Persistent
      Returns:
      true if the object is filled with values, or false if the object is empty (only OID is set).
    • dbFields

      public List<Field> dbFields()
      Returns the persistent fields of this object in a List containing java.lang.reflect.Field objects.
      Specified by:
      dbFields in interface Persistent
      Returns:
      A List containing the persistent fields of this persistent object. The List must contain the fields as java.lang.reflect.Field objects.
    • onInsert

      @Deprecated(since="9.0", forRemoval=true) public void onInsert()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use beforeInsert() instead.
    • onUpdate

      @Deprecated(since="9.0", forRemoval=true) public void onUpdate()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use beforeUpdate() instead.
    • onDelete

      @Deprecated(since="9.0", forRemoval=true) public void onDelete()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use beforeDelete() instead.
    • onRead

      @Deprecated(since="9.0", forRemoval=true) public void onRead()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use afterRead() instead.
    • beforeInsert

      public void beforeInsert()
      Description copied from interface: Persistent
      This method is called before the persistent object is inserted into the store.
      Specified by:
      beforeInsert in interface Persistent
      See Also:
    • afterInsert

      public void afterInsert()
      Description copied from interface: Persistent
      This method is called after the persistent object has been inserted into the store.
      Specified by:
      afterInsert in interface Persistent
      See Also:
    • beforeUpdate

      public void beforeUpdate()
      Description copied from interface: Persistent
      This method is called before the persistent object is updated in the store (the existing object in the store will be overwritten with the values of this object).
      Specified by:
      beforeUpdate in interface Persistent
      See Also:
    • afterUpdate

      public void afterUpdate()
      Description copied from interface: Persistent
      This method is called after the persistent object has been updated in the store.
      Specified by:
      afterUpdate in interface Persistent
      See Also:
    • beforeDelete

      public void beforeDelete()
      Description copied from interface: Persistent
      This method is called before the persistent object is deleted. Note that the Store.delete(Class, String, Object[]) and Store.delete(String, String, Object[]) methods do NOT call Persistent.beforeDelete().
      Specified by:
      beforeDelete in interface Persistent
      See Also:
    • afterDelete

      public void afterDelete()
      Description copied from interface: Persistent
      This method is called after the persistent object has been deleted. Note that the Store.delete(Class, String, Object[]) and Store.delete(String, String, Object[]) methods do NOT call Persistent.afterDelete().
      Specified by:
      afterDelete in interface Persistent
      See Also:
    • afterRead

      public void afterRead()
      Description copied from interface: Persistent
      This method is called after the persistent object has been read.
      Specified by:
      afterRead in interface Persistent
      See Also:
    • equals

      public boolean equals(Object o)
      Compares two persistent objects and returns true if they are equal (i.e., they must have the same OID and the same class).
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hash code for this persistent object. Equal objects must have equal hash codes, so the object's OID is used as hash code.
      Overrides:
      hashCode in class Object
    • getKey

      public String getKey()
      Returns the key (className:OID) of this KeyValuePair.
      Specified by:
      getKey in interface KeyValuePair<String,String>
      Specified by:
      getKey in interface Persistent
    • getValue

      public String getValue()
      Returns the value (String representation) of this KeyValuePair.
      Specified by:
      getValue in interface KeyValuePair<String,String>
      Specified by:
      getValue in interface Persistent
    • getLocalObjectName

      public String getLocalObjectName()
      Get the object name in localized form. Subclasses should override this method!
      Specified by:
      getLocalObjectName in interface Persistent
      Returns:
      the name of the objects in localized form
    • getLocalClassName

      public String getLocalClassName()
      Specified by:
      getLocalClassName in interface Persistent
      Returns:
      the name of the class in localized form. Subclasses should override this method!
    • toListString

      public String toListString()
      Returns a special string representation of the object.
      Specified by:
      toListString in interface Persistent
      Returns:
      a string representation of this Object suitable for usage in lists
    • isValid

      public void isValid()
      Overwrite this method to check ids, etc. It is called before inserts and updates are performed. The method should throw an ApplicationException or RunTimeException when the object is considered invalid.
      Specified by:
      isValid in interface Persistent
    • clone

      public Object clone()
      Overrides:
      clone in class Object
    • getKeys

      public String[][] getKeys()
      Description copied from interface: Persistent
      A class may return key field groups in order to identify already existing objects of that class. A key field group must uniquely identify an object. Multiple such key field groups can be defined. Each of the key field groups must be unique for an object to be unique (thus, group1 matches OR group2 matches etc.).

      The first key field group is occasionally treated in a special manner as the primary business key. E.g. the export import functionality checks for object existence according to just the first key field group.

      If no key field groups can be provided by the implementing class an empty result must be returned - use Persistent.emptyKeys to do so.

      Specified by:
      getKeys in interface Persistent
      Returns:
      An array of arrays containing object field names of those fields which constitute key field groups for uniquely identifying objects of classes implementing this interface. An example would be {{"name", "birthdate"},{"ssn"}} for a class defining two key field groups. The first one contains the fields name and birthdate, the second key field group has just one field ssn.