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));
}
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);
}
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();
}
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;
}
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;
}
Aggregations