use of com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow 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.CustomServicesWorkflow in project coprhd-controller by CoprHD.
the class CustomServicesWorkflowManagerImpl method getByNameOrId.
@Override
public List<CustomServicesWorkflow> getByNameOrId(final String name) {
if (null == name) {
return null;
}
final List<CustomServicesWorkflow> workflowList = Lists.newArrayList();
try {
// first check if id is passed
if (URIUtil.isValid(new URI(name))) {
CustomServicesWorkflow csWF = client.customServicesWorkflows().findById(URIUtil.uri(name));
if (csWF != null) {
workflowList.add(csWF);
return workflowList;
}
}
} catch (final URISyntaxException e) {
// the passed value is not id.
log.debug("URISyntaxException : uri passed is " + name);
log.debug("Moving on to get by label");
}
final List<NamedElement> workflows = client.findByLabel(CustomServicesWorkflow.class, name);
final ImmutableList.Builder<URI> ids = ImmutableList.<URI>builder();
for (final NamedElement workflow : workflows) {
if (workflow.getName().equals(name)) {
ids.add(workflow.getId());
}
}
return client.findByIds(CustomServicesWorkflow.class, ids.build());
}
use of com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow in project coprhd-controller by CoprHD.
the class DefaultExecutionServiceFactory method createService.
@Override
public ExecutionService createService(Order order, CatalogService catalogService) throws ServiceNotFoundException {
String serviceName;
if (null == catalogService) {
// This is case of "Test Orders".
// Getting service name from workflow (as there is no catalog service)
final CustomServicesWorkflow customServicesWorkflow = customServicesWorkflowManager.getById(order.getCatalogServiceId());
serviceName = customServicesWorkflow.getLabel();
} else {
serviceName = catalogService.getBaseService();
}
Class<? extends ExecutionService> serviceClass = services.get(serviceName);
if (serviceClass == null) {
// For these services there is only one executor - CustomServicesService
if (isWorkflowService(serviceName)) {
serviceClass = services.get("CustomServicesService");
} else {
throw new ServiceNotFoundException(String.format("Service '%s' not found", serviceName));
}
}
return newInstance(serviceClass, serviceName);
}
use of com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow in project coprhd-controller by CoprHD.
the class WorkflowHelper method create.
/**
* Create a workflow definition
*
* @throws IOException
* @throws JsonMappingException
* @throws JsonGenerationException
*/
public static CustomServicesWorkflow create(final CustomServicesWorkflowDocument document) throws JsonGenerationException, JsonMappingException, IOException {
final CustomServicesWorkflow workflow = new CustomServicesWorkflow();
workflow.setId(URIUtil.createId(CustomServicesWorkflow.class));
if (StringUtils.isNotBlank(document.getName())) {
workflow.setLabel(document.getName().trim());
} else {
throw APIException.badRequests.requiredParameterMissingOrEmpty("name");
}
workflow.setDescription(document.getDescription());
workflow.setSteps(toStepsJson(document.getSteps()));
workflow.setPrimitives(getPrimitives(document));
return workflow;
}
use of com.emc.storageos.db.client.model.uimodels.CustomServicesWorkflow in project coprhd-controller by CoprHD.
the class WorkflowHelper method importWorkflow.
/**
* @param client
* @param wfDirectory
* @param value
* @throws IOException
* @throws JsonMappingException
* @throws JsonGenerationException
*/
private static void importWorkflow(final CustomServicesWorkflowRestRep workflow, final ModelClient client, final WFDirectory wfDirectory) throws JsonGenerationException, JsonMappingException, IOException {
final CustomServicesWorkflow dbWorkflow = new CustomServicesWorkflow();
dbWorkflow.setId(workflow.getId());
dbWorkflow.setLabel(findImportName(workflow.getName(), client));
dbWorkflow.setInactive(false);
dbWorkflow.setDescription(workflow.getDocument().getDescription());
dbWorkflow.setSteps(toStepsJson(workflow.getDocument().getSteps()));
dbWorkflow.setPrimitives(getPrimitives(workflow.getDocument()));
client.save(dbWorkflow);
if (null != wfDirectory.getId()) {
wfDirectory.addWorkflows(Collections.singleton(workflow.getId()));
client.save(wfDirectory);
}
}
Aggregations