UPDATE: Some improvements with Map iterations (https://issues.apache.org/jira/browse/OFBIZ-4415) A patch from Dimitri Unruh which improves some Map Iterations.
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1170525 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -274,8 +274,9 @@ public class UtilHttp {
|
||||
public static Map<String, Object> getJSONAttributeMap(HttpServletRequest request) {
|
||||
Map<String, Object> returnMap = FastMap.newInstance();
|
||||
Map<String, Object> attrMap = getAttributeMap(request);
|
||||
for (String key: attrMap.keySet()) {
|
||||
Object val = attrMap.get(key);
|
||||
for (Map.Entry<String, Object> entry : attrMap.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object val = entry.getValue();
|
||||
if (val instanceof java.sql.Timestamp) {
|
||||
val = val.toString();
|
||||
}
|
||||
@@ -1116,7 +1117,8 @@ public class UtilHttp {
|
||||
}
|
||||
|
||||
// next put all parameters with matching N in the right map
|
||||
for (String key: parameters.keySet()) {
|
||||
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
// skip keys without DELIMITER and skip ROW_SUBMIT_PREFIX
|
||||
if (key == null) continue;
|
||||
int index = key.indexOf(MULTI_ROW_DELIMITER);
|
||||
@@ -1130,7 +1132,7 @@ public class UtilHttp {
|
||||
|
||||
// get the key without the <DELIMITER>N suffix and store it and its value
|
||||
String newKey = key.substring(0, index);
|
||||
map.put(newKey, parameters.get(key));
|
||||
map.put(newKey, entry.getValue());
|
||||
}
|
||||
// return only the values, which is the list of maps
|
||||
return rows.values();
|
||||
@@ -1142,12 +1144,13 @@ public class UtilHttp {
|
||||
*/
|
||||
public static <V> Map<String, V> removeMultiFormParameters(Map<String, V> parameters) {
|
||||
FastMap<String, V> filteredParameters = new FastMap<String, V>();
|
||||
for (String key: parameters.keySet()) {
|
||||
for (Map.Entry<String, V> entry : parameters.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (key != null && (key.indexOf(MULTI_ROW_DELIMITER) != -1 || key.indexOf("_useRowSubmit") != -1 || key.indexOf("_rowCount") != -1)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
filteredParameters.put(key, parameters.get(key));
|
||||
filteredParameters.put(key, entry.getValue());
|
||||
}
|
||||
return filteredParameters;
|
||||
}
|
||||
|
||||
@@ -393,8 +393,7 @@ public class DatabaseUtil {
|
||||
}
|
||||
|
||||
// -list all fields that do not have a corresponding column
|
||||
for (String colName: fieldColNames.keySet()) {
|
||||
ModelField field = fieldColNames.get(colName);
|
||||
for (ModelField field : fieldColNames.values()) {
|
||||
String message = "Field [" + field.getName() + "] of entity [" + entity.getEntityName() + "] is missing its corresponding column [" + field.getColName() + "]" + (field.getIsPk() ? " (and it is a PRIMARY KEY FIELD)" : "");
|
||||
|
||||
Debug.logWarning(message, module);
|
||||
|
||||
@@ -444,8 +444,9 @@ public class CoreEvents {
|
||||
Map<String, String[]> serviceFieldsToSave = checkMap(request.getParameterMap(), String.class, String[].class);
|
||||
Map<String, Object> savedFields = FastMap.newInstance();
|
||||
|
||||
for (String key: serviceFieldsToSave.keySet()) {
|
||||
if (null!=serviceFieldsToSave.get(key) && request.getParameter(key).equalsIgnoreCase("on") && !key.equals("_CLEAR_PREVIOUS_PARAMS_")) {
|
||||
for (Map.Entry<String, String[]> entry : serviceFieldsToSave.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (entry.getValue() != null && "on".equalsIgnoreCase(request.getParameter(key)) && !"_CLEAR_PREVIOUS_PARAMS_".equals(key)) {
|
||||
String[] servicePath = key.split("\\|\\|");
|
||||
String partialKey = servicePath[servicePath.length-1];
|
||||
savedFields.put(partialKey, getObjectFromServicePath(key ,syncServiceResult));
|
||||
|
||||
@@ -148,12 +148,13 @@ public class WidgetContextCacheKey {
|
||||
|
||||
public static String printMap(Map<String, ? extends Object> map) {
|
||||
Map<String, Object> printableMap = FastMap.newInstance();
|
||||
for (String fieldName: map.keySet()) {
|
||||
for (Map.Entry<String, ? extends Object> entry : map.entrySet()) {
|
||||
String fieldName = entry.getKey();
|
||||
if (!fieldNamesToSkip.contains(fieldName) &&
|
||||
!fieldName.startsWith("javax.servlet") &&
|
||||
!fieldName.startsWith("org.apache") &&
|
||||
!fieldName.startsWith("_CLIENT_")) {
|
||||
printableMap.put(fieldName, map.get(fieldName));
|
||||
printableMap.put(fieldName, entry.getValue());
|
||||
}
|
||||
}
|
||||
return UtilMisc.printMap(printableMap);
|
||||
|
||||
@@ -2944,16 +2944,18 @@ public class MacroFormRenderer implements FormStringRenderer {
|
||||
if(UtilValidate.isEmpty(ajaxParams)){
|
||||
ajaxParams = "";
|
||||
}
|
||||
for (String key : parameters.keySet()) {
|
||||
for (Map.Entry<String, String> entry : parameters.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
//test if ajax parameters are not already into extraParams, if so do not add it
|
||||
if(UtilValidate.isNotEmpty(extraParams) && extraParams.contains(parameters.get(key))){
|
||||
if(UtilValidate.isNotEmpty(extraParams) && extraParams.contains(value)){
|
||||
continue;
|
||||
}
|
||||
if (ajaxParams.length() > 0 && ajaxParams.indexOf(key) < 0) {
|
||||
ajaxParams += "&";
|
||||
}
|
||||
if (ajaxParams.indexOf(key) < 0) {
|
||||
ajaxParams += key + "=" + parameters.get(key);
|
||||
ajaxParams += key + "=" + value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user