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