Author: jacopoc
Date: Thu Jun 7 07:36:47 2012
New Revision: 1347442
URL: http://svn.apache.org/viewvc?rev=1347442&view=rev
Log:
Set cache flag for findByAnd method calls in PreferenceServices; improved logic
to avoid to run the same query twice when user is not passed.
Modified:
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
Modified:
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java?rev=1347442&r1=1347441&r2=1347442&view=diff
==============================================================================
---
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
(original)
+++
ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceServices.java
Thu Jun 7 07:36:47 2012
@@ -80,7 +80,7 @@ public class PreferenceServices {
Map<String, Object> userPrefMap = null;
try {
- GenericValue preference =
EntityUtil.getFirst(delegator.findByAnd("UserPreference", fieldMap, null,
false));
+ GenericValue preference =
EntityUtil.getFirst(delegator.findByAnd("UserPreference", fieldMap, null,
true));
if (preference != null) {
userPrefMap = PreferenceWorker.createUserPrefMap(preference);
}
@@ -124,14 +124,16 @@ public class PreferenceServices {
if (UtilValidate.isEmpty(userPrefGroupTypeId)) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"getPreference.invalidArgument", locale));
}
- String userLoginId = PreferenceWorker.getUserLoginId(context, true);
+ String userLoginId = PreferenceWorker.getUserLoginId(context, false);
Map<String, Object> userPrefMap = null;
try {
Map<String, String> fieldMap = UtilMisc.toMap("userLoginId",
"_NA_", "userPrefGroupTypeId", userPrefGroupTypeId);
- userPrefMap =
PreferenceWorker.createUserPrefMap(delegator.findByAnd("UserPreference",
fieldMap, null, false));
- fieldMap.put("userLoginId", userLoginId);
-
userPrefMap.putAll(PreferenceWorker.createUserPrefMap(delegator.findByAnd("UserPreference",
fieldMap, null, false)));
+ userPrefMap =
PreferenceWorker.createUserPrefMap(delegator.findByAnd("UserPreference",
fieldMap, null, true));
+ if (userLoginId != null) {
+ fieldMap.put("userLoginId", userLoginId);
+
userPrefMap.putAll(PreferenceWorker.createUserPrefMap(delegator.findByAnd("UserPreference",
fieldMap, null, true)));
+ }
} catch (GenericEntityException e) {
Debug.logWarning(e.getMessage(), module);
return ServiceUtil.returnError(UtilProperties.getMessage(resource,
"getPreference.readFailure", new Object[] { e.getMessage() }, locale));