use of com.emc.sa.descriptor.ServiceDescriptor in project coprhd-controller by CoprHD.
the class CatalogBuilder method createService.
public CatalogService createService(ServiceDef def, NamedURI parentId) {
ServiceDescriptor descriptor = descriptors.getDescriptor(Locale.getDefault(), def.baseService);
String label = StringUtils.defaultString(getMessage(getLabel(def)), descriptor.getTitle());
String title = StringUtils.defaultString(getMessage(def.title), descriptor.getTitle());
String description = StringUtils.defaultString(getMessage(def.description), descriptor.getDescription());
CatalogService service = new CatalogService();
service.setBaseService(def.baseService);
service.setLabel(StringUtils.deleteWhitespace(label));
service.setTitle(title);
service.setDescription(description);
service.setImage(def.image);
service.setCatalogCategoryId(parentId);
service.setSortedIndex(sortedIndexCounter++);
log.info("Create new service" + def.baseService);
if (AllowRecurringSchedulerMigration.RECURRING_ALLOWED_CATALOG_SERVICES.contains(def.baseService) || AllowRecurringSchedulerForApplicationServicesMigration.RECURRING_ALLOWED_CATALOG_SERVICES.contains(def.baseService)) {
service.setRecurringAllowed(true);
}
models.save(service);
if (def.lockFields != null) {
for (Map.Entry<String, String> lockField : def.lockFields.entrySet()) {
CatalogServiceField field = new CatalogServiceField();
field.setLabel(lockField.getKey());
field.setValue(lockField.getValue());
field.setCatalogServiceId(new NamedURI(service.getId(), service.getLabel()));
models.save(field);
}
}
return service;
}
use of com.emc.sa.descriptor.ServiceDescriptor in project coprhd-controller by CoprHD.
the class CatalogCategoryManagerImpl method upgradeServices.
private void upgradeServices(CatalogCategory currentCategory, com.emc.sa.catalog.CategoryDef newCategory) {
List<CatalogService> services = client.catalogServices().findByCatalogCategory(currentCategory.getId());
// Add or Update Missing Services
if (newCategory.services != null) {
for (com.emc.sa.catalog.ServiceDef newService : newCategory.services) {
List<CatalogService> matchingServices = findServices(services, newService.baseService);
if (matchingServices != null && !matchingServices.isEmpty()) {
updateMatchingServices(currentCategory, matchingServices, newService);
} else {
ServiceDescriptor descriptor = serviceDescriptors.getDescriptor(Locale.getDefault(), newService.baseService);
String label = "";
if (descriptor != null) {
label = StringUtils.deleteWhitespace(StringUtils.defaultString(getMessage(getLabel(newService)), descriptor.getTitle()));
}
log.info(String.format("CREATING Missing Service %s: for tenant: %s", label, currentCategory.getTenant()));
catalogServiceManager.createCatalogService(newService, currentCategory);
}
}
}
// Remove Old Services
for (CatalogService service : services) {
ServiceDescriptor serviceDescriptor = null;
try {
serviceDescriptor = serviceDescriptors.getDescriptor(Locale.getDefault(), service.getBaseService());
} catch (IllegalStateException ese) {
// getDescriptor throws exception when no descriptor found
}
if (serviceDescriptor == null) {
log.info(String.format("REMOVING Service '%s' as base service '%s' no longer exists for tenant:%s", service.getTitle(), service.getBaseService(), currentCategory.getTenant()));
catalogServiceManager.deleteCatalogService(service);
}
}
}
use of com.emc.sa.descriptor.ServiceDescriptor 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.ServiceDescriptor in project coprhd-controller by CoprHD.
the class WorkflowServiceDescriptor method listDescriptors.
// This method will only return service descriptors for PUBLISHED workflows
public Collection<ServiceDescriptor> listDescriptors() {
List<ServiceDescriptor> wfServiceDescriptors = new ArrayList<>();
List<NamedElement> oeElements = customServicesWorkflowManager.listByStatus(CustomServicesWorkflowStatus.PUBLISHED);
if (null != oeElements) {
CustomServicesWorkflow oeWorkflow;
for (NamedElement oeElement : oeElements) {
oeWorkflow = customServicesWorkflowManager.getById(oeElement.getId());
wfServiceDescriptors.add(mapWorkflowToServiceDescriptor(oeWorkflow));
}
}
return wfServiceDescriptors;
}
Aggregations