You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2008/06/29 22:33:20 UTC
svn commit: r672672 [2/2] - in
/ofbiz/trunk/framework/common/src/org/ofbiz/common: ./ geo/ login/ period/
preferences/ status/
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=672672&r1=672671&r2=672672&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 Sun Jun 29 13:33:19 2008
@@ -26,6 +26,7 @@
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.GeneralException;
import org.ofbiz.base.util.ObjectType;
+import static org.ofbiz.base.util.UtilGenerics.checkMap;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.base.util.UtilProperties;
import org.ofbiz.base.util.UtilValidate;
@@ -59,7 +60,7 @@
* @param context Map containing the input arguments.
* @return Map with the result of the service, the output parameters.
*/
- public static Map getUserPreference(DispatchContext ctx, Map context) {
+ public static Map<String, Object> getUserPreference(DispatchContext ctx, Map<String, ?> context) {
GenericDelegator delegator = ctx.getDelegator();
Locale locale = (Locale) context.get("locale");
@@ -68,13 +69,13 @@
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "getPreference.invalidArgument", locale));
}
String userLoginId = PreferenceWorker.getUserLoginId(context, true);
- Map fieldMap = UtilMisc.toMap("userLoginId", userLoginId, "userPrefTypeId", userPrefTypeId);
+ Map<String, String> fieldMap = UtilMisc.toMap("userLoginId", userLoginId, "userPrefTypeId", userPrefTypeId);
String userPrefGroupId = (String) context.get("userPrefGroupId");
if (UtilValidate.isNotEmpty(userPrefGroupId)) {
fieldMap.put("userPrefGroupId", userPrefGroupId);
}
- Map userPrefMap = null;
+ Map<String, Object> userPrefMap = null;
try {
GenericValue preference = EntityUtil.getFirst(delegator.findByAnd("UserPreference", fieldMap));
if (preference != null) {
@@ -109,7 +110,7 @@
* @param context Map containing the input arguments.
* @return Map with the result of the service, the output parameters.
*/
- public static Map getUserPreferenceGroup(DispatchContext ctx, Map context) {
+ public static Map<String, Object> getUserPreferenceGroup(DispatchContext ctx, Map<String, ?> context) {
GenericDelegator delegator = ctx.getDelegator();
Locale locale = (Locale) context.get("locale");
@@ -119,9 +120,9 @@
}
String userLoginId = PreferenceWorker.getUserLoginId(context, true);
- Map userPrefMap = null;
+ Map<String, Object> userPrefMap = null;
try {
- Map fieldMap = UtilMisc.toMap("userLoginId", userLoginId, "userPrefGroupId", userPrefGroupId);
+ Map<String, String> fieldMap = UtilMisc.toMap("userLoginId", userLoginId, "userPrefGroupId", userPrefGroupId);
userPrefMap = PreferenceWorker.createUserPrefMap(delegator.findByAnd("UserPreference", fieldMap));
} catch (GenericEntityException e) {
Debug.logWarning(e.getMessage(), module);
@@ -145,7 +146,7 @@
* @param context Map containing the input arguments.
* @return Map with the result of the service, the output parameters.
*/
- public static Map setUserPreference(DispatchContext ctx, Map context) {
+ public static Map<String, Object> setUserPreference(DispatchContext ctx, Map<String, ?> context) {
GenericDelegator delegator = ctx.getDelegator();
Locale locale = (Locale) context.get("locale");
@@ -184,12 +185,12 @@
* @param context Map containing the input arguments.
* @return Map with the result of the service, the output parameters.
*/
- public static Map setUserPreferenceGroup(DispatchContext ctx, Map context) {
+ public static Map<String, Object> setUserPreferenceGroup(DispatchContext ctx, Map<String, ?> context) {
GenericDelegator delegator = ctx.getDelegator();
Locale locale = (Locale) context.get("locale");
String userLoginId = PreferenceWorker.getUserLoginId(context, false);
- Map userPrefMap = (Map) context.get("userPrefMap");
+ Map<String, Object> userPrefMap = checkMap(context.get("userPrefMap"), String.class, Object.class);
String userPrefGroupId = (String) context.get("userPrefGroupId");
if (UtilValidate.isEmpty(userLoginId) || UtilValidate.isEmpty(userPrefGroupId) || userPrefMap == null) {
return ServiceUtil.returnError(UtilProperties.getMessage(resource, "setPreference.invalidArgument", locale));
@@ -221,7 +222,7 @@
* @param context Map containing the input arguments.
* @return Map with the result of the service, the output parameters.
*/
- public static Map copyUserPreferenceGroup(DispatchContext ctx, Map context) {
+ public static Map<String, Object> copyUserPreferenceGroup(DispatchContext ctx, Map<String, ?> context) {
GenericDelegator delegator = ctx.getDelegator();
Locale locale = (Locale) context.get("locale");
@@ -233,11 +234,10 @@
}
try {
- Map fieldMap = UtilMisc.toMap("userLoginId", fromUserLoginId, "userPrefGroupId", userPrefGroupId);
+ Map<String, String> fieldMap = UtilMisc.toMap("userLoginId", fromUserLoginId, "userPrefGroupId", userPrefGroupId);
List<GenericValue> resultList = delegator.findByAnd("UserPreference", fieldMap);
if (resultList != null) {
- for (Iterator i = resultList.iterator(); i.hasNext();) {
- GenericValue preference = (GenericValue) i.next();
+ for (GenericValue preference: resultList) {
preference.set("userLoginId", userLoginId);
}
delegator.storeAll(resultList);
Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java?rev=672672&r1=672671&r2=672672&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java (original)
+++ ofbiz/trunk/framework/common/src/org/ofbiz/common/preferences/PreferenceWorker.java Sun Jun 29 13:33:19 2008
@@ -56,7 +56,7 @@
* @throws GeneralException
* @return user preference map
*/
- public static Map<Object, Object> addPrefToMap(GenericValue rec, Map<Object, Object> userPrefMap) throws GeneralException {
+ public static Map<String, Object> addPrefToMap(GenericValue rec, Map<String, Object> userPrefMap) throws GeneralException {
String prefDataType = rec.getString("userPrefDataType");
if (UtilValidate.isEmpty(prefDataType)) {
// default to String
@@ -77,7 +77,7 @@
* @param context Map containing the input arguments.
* @return Map with the result of the service, the output parameters.
*/
- public static Map checkCopyPermission(DispatchContext ctx, Map context) {
+ public static Map<String, Object> checkCopyPermission(DispatchContext ctx, Map<String, ?> context) {
boolean hasPermission = false;
GenericValue userLogin = (GenericValue) context.get("userLogin");
if (userLogin != null) {
@@ -92,7 +92,7 @@
}
}
Map<String, Object> result = ServiceUtil.returnSuccess();
- result.put("hasPermission", new Boolean(hasPermission));
+ result.put("hasPermission", hasPermission);
return result;
}
@@ -104,7 +104,7 @@
* @param context Map containing the input arguments.
* @return Map with the result of the service, the output parameters.
*/
- public static Map checkPermission(DispatchContext ctx, Map context) {
+ public static Map<String, Object> checkPermission(DispatchContext ctx, Map<String, ?> context) {
boolean hasPermission = false;
String mainAction = (String) context.get("mainAction");
if ("VIEW".equals(mainAction)) {
@@ -119,7 +119,7 @@
hasPermission = false;
}
Map<String, Object> result = ServiceUtil.returnSuccess();
- result.put("hasPermission", new Boolean(hasPermission));
+ result.put("hasPermission", hasPermission);
return result;
}
@@ -129,8 +129,8 @@
* @throws GeneralException
* @return user preference map
*/
- public static Map createUserPrefMap(GenericValue rec) throws GeneralException {
- return addPrefToMap(rec, FastMap.newInstance());
+ public static Map<String, Object> createUserPrefMap(GenericValue rec) throws GeneralException {
+ return addPrefToMap(rec, FastMap.<String, Object>newInstance());
}
/**
@@ -139,11 +139,11 @@
* @throws GeneralException
* @return user preference map
*/
- public static Map<Object, Object> createUserPrefMap(List recList) throws GeneralException {
- Map<Object, Object> userPrefMap = FastMap.newInstance();
+ public static Map<String, Object> createUserPrefMap(List<GenericValue> recList) throws GeneralException {
+ Map<String, Object> userPrefMap = FastMap.newInstance();
if (recList != null) {
- for (Iterator i = recList.iterator(); i.hasNext();) {
- addPrefToMap((GenericValue) i.next(), userPrefMap);
+ for (GenericValue value: recList) {
+ addPrefToMap(value, userPrefMap);
}
}
return userPrefMap;
@@ -160,7 +160,7 @@
* @param returnDefault return <a href="#DEFAULT_UID">DEFAULT_UID</a> if no userLoginId is found.
* @return userLoginId String
*/
- public static String getUserLoginId(Map context, boolean returnDefault) {
+ public static String getUserLoginId(Map<String, ?> context, boolean returnDefault) {
String userLoginId = (String) context.get("userLoginId");
if (UtilValidate.isEmpty(userLoginId)) {
GenericValue userLogin = (GenericValue) context.get("userLogin");
@@ -192,7 +192,7 @@
* @param context Map containing the input arguments.
* @return true if the userLoginId arguments are valid
*/
- public static boolean isValidGetId(DispatchContext ctx, Map context) {
+ public static boolean isValidGetId(DispatchContext ctx, Map<String, ?> context) {
String currentUserLoginId = null;
GenericValue userLogin = (GenericValue) context.get("userLogin");
if (userLogin == null) {
@@ -226,7 +226,7 @@
* @param context Map containing the input arguments.
* @return true if arguments are valid
*/
- public static boolean isValidSetId(DispatchContext ctx, Map context) {
+ public static boolean isValidSetId(DispatchContext ctx, Map<String, ?> context) {
GenericValue userLogin = (GenericValue) context.get("userLogin");
if (userLogin == null) {
return false;
Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java?rev=672672&r1=672671&r2=672672&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java (original)
+++ ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusServices.java Sun Jun 29 13:33:19 2008
@@ -18,17 +18,18 @@
*******************************************************************************/
package org.ofbiz.common.status;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import javolution.util.FastList;
+import javolution.util.FastMap;
+
import org.ofbiz.base.util.Debug;
+import static org.ofbiz.base.util.UtilGenerics.checkList;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
import org.ofbiz.service.DispatchContext;
import org.ofbiz.service.ServiceUtil;
@@ -39,39 +40,37 @@
public static final String module = StatusServices.class.getName();
- public static Map getStatusItems(DispatchContext ctx, Map context) {
+ public static Map<String, Object> getStatusItems(DispatchContext ctx, Map<String, ?> context) {
GenericDelegator delegator = ctx.getDelegator();
- List statusTypes = (List) context.get("statusTypeIds");
+ List<String> statusTypes = checkList(context.get("statusTypeIds"), String.class);
if (statusTypes == null || statusTypes.size() == 0) {
return ServiceUtil.returnError("Parameter statusTypeIds can not be null and must contain at least one element");
}
- Iterator i = statusTypes.iterator();
- List statusItems = new LinkedList();
- while (i.hasNext()) {
- String statusTypeId = (String) i.next();
+ List<GenericValue> statusItems = FastList.newInstance();
+ for (String statusTypeId: statusTypes) {
try {
- Collection myStatusItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeId), UtilMisc.toList("sequenceId"));
+ List<GenericValue> myStatusItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeId), UtilMisc.toList("sequenceId"));
statusItems.addAll(myStatusItems);
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
}
- Map ret = new HashMap();
+ Map<String, Object> ret = FastMap.newInstance();
ret.put("statusItems",statusItems);
return ret;
}
- public static Map getStatusValidChangeToDetails(DispatchContext ctx, Map context) {
+ public static Map<String, Object> getStatusValidChangeToDetails(DispatchContext ctx, Map<String, ?> context) {
GenericDelegator delegator = ctx.getDelegator();
- List statusValidChangeToDetails = null;
+ List<GenericValue> statusValidChangeToDetails = null;
String statusId = (String) context.get("statusId");
try {
statusValidChangeToDetails = delegator.findByAndCache("StatusValidChangeToDetail", UtilMisc.toMap("statusId", statusId), UtilMisc.toList("sequenceId"));
} catch (GenericEntityException e) {
Debug.logError(e, module);
}
- Map ret = ServiceUtil.returnSuccess();
+ Map<String, Object> ret = ServiceUtil.returnSuccess();
if (statusValidChangeToDetails != null) {
ret.put("statusValidChangeToDetails", statusValidChangeToDetails);
}
Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusWorker.java?rev=672672&r1=672671&r2=672672&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusWorker.java (original)
+++ ofbiz/trunk/framework/common/src/org/ofbiz/common/status/StatusWorker.java Sun Jun 29 13:33:19 2008
@@ -18,16 +18,17 @@
*******************************************************************************/
package org.ofbiz.common.status;
-import java.util.Collection;
-import java.util.LinkedList;
import java.util.List;
import javax.servlet.jsp.PageContext;
+import javolution.util.FastList;
+
import org.ofbiz.base.util.Debug;
import org.ofbiz.base.util.UtilMisc;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
/**
* StatusWorker
@@ -40,7 +41,7 @@
GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");
try {
- Collection statusItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeId), UtilMisc.toList("sequenceId"));
+ List<GenericValue> statusItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeId), UtilMisc.toList("sequenceId"));
if (statusItems != null)
pageContext.setAttribute(attributeName, statusItems);
@@ -51,10 +52,10 @@
public static void getStatusItems(PageContext pageContext, String attributeName, String statusTypeIdOne, String statusTypeIdTwo) {
GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");
- List statusItems = new LinkedList();
+ List<GenericValue> statusItems = FastList.newInstance();
try {
- Collection calItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeIdOne), UtilMisc.toList("sequenceId"));
+ List<GenericValue> calItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeIdOne), UtilMisc.toList("sequenceId"));
if (calItems != null)
statusItems.addAll(calItems);
@@ -62,7 +63,7 @@
Debug.logError(e, module);
}
try {
- Collection taskItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeIdTwo), UtilMisc.toList("sequenceId"));
+ List<GenericValue> taskItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeIdTwo), UtilMisc.toList("sequenceId"));
if (taskItems != null)
statusItems.addAll(taskItems);
@@ -76,7 +77,7 @@
public static void getStatusValidChangeToDetails(PageContext pageContext, String attributeName, String statusId) {
GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");
- Collection statusValidChangeToDetails = null;
+ List<GenericValue> statusValidChangeToDetails = null;
try {
statusValidChangeToDetails = delegator.findByAndCache("StatusValidChangeToDetail", UtilMisc.toMap("statusId", statusId), UtilMisc.toList("sequenceId"));