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