Search in sources :

Example 1 with ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 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 ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 in project coprhd-controller by CoprHD.

the class OrdersApi method orderExecution.

public static void orderExecution(String orderId) {
    ViPRCatalogClient2 catalog = getCatalogClient();
    ExecutionStateRestRep executionState = catalog.orders().getExecutionState(uri(orderId));
    List<OrderLogRestRep> logs = catalog.orders().getLogs(uri(orderId));
    List<ExecutionLogRestRep> taskLogs = catalog.orders().getExecutionLogs(uri(orderId));
    renderApi(newExecutionInfo(executionState, logs, taskLogs));
}
Also used : ExecutionStateRestRep(com.emc.vipr.model.catalog.ExecutionStateRestRep) OrderLogRestRep(com.emc.vipr.model.catalog.OrderLogRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) ExecutionLogRestRep(com.emc.vipr.model.catalog.ExecutionLogRestRep)

Example 3 with ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 in project coprhd-controller by CoprHD.

the class OrdersApi method queryOrders.

private static List<? extends RelatedResourceRep> queryOrders(String startTime, String endTime) {
    Date startDate = TimeUtils.getDateTimestamp(startTime);
    Date endDate = TimeUtils.getDateTimestamp(endTime);
    ViPRCatalogClient2 catalog = getCatalogClient();
    List<? extends RelatedResourceRep> elements;
    if (startDate == null && endDate == null) {
        elements = catalog.orders().listByUserTenant();
    } else {
        Map<String, Object> params = Maps.newHashMap();
        if (startDate != null) {
            params.put(START_TIME_PARAM, Long.toString(startDate.getTime()));
        }
        if (endDate != null) {
            params.put(END_TIME_PARAM, Long.toString(endDate.getTime()));
        }
        elements = catalog.orders().performSearch(params);
    }
    return elements;
}
Also used : ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) Date(java.util.Date)

Example 4 with ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 in project coprhd-controller by CoprHD.

the class OrdersApi method updateOrderTags.

private static void updateOrderTags(URI orderId, TagAssignment assignment) {
    // shouldn't happen but we'll protect against it anyway.
    if (assignment == null) {
        error(401, Messages.get("OrdersApi.invalidTagChangesElement"));
    }
    ViPRCatalogClient2 catalog = getCatalogClient();
    catalog.orders().addTags(orderId, assignment.getAdd());
    catalog.orders().removeTags(orderId, assignment.getRemove());
}
Also used : ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2)

Example 5 with ViPRCatalogClient2

use of com.emc.vipr.client.ViPRCatalogClient2 in project coprhd-controller by CoprHD.

the class Notifications method getNotifications.

@Util
public static List<Notification> getNotifications() {
    ViPRCatalogClient2 catalog = getCatalogClient();
    List<Notification> notifications = Lists.newArrayList();
    List<ApprovalRestRep> approvals = catalog.approvals().search().byStatus(ApprovalRestRep.PENDING).run();
    for (ApprovalRestRep approval : approvals) {
        if (approval.getOrder() != null) {
            OrderRestRep order = getOrder(approval.getOrder());
            if (order != null) {
                CatalogServiceRestRep service = getCatalogService(order.getCatalogService());
                Notification notification = new Notification();
                notification.id = approval.getId().toString();
                notification.orderId = order.getId().toString();
                if (service != null) {
                    notification.image = service.getImage();
                    notification.message = MessagesUtils.get("notification.approvalPending", service.getTitle(), order.getSubmittedBy());
                }
                notification.lastUpdated = approval.getDateActioned() != null ? approval.getDateActioned() : approval.getCreationTime().getTime();
                notifications.add(notification);
            }
        }
    }
    return notifications;
}
Also used : ApprovalRestRep(com.emc.vipr.model.catalog.ApprovalRestRep) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) Util(play.mvc.Util)

Aggregations

ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)32 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)7 ApprovalRestRep (com.emc.vipr.model.catalog.ApprovalRestRep)4 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)4 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)2 URI (java.net.URI)2 Date (java.util.Date)2 OrderTextCreator (com.emc.storageos.db.client.util.OrderTextCreator)1 AssetDependencyRequest (com.emc.vipr.model.catalog.AssetDependencyRequest)1 AssetOptionsRequest (com.emc.vipr.model.catalog.AssetOptionsRequest)1 ExecutionLogRestRep (com.emc.vipr.model.catalog.ExecutionLogRestRep)1 ExecutionStateRestRep (com.emc.vipr.model.catalog.ExecutionStateRestRep)1 ExecutionWindowRestRep (com.emc.vipr.model.catalog.ExecutionWindowRestRep)1 OrderLogRestRep (com.emc.vipr.model.catalog.OrderLogRestRep)1 Reference (com.emc.vipr.model.catalog.Reference)1 ScheduledEventRestRep (com.emc.vipr.model.catalog.ScheduledEventRestRep)1 ApprovalRequestInfo (models.datatable.ApprovalsDataTable.ApprovalRequestInfo)1 DateTime (org.joda.time.DateTime)1 Util (play.mvc.Util)1