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