use of org.hibernate.envers.Audited in project CzechIdMng by bcvsolutions.
the class IdmAuditStrategy method fillAbstractAuditedFields.
/**
* Method initialize list with all audited fields from {@link AbstractEntity}.
* The initialization will be done only once.
*
* @param auditCfg
*/
private void fillAbstractAuditedFields(AuditConfiguration auditCfg) {
if (auditedFieldsFromAbstractEntity == null) {
String modifiedFlagSuffix = auditCfg.getGlobalCfg().getModifiedFlagSuffix();
//
auditedFieldsFromAbstractEntity = new ArrayList<>();
//
for (Field field : AbstractEntity.class.getDeclaredFields()) {
Audited annotation = field.getAnnotation(Audited.class);
if (annotation != null) {
auditedFieldsFromAbstractEntity.add(field.getName() + modifiedFlagSuffix);
}
}
}
}
use of org.hibernate.envers.Audited in project hibernate-orm by hibernate.
the class AuditedPropertiesReader method addPropertiesFromClass.
/**
* Recursively adds all audited properties of entity class and its superclasses.
*
* @param clazz Currently processed class.
*/
private void addPropertiesFromClass(XClass clazz) {
final Audited allClassAudited = computeAuditConfiguration(clazz);
// look in the class
addFromProperties(clazz.getDeclaredProperties("field"), it -> "field", fieldAccessedPersistentProperties, allClassAudited);
addFromProperties(clazz.getDeclaredProperties("property"), propertyAccessedPersistentProperties::get, propertyAccessedPersistentProperties.keySet(), allClassAudited);
if (allClassAudited != null || !auditedPropertiesHolder.isEmpty()) {
final XClass superclazz = clazz.getSuperclass();
if (!clazz.isInterface() && !"java.lang.Object".equals(superclazz.getName())) {
addPropertiesFromClass(superclazz);
}
}
}
use of org.hibernate.envers.Audited in project hibernate-orm by hibernate.
the class AuditedPropertiesReader method addPropertiesFromDynamicComponent.
private void addPropertiesFromDynamicComponent(DynamicComponentSource dynamicComponentSource) {
Audited audited = computeAuditConfiguration(dynamicComponentSource.getXClass());
if (!fieldAccessedPersistentProperties.isEmpty()) {
throw new MappingException("Audited dynamic component cannot have properties with access=\"field\" for properties: " + fieldAccessedPersistentProperties + ". \n Change properties access=\"property\", to make it work)");
}
for (Map.Entry<String, String> entry : propertyAccessedPersistentProperties.entrySet()) {
String property = entry.getKey();
String accessType = entry.getValue();
if (!auditedPropertiesHolder.contains(property)) {
final Value propertyValue = persistentPropertiesSource.getProperty(property).getValue();
if (propertyValue instanceof Component) {
this.addFromComponentProperty(new DynamicProperty(dynamicComponentSource, property), accessType, (Component) propertyValue, audited);
} else {
this.addFromNotComponentProperty(new DynamicProperty(dynamicComponentSource, property), accessType, audited);
}
}
}
}
Aggregations