Search in sources :

Example 11 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep 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)

Example 12 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.

the class OrderUtils method getErrorOrders.

public static List<OrderRestRep> getErrorOrders(URI tenantId) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    List<OrderRestRep> scheduledOrders = catalog.orders().search().byStatus(OrderStatus.ERROR.name(), tenantId).run();
    return scheduledOrders;
}
Also used : OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2)

Example 13 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.

the class OrderUtils method getOrder.

public static OrderRestRep getOrder(URI id) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    OrderRestRep order = null;
    try {
        order = catalog.orders().get(id);
    } catch (ViPRHttpException e) {
        if (e.getHttpCode() == 404) {
            order = null;
        } else {
            throw e;
        }
    }
    return order;
}
Also used : OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) ViPRHttpException(com.emc.vipr.client.exceptions.ViPRHttpException)

Example 14 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.

the class OrderUtils method getScheduledOrders.

public static List<OrderRestRep> getScheduledOrders(URI tenantId) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    List<OrderRestRep> scheduledOrders = catalog.orders().search().byStatus(OrderStatus.SCHEDULED.name(), tenantId).run();
    return scheduledOrders;
}
Also used : OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2)

Example 15 with OrderRestRep

use of com.emc.vipr.model.catalog.OrderRestRep in project coprhd-controller by CoprHD.

the class SupportPackageCreator method getOrders.

private List<OrderRestRep> getOrders() {
    if ((orderTypes == OrderTypes.ALL) || (orderTypes == OrderTypes.ERROR)) {
        List<OrderRestRep> orders = Lists.newArrayList();
        if (tenantIds != null) {
            for (URI tenantId : tenantIds) {
                SearchBuilder<OrderRestRep> search = catalogApi().orders().search().byTimeRange(this.startTime, this.endTime, tenantId);
                if (orderTypes == OrderTypes.ERROR) {
                    search.filter(new FailedOrderFilter());
                }
                List<OrderRestRep> tenantOrders = search.run();
                Logger.info("Found %s Orders for tenantId %s", tenantOrders.size(), tenantId);
                orders.addAll(tenantOrders);
            }
        } else {
            SearchBuilder<OrderRestRep> search = catalogApi().orders().search().byTimeRange(this.startTime, this.endTime);
            if (orderTypes == OrderTypes.ERROR) {
                search.filter(new FailedOrderFilter());
            }
            orders = search.run();
            Logger.info("Found %s Orders", orders.size());
        }
        return orders;
    } else {
        return Collections.emptyList();
    }
}
Also used : OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) URI(java.net.URI)

Aggregations

OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)27 ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)7 ApprovalRestRep (com.emc.vipr.model.catalog.ApprovalRestRep)4 URI (java.net.URI)4 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)3 OrderBulkRep (com.emc.vipr.model.catalog.OrderBulkRep)3 ArrayList (java.util.ArrayList)3 Order (com.emc.storageos.db.client.model.uimodels.Order)2 OrderAndParams (com.emc.storageos.db.client.model.uimodels.OrderAndParams)2 OrderParameter (com.emc.storageos.db.client.model.uimodels.OrderParameter)2 OrderCreateParam (com.emc.vipr.model.catalog.OrderCreateParam)2 ScheduledEventRestRep (com.emc.vipr.model.catalog.ScheduledEventRestRep)2 FlashException (controllers.util.FlashException)2 OrderFilter (com.emc.sa.api.mapper.OrderFilter)1 TimeSeriesConstraint (com.emc.storageos.db.client.constraint.TimeSeriesConstraint)1 Tags (com.emc.storageos.model.search.Tags)1 StorageOSUser (com.emc.storageos.security.authentication.StorageOSUser)1 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)1 ExecutionWindowRestRep (com.emc.vipr.model.catalog.ExecutionWindowRestRep)1 OrderInfo (com.emc.vipr.model.catalog.OrderInfo)1