use of org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener in project jmix by jmix-framework.
the class EntityChangedEventManager method internalCollect.
public List<EntityChangedEventInfo> internalCollect(Collection<Object> entities) {
List<EntityChangedEventInfo> list = new ArrayList<>();
for (Object entity : entities) {
EntityChangedEvent.Type type = null;
AttributeChanges.Builder attributeChangesBuilder = null;
if (getEntityEntry(entity).isNew()) {
type = EntityChangedEvent.Type.CREATED;
attributeChangesBuilder = getEntityAttributeChanges(entity, false);
} else {
AttributeChangeListener changeListener = (AttributeChangeListener) ((ChangeTracker) entity)._persistence_getPropertyChangeListener();
if (changeListener == null) {
log.debug("Cannot publish EntityChangedEvent for {} because its AttributeChangeListener is null", entity);
continue;
}
if (persistenceSupport.isDeleted(entity, changeListener)) {
type = EntityChangedEvent.Type.DELETED;
attributeChangesBuilder = getEntityAttributeChanges(entity, true);
} else if (changeListener.hasChanges()) {
type = EntityChangedEvent.Type.UPDATED;
attributeChangesBuilder = getEntityAttributeChanges(entity, changeListener.getObjectChangeSet());
}
}
if (type != null && attributeChangesBuilder != null) {
MetaClass originalMetaClass = extendedEntities.getOriginalOrThisMetaClass(metadata.getClass(entity));
EntityChangedEventInfo eventData = new EntityChangedEventInfo(this, entity, type, attributeChangesBuilder.build(), originalMetaClass);
list.add(eventData);
}
}
log.trace("collected {}", list);
return list;
}
use of org.eclipse.persistence.internal.descriptors.changetracking.AttributeChangeListener in project jmix by jmix-framework.
the class EclipselinkAttributeChangesProvider method getChangedAttributeNamesByImplementation.
@Override
protected Set<String> getChangedAttributeNamesByImplementation(Object entity) {
checkEntityByImplementation(entity);
PropertyChangeListener propertyChangeListener = ((ChangeTracker) entity)._persistence_getPropertyChangeListener();
ObjectChangeSet objectChanges = ((AttributeChangeListener) propertyChangeListener).getObjectChangeSet();
if (objectChanges != null) {
return new HashSet<>(objectChanges.getChangedAttributeNames());
}
return Collections.emptySet();
}
Aggregations