Search in sources :

Example 1 with IdmAuditFilter

use of eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter in project CzechIdMng by bcvsolutions.

the class DefaultAuditService method findRevisionsForEntity.

@Override
public Page<IdmAuditDto> findRevisionsForEntity(String entityClass, UUID entityId, Pageable pageable) {
    IdmAuditFilter filter = new IdmAuditFilter();
    filter.setType(entityClass);
    filter.setEntityId(entityId);
    return this.find(filter, pageable);
}
Also used : IdmAuditFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter)

Example 2 with IdmAuditFilter

use of eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter in project CzechIdMng by bcvsolutions.

the class DefaultAuditService method findRevisions.

@Override
public <T> List<IdmAuditDto> findRevisions(Class<T> classType, UUID entityId) {
    IdmAuditFilter filter = new IdmAuditFilter();
    filter.setEntityId(entityId);
    filter.setType(classType.getName());
    Pageable page = new PageRequest(0, Integer.MAX_VALUE, new Sort("timestamp"));
    Page<IdmAuditDto> result = this.find(filter, page);
    return result.getContent();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) IdmAuditDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto) IdmAuditFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter) Sort(org.springframework.data.domain.Sort)

Example 3 with IdmAuditFilter

use of eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter in project CzechIdMng by bcvsolutions.

the class DefaultAuditIdentityService method findRevisionBy.

@Override
public Page<IdmAudit> findRevisionBy(AuditEntityFilter filter, Pageable pageable) {
    AuditIdentityFilter identityFilter = (AuditIdentityFilter) filter;
    // 
    List<String> identitiesIds = Collections.emptyList();
    if (identityFilter.getUsername() != null) {
        // in identities can be more UUID, we search for all
        identitiesIds = getAuditRepository().findDistinctOwnerIdByOwnerTypeAndOwnerCode(IdmIdentity.class.getName(), identityFilter.getUsername());
        // remove null values
        identitiesIds.removeAll(Collections.singleton(null));
        // no entity found for this username return empty list
        if (identitiesIds.isEmpty()) {
            return new PageImpl<>(Collections.emptyList());
        }
    }
    // 
    IdmAuditFilter auditFilter = new IdmAuditFilter();
    auditFilter.setFrom(identityFilter.getFrom());
    auditFilter.setTill(identityFilter.getTill());
    auditFilter.setOwnerType(IdmIdentity.class.getName());
    auditFilter.setChangedAttributes(identityFilter.getChangedAttributes());
    // set id as owner id
    if (identityFilter.getId() != null) {
        auditFilter.setOwnerId(identityFilter.getId().toString());
    }
    // 
    if (!identitiesIds.isEmpty()) {
        auditFilter.setOwnerIds(identitiesIds);
    }
    // 
    return this.getAuditRepository().find(auditFilter, pageable);
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) AuditIdentityFilter(eu.bcvsolutions.idm.core.audit.dto.filter.AuditIdentityFilter) IdmAuditFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity)

Example 4 with IdmAuditFilter

use of eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter in project CzechIdMng by bcvsolutions.

the class DefaultAuditServiceTest method auditQuickSearch.

@Test
public void auditQuickSearch() {
    IdmAuditFilter filter = new IdmAuditFilter();
    filter.setModifier("admin");
    filter.setType(IdmRole.class.getSimpleName());
    Pageable pageable = new PageRequest(0, 10);
    List<IdmAuditDto> result = auditService.find(filter, pageable).getContent();
    for (IdmAuditDto idmAudit : result) {
        assertEquals("admin", idmAudit.getModifier());
        assertEquals(IdmRole.class.getName(), idmAudit.getType());
    }
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) IdmAuditDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto) IdmAuditFilter(eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter) IdmRole(eu.bcvsolutions.idm.core.model.entity.IdmRole) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmAuditFilter (eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter)4 IdmAuditDto (eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto)2 PageRequest (org.springframework.data.domain.PageRequest)2 Pageable (org.springframework.data.domain.Pageable)2 AuditIdentityFilter (eu.bcvsolutions.idm.core.audit.dto.filter.AuditIdentityFilter)1 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)1 IdmRole (eu.bcvsolutions.idm.core.model.entity.IdmRole)1 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)1 Test (org.junit.Test)1 PageImpl (org.springframework.data.domain.PageImpl)1 Sort (org.springframework.data.domain.Sort)1