use of com.emc.vipr.model.catalog.ServiceFieldRestRep in project coprhd-controller by CoprHD.
the class OrderExecution method addColumnValues.
/**
* Adds all column values for the given table.
*
* @param service
* the catalog service.
* @param table
* the table of fields.
* @param values
* the map holding the values.
* @param locked
* all locked values for the service.
*/
private static void addColumnValues(CatalogServiceRestRep service, ServiceFieldTableRestRep table, Map<String, String> values, Map<String, String> locked) {
List<ServiceFieldRestRep> fields = ServiceDescriptorUtils.getAllFieldList(table.getItems());
int rowCount = 0;
for (ServiceFieldRestRep field : fields) {
if (!locked.containsKey(field.getName())) {
String[] columns = getColumnValue(table, field);
rowCount = Math.max(rowCount, columns.length);
}
}
for (ServiceFieldRestRep field : fields) {
String[] columns = new String[rowCount];
if (locked.containsKey(field.getName())) {
String lockedValue = locked.get(field.getName());
for (int i = 0; i < columns.length; i++) {
columns[i] = lockedValue;
}
} else {
String[] col = getColumnValue(table, field);
System.arraycopy(col, 0, columns, 0, col.length);
}
for (int i = 0; i < columns.length; i++) {
String prefix = table.getName() + "[" + i + "]";
ServiceFieldValidator.validateField(service, prefix, field, columns[i]);
}
values.put(field.getName(), TextUtils.formatCSV(columns));
}
}
use of com.emc.vipr.model.catalog.ServiceFieldRestRep 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);
}
}
}
use of com.emc.vipr.model.catalog.ServiceFieldRestRep in project coprhd-controller by CoprHD.
the class Services method getDefaultValues.
/**
* Gets the default field values for the given service.
*
* @param descriptor
* the service descriptor.
* @return the default field values.
*/
private static Map<String, String> getDefaultValues(ServiceDescriptorRestRep descriptor) {
Map<String, String> defaultValues = Maps.newHashMap();
List<ServiceFieldRestRep> allFields = ServiceDescriptorUtils.getAllFieldList(descriptor.getItems());
for (ServiceFieldRestRep field : allFields) {
if (flash.contains(field.getName())) {
defaultValues.put(field.getName(), flash.get(field.getName()));
} else {
defaultValues.put(field.getName(), field.getInitialValue());
}
}
return defaultValues;
}
Aggregations