Search in sources :

Example 11 with ServiceFieldRestRep

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));
    }
}
Also used : CatalogServiceFieldRestRep(com.emc.vipr.model.catalog.CatalogServiceFieldRestRep) ServiceFieldRestRep(com.emc.vipr.model.catalog.ServiceFieldRestRep)

Example 12 with ServiceFieldRestRep

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);
        }
    }
}
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)

Example 13 with ServiceFieldRestRep

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;
}
Also used : CatalogServiceFieldRestRep(com.emc.vipr.model.catalog.CatalogServiceFieldRestRep) 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