Search in sources :

Example 1 with IdmLoggingEventException

use of eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEventException in project CzechIdMng by bcvsolutions.

the class DefaultIdmLoggingEventExceptionService method saveInternal.

/**
 * Needst to be overriden here, because original implementation from parent cannot handle composite identifier.
 *
 * @param dto {@link IdmLoggingEventExceptionDto} to save
 * @return saved {@link IdmLoggingEventExceptionDto}
 */
@Override
@Transactional
public IdmLoggingEventExceptionDto saveInternal(IdmLoggingEventExceptionDto dto) {
    Assert.notNull(dto, "DTO is required for save.");
    dto = validateDto(dto);
    // 
    IdmLoggingEventException persistedEntity = null;
    if (dto.getId() != null) {
        IdmLoggingEventExceptionFilter filter = new IdmLoggingEventExceptionFilter();
        filter.setId((Long) dto.getId());
        filter.setEvent(dto.getEvent());
        persistedEntity = findEntities(filter, PageRequest.of(0, 1)).stream().findFirst().orElse(null);
    }
    // convert to entity
    IdmLoggingEventException entity = toEntity(dto, persistedEntity);
    // validate
    entity = validateEntity(entity);
    // then persist
    entity = getRepository().saveAndFlush(entity);
    // finally convert to dto
    return toDto(entity);
}
Also used : IdmLoggingEventException(eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEventException) IdmLoggingEventExceptionFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmLoggingEventExceptionFilter) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with IdmLoggingEventException

use of eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEventException in project CzechIdMng by bcvsolutions.

the class DefaultIdmLoggingEventExceptionService method toEntity.

@Override
protected IdmLoggingEventException toEntity(IdmLoggingEventExceptionDto dto, IdmLoggingEventException entity) {
    final IdmLoggingEventException idmLoggingEventException = super.toEntity(dto, entity);
    if (idmLoggingEventException.getEvent() == null && dto.getEvent() != null) {
        // Try to find event
        final IdmLoggingEvent event = loggingEventRepository.findOneById(dto.getEvent());
        idmLoggingEventException.setEvent(event);
    }
    idmLoggingEventException.setId(dto.getId());
    return idmLoggingEventException;
}
Also used : IdmLoggingEvent(eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEvent) IdmLoggingEventException(eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEventException)

Example 3 with IdmLoggingEventException

use of eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEventException in project CzechIdMng by bcvsolutions.

the class DefaultIdmLoggingEventExceptionService method getEntity.

@Override
protected IdmLoggingEventException getEntity(Serializable id, BasePermission... permission) {
    Assert.notNull(id, "Identifier is required to load a log event.");
    IdmLoggingEventExceptionFilter filter = new IdmLoggingEventExceptionFilter();
    filter.setId(Long.valueOf(id.toString()));
    List<IdmLoggingEventExceptionDto> entities = this.find(filter, null, permission).getContent();
    if (entities.isEmpty()) {
        return null;
    }
    // for given id must found only one entity
    IdmLoggingEventException entity = this.toEntity(entities.get(0));
    return checkAccess(entity, permission);
}
Also used : IdmLoggingEventExceptionDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto) IdmLoggingEventException(eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEventException) IdmLoggingEventExceptionFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmLoggingEventExceptionFilter)

Aggregations

IdmLoggingEventException (eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEventException)3 IdmLoggingEventExceptionFilter (eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmLoggingEventExceptionFilter)2 IdmLoggingEventExceptionDto (eu.bcvsolutions.idm.core.api.audit.dto.IdmLoggingEventExceptionDto)1 IdmLoggingEvent (eu.bcvsolutions.idm.core.audit.entity.IdmLoggingEvent)1 Transactional (org.springframework.transaction.annotation.Transactional)1