use of io.jmix.audit.entity.EntityLogItem in project jmix by jmix-framework.
the class EntityLogImpl method registerModify.
@Override
public void registerModify(Object entity, boolean auto, @Nullable AttributeChanges changes) {
try {
if (doNotRegister(entity))
return;
String entityName = getEntityName(entity);
Set<String> attributes = getLoggedAttributes(entityName, auto);
if (attributes != null && attributes.contains("*")) {
attributes = getAllAttributes(entity);
}
if (attributes == null) {
return;
}
MetaClass metaClass = metadata.getClass(entityName);
attributes = filterRemovedAttributes(entity, attributes);
String storeName = metaClass.getStore().getName();
EntityLogItem item;
// Create a new transaction in main DB if we are saving an entity from additional data store
if (!Stores.isMain(storeName)) {
Set<String> finalAttributes = attributes;
item = transaction.execute(status -> internalRegisterModify(entity, changes, metaClass, storeName, finalAttributes));
} else {
item = internalRegisterModify(entity, changes, metaClass, storeName, attributes);
}
enqueueItem(item, storeName);
} catch (Exception e) {
logError(entity, e);
}
}
use of io.jmix.audit.entity.EntityLogItem in project jmix by jmix-framework.
the class EntityLogImpl method internalRegisterDelete.
protected void internalRegisterDelete(Object entity, String entityName, String storeName, Set<String> attributes) {
EntityLogItem item;
// Create a new transaction in main DB if we are saving an entity from additional data store
if (!Stores.isMain(storeName)) {
item = transaction.execute(status -> generateEntityLogItem(entity, entityName, attributes, EntityLogItem.Type.DELETE));
} else {
item = generateEntityLogItem(entity, entityName, attributes, EntityLogItem.Type.DELETE);
}
assert item != null;
enqueueItem(item, storeName);
}
Aggregations