use of com.emc.vipr.model.catalog.ServiceFieldModalRestRep 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;
}
use of com.emc.vipr.model.catalog.ServiceFieldModalRestRep in project coprhd-controller by CoprHD.
the class ServiceDescriptorMapper method map.
public static ServiceFieldModalRestRep map(ServiceFieldModal from) {
if (from == null) {
return null;
}
ServiceFieldModalRestRep to = new ServiceFieldModalRestRep();
mapServiceItemCommon(to, from);
to.getItems().addAll(map(from.getItems().values()));
return to;
}
use of com.emc.vipr.model.catalog.ServiceFieldModalRestRep 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;
}
Aggregations