Search in sources :

Example 6 with ServiceFieldRestRep

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

the class ServiceFormUtils method createAssetFieldsFromItems.

/**
 * Creates the asset fields for the container and all its children.
 *
 * @param container
 *            the service item container.
 * @param providedFields
 *            the asset fields provided by the parent, mapped by asset type.
 * @return the map of field name->AssetFieldDescriptor.
 */
private static Map<String, AssetFieldDescriptor> createAssetFieldsFromItems(Collection<? extends ServiceItemRestRep> items, Map<String, ServiceFieldRestRep> providedFields) {
    List<ServiceFieldRestRep> fields = ServiceFieldRestRep.getAssetFields(items);
    Map<String, AssetFieldDescriptor> assetFields = createAssetFields(fields, providedFields);
    // Add the container fields to the provided fields for the children
    providedFields = addFieldsByType(fields, providedFields);
    for (ServiceItemRestRep child : items) {
        if (child instanceof ServiceFieldGroupRestRep) {
            assetFields.putAll(createAssetFieldsFromItems(((ServiceFieldGroupRestRep) child).getItems(), providedFields));
        } else if (child instanceof ServiceFieldTableRestRep) {
            assetFields.putAll(createAssetFieldsFromItems(((ServiceFieldTableRestRep) child).getItems(), providedFields));
        } else if (child instanceof ServiceFieldModalRestRep) {
            assetFields.putAll(createAssetFieldsFromItems(((ServiceFieldModalRestRep) child).getItems(), providedFields));
        }
    }
    return assetFields;
}
Also used : ServiceItemRestRep(com.emc.vipr.model.catalog.ServiceItemRestRep) ServiceFieldGroupRestRep(com.emc.vipr.model.catalog.ServiceFieldGroupRestRep) ServiceFieldModalRestRep(com.emc.vipr.model.catalog.ServiceFieldModalRestRep) ServiceFieldTableRestRep(com.emc.vipr.model.catalog.ServiceFieldTableRestRep) ServiceFieldRestRep(com.emc.vipr.model.catalog.ServiceFieldRestRep)

Example 7 with ServiceFieldRestRep

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

the class CatalogApi method serviceDescriptor.

public static void serviceDescriptor(String serviceId) {
    CatalogServiceRestRep service = CatalogServiceUtils.getCatalogService(uri(serviceId));
    ServiceDescriptorRestRep descriptor = service.getServiceDescriptor();
    // Remove any locked fields so user does not see things they cannot change
    for (CatalogServiceFieldRestRep catalogServiceField : service.getCatalogServiceFields()) {
        if (catalogServiceField.getOverride()) {
            ServiceFieldRestRep serviceField = ServiceDescriptorUtils.getField(descriptor, catalogServiceField.getName());
            descriptor.getItems().remove(serviceField);
        }
    }
    renderPrettyJson(descriptor);
}
Also used : ServiceDescriptorRestRep(com.emc.vipr.model.catalog.ServiceDescriptorRestRep) CatalogServiceFieldRestRep(com.emc.vipr.model.catalog.CatalogServiceFieldRestRep) CatalogServiceFieldRestRep(com.emc.vipr.model.catalog.CatalogServiceFieldRestRep) ServiceFieldRestRep(com.emc.vipr.model.catalog.ServiceFieldRestRep) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep)

Example 8 with ServiceFieldRestRep

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

the class ServiceDescriptorMapper method map.

public static ServiceFieldRestRep map(ServiceField from) {
    if (from == null) {
        return null;
    }
    ServiceFieldRestRep to = new ServiceFieldRestRep();
    mapServiceItemCommon(to, from);
    to.setFailureMessage(from.getValidation().getError());
    to.setInitialValue(from.getInitialValue());
    to.setLockable(from.isLockable());
    to.setMax(from.getValidation().getMax());
    to.setMin(from.getValidation().getMin());
    to.setRegEx(from.getValidation().getRegEx());
    to.setRequired(from.isRequired());
    to.setOmitNone(from.isOmitNone());
    to.setModalField(from.isModalField());
    to.setSelect(from.getSelect());
    to.setHideIfEmpty(from.getHideIfEmpty());
    for (String key : from.getOptions().keySet()) {
        to.getOptions().add(new Option(key, from.getOptions().get(key)));
    }
    return to;
}
Also used : ServiceFieldRestRep(com.emc.vipr.model.catalog.ServiceFieldRestRep) Option(com.emc.vipr.model.catalog.Option)

