use of io.jmix.audit.entity.EntitySnapshot in project jmix by jmix-framework.
the class EntitySnapshotDataStoreImpl method save.
@Override
public EntitySnapshotModel save(EntitySnapshotModel entitySnapshotModel) {
EntitySnapshot entitySnapshot = entitySnapshotModelConverter.createEntitySnapshot(entitySnapshotModel);
entitySnapshot = unconstrainedDataManager.save(entitySnapshot);
return entitySnapshotModelConverter.createEntitySnapshotModel(entitySnapshot);
}
use of io.jmix.audit.entity.EntitySnapshot in project jmix by jmix-framework.
the class EntitySnapshotDataStoreImpl method findLastSnapshot.
@Override
public EntitySnapshotModel findLastSnapshot(Object entity, MetaClass entityMetaClass) {
MetaClass metaClass = extendedEntities.getOriginalOrThisMetaClass(entityMetaClass);
LoadContext<EntitySnapshot> lx = new LoadContext<EntitySnapshot>(metadata.getClass(EntitySnapshot.class)).setQuery(new LoadContext.Query(format("select e from audit_EntitySnapshot e where e.entityMetaClass = :metaClass and" + " e.entity.%s = :entityId order by e.snapshotDate desc", referenceToEntitySupport.getReferenceIdPropertyName(metaClass))).setParameter("metaClass", metaClass.getName()).setParameter("entityId", referenceToEntitySupport.getReferenceId(entity)).setMaxResults(1));
return entitySnapshotModelConverter.createEntitySnapshotModel(unconstrainedDataManager.load(lx));
}
use of io.jmix.audit.entity.EntitySnapshot in project jmix by jmix-framework.
the class EntitySnapshotDataStoreImpl method findLastSnapshotById.
@Override
public EntitySnapshotModel findLastSnapshotById(Object referenceId, MetaClass metaClass) {
MetaClass originalMetaClass = extendedEntities.getOriginalOrThisMetaClass(metaClass);
LoadContext<EntitySnapshot> entitySnapshotLoadContext = new LoadContext<EntitySnapshot>(metadata.getClass(EntitySnapshot.class)).setQuery(new LoadContext.Query(String.format("select e from audit_EntitySnapshot e where e.entityMetaClass = :metaClass and" + " e.entity.%s = :entityId order by e.snapshotDate desc", referenceToEntitySupport.getReferenceIdPropertyName(originalMetaClass))).setParameter("metaClass", originalMetaClass.getName()).setParameter("entityId", referenceId).setMaxResults(1));
return entitySnapshotModelConverter.createEntitySnapshotModel(unconstrainedDataManager.load(entitySnapshotLoadContext));
}
use of io.jmix.audit.entity.EntitySnapshot in project jmix by jmix-framework.
the class EntitySnapshotModelConverter method createEntitySnapshot.
public EntitySnapshot createEntitySnapshot(EntitySnapshotModel entitySnapshotModel) {
if (entitySnapshotModel == null) {
return null;
}
EntitySnapshot entitySnapshot = metadata.create(EntitySnapshot.class);
ReferenceToEntity referenceToEntity = metadata.create(ReferenceToEntity.class);
referenceToEntity.setEntityId(entitySnapshotModel.getEntityId());
referenceToEntity.setIntEntityId(entitySnapshotModel.getIntEntityId());
referenceToEntity.setLongEntityId(entitySnapshotModel.getLongEntityId());
referenceToEntity.setStringEntityId(entitySnapshotModel.getStringEntityId());
entitySnapshot.setEntity(referenceToEntity);
entitySnapshot.setSnapshotXml(entitySnapshotModel.getSnapshotXml());
entitySnapshot.setSnapshotDate(entitySnapshotModel.getSnapshotDate());
entitySnapshot.setCreatedBy(entitySnapshotModel.getCreatedBy());
entitySnapshot.setCreatedDate(entitySnapshotModel.getCreatedDate());
entitySnapshot.setSysTenantId(entitySnapshotModel.getSysTenantId());
entitySnapshot.setFetchPlanXml(entitySnapshotModel.getFetchPlanXml());
entitySnapshot.setEntityMetaClass(entitySnapshotModel.getEntityMetaClass());
entitySnapshot.setAuthorUsername(entitySnapshotModel.getAuthorUsername());
return entitySnapshot;
}
Aggregations