use of com.emc.vipr.model.catalog.OrderCount in project coprhd-controller by CoprHD.
the class OrderService method getOrderCount.
/**
* @brief Get number of orders under given tenants within a time range
* @param startTimeStr start time
* @param endTimeStr end time
* @return number of orders within the time range of each tenant
* @throws DatabaseException when a DB error occurs
*/
@GET
@Path("/count")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public OrderCount getOrderCount(@DefaultValue("") @QueryParam(SearchConstants.START_TIME_PARAM) String startTimeStr, @DefaultValue("") @QueryParam(SearchConstants.END_TIME_PARAM) String endTimeStr, @DefaultValue("") @QueryParam(SearchConstants.TENANT_IDS_PARAM) String tenantIDs) throws DatabaseException {
StorageOSUser user = getUserFromContext();
log.info("user={}", user.getName());
long startTimeInMS = getTime(startTimeStr, 0);
long endTimeInMS = getTime(endTimeStr, System.currentTimeMillis());
if (startTimeInMS > endTimeInMS) {
throw APIException.badRequests.endTimeBeforeStartTime(startTimeStr, endTimeStr);
}
List<URI> tids = toIDs(SearchConstants.TENANT_IDS_PARAM, tenantIDs);
Map<String, Long> countMap = orderManager.getOrderCount(tids, startTimeInMS, endTimeInMS);
OrderCount resp = new OrderCount(countMap);
return resp;
}
use of com.emc.vipr.model.catalog.OrderCount in project coprhd-controller by CoprHD.
the class OrderService method getUserOrderCount.
/**
* Gets the number of orders within a time range for current user
*
* @brief Get number of orders created by current user
* @param startTimeStr
* @param endTimeStr
* @return number of orders
* @throws DatabaseException when a DB error occurs
*/
@GET
@Path("/my-order-count")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public OrderCount getUserOrderCount(@DefaultValue("") @QueryParam(SearchConstants.START_TIME_PARAM) String startTimeStr, @DefaultValue("") @QueryParam(SearchConstants.END_TIME_PARAM) String endTimeStr) throws DatabaseException {
StorageOSUser user = getUserFromContext();
log.info("user={}", user.getName());
long startTimeInMS = getTime(startTimeStr, 0);
long endTimeInMS = getTime(endTimeStr, System.currentTimeMillis());
if (startTimeInMS > endTimeInMS) {
throw APIException.badRequests.endTimeBeforeStartTime(startTimeStr, endTimeStr);
}
log.info("start={} end={}", startTimeInMS, endTimeInMS);
long count = orderManager.getOrderCount(user, startTimeInMS, endTimeInMS);
log.info("count={}", count);
OrderCount resp = new OrderCount();
resp.put(user.getName(), count);
return resp;
}
Aggregations