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