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);
}
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();
}
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);
}
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());
}
}
Aggregations