@@ -16,14 +16,16 @@ import org.eclipse.hawkbit.repository.model.Target;
|
||||
*/
|
||||
public class TargetUpdatedEvent extends AbstractBaseEntityEvent<Target> {
|
||||
|
||||
private static final long serialVersionUID = 5665118668865832477L;
|
||||
private static final long serialVersionUID = 5665118668865832477L;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param baseEntity Target entity
|
||||
*/
|
||||
public TargetUpdatedEvent(final Target baseEntity) {
|
||||
super(baseEntity);
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param baseEntity
|
||||
* Target entity
|
||||
*/
|
||||
public TargetUpdatedEvent(final Target baseEntity) {
|
||||
super(baseEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,31 +17,33 @@ import org.eclipse.persistence.descriptors.DescriptorEvent;
|
||||
*/
|
||||
public class DescriptorEventDetails {
|
||||
|
||||
enum ActionType {
|
||||
CREATE, UPDATE;
|
||||
}
|
||||
enum ActionType {
|
||||
CREATE, UPDATE;
|
||||
}
|
||||
|
||||
private final DescriptorEvent descriptorEvent;
|
||||
private final DescriptorEvent descriptorEvent;
|
||||
|
||||
private final ActionType actiontype;
|
||||
private final ActionType actiontype;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param actionType Action type
|
||||
* @param descriptorEvent Descriptor Event
|
||||
*/
|
||||
public DescriptorEventDetails(final ActionType actionType,
|
||||
final DescriptorEvent descriptorEvent) {
|
||||
this.descriptorEvent = descriptorEvent;
|
||||
this.actiontype = actionType;
|
||||
}
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param actionType
|
||||
* Action type
|
||||
* @param descriptorEvent
|
||||
* Descriptor Event
|
||||
*/
|
||||
public DescriptorEventDetails(final ActionType actionType, final DescriptorEvent descriptorEvent) {
|
||||
this.descriptorEvent = descriptorEvent;
|
||||
this.actiontype = actionType;
|
||||
}
|
||||
|
||||
public DescriptorEvent getDescriptorEvent() {
|
||||
return descriptorEvent;
|
||||
}
|
||||
public DescriptorEvent getDescriptorEvent() {
|
||||
return descriptorEvent;
|
||||
}
|
||||
|
||||
public ActionType getActiontype() {
|
||||
return actiontype;
|
||||
}
|
||||
public ActionType getActiontype() {
|
||||
return actiontype;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@ import org.eclipse.persistence.queries.UpdateObjectQuery;
|
||||
import org.eclipse.persistence.sessions.changesets.DirectToFieldChangeRecord;
|
||||
|
||||
/**
|
||||
*Helper class to get the change set for the property changes in the Entity.
|
||||
* Helper class to get the change set for the property changes in the Entity.
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public class EntityPropertyChangeHelper<T extends TenantAwareBaseEntity> {
|
||||
|
||||
|
||||
public class EntityPropertyChangeHelper<T extends TenantAwareBaseEntity> {
|
||||
|
||||
/**
|
||||
* To get the map of entity property change set
|
||||
*
|
||||
* @param clazz
|
||||
* @param event
|
||||
* @return the map of the changeSet
|
||||
@@ -35,19 +35,12 @@ public class EntityPropertyChangeHelper<T extends TenantAwareBaseEntity> {
|
||||
public static <T extends TenantAwareBaseEntity> Map<String, AbstractPropertyChangeEvent<T>.Values> getChangeSet(
|
||||
final Class<T> clazz, final DescriptorEvent event) {
|
||||
final T rolloutGroup = clazz.cast(event.getObject());
|
||||
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery())
|
||||
.getObjectChangeSet();
|
||||
return changeSet
|
||||
.getChanges()
|
||||
.stream()
|
||||
.filter(record -> record instanceof DirectToFieldChangeRecord)
|
||||
final ObjectChangeSet changeSet = ((UpdateObjectQuery) event.getQuery()).getObjectChangeSet();
|
||||
return changeSet.getChanges().stream().filter(record -> record instanceof DirectToFieldChangeRecord)
|
||||
.map(record -> (DirectToFieldChangeRecord) record)
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
record -> record.getAttribute(),
|
||||
record -> new AbstractPropertyChangeEvent<T>(
|
||||
rolloutGroup, null).new Values(record
|
||||
.getOldValue(), record.getNewValue())));
|
||||
.collect(Collectors.toMap(record -> record.getAttribute(),
|
||||
record -> new AbstractPropertyChangeEvent<T>(rolloutGroup, null).new Values(
|
||||
record.getOldValue(), record.getNewValue())));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user