public class EntityDetails
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
private ChangeType |
changeType |
static DateFormatter |
DATE_FORMAT |
static DateFormatter |
DATETIME_FORMAT |
private int[] |
dirty |
private java.lang.Object |
entity |
private java.lang.Object[] |
previousState |
private java.lang.String[] |
properties |
private java.lang.Object[] |
state |
private Type[] |
types |
Constructor and Description |
---|
EntityDetails(java.lang.Object entity,
ChangeType changeType,
java.lang.Object[] state,
java.lang.Object[] previousState,
java.lang.String[] properties,
Type[] types) |
Modifier and Type | Method and Description |
---|---|
ChangeType |
getChangeType()
Was it a creation/update/deletion?
|
private static java.lang.String |
getDataClassName(java.lang.Object value) |
int |
getDirty(int index) |
java.lang.Object |
getEntity()
Get the entity that was changed.
|
int |
getIndex(java.lang.String property)
Get the array index of the given property.
|
java.lang.String |
getModifiedProperties(java.lang.String prefix,
java.lang.String separator,
java.lang.String suffix)
Get all modified properties as a string, separating each
property name with the given separator.
|
java.lang.Object[] |
getPreviousState()
Get an array with the previous state of the entity.
|
java.lang.String[] |
getProperties()
Get an array with the names of all properties.
|
java.lang.Object[] |
getState()
Get an array with the current state of the entity.
|
Type[] |
getTypes()
Get an array representing the data type for each property.
|
private void |
initializeDirtynessForSomeProperties()
We must initialize "dirtyness" for collections and some other
properties from the constructor.
|
boolean |
isOnlyDirty(java.lang.String property)
Checks if the given property is the only modified property.
|
void |
setDirty(int index,
int value)
Set the dirtyness for the property with the given index.
|
java.util.List<ChangeHistoryDetailData> |
toChangeDetails(boolean detailedProperties,
boolean oldPropertyValues)
Create a list of ChangeHistoryDetailData objects from the information
in this object assuming that the entity is a subclass of
BasicData . |
java.util.List<ChangeHistoryDetailData> |
toChangeDetails(Item itemType,
int itemId,
java.lang.String propertyPrefix,
ChangeType changeType,
boolean detailedProperties,
boolean oldPropertyValues)
Create a list of ChangeHistoryDetailData objects using a mix of the information
in this object, and the given parameters.
|
ChangeHistoryDetailData |
toChangeHistoryDetailData(BasicData data,
ChangeType changeType,
boolean detailedProperties)
Deprecated.
In 3.3. Use
toChangeDetails(Item, int, String, ChangeType, boolean, boolean) instead |
ChangeHistoryDetailData |
toChangeHistoryDetailData(boolean detailedProperties)
Deprecated.
In 3.3. Use
toChangeDetails(boolean, boolean) instead |
static java.lang.String |
toLoggableString(Type type,
java.lang.Object value) |
public static final DateFormatter DATE_FORMAT
public static final DateFormatter DATETIME_FORMAT
private final java.lang.Object entity
private final ChangeType changeType
private final java.lang.Object[] state
private final java.lang.Object[] previousState
private final java.lang.String[] properties
private final Type[] types
private final int[] dirty
public EntityDetails(java.lang.Object entity, ChangeType changeType, java.lang.Object[] state, java.lang.Object[] previousState, java.lang.String[] properties, Type[] types)
public java.lang.Object getEntity()
public ChangeType getChangeType()
public java.lang.Object[] getState()
public java.lang.Object[] getPreviousState()
getState()
for delete events.public java.lang.String[] getProperties()
public Type[] getTypes()
public int getDirty(int index)
public int getIndex(java.lang.String property)
public void setDirty(int index, int value)
index
- The index number of the propertyvalue
- The dirtyness (-1=not dirty, 0=not known, 1=dirty)public java.lang.String getModifiedProperties(java.lang.String prefix, java.lang.String separator, java.lang.String suffix)
prefix
- A string that is added first in the result, or nullseparator
- A separator string (if null, comma is used)suffix
- A string that is added last in the result, or nullpublic boolean isOnlyDirty(java.lang.String property)
@Deprecated public ChangeHistoryDetailData toChangeHistoryDetailData(boolean detailedProperties)
toChangeDetails(boolean, boolean)
insteadBasicData
.detailedProperties
- If TRUE, the ChangeHistoryDetailData.getChangeInfo()
is populated with a list of the names of the modified properties (only
relevant for UPDATE changes)@Deprecated public ChangeHistoryDetailData toChangeHistoryDetailData(BasicData data, ChangeType changeType, boolean detailedProperties)
toChangeDetails(Item, int, String, ChangeType, boolean, boolean)
insteaddata
- The entity that was changedchangeType
- The change typedetailedProperties
- If TRUE, the ChangeHistoryDetailData.getChangeInfo()
is populated with a list of the names of the modified properties (only
relevant for UPDATE changes)public java.util.List<ChangeHistoryDetailData> toChangeDetails(boolean detailedProperties, boolean oldPropertyValues)
BasicData
.detailedProperties
- If TRUE, one log entry is generated for each modified
property (UPDATE only), otherwise only a single log entry is createdoldPropertyValues
- If TRUE, the log entry will save the old and new
value (ignored unless detailedProperties is also set)public java.util.List<ChangeHistoryDetailData> toChangeDetails(Item itemType, int itemId, java.lang.String propertyPrefix, ChangeType changeType, boolean detailedProperties, boolean oldPropertyValues)
itemType
- The type of the item the log entries should be attached toitemId
- The id of the item the log entries should be attachedpropertyPrefix
- A prefix that is added to the property description to indicate what child object
that was modifiedchangeType
- The change typedetailedProperties
- If TRUE, the ChangeHistoryDetailData.getChangeInfo()
is populated with a list of the names of the modified properties (only
relevant for UPDATE changes)oldPropertyValues
- If TRUE, the log entry will save the old and new
value (ignored unless detailedProperties is also set)private void initializeDirtynessForSomeProperties()
public static java.lang.String toLoggableString(Type type, java.lang.Object value)
private static java.lang.String getDataClassName(java.lang.Object value)