Search in sources :

Example 1 with OrderBulkRep

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;
}
Also used : OrderAndParams(com.emc.storageos.db.client.model.uimodels.OrderAndParams) ArrayList(java.util.ArrayList) OrderBulkRep(com.emc.vipr.model.catalog.OrderBulkRep) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep)

Example 2 with OrderBulkRep

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);
}
Also used : OrderAndParams(com.emc.storageos.db.client.model.uimodels.OrderAndParams) ArrayList(java.util.ArrayList) OrderBulkRep(com.emc.vipr.model.catalog.OrderBulkRep) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) OrderFilter(com.emc.sa.api.mapper.OrderFilter)

Example 3 with OrderBulkRep

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;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) OrderBulkRep(com.emc.vipr.model.catalog.OrderBulkRep) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) TimeSeriesConstraint(com.emc.storageos.db.client.constraint.TimeSeriesConstraint) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

OrderBulkRep (com.emc.vipr.model.catalog.OrderBulkRep)3 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)3 OrderAndParams (com.emc.storageos.db.client.model.uimodels.OrderAndParams)2 ArrayList (java.util.ArrayList)2 OrderFilter (com.emc.sa.api.mapper.OrderFilter)1 TimeSeriesConstraint (com.emc.storageos.db.client.constraint.TimeSeriesConstraint)1 Order (com.emc.storageos.db.client.model.uimodels.Order)1 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1