use of eu.bcvsolutions.idm.core.api.domain.Identifiable in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManager method toEvent.
@Override
public EntityEvent<Identifiable> toEvent(IdmEntityEventDto entityEvent) {
Identifiable content = null;
// only if type and id is the same as owner can be used
if (entityEvent.getContent() != null && entityEvent.getContent().getClass().getCanonicalName().equals(entityEvent.getOwnerType()) && entityEvent.getContent().getId().equals(entityEvent.getOwnerId())) {
content = entityEvent.getContent();
}
if (content == null) {
// content is not persisted - try to find actual entity
content = findOwner(entityEvent);
}
if (content == null) {
throw new EventContentDeletedException(entityEvent);
}
//
Map<String, Serializable> eventProperties = entityEvent.getProperties().toMap();
eventProperties.put(EVENT_PROPERTY_EVENT_ID, entityEvent.getId());
eventProperties.put(EVENT_PROPERTY_PRIORITY, entityEvent.getPriority());
eventProperties.put(EVENT_PROPERTY_EXECUTE_DATE, entityEvent.getExecuteDate());
eventProperties.put(EVENT_PROPERTY_PARENT_EVENT_TYPE, entityEvent.getParentEventType());
final String type = entityEvent.getEventType();
DefaultEventContext<Identifiable> initContext = new DefaultEventContext<>();
initContext.setProcessedOrder(entityEvent.getProcessedOrder());
EventType eventType = (EventType) () -> type;
EntityEvent<Identifiable> resurectedEvent = new CoreEvent<>(eventType, content, eventProperties, initContext);
resurectedEvent.setOriginalSource(entityEvent.getOriginalSource());
//
return resurectedEvent;
}
Aggregations