Author: sascharodekamp
Date: Wed Sep 14 10:52:01 2011 New Revision: 1170525 URL: http://svn.apache.org/viewvc?rev=1170525&view=rev Log: UPDATE: Some improvements with Map iterations (https://issues.apache.org/jira/browse/OFBIZ-4415) A patch from Dimitri Unruh which improves some Map Iterations. Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java?rev=1170525&r1=1170524&r2=1170525&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java (original) +++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilHttp.java Wed Sep 14 10:52:01 2011 @@ -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; } Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java?rev=1170525&r1=1170524&r2=1170525&view=diff ============================================================================== --- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java (original) +++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/jdbc/DatabaseUtil.java Wed Sep 14 10:52:01 2011 @@ -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); Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java?rev=1170525&r1=1170524&r2=1170525&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java Wed Sep 14 10:52:01 2011 @@ -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)); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java?rev=1170525&r1=1170524&r2=1170525&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java Wed Sep 14 10:52:01 2011 @@ -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); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=1170525&r1=1170524&r2=1170525&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Wed Sep 14 10:52:01 2011 @@ -2944,16 +2944,18 @@ public class MacroFormRenderer implement 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; } } } |
Free forum by Nabble | Edit this page |