You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2008/12/02 23:25:44 UTC
svn commit: r722640 -
/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
Author: jleroux
Date: Tue Dec 2 14:25:44 2008
New Revision: 722640
URL: http://svn.apache.org/viewvc?rev=722640&view=rev
Log:
Genericization
Modified:
ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
Modified: ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java?rev=722640&r1=722639&r2=722640&view=diff
==============================================================================
--- ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java (original)
+++ ofbiz/trunk/applications/order/src/org/ofbiz/order/order/OrderServices.java Tue Dec 2 14:25:44 2008
@@ -3125,6 +3125,7 @@
}
return ServiceUtil.returnSuccess();
}
+
/** Service to invoice service items from order*/
public static Map invoiceServiceItems(DispatchContext dctx, Map context){
GenericDelegator delegator = dctx.getDelegator();
@@ -3143,7 +3144,7 @@
}
// get all the items for the order
- List orderItems = null;
+ List<GenericValue> orderItems = null;
if (orderHeader != null) {
try {
orderItems = orderHeader.getRelated("OrderItem");
@@ -3154,12 +3155,10 @@
}
// find any service items
- List serviceItems = new ArrayList();
- Map serviceProducts = new HashMap();
- if (orderItems != null && orderItems.size() > 0) {
- Iterator i = orderItems.iterator();
- while (i.hasNext()) {
- GenericValue item = (GenericValue) i.next();
+ List<GenericValue> serviceItems = FastList.newInstance();
+ Map<GenericValue, GenericValue> serviceProducts = FastMap.newInstance();
+ if (UtilValidate.isNotEmpty(orderItems)) {
+ for(GenericValue item : orderItems) {
GenericValue product = null;
try {
product = item.getRelatedOne("Product");
@@ -3182,7 +3181,7 @@
// we only invoice APPROVED items
if ("ITEM_APPROVED".equals(item.getString("statusId"))) {
serviceItems.add(item);
- serviceProducts.put(item,product);
+ serviceProducts.put(item, product);
}
}
}
@@ -3191,18 +3190,16 @@
}
// now process the service items
- if (serviceItems.size() > 0) {
-
-
+ if (UtilValidate.isNotEmpty(serviceItems)) {
// single list with all invoice items
- List itemsToInvoice = FastList.newInstance();
+ List<GenericValue> itemsToInvoice = FastList.newInstance();
itemsToInvoice.addAll(serviceItems);
// do something tricky here: run as a different user that can actually create an invoice, post transaction, etc
- Map invoiceResult = null;
+ Map<String, Object> invoiceResult = null;
try {
GenericValue permUserLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", "system"));
- Map invoiceContext = UtilMisc.toMap("orderId", orderId, "billItems", itemsToInvoice, "userLogin", permUserLogin);
+ Map<String, Object> invoiceContext = UtilMisc.toMap("orderId", orderId, "billItems", itemsToInvoice, "userLogin", permUserLogin);
invoiceResult = dispatcher.runSync("createInvoiceForOrder", invoiceContext);
} catch (GenericEntityException e) {
Debug.logError(e, "ERROR: Unable to invoice service items", module);
@@ -3216,10 +3213,8 @@
}
// update the status of service goods to COMPLETED;
- Iterator dii = itemsToInvoice.iterator();
- while (dii.hasNext()) {
+ for(GenericValue item : itemsToInvoice) {
GenericValue productType = null;
- GenericValue item = (GenericValue) dii.next();
GenericValue product = (GenericValue) serviceProducts.get(item);
boolean markComplete = false;
if(product != null){
@@ -3237,7 +3232,7 @@
}
if (markComplete) {
- Map statusCtx = new HashMap();
+ Map<String, Object> statusCtx = FastMap.newInstance();
statusCtx.put("orderId", item.getString("orderId"));
statusCtx.put("orderItemSeqId", item.getString("orderItemSeqId"));
statusCtx.put("statusId", "ITEM_COMPLETED");