use of com.emc.storageos.model.event.EventStatsRestRep in project coprhd-controller by CoprHD.
the class Events method getCountSummary.
public static void getCountSummary(URI tenantId) {
ViPRCoreClient client = getViprClient();
EventStatsRestRep stats = client.events().getStatsByTenant(tenantId);
renderJSON(stats);
}
use of com.emc.storageos.model.event.EventStatsRestRep in project coprhd-controller by CoprHD.
the class EventService method getStats.
/**
* Get Stats
*
* @param tenantId
* @brief Show numbers of pending, approved, declined, and failed events for a tenant
* @return
*/
@GET
@Path("/stats")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public EventStatsRestRep getStats(@QueryParam(TENANT_QUERY_PARAM) URI tenantId) {
verifyAuthorizedInTenantOrg(tenantId, getUserFromContext());
int approved = 0;
int declined = 0;
int pending = 0;
int failed = 0;
Constraint constraint = AggregatedConstraint.Factory.getAggregationConstraint(ActionableEvent.class, "tenant", tenantId.toString(), "eventStatus");
AggregationQueryResultList queryResults = new AggregationQueryResultList();
_dbClient.queryByConstraint(constraint, queryResults);
Iterator<AggregationQueryResultList.AggregatedEntry> it = queryResults.iterator();
while (it.hasNext()) {
AggregationQueryResultList.AggregatedEntry entry = it.next();
if (entry.getValue().equals(ActionableEvent.Status.approved.name())) {
approved++;
} else if (entry.getValue().equals(ActionableEvent.Status.declined.name())) {
declined++;
} else if (entry.getValue().equals(ActionableEvent.Status.failed.name())) {
failed++;
} else {
pending++;
}
}
return new EventStatsRestRep(pending, approved, declined, failed);
}
use of com.emc.storageos.model.event.EventStatsRestRep in project coprhd-controller by CoprHD.
the class Events method getPendingAndFailedCount.
public static void getPendingAndFailedCount() {
ViPRCoreClient client = getViprClient();
int activeCount = 0;
Set<URI> tenants = getAccessibleTenants();
for (URI tenant : tenants) {
EventStatsRestRep eventStats = client.events().getStatsByTenant(tenant);
if (eventStats != null) {
activeCount += eventStats.getPending() + eventStats.getFailed();
}
}
if (Security.isSystemAdmin()) {
EventStatsRestRep systemEventStats = client.events().getStatsByTenant(SYSTEM_TENANT);
if (systemEventStats != null) {
activeCount += systemEventStats.getPending() + systemEventStats.getFailed();
}
}
renderJSON(activeCount);
}
Aggregations