use of com.emc.sa.descriptor.ServiceField in project coprhd-controller by CoprHD.
the class OrderManagerImpl method createOrder.
public Order createOrder(Order order, List<OrderParameter> orderParameters, StorageOSUser user) {
CatalogService catalogService = catalogServiceManager.getCatalogServiceById(order.getCatalogServiceId());
ServiceDescriptor serviceDescriptor = ServiceDescriptorUtil.getServiceDescriptorByName(serviceDescriptors, workflowServiceDescriptor, catalogService.getBaseService());
order.setOrderNumber(getNextOrderNumber());
order.setSummary(catalogService.getTitle());
if (order.getScheduledEventId() == null) {
if (catalogService.getExecutionWindowRequired()) {
if (catalogService.getDefaultExecutionWindowId() == null || catalogService.getDefaultExecutionWindowId().getURI().equals(ExecutionWindow.NEXT)) {
// For default execution window, null is deemed as NEXT window as well.
// But we always need to set order execution window to NEXT explicitly to different it
// with INFINITE window in new scheduler framework.
// Set schedule time to latest updated time. It would still be scheduled in executed window
Calendar scheduleTime = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
scheduleTime.setTime(new Date());
order.setScheduledTime(scheduleTime);
order.setExecutionWindowId(new NamedURI(ExecutionWindow.NEXT, "NEXT"));
} else {
// Set schedule time to
// either 1) the next execution window starting time
// or 2) the current time if it is in current execution window
ExecutionWindow executionWindow = client.findById(catalogService.getDefaultExecutionWindowId().getURI());
ExecutionWindowHelper helper = new ExecutionWindowHelper(executionWindow);
order.setScheduledTime(helper.getScheduledTime());
order.setExecutionWindowId(catalogService.getDefaultExecutionWindowId());
}
} else {
// If no execution window is indicated, order will be submitted to DQ immediately.
;
}
} else {
// ExecutionWindow and ScheduleTime are already set via Parameter
;
}
order.setMessage("");
order.setSubmittedByUserId(user.getUserName());
order.setOrderStatus(OrderStatus.PENDING.name());
createExecutionState(order, user);
client.save(order);
Map<String, String> assetOptions = getAssetValues(serviceDescriptor, orderParameters);
for (OrderParameter orderParameter : orderParameters) {
ServiceField serviceField = findServiceField(serviceDescriptor, orderParameter.getLabel());
String friendlyLabel = serviceField.getLabel();
StringBuilder friendlyValue = new StringBuilder();
List<String> values = TextUtils.parseCSV(orderParameter.getValue());
for (String value : values) {
if (friendlyValue.length() > 0) {
friendlyValue.append(",");
}
friendlyValue.append(getFriendlyValue(serviceField, value, assetOptions, user));
}
orderParameter.setFriendlyLabel(friendlyLabel);
orderParameter.setFriendlyValue(friendlyValue.toString());
createOrderParameter(orderParameter);
}
return order;
}
use of com.emc.sa.descriptor.ServiceField in project coprhd-controller by CoprHD.
the class OrderManagerImpl method findServiceField.
private ServiceField findServiceField(ServiceDescriptor serviceDescriptor, String serviceFieldName) {
for (ServiceField serviceField : serviceDescriptor.getAllFieldList()) {
if (StringUtils.equalsIgnoreCase(serviceFieldName, serviceField.getName())) {
return serviceField;
}
}
log.info(String.format("Unexpected service field value found: %s", serviceFieldName));
ServiceField field = new ServiceField();
field.setName(serviceFieldName);
field.setLabel(serviceFieldName);
return field;
}
Aggregations