public class EntityDetails extends 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 Object |
entity |
private Object[] |
previousState |
private String[] |
properties |
private Object[] |
state |
private Type[] |
types |
Constructor and Description |
---|
EntityDetails(Object entity,
ChangeType changeType,
Object[] state,
Object[] previousState,
String[] properties,
Type[] types) |
Modifier and Type | Method and Description |
---|---|
ChangeType |
getChangeType()
Was it a creation/update/deletion?
|
private static String |
getDataClassName(Object value) |
int |
getDirty(int index) |
Object |
getEntity()
Get the entity that was changed.
|
int |
getIndex(String property)
Get the array index of the given property.
|
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.
|
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(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.
|
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 . |
List<ChangeHistoryDetailData> |
toChangeDetails(Item itemType,
int itemId,
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 String |
toLoggableString(Type type,
Object value) |
public static final DateFormatter DATE_FORMAT
public static final DateFormatter DATETIME_FORMAT
private final Object entity
private final ChangeType changeType
private final Object[] state
private final Object[] previousState
private final String[] properties
private final Type[] types
private final int[] dirty
public Object getEntity()
public ChangeType getChangeType()
public Object[] getState()
public Object[] getPreviousState()
getState()
for delete events.public String[] getProperties()
public Type[] getTypes()
public int getDirty(int index)
public int getIndex(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 String getModifiedProperties(String prefix, String separator, 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(String property)
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 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 List<ChangeHistoryDetailData> toChangeDetails(Item itemType, int itemId, 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()