Search in sources :

Example 1 with ServiceDescriptorRestRep

use of com.emc.vipr.model.catalog.ServiceDescriptorRestRep in project coprhd-controller by CoprHD.

the class EditCatalog method addFieldOptions.

private static void addFieldOptions(String baseService) {
    // Base service may be null for a new service
    if (StringUtils.isNotBlank(baseService)) {
        ServiceDescriptorRestRep serviceDescriptor = getServiceDescriptorForEditing(baseService);
        // Load any Asset Options for root fields so they are rendered directly onto the form
        List<ServiceFieldRestRep> fields = ServiceDescriptorUtils.getAllFieldList(serviceDescriptor.getItems());
        for (ServiceFieldRestRep field : fields) {
            if (field.isAsset() && field.isLockable()) {
                try {
                    List<AssetOption> options = AssetOptionUtils.getAssetOptions(field.getAssetType());
                    request.current().args.put(field.getType() + "-options", options);
                } catch (RuntimeException e) {
                    request.current().args.put(field.getType() + "-error", e.getMessage());
                }
            }
        }
    }
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) ServiceFieldRestRep(com.emc.vipr.model.catalog.ServiceFieldRestRep) CatalogServiceFieldRestRep(com.emc.vipr.model.catalog.CatalogServiceFieldRestRep)

Example 2 with ServiceDescriptorRestRep

use of com.emc.vipr.model.catalog.ServiceDescriptorRestRep in project coprhd-controller by CoprHD.

the class EditCatalog method edit.

private static void edit(ServiceForm service) {
    addImagesToRenderArgs();
    addExecutionWindowsToRenderArgs();
    addBaseServicesToRenderArgs();
    addCategoriesToRenderArgs();
    addBreadCrumbToRenderArgs(Models.currentAdminTenant(), service);
    addACLsToRenderArgs();
    // Add information for service fields
    ServiceDescriptorRestRep serviceDescriptor = null;
    if (service.baseService != null) {
        serviceDescriptor = getServiceDescriptorForEditing(service.baseService);
        addFieldOptions(service.baseService);
    }
    render("@editService", service, serviceDescriptor);
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep)

Example 3 with ServiceDescriptorRestRep

use of com.emc.vipr.model.catalog.ServiceDescriptorRestRep in project coprhd-controller by CoprHD.

the class EditCatalog method serviceFields.

public static void serviceFields(String baseService, String serviceId) {
    ServiceDescriptorRestRep serviceDescriptor = ServiceDescriptorUtils.getDescriptor(baseService);
    ServiceForm service = null;
    if (StringUtils.isNotBlank(serviceId)) {
        CatalogServiceRestRep dbService = CatalogServiceUtils.getCatalogService(uri(serviceId));
        if (dbService != null) {
            service = new ServiceForm(dbService);
        } else {
            service = new ServiceForm();
            service.baseService = baseService;
        }
    }
    addFieldOptions(baseService);
    render(serviceDescriptor, service);
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep)

Example 4 with ServiceDescriptorRestRep

use of com.emc.vipr.model.catalog.ServiceDescriptorRestRep in project coprhd-controller by CoprHD.

the class EditCatalog method addBaseServicesToRenderArgs.

private static void addBaseServicesToRenderArgs() {
    Map<String, List<ServiceDescriptorRestRep>> descriptors = Maps.newTreeMap();
    for (ServiceDescriptorRestRep descriptor : ServiceDescriptorUtils.getDescriptors()) {
        String category = StringUtils.defaultString(descriptor.getCategory());
        List<ServiceDescriptorRestRep> values = descriptors.get(category);
        if (values == null) {
            values = Lists.newArrayList();
            descriptors.put(category, values);
        }
        values.add(descriptor);
    }
    for (List<ServiceDescriptorRestRep> values : descriptors.values()) {
        Collections.sort(values, new ServiceDescriptorComparator());
    }
    renderArgs.put("baseServices", descriptors);
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep) List(java.util.List) ArrayList(java.util.ArrayList)

Example 5 with ServiceDescriptorRestRep

use of com.emc.vipr.model.catalog.ServiceDescriptorRestRep in project coprhd-controller by CoprHD.

the class Orders method createAndValidateOrder.

@Util
public static OrderCreateParam createAndValidateOrder(String serviceId) {
    CatalogServiceRestRep service = CatalogServiceUtils.getCatalogService(uri(serviceId));
    ServiceDescriptorRestRep descriptor = service.getServiceDescriptor();
    if (descriptor == null) {
        flash.error("order.submitFailedWithDetail", " The Workflow or Service Descriptor is deleted");
        Logger.error("Service Descriptor not found");
        throw new IllegalStateException("No Service Descriptor found. Might be Customservices Workflow  is deleted ");
    }
    // Filter out actual Service Parameters
    Map<String, String> parameters = parseParameters(service, descriptor);
    if (Validation.hasErrors()) {
        Validation.keep();
        Common.flashParamsExcept("json", "body");
        Services.showForm(serviceId);
    }
    return createOrder(service, descriptor, parameters);
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) BourneUtil(util.BourneUtil) TaskUtil(com.emc.vipr.client.core.impl.TaskUtil) Util(play.mvc.Util)

Aggregations

ServiceDescriptorRestRep (com.emc.vipr.model.catalog.ServiceDescriptorRestRep)14 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)7 CatalogServiceFieldRestRep (com.emc.vipr.model.catalog.CatalogServiceFieldRestRep)3 ServiceFieldRestRep (com.emc.vipr.model.catalog.ServiceFieldRestRep)3 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 WorkflowServiceDescriptor (com.emc.sa.catalog.WorkflowServiceDescriptor)1 ServiceDescriptor (com.emc.sa.descriptor.ServiceDescriptor)1 TaskUtil (com.emc.vipr.client.core.impl.TaskUtil)1 OrderCreateParam (com.emc.vipr.model.catalog.OrderCreateParam)1 Reference (com.emc.vipr.model.catalog.Reference)1 ServiceDescriptorList (com.emc.vipr.model.catalog.ServiceDescriptorList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Gson (com.google.gson.Gson)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Util (play.mvc.Util)1