Search in sources :

Example 1 with AuditIdentityFilter

use of eu.bcvsolutions.idm.core.audit.dto.filter.AuditIdentityFilter 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 2 with AuditIdentityFilter

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

the class DefaultAuditIdentityService method getFilter.

@Override
public AuditEntityFilter getFilter(MultiValueMap<String, Object> parameters) {
    // TODO: refactor use mapper? FilterConverter
    AuditIdentityFilter filter = new AuditIdentityFilter();
    // 
    Object id = parameters.getFirst("id");
    Object username = parameters.getFirst("username");
    Object from = parameters.getFirst("from");
    Object till = parameters.getFirst("till");
    Object modifier = parameters.getFirst("modifier");
    Object changedAttributes = parameters.getFirst("changedAttributes");
    // 
    filter.setId(EntityUtils.toUuid(id));
    filter.setUsername(username != null ? username.toString() : null);
    filter.setFrom(from != null ? new DateTime(from) : null);
    filter.setTill(till != null ? new DateTime(till) : null);
    filter.setModifier(modifier != null ? modifier.toString() : null);
    filter.setChangedAttributes(changedAttributes != null ? changedAttributes.toString() : null);
    // 
    return filter;
}
Also used : AuditIdentityFilter(eu.bcvsolutions.idm.core.audit.dto.filter.AuditIdentityFilter) DateTime(org.joda.time.DateTime)

Aggregations

AuditIdentityFilter (eu.bcvsolutions.idm.core.audit.dto.filter.AuditIdentityFilter)2 IdmAuditFilter (eu.bcvsolutions.idm.core.api.audit.dto.filter.IdmAuditFilter)1 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)1 DateTime (org.joda.time.DateTime)1 PageImpl (org.springframework.data.domain.PageImpl)1