Search in sources :

Example 1 with ApprovalRestRep

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

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

Example 3 with ApprovalRestRep

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

the class ApprovalsApi method pending.

public static void pending() {
    List<Reference> approvals = Lists.newArrayList();
    List<ApprovalRestRep> pendingApprovals = getCatalogClient().approvals().search().byStatus(ApprovalRestRep.PENDING).run();
    for (ApprovalRestRep request : pendingApprovals) {
        approvals.add(newApprovalReference(request.getId().toString()));
    }
    renderApi(approvals);
}
Also used : ApiMapperUtils.newApprovalReference(util.api.ApiMapperUtils.newApprovalReference) Reference(com.emc.vipr.model.catalog.Reference) ApprovalRestRep(com.emc.vipr.model.catalog.ApprovalRestRep)

Example 4 with ApprovalRestRep

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

the class ApprovalsApi method approval.

public static void approval(String approvalId) {
    ApprovalRestRep approval = getCatalogClient().approvals().get(uri(approvalId));
    renderApi(newApprovalInfo(approval));
}
Also used : ApprovalRestRep(com.emc.vipr.model.catalog.ApprovalRestRep)

Example 5 with ApprovalRestRep

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

the class ApprovalMapper method map.

public static ApprovalRestRep map(ApprovalRequest from) {
    if (from == null) {
        return null;
    }
    ApprovalRestRep to = new ApprovalRestRep();
    mapDataObjectFields(from, to);
    if (from.getTenant() != null) {
        to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, uri(from.getTenant())));
    }
    if (from.getOrderId() != null) {
        to.setOrder(toRelatedResource(ResourceTypeEnum.ORDER, from.getOrderId()));
    }
    to.setApprovedBy(from.getApprovedBy());
    to.setDateActioned(from.getDateActioned());
    to.setMessage(from.getMessage());
    to.setApprovalStatus(from.getApprovalStatus());
    return to;
}
Also used : ApprovalRestRep(com.emc.vipr.model.catalog.ApprovalRestRep)

Aggregations

ApprovalRestRep (com.emc.vipr.model.catalog.ApprovalRestRep)10 ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)4 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)4 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)3 URI (java.net.URI)2 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)1 ApprovalUpdateParam (com.emc.vipr.model.catalog.ApprovalUpdateParam)1 Reference (com.emc.vipr.model.catalog.Reference)1 ScheduledEventRestRep (com.emc.vipr.model.catalog.ScheduledEventRestRep)1 Client (com.sun.jersey.api.client.Client)1 ClientHandlerException (com.sun.jersey.api.client.ClientHandlerException)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 WebResource (com.sun.jersey.api.client.WebResource)1 ClientConfig (com.sun.jersey.api.client.config.ClientConfig)1 DefaultClientConfig (com.sun.jersey.api.client.config.DefaultClientConfig)1 Date (java.util.Date)1 ApprovalRequestInfo (models.datatable.ApprovalsDataTable.ApprovalRequestInfo)1 DateTime (org.joda.time.DateTime)1 Util (play.mvc.Util)1 Result (play.mvc.results.Result)1