Hi all,
  I am working on the facility-->physicalInventory tab... the present
feature is if we give the product id corresponding inventory details will be
displayed ... but what i want to do is... i want to display the inventory
details of all the product by pressing a button .... this is the bsh script
which i modified and at log it is giving the class cast exception... the
code is as follows... Can any one tell me where i am going wrong...


import java.util.HashSet;
import javolution.util.FastList;
import javolution.util.FastMap;

import org.ofbiz.base.util.*;
import org.ofbiz.service.ServiceUtil;
import org.ofbiz.entity.condition.*;

facilityId = parameters.get("facilityId");

// fields to search by
//productId = parameters.get("productId");
//internalName = parameters.get("internalName");


product=delegator.findAll("Product");
//print("\n====================================");
//print(product);
//print("======================================");

List InventoryList=new ArrayList();
Iterator i = product.iterator();
while (i.hasNext()) {
       GenericValue v = (GenericValue) i.next();
       productId=v.getString("productId");
       internalName=v.getString("internalName");
       print("\n====================================");
       print(productId);
       print("======================================");
   
// build conditions
conditions = UtilMisc.toList(
        new EntityExpr("facilityId", EntityOperator.EQUALS, facilityId),
        new EntityExpr("inventoryItemTypeId", EntityOperator.EQUALS,
"NON_SERIAL_INV_ITEM")
        );
if (productId != null && productId.trim().length() != 0) {
    conditions.add( new EntityExpr("productId", EntityOperator.LIKE,
productId.trim() + "%") );
}
if (internalName != null && internalName.trim().length() != 0) {
    conditions.add( new EntityExpr("internalName", true,
EntityOperator.LIKE, internalName.trim() + "%", true) );
}

if (conditions.size() > 2) {
    physicalInventory = delegator.findByAnd("ProductInventoryItem",
conditions, UtilMisc.toList("productId"));

    // also need the overal product QOH and ATP for each product
    atpMap = FastMap.newInstance();
    qohMap = FastMap.newInstance();
    
    // build a list of productIds
    productIds = new HashSet();
    for (iter = physicalInventory.iterator(); iter.hasNext(); ) {
        productIds.add(iter.next().get("productId"));
    }

    // for each product, call the inventory counting service
    for (iter = productIds.iterator(); iter.hasNext(); ) {
        productId = iter.next();
        result = dispatcher.runSync("getInventoryAvailableByFacility",
UtilMisc.toMap("facilityId", facilityId, "productId", productId));
        //print("result"+result);
        if (!ServiceUtil.isError(result)) {
            atpMap.put(productId, result.get("availableToPromiseTotal"));
            qohMap.put(productId, result.get("quantityOnHandTotal"));
            }
        
    }

    // associate the quantities to each row and store the combined data as
our list
    physicalInventoryCombined = FastList.newInstance();
    for (iter = physicalInventory.iterator(); iter.hasNext(); ) {
        row = iter.next().getAllFields();
               
        row.put("productATP", atpMap.get(row.get("productId")));
        row.put("productQOH", qohMap.get(row.get("productId")));
        physicalInventoryCombined.add(row);
       
    }
 
} 
    // print("physicalInventoryCombined"+physicalInventoryCombined);
     InventoryList.add(physicalInventoryCombined);
 }
  context.put("InventoryList",InventoryList);  
  //print("\nInventoryList"+InventoryList);


the error which i am getting in the log is ..

 Error in request handler:
Exception: org.ofbiz.widget.screen.ScreenRenderException
Message: Error rendering screen
[component://common/widget/CommonScreens.xml#GlobalDecorator]:
java.lang.ClassCastException: javolution.util.FastList cannot be cast to
java.util.Map (javolution.util.FastList cannot be cast to java.util.Map)
-- 
View this message in context: 
http://www.nabble.com/java.lang.ClassCastException%3A-javolution.util.FastList-cannot-be-cast-to-java.util.Map-tp22251447p22251447.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Reply via email to