Search in sources :

Example 6 with OrderRestRep

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

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

the class OrderService method queryBulkResourceReps.

@Override
public OrderBulkRep queryBulkResourceReps(List<URI> ids) {
    List<OrderRestRep> orderRestReps = new ArrayList<OrderRestRep>();
    List<OrderAndParams> ordersAndParams = orderManager.getOrdersAndParams(ids);
    for (OrderAndParams orderAndParams : ordersAndParams) {
        orderRestReps.add(OrderMapper.map(orderAndParams.getOrder(), orderAndParams.getParameters()));
    }
    OrderBulkRep rep = new OrderBulkRep(orderRestReps);
    return rep;
}
Also used : OrderAndParams(com.emc.storageos.db.client.model.uimodels.OrderAndParams) ArrayList(java.util.ArrayList) OrderBulkRep(com.emc.vipr.model.catalog.OrderBulkRep) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep)

Example 8 with OrderRestRep

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

the class OrderService method queryFilteredBulkResourceReps.

@Override
public OrderBulkRep queryFilteredBulkResourceReps(List<URI> ids) {
    OrderFilter filter = new OrderFilter(getUserFromContext(), _permissionsHelper);
    List<OrderRestRep> orderRestReps = new ArrayList<OrderRestRep>();
    List<OrderAndParams> ordersAndParams = orderManager.getOrdersAndParams(ids);
    for (OrderAndParams orderAndParams : ordersAndParams) {
        if (filter.isAccessible(orderAndParams.getOrder())) {
            orderRestReps.add(OrderMapper.map(orderAndParams.getOrder(), orderAndParams.getParameters()));
        }
    }
    return new OrderBulkRep(orderRestReps);
}
Also used : OrderAndParams(com.emc.storageos.db.client.model.uimodels.OrderAndParams) ArrayList(java.util.ArrayList) OrderBulkRep(com.emc.vipr.model.catalog.OrderBulkRep) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) OrderFilter(com.emc.sa.api.mapper.OrderFilter)

Example 9 with OrderRestRep

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

the class OrderService method toOrders.

private List<OrderRestRep> toOrders(List<Order> orders, StorageOSUser user, boolean ordersOnly) {
    List<OrderRestRep> orderList = new ArrayList();
    List<OrderParameter> orderParameters = null;
    for (Order order : orders) {
        if (ordersOnly == false) {
            orderParameters = orderManager.getOrderParameters(order.getId());
        }
        orderList.add(map(order, orderParameters));
    }
    return orderList;
}
Also used : Order(com.emc.storageos.db.client.model.uimodels.Order) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) ArrayList(java.util.ArrayList) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep)

Example 10 with OrderRestRep

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

the class OrderMapper method map.

public static OrderRestRep map(Order from, List<OrderParameter> orderParameters) {
    if (from == null) {
        return null;
    }
    OrderRestRep to = new OrderRestRep();
    mapDataObjectFields(from, to);
    if (from.getCatalogServiceId() != null) {
        to.setCatalogService(toRelatedResource(ResourceTypeEnum.CATALOG_SERVICE, from.getCatalogServiceId()));
    }
    if (from.getExecutionWindowId() != null) {
        to.setExecutionWindow(toRelatedResource(ResourceTypeEnum.EXECUTION_WINDOW, from.getExecutionWindowId().getURI()));
    }
    to.setDateCompleted(from.getDateCompleted());
    to.setMessage(from.getMessage());
    to.setOrderNumber(from.getOrderNumber());
    to.setSummary(from.getSummary());
    to.setSubmittedBy(from.getSubmittedByUserId());
    to.setOrderStatus(from.getOrderStatus());
    if (StringUtils.isNotBlank(from.getTenant())) {
        to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, uri(from.getTenant())));
    }
    to.setLastUpdated(from.getLastUpdated());
    if (orderParameters != null) {
        for (OrderParameter orderParameter : orderParameters) {
            Parameter parameter = new Parameter();
            parameter.setEncrypted(orderParameter.getEncrypted());
            if (parameter.isEncrypted()) {
                parameter.setFriendlyValue(ENCRYPTED_FIELD_MASK);
                parameter.setValue(ENCRYPTED_FIELD_MASK);
            } else {
                parameter.setFriendlyValue(orderParameter.getFriendlyValue());
                parameter.setValue(orderParameter.getValue());
            }
            parameter.setFriendlyLabel(orderParameter.getFriendlyLabel());
            parameter.setLabel(orderParameter.getLabel());
            to.getParameters().add(parameter);
        }
    }
    if (from.getScheduledEventId() != null) {
        to.setScheduledEventId(from.getScheduledEventId());
    }
    if (from.getScheduledTime() != null) {
        to.setScheduledTime(from.getScheduledTime());
    }
    return to;
}
Also used : OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) OrderRestRep(com.emc.vipr.model.catalog.OrderRestRep) OrderParameter(com.emc.storageos.db.client.model.uimodels.OrderParameter) Parameter(com.emc.vipr.model.catalog.Parameter)

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