use of com.emc.vipr.model.catalog.OrderBulkRep in project coprhd-controller by CoprHD.
the class OrderService method queryBulkResourceReps.
@Override
public OrderBulkRep queryBulkResourceReps(List<URI> ids) {
List<OrderRestRep> orderRestReps = new ArrayList<OrderRestRep>();
List<OrderAndParams> ordersAndParams = orderManager.getOrdersAndParams(ids);
for (OrderAndParams orderAndParams : ordersAndParams) {
orderRestReps.add(OrderMapper.map(orderAndParams.getOrder(), orderAndParams.getParameters()));
}
OrderBulkRep rep = new OrderBulkRep(orderRestReps);
return rep;
}
use of com.emc.vipr.model.catalog.OrderBulkRep in project coprhd-controller by CoprHD.
the class OrderService method queryFilteredBulkResourceReps.
@Override
public OrderBulkRep queryFilteredBulkResourceReps(List<URI> ids) {
OrderFilter filter = new OrderFilter(getUserFromContext(), _permissionsHelper);
List<OrderRestRep> orderRestReps = new ArrayList<OrderRestRep>();
List<OrderAndParams> ordersAndParams = orderManager.getOrdersAndParams(ids);
for (OrderAndParams orderAndParams : ordersAndParams) {
if (filter.isAccessible(orderAndParams.getOrder())) {
orderRestReps.add(OrderMapper.map(orderAndParams.getOrder(), orderAndParams.getParameters()));
}
}
return new OrderBulkRep(orderRestReps);
}
use of com.emc.vipr.model.catalog.OrderBulkRep in project coprhd-controller by CoprHD.
the class OrderService method getUserOrders.
/**
* Gets the list of orders within a time range for current user
*
* @brief List Orders
* @param startTimeStr start time of the query
* @param endTimeStr end time of the query
* @param maxCount The max number of orders this API returns
* @param ordersOnlyStr if ture, only returns orders info, other info such as OrderParameter
* will not be returned
* @return a list of orders
* @throws DatabaseException when a DB error occurs
*/
@GET
@Path("/my-orders")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public OrderBulkRep getUserOrders(@DefaultValue("") @QueryParam(SearchConstants.START_TIME_PARAM) String startTimeStr, @DefaultValue("") @QueryParam(SearchConstants.END_TIME_PARAM) String endTimeStr, @DefaultValue("-1") @QueryParam(SearchConstants.ORDER_MAX_COUNT) String maxCount, @DefaultValue("false") @QueryParam(SearchConstants.ORDERS_ONLY) String ordersOnlyStr) throws DatabaseException {
long startTimeInMS = getTime(startTimeStr, 0);
long endTimeInMS = getTime(endTimeStr, System.currentTimeMillis());
if (startTimeInMS > endTimeInMS) {
throw APIException.badRequests.endTimeBeforeStartTime(startTimeStr, endTimeStr);
}
int max = Integer.parseInt(maxCount);
boolean ordersOnly = Boolean.parseBoolean(ordersOnlyStr);
log.info("start={} end={} max={}", startTimeInMS, endTimeInMS, max);
StorageOSUser user = getUserFromContext();
List<Order> orders = orderManager.getUserOrders(user, startTimeInMS, endTimeInMS, max);
List<OrderRestRep> list = toOrders(orders, user, ordersOnly);
OrderBulkRep rep = new OrderBulkRep(list);
return rep;
}
Aggregations