use of com.emc.storageos.db.client.model.uimodels.CatalogService 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.storageos.db.client.model.uimodels.CatalogService 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.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.
the class CatalogCategoryManagerImpl method deleteCategoryContents.
private void deleteCategoryContents(CatalogCategory catalogCategory) {
List<CatalogCategory> categories = getSubCategories(catalogCategory.getId());
for (CatalogCategory subCategory : categories) {
deleteCatalogCategory(subCategory);
}
List<CatalogService> services = catalogServiceManager.getCatalogServices(catalogCategory.getId());
for (CatalogService service : services) {
catalogServiceManager.deleteCatalogService(service);
}
}
use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.
the class CatalogServiceManagerImpl method getCatalogServiceById.
public CatalogService getCatalogServiceById(URI id) {
if (id == null) {
return null;
}
CatalogService catalogService = client.catalogServices().findById(id);
// For "Test Workflow" CustomServiceWorkflow ID is set as CatalogService.
if (null == catalogService && id.toString().startsWith(CustomServicesWorkflow.ID_PREFIX)) {
final CustomServicesWorkflow customServicesWorkflow = customServicesWorkflowManager.getById(id);
if (customServicesWorkflow == null) {
log.debug(String.format("Unable to get Catalog Service by Id [%s]. Workflow may have been deleted.", id));
throw new IllegalStateException("Unable to get Catalog Service by Id" + id + "Workflow may have been deleted.");
}
catalogService = new CatalogService();
catalogService.setId(id);
catalogService.setTitle(customServicesWorkflow.getLabel());
catalogService.setDescription(customServicesWorkflow.getLabel());
catalogService.setImage("icon_orchestration.png");
catalogService.setBaseService(URIUtil.asString(id));
}
return catalogService;
}
use of com.emc.storageos.db.client.model.uimodels.CatalogService in project coprhd-controller by CoprHD.
the class ExecutionUtils method createContext.
public static void createContext(ModelClient modelClient, Order order) {
// Ensure there is no existing context
destroyContext();
// Initialize the execution state for this order
ExecutionState state = modelClient.executionStates().findById(order.getExecutionStateId());
state.setStartDate(new Date());
ExecutionContext context = currentContext();
context.setOrder(order);
context.setModelClient(modelClient);
context.setExecutionState(state);
URI scheduledEventId = order.getScheduledEventId();
if (scheduledEventId != null) {
ScheduledEvent event = modelClient.findById(ScheduledEvent.class, scheduledEventId);
context.setScheduledEvent(event);
}
CatalogService catalogService = modelClient.catalogServices().findById(order.getCatalogServiceId());
if (null != catalogService) {
context.setServiceName(catalogService.getLabel());
}
List<OrderParameter> orderParameters = modelClient.orderParameters().findByOrderId(order.getId());
Map<String, Object> params = Maps.newLinkedHashMap();
for (OrderParameter param : orderParameters) {
params.put(param.getLabel(), param.getValue());
}
context.setParameters(params);
}
Aggregations