protected boolean justDeleted(SoftDelete entity) { return entity.isDeleted() && persistence.getTools().getDirtyFields((Entity) entity).contains("deleteTs"); }
protected void restoreEntity(Entity entity, String storeName) { EntityManager em = persistence.getEntityManager(storeName); Entity reloadedEntity = em.find(entity.getClass(), entity.getId()); if (reloadedEntity != null && ((SoftDelete) reloadedEntity).isDeleted()) { log.info("Restoring deleted entity " + entity); Date deleteTs = ((SoftDelete) reloadedEntity).getDeleteTs(); ((SoftDelete) reloadedEntity).setDeleteTs(null); em.merge(reloadedEntity); restoreDetails(reloadedEntity, deleteTs, storeName); } }
@Override public void remove(Entity entity) { log.debug("remove {}", entity); if (PersistenceHelper.isDetached(entity)) { entity = internalMerge(entity); } if (entity instanceof SoftDelete && softDeletion) { ((SoftDelete) entity).setDeleteTs(timeSource.currentTimestamp()); ((SoftDelete) entity).setDeletedBy(auditInfoProvider.getCurrentUserLogin()); } else { delegate.remove(entity); if (entity instanceof BaseGenericIdEntity) { BaseEntityInternalAccess.setRemoved((BaseGenericIdEntity) entity, true); } } }
if (commitInstance instanceof SoftDelete && ((SoftDelete) commitInstance).isDeleted()) { ((SoftDelete) commitInstance).setDeleteTs(null);
if (softDeleteEntity.getDeleteTs() != null) { includeParam("table.showInfoAction.deleteTs", df.format(softDeleteEntity.getDeleteTs())); if (softDeleteEntity.getDeletedBy() != null) { includeParam("table.showInfoAction.deletedBy", softDeleteEntity.getDeletedBy());
protected static boolean isDeleted(BaseGenericIdEntity entity, AttributeChangeListener changeListener) { if ((entity instanceof SoftDelete)) { ObjectChangeSet changeSet = changeListener.getObjectChangeSet(); return changeSet != null && changeSet.getAttributesToChanges().containsKey("deleteTs") && ((SoftDelete) entity).isDeleted(); } else { return BaseEntityInternalAccess.isRemoved(entity); } }
/** * Determines whether the entity instance was <em>deleted</em>. * * @param entity entity instance * @return - true if the instance was deleted * - false otherwise * @throws IllegalArgumentException if entity instance is null */ public boolean isDeleted(Object entity) { checkNotNullArgument(entity, "entity is null"); if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) return true; if (entity instanceof BaseGenericIdEntity && BaseEntityInternalAccess.isRemoved((BaseGenericIdEntity) entity)) { return true; } return false; }
@Override public <T extends Entity<K>, K> T find(Class<T> entityClass, K id) { Preconditions.checkNotNullArgument(entityClass, "entityClass is null"); Preconditions.checkNotNullArgument(id, "id is null"); Object realId = getRealId(id); log.debug("find {} by id={}", entityClass.getSimpleName(), realId); MetaClass metaClass = metadata.getExtendedEntities().getEffectiveMetaClass(entityClass); Class<T> javaClass = metaClass.getJavaClass(); T entity = delegate.find(javaClass, realId); if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted() && isSoftDeletion()) return null; // in case of entity cache else return entity; }
@Override protected boolean isPermitted() { if (getTarget().getSingleSelected() instanceof SoftDelete) { for (Object e : getTarget().getSelected()) { if (((SoftDelete) e).isDeleted()) return false; } } return super.isPermitted(); } };
@Override public void postUpdate(DescriptorEvent event) { String storeName = support.getStorageName(event.getSession()); Entity entity = (Entity) event.getSource(); if (entity instanceof SoftDelete && persistence.getTools().isDirty(entity, "deleteTs") && ((SoftDelete) entity).isDeleted()) { manager.fireListener(entity, EntityListenerType.AFTER_DELETE, storeName); } else { manager.fireListener(entity, EntityListenerType.AFTER_UPDATE, storeName); } }
Set<EntityLogAttr> entityLogAttrs; EntityLogItem.Type type; if (entity instanceof SoftDelete && dirty.contains("deleteTs") && !((SoftDelete) entity).isDeleted()) { type = EntityLogItem.Type.RESTORE; entityLogAttrs = createLogAttributes(entity, attributes, changes);
if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) { wm.showNotification(messages.getMainMessage("OpenAction.objectIsDeleted"), Frame.NotificationType.HUMANIZED);
desc.setDeletePredicate(entity -> entity instanceof SoftDelete && PersistenceHelper.isLoaded(entity, "deleteTs") && ((SoftDelete) entity).isDeleted());
if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) { ScreenContext screenContext = ComponentsHelper.getScreenContext(pickerField); Notifications notifications = screenContext.getNotifications();
if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) { Messages messages = AppBeans.get(Messages.NAME); context.getNotifications().create(Notifications.NotificationType.HUMANIZED)
if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) { Messages messages = AppBeans.get(Messages.NAME); wm.showNotification(