2.17.2: 2011-06-17

net.sf.basedb.core.log
Class EntityDetails

java.lang.Object
  extended by net.sf.basedb.core.log.EntityDetails

public class EntityDetails
extends Object

Contains detailed information about the changes made to an entity during a transaction. This information is sent to an EntityLogger that is responsible for the actual logging.

NOTE! The information in this object is more or less drawn from what Hibernate reveals about the entity. It is recommended that no information is changed.

Version:
2.13
Author:
Nicklas
Last modified
$Date: 2010-01-18 08:31:09 +0100 (Mon, 18 Jan 2010) $

Field Summary
private  ChangeType changeType
           
private  int[] dirty
           
private  Object entity
           
private  EntityLogger logger
           
private  Object[] previousState
           
private  String[] properties
           
private  Object[] state
           
private  org.hibernate.type.Type[] types
           
 
Constructor Summary
EntityDetails(EntityLogger logger, Object entity, ChangeType changeType, Object[] state, Object[] previousState, String[] properties, org.hibernate.type.Type[] types)
           
 
Method Summary
private  void findDirtyCollections()
          We must do this from the constructor since the "dirtyness" of a collection is reset after flush the SQL to the database, which is completed before the rest of the logging is done.
 ChangeType getChangeType()
          Was it a creation/update/deletion?
 Object getEntity()
          Get the entity that was changed.
 EntityLogger getEntityLogger()
          Get the entity logger that handles the logging for this event.
 String getModifiedProperties(String prefix, String separator, String suffix)
          Get all modified properties as a string, separating each property name with the given separator.
 Object[] getPreviousState()
          Get an array with the previous state of the entity.
 String[] getProperties()
          Get an array with the names of all properties.
 Object[] getState()
          Get an array with the current state of the entity.
 org.hibernate.type.Type[] getTypes()
          Get an array representing the data type for each property.
 ChangeHistoryDetailData toChangeHistoryDetailData(BasicData data, ChangeType changeType, boolean detailedProperties)
          Create a new ChangeHistoryDetailData object using a mix of the information in this object, and the given parameters.
 ChangeHistoryDetailData toChangeHistoryDetailData(boolean detailedProperties)
          Create a new ChangeHistoryDetailData object from the information in this object assuming that the entity is a subclass of BasicData.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private final EntityLogger logger

entity

private final Object entity

changeType

private final ChangeType changeType

state

private final Object[] state

previousState

private final Object[] previousState

properties

private final String[] properties

types

private final org.hibernate.type.Type[] types

dirty

private final int[] dirty
Constructor Detail

EntityDetails

public EntityDetails(EntityLogger logger,
                     Object entity,
                     ChangeType changeType,
                     Object[] state,
                     Object[] previousState,
                     String[] properties,
                     org.hibernate.type.Type[] types)
Method Detail

getEntityLogger

public EntityLogger getEntityLogger()
Get the entity logger that handles the logging for this event.


getEntity

public Object getEntity()
Get the entity that was changed.


getChangeType

public ChangeType getChangeType()
Was it a creation/update/deletion?


getState

public Object[] getState()
Get an array with the current state of the entity.


getPreviousState

public Object[] getPreviousState()
Get an array with the previous state of the entity. The array is null for new items and is identical to the array returned by getState() for delete events.


getProperties

public String[] getProperties()
Get an array with the names of all properties.


getTypes

public org.hibernate.type.Type[] getTypes()
Get an array representing the data type for each property.


getModifiedProperties

public String getModifiedProperties(String prefix,
                                    String separator,
                                    String suffix)
Get all modified properties as a string, separating each property name with the given separator.

Parameters:
prefix - A string that is added first in the result, or null
separator - A separator string (if null, comma is used)
suffix - A string that is added last in the result, or null
Returns:
A string with the modified properties, or null if this is a CREATE or DELETE change or if no modified properties was found

toChangeHistoryDetailData

public ChangeHistoryDetailData toChangeHistoryDetailData(boolean detailedProperties)
Create a new ChangeHistoryDetailData object from the information in this object assuming that the entity is a subclass of BasicData.

Parameters:
detailedProperties - If TRUE, the ChangeHistoryDetailData.getChangeInfo() is populated with a list of the names of the modified properties (only relevant for UPDATE changes)
Returns:
A new ChangeHistoryDetailData instance

toChangeHistoryDetailData

public ChangeHistoryDetailData toChangeHistoryDetailData(BasicData data,
                                                         ChangeType changeType,
                                                         boolean detailedProperties)
Create a new ChangeHistoryDetailData object using a mix of the information in this object, and the given parameters.

Parameters:
data - The entity that was changed
changeType - The change type
detailedProperties - If TRUE, the ChangeHistoryDetailData.getChangeInfo() is populated with a list of the names of the modified properties (only relevant for UPDATE changes)
Returns:
A new ChangeHistoryDetailData instance

findDirtyCollections

private void findDirtyCollections()
We must do this from the constructor since the "dirtyness" of a collection is reset after flush the SQL to the database, which is completed before the rest of the logging is done.


2.17.2: 2011-06-17