Search in sources :

Example 1 with AuditEntityType

use of io.apiman.manager.api.beans.audit.AuditEntityType in project apiman by apiman.

the class JpaStorage method auditEntity.

/**
 * {@inheritDoc}
 */
@Override
public <T> SearchResultsBean<AuditEntryBean> auditEntity(String organizationId, String entityId, String entityVersion, Class<T> type, PagingBean paging) throws StorageException {
    SearchCriteriaBean criteria = new SearchCriteriaBean();
    if (paging != null) {
        criteria.setPaging(paging);
    } else {
        criteria.setPage(1);
        criteria.setPageSize(20);
    }
    criteria.setOrder("id", false);
    if (organizationId != null) {
        criteria.addFilter("organizationId", organizationId, SearchCriteriaFilterOperator.eq);
    }
    if (entityId != null) {
        criteria.addFilter("entityId", entityId, SearchCriteriaFilterOperator.eq);
    }
    if (entityVersion != null) {
        criteria.addFilter("entityVersion", entityVersion, SearchCriteriaFilterOperator.eq);
    }
    if (type != null) {
        AuditEntityType entityType = null;
        if (type == OrganizationBean.class) {
            entityType = AuditEntityType.Organization;
        } else if (type == ClientBean.class) {
            entityType = AuditEntityType.Client;
        } else if (type == ApiBean.class) {
            entityType = AuditEntityType.Api;
        } else if (type == PlanBean.class) {
            entityType = AuditEntityType.Plan;
        }
        if (entityType != null) {
            criteria.addFilter("entityType", entityType.name(), SearchCriteriaFilterOperator.eq);
        }
    }
    return find(criteria, List.of(new OrderByBean(true, AuditEntryBean_.ID)), AuditEntryBean.class, true);
}
Also used : AuditEntityType(io.apiman.manager.api.beans.audit.AuditEntityType) ClientBean(io.apiman.manager.api.beans.clients.ClientBean) SearchCriteriaBean(io.apiman.manager.api.beans.search.SearchCriteriaBean) ApiPlanBean(io.apiman.manager.api.beans.apis.ApiPlanBean) PlanBean(io.apiman.manager.api.beans.plans.PlanBean) OrderByBean(io.apiman.manager.api.beans.search.OrderByBean)

Example 2 with AuditEntityType

use of io.apiman.manager.api.beans.audit.AuditEntityType in project apiman by apiman.

the class EsStorage method auditEntity.

/**
 * @see io.apiman.manager.api.core.IStorageQuery#auditEntity(java.lang.String, java.lang.String, java.lang.String, java.lang.Class, io.apiman.manager.api.beans.search.PagingBean)
 */
@Override
public <T> SearchResultsBean<AuditEntryBean> auditEntity(String organizationId, String entityId, String entityVersion, Class<T> type, PagingBean paging) throws StorageException {
    SearchCriteriaBean criteria = new SearchCriteriaBean();
    if (paging != null) {
        criteria.setPaging(paging);
    } else {
        criteria.setPage(1);
        criteria.setPageSize(20);
    }
    // $NON-NLS-1$
    criteria.setOrder("createdOn", false);
    if (organizationId != null) {
        // $NON-NLS-1$
        criteria.addFilter("organizationId", organizationId, SearchCriteriaFilterOperator.eq);
    }
    if (entityId != null) {
        // $NON-NLS-1$
        criteria.addFilter("entityId", entityId, SearchCriteriaFilterOperator.eq);
    }
    if (entityVersion != null) {
        // $NON-NLS-1$
        criteria.addFilter("entityVersion", entityVersion, SearchCriteriaFilterOperator.eq);
    }
    if (type != null) {
        AuditEntityType entityType = null;
        if (type == OrganizationBean.class) {
            entityType = AuditEntityType.Organization;
        } else if (type == ClientBean.class) {
            entityType = AuditEntityType.Client;
        } else if (type == ApiBean.class) {
            entityType = AuditEntityType.Api;
        } else if (type == PlanBean.class) {
            entityType = AuditEntityType.Plan;
        }
        if (entityType != null) {
            // $NON-NLS-1$
            criteria.addFilter("entityType", entityType.name(), SearchCriteriaFilterOperator.eq);
        }
    }
    return find(criteria, INDEX_MANAGER_POSTFIX_AUDIT_ENTRY, new IUnmarshaller<AuditEntryBean>() {

        @Override
        public AuditEntryBean unmarshal(Map<String, Object> source) {
            return EsMarshalling.unmarshallAuditEntry(source);
        }
    });
}
Also used : AuditEntityType(io.apiman.manager.api.beans.audit.AuditEntityType) ClientBean(io.apiman.manager.api.beans.clients.ClientBean) SearchCriteriaBean(io.apiman.manager.api.beans.search.SearchCriteriaBean) AuditEntryBean(io.apiman.manager.api.beans.audit.AuditEntryBean) PlanBean(io.apiman.manager.api.beans.plans.PlanBean) ApiPlanBean(io.apiman.manager.api.beans.apis.ApiPlanBean)

Aggregations

ApiPlanBean (io.apiman.manager.api.beans.apis.ApiPlanBean)2 AuditEntityType (io.apiman.manager.api.beans.audit.AuditEntityType)2 ClientBean (io.apiman.manager.api.beans.clients.ClientBean)2 PlanBean (io.apiman.manager.api.beans.plans.PlanBean)2 SearchCriteriaBean (io.apiman.manager.api.beans.search.SearchCriteriaBean)2 AuditEntryBean (io.apiman.manager.api.beans.audit.AuditEntryBean)1 OrderByBean (io.apiman.manager.api.beans.search.OrderByBean)1