Example 9 with ServiceFieldRestRep

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

the class ServiceDescriptorMapper method map.

public static ServiceFieldTableRestRep map(ServiceFieldTable from) {
    if (from == null) {
        return null;
    }
    ServiceFieldTableRestRep to = new ServiceFieldTableRestRep();
    mapServiceItemCommon(to, from);
    to.getItems().addAll((List<ServiceFieldRestRep>) map(from.getItems().values()));
    return to;
}
Also used : ServiceFieldTableRestRep(com.emc.vipr.model.catalog.ServiceFieldTableRestRep) ServiceFieldRestRep(com.emc.vipr.model.catalog.ServiceFieldRestRep)

Example 10 with ServiceFieldRestRep

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

the class ServiceDescriptorUtils method findField.

public static ServiceFieldRestRep findField(Collection<? extends ServiceItemRestRep> items, String name) {
    ServiceItemRestRep value = findItemByName(items, name);
    if (value != null && value.isField()) {
        return (ServiceFieldRestRep) value;
    }
    // Search for a nested field
    for (ServiceItemRestRep item : items) {
        if (item instanceof ServiceFieldGroupRestRep) {
            ServiceFieldGroupRestRep group = (ServiceFieldGroupRestRep) item;
            ServiceFieldRestRep field = findField(group.getItems(), name);
            if (field != null) {
                return field;
            }
        } else if (item instanceof ServiceFieldTableRestRep) {
            ServiceFieldTableRestRep table = (ServiceFieldTableRestRep) item;
            ServiceFieldRestRep field = findField(table.getItems(), name);
            if (field != null) {
                return field;
            }
        } else if (item instanceof ServiceFieldModalRestRep) {
            ServiceFieldModalRestRep modal = (ServiceFieldModalRestRep) item;
            ServiceFieldRestRep field = findField(modal.getItems(), name);
            if (field != null) {
                return field;
            }
        }
    }
    // No field found
    return null;
}
Also used : ServiceItemRestRep(com.emc.vipr.model.catalog.ServiceItemRestRep) ServiceFieldGroupRestRep(com.emc.vipr.model.catalog.ServiceFieldGroupRestRep) ServiceFieldModalRestRep(com.emc.vipr.model.catalog.ServiceFieldModalRestRep) ServiceFieldTableRestRep(com.emc.vipr.model.catalog.ServiceFieldTableRestRep) ServiceFieldRestRep(com.emc.vipr.model.catalog.ServiceFieldRestRep)

Aggregations

ServiceFieldRestRep (com.emc.vipr.model.catalog.ServiceFieldRestRep)13 CatalogServiceFieldRestRep (com.emc.vipr.model.catalog.CatalogServiceFieldRestRep)6 ServiceFieldTableRestRep (com.emc.vipr.model.catalog.ServiceFieldTableRestRep)4 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)3 ServiceDescriptorRestRep (com.emc.vipr.model.catalog.ServiceDescriptorRestRep)3 ServiceItemRestRep (com.emc.vipr.model.catalog.ServiceItemRestRep)3 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 Parameter (com.emc.vipr.model.catalog.Parameter)2 ServiceFieldGroupRestRep (com.emc.vipr.model.catalog.ServiceFieldGroupRestRep)2 ServiceFieldModalRestRep (com.emc.vipr.model.catalog.ServiceFieldModalRestRep)2 HashMap (java.util.HashMap)2 Util (play.mvc.Util)2 TaskUtil (com.emc.vipr.client.core.impl.TaskUtil)1 Option (com.emc.vipr.model.catalog.Option)1 OrderCreateParam (com.emc.vipr.model.catalog.OrderCreateParam)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Gson (com.google.gson.Gson)1 BourneUtil (util.BourneUtil)1 AssetFieldDescriptor (util.ServiceFormUtils.AssetFieldDescriptor)1