Search in sources :

Example 1 with ApprovalRequestInfo

use of models.datatable.ApprovalsDataTable.ApprovalRequestInfo 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)

Aggregations

ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)1 ApprovalRestRep (com.emc.vipr.model.catalog.ApprovalRestRep)1 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)1 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)1 URI (java.net.URI)1 ApprovalRequestInfo (models.datatable.ApprovalsDataTable.ApprovalRequestInfo)1