Search in sources :

Example 1 with OrderRestRep

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

the class Approvals method approvalsJson.

public static void approvalsJson() {
    ViPRCatalogClient2 catalog = getCatalogClient();
    Map<URI, OrderRestRep> orders = Maps.newHashMap();
    Map<URI, CatalogServiceRestRep> catalogServices = Maps.newHashMap();
    List<ApprovalRequestInfo> approvalRequestInfos = Lists.newArrayList();
    List<ApprovalRestRep> approvals = catalog.approvals().getByUserTenant();
    for (ApprovalRestRep approval : approvals) {
        OrderRestRep order = null;
        if (approval.getOrder() != null) {
            if (!orders.keySet().contains(approval.getOrder().getId())) {
                order = getOrder(approval.getOrder());
                if (order != null) {
                    orders.put(order.getId(), order);
                }
            } else {
                order = orders.get(approval.getOrder().getId());
            }
        }
        CatalogServiceRestRep catalogService = null;
        if (order != null && order.getCatalogService() != null) {
            if (!catalogServices.keySet().contains(order.getCatalogService().getId())) {
                catalogService = getCatalogService(order.getCatalogService());
                if (catalogService != null) {
                    catalogServices.put(catalogService.getId(), catalogService);
                }
            } else {
                catalogService = catalogServices.get(order.getCatalogService().getId());
            }
        }
        approvalRequestInfos.add(new ApprovalRequestInfo(approval, order, catalogService));
    }
    renderJSON(DataTablesSupport.createJSON(approvalRequestInfos, params));
}
Also used : ApprovalRestRep(com.emc.vipr.model.catalog.ApprovalRestRep) ApprovalRequestInfo(models.datatable.ApprovalsDataTable.ApprovalRequestInfo) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) URI(java.net.URI)

Example 2 with OrderRestRep

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

the class Orders method itemsJson.

public static void itemsJson(@As(",") String[] ids) {
    List<OrderInfo> results = Lists.newArrayList();
    if (ids != null && ids.length > 0) {
        for (String id : ids) {
            if (StringUtils.isNotBlank(id)) {
                OrderRestRep order = OrderUtils.getOrder(uri(id));
                if (order != null) {
                    Models.checkAccess(order.getTenant());
                    results.add(new OrderInfo(order));
                }
            }
        }
    }
    renderJSON(results);
}
Also used : OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) OrderInfo(models.datatable.OrderDataTable.OrderInfo)

Example 3 with OrderRestRep

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

the class ScheduledOrders method cancel.

public static void cancel(@As(",") String[] ids) {
    if ((ids != null) && (ids.length > 0)) {
        Logger.info("Cancel: " + StringUtils.join(ids, ", "));
        for (String orderId : ids) {
            if (StringUtils.isNotBlank(orderId)) {
                OrderRestRep order = OrderUtils.getOrder(uri(orderId));
                URI scheduledEventId = order.getScheduledEventId();
                if (scheduledEventId == null) {
                    OrderUtils.cancelOrder(uri(orderId));
                } else {
                    getCatalogClient().orders().cancelScheduledEvent(scheduledEventId);
                }
            }
        }
    }
    list();
}
Also used : OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) URI(java.net.URI)

Example 4 with OrderRestRep

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

the class OrderUtils method getScheduledOrdersByExecutionWindow.

public static List<OrderRestRep> getScheduledOrdersByExecutionWindow(URI executionWindowId, URI tenantId) {
    List<OrderRestRep> scheduledOrders = getScheduledOrders(tenantId);
    List<OrderRestRep> scheduledOrdersInWindow = Lists.newArrayList();
    for (OrderRestRep scheduledOrder : scheduledOrders) {
        if (scheduledOrder.getExecutionWindow() != null && executionWindowId.equals(scheduledOrder.getExecutionWindow().getId())) {
            scheduledOrdersInWindow.add(scheduledOrder);
        }
    }
    return scheduledOrdersInWindow;
}
Also used : OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep)

Example 5 with OrderRestRep

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

the class ScheduledOrdersDataTable method fetchData.

public List<ScheduledOrderInfo> fetchData(DataTableParams params) {
    List<OrderRestRep> orders = OrderUtils.getScheduledOrders(URI.create(Models.currentAdminTenant()));
    if (maxOrders > 0) {
        while (orders.size() > maxOrders) {
            orders.remove(orders.size() - 1);
        }
    }
    List<ScheduledOrderInfo> orderInfos = Lists.newArrayList();
    if (orders != null) {
        for (OrderRestRep orderRestRep : orders) {
            orderInfos.add(new ScheduledOrderInfo(orderRestRep));
        }
    }
    return orderInfos;
}
Also used : OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep)

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