SDK improvements (#1693)
Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -9,14 +9,22 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
|
||||
/**
|
||||
* Defines the remote event of creating a new {@link Action}.
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = false)
|
||||
public abstract class AbstractActionEvent extends RemoteEntityEvent<Action> {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Long targetId;
|
||||
@@ -36,16 +44,11 @@ public abstract class AbstractActionEvent extends RemoteEntityEvent<Action> {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param action
|
||||
* the created action
|
||||
* @param targetId
|
||||
* targetId identifier (optional)
|
||||
* @param rolloutId
|
||||
* rollout identifier (optional)
|
||||
* @param rolloutGroupId
|
||||
* rollout group identifier (optional)
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
* @param action the created action
|
||||
* @param targetId targetId identifier (optional)
|
||||
* @param rolloutId rollout identifier (optional)
|
||||
* @param rolloutGroupId rollout group identifier (optional)
|
||||
* @param applicationId the origin application id
|
||||
*/
|
||||
protected AbstractActionEvent(final Action action, final Long targetId, final Long rolloutId,
|
||||
final Long rolloutGroupId, final String applicationId) {
|
||||
@@ -54,34 +57,4 @@ public abstract class AbstractActionEvent extends RemoteEntityEvent<Action> {
|
||||
this.rolloutId = rolloutId;
|
||||
this.rolloutGroupId = rolloutGroupId;
|
||||
}
|
||||
|
||||
public Long getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
|
||||
public Long getRolloutId() {
|
||||
return rolloutId;
|
||||
}
|
||||
|
||||
public Long getRolloutGroupId() {
|
||||
return rolloutGroupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
if (!super.equals(o))
|
||||
return false;
|
||||
final AbstractActionEvent that = (AbstractActionEvent) o;
|
||||
return Objects.equals(targetId, that.targetId) && Objects.equals(rolloutId, that.rolloutId)
|
||||
&& Objects.equals(rolloutGroupId, that.rolloutGroupId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), targetId, rolloutId, rolloutGroupId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,11 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.event.remote.entity;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Optional;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.hawkbit.repository.event.remote.EventEntityManagerHolder;
|
||||
import org.eclipse.hawkbit.repository.event.remote.RemoteIdEvent;
|
||||
@@ -19,32 +22,24 @@ import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
/**
|
||||
* A base definition class for remote events which contain a tenant aware base
|
||||
* entity.
|
||||
* A base definition class for remote events which contain a tenant aware base entity.
|
||||
*
|
||||
* @param <E> the type of the entity
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
@Slf4j
|
||||
public class RemoteEntityEvent<E extends TenantAwareBaseEntity> extends RemoteIdEvent {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private transient E entity;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
protected RemoteEntityEvent() {
|
||||
// for serialization libs like jackson
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param baseEntity
|
||||
* the base entity
|
||||
* @param applicationId
|
||||
* the origin application id
|
||||
* @param baseEntity the base entity
|
||||
* @param applicationId the origin application id
|
||||
*/
|
||||
protected RemoteEntityEvent(final E baseEntity, final String applicationId) {
|
||||
super(baseEntity.getId(), baseEntity.getTenant(), baseEntity.getClass(), applicationId);
|
||||
@@ -63,8 +58,8 @@ public class RemoteEntityEvent<E extends TenantAwareBaseEntity> extends RemoteId
|
||||
private E reloadEntityFromRepository() {
|
||||
try {
|
||||
final Class<E> clazz = (Class<E>) Class.forName(getEntityClass());
|
||||
return EventEntityManagerHolder.getInstance().getEventEntityManager().findEntity(getTenant(), getEntityId(),
|
||||
clazz);
|
||||
return EventEntityManagerHolder.getInstance().getEventEntityManager().findEntity(
|
||||
getTenant(), getEntityId(), clazz);
|
||||
} catch (final ClassNotFoundException e) {
|
||||
log.error("Cannot reload entity because class is not found", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user