Search in sources :

Example 1 with ServiceItemRestRep

use of com.emc.vipr.model.catalog.ServiceItemRestRep 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 2 with ServiceItemRestRep

use of com.emc.vipr.model.catalog.ServiceItemRestRep 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)

Example 3 with ServiceItemRestRep

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

the class Orders method addParametersToFlash.

@Util
private static void addParametersToFlash(OrderRestRep order) {
    CatalogServiceRestRep service = CatalogServiceUtils.getCatalogService(uri(order.getCatalogService().getId().toString()));
    HashMap<String, String> tableParams = new HashMap<String, String>();
    if (service == null || service.getServiceDescriptor() == 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 ");
    }
    for (ServiceItemRestRep item : service.getServiceDescriptor().getItems()) {
        if (item.isTable()) {
            for (ServiceFieldRestRep tableItem : ((ServiceFieldTableRestRep) item).getItems()) {
                tableParams.put(tableItem.getName(), item.getName());
            }
        }
    }
    for (Parameter parameter : order.getParameters()) {
        // Do not add encrypted values to the flash scope
        if (parameter.isEncrypted()) {
            continue;
        }
        List<String> values = TextUtils.parseCSV(parameter.getValue());
        for (int i = 0; i < values.size(); i++) {
            String value = values.get(i);
            String name = parameter.getLabel();
            if (tableParams.containsKey(name)) {
                name = tableParams.get(name) + "[" + i + "]." + name;
            }
            flash.put(name, value);
        }
    }
}
Also used : ServiceItemRestRep(com.emc.vipr.model.catalog.ServiceItemRestRep) ServiceFieldTableRestRep(com.emc.vipr.model.catalog.ServiceFieldTableRestRep) HashMap(java.util.HashMap) ServiceFieldRestRep(com.emc.vipr.model.catalog.ServiceFieldRestRep) Parameter(com.emc.vipr.model.catalog.Parameter) CatalogServiceRestRep(com.emc.vipr.model.catalog.CatalogServiceRestRep) BourneUtil(util.BourneUtil) TaskUtil(com.emc.vipr.client.core.impl.TaskUtil) Util(play.mvc.Util)

Aggregations

ServiceFieldRestRep (com.emc.vipr.model.catalog.ServiceFieldRestRep)3 ServiceFieldTableRestRep (com.emc.vipr.model.catalog.ServiceFieldTableRestRep)3 ServiceItemRestRep (com.emc.vipr.model.catalog.ServiceItemRestRep)3 ServiceFieldGroupRestRep (com.emc.vipr.model.catalog.ServiceFieldGroupRestRep)2 ServiceFieldModalRestRep (com.emc.vipr.model.catalog.ServiceFieldModalRestRep)2 TaskUtil (com.emc.vipr.client.core.impl.TaskUtil)1 CatalogServiceRestRep (com.emc.vipr.model.catalog.CatalogServiceRestRep)1 Parameter (com.emc.vipr.model.catalog.Parameter)1 HashMap (java.util.HashMap)1 Util (play.mvc.Util)1 BourneUtil (util.BourneUtil)1