@Util public static OrderCreateParam createOrder( CatalogServiceRestRep service, ServiceDescriptorRestRep descriptor, Map<String, String> parameters) { OrderCreateParam order = new OrderCreateParam(); order.setTenantId(uri(Models.currentAdminTenant())); order.setCatalogService(service.getId()); List<Parameter> orderParameters = Lists.newArrayList(); List<ServiceFieldRestRep> fields = ServiceDescriptorUtils.getAllFieldList(descriptor.getItems()); for (ServiceFieldRestRep field : fields) { String value = parameters.get(field.getName()); if (StringUtils.isNotBlank(value)) { orderParameters.add(createOrderParameter(field, value)); } } order.setParameters(orderParameters); return order; }
/** * 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)); } }