int intEndParam = intEnd.intValue();
int beginIndex = 0;
Float f = new Float(5);
ItemList list = new ItemList();
list.setSortMember(strSortMem);
CVDal cvdl = new CVDal(dataSource);
Collection colList;
String sortType= "";
if (charSort == 'D')
{
sortType = "DESC";
}
String appendSearchCondition ="";
if ((strSearch != null) && strSearch.startsWith("ADVANCE:"))
{
int searchIndex = (strSearch.toUpperCase()).indexOf("WHERE");
appendSearchCondition = " and "+strSearch.substring((searchIndex+5),strSearch.length());
}
String itemQuery = " select item.itemid,item.sku,item.title as Name ,itemtype.title as type ,item.listprice as Price ,count(inventory.qty) as OnHand ,taxclass.taxclassid as taxclassid ,taxclass.title as taxclass,item.cost ,"+
" ven.entityid as vendorid,ven.name as vendor,man.entityid as manid, man.name as manufacturer from item left outer join itemtype on item.type = itemtype.itemtypeid "+
" left outer join inventory on item.itemid = inventory.item left outer join taxclass on item.taxclass = taxclass.taxclassid "+
" left outer join entity man on item.manufacturerid = man.entityid left outer join entity ven on item.vendorid = ven.entityid "+
" where item.deletestatus != 'Deleted' "+appendSearchCondition+" Group by item.itemid,item.sku,item.title,itemtype.title,item.listprice, taxclass.title,item.cost order by '"+ strSortMem +"' "+sortType;
cvdl.setSqlQuery(itemQuery);
colList = cvdl.executeQuery();
cvdl.clearParameters();
cvdl.destroy();
if (colList != null)
{
Iterator it = colList.iterator();
int i = 0;
while (it.hasNext())
{
i++;
HashMap hm = (HashMap) it.next();
int id = ((Long) hm.get("itemid")).intValue();
try
{
IntMember intListID =
new IntMember("ItemID", id, 10, "", 'T', false, 10);
StringMember strSku = null;
if ((hm.get("sku") != null))
{
strSku =
new StringMember("SKU", (String) hm.get("sku"), 10, "", 'T', true);
}
else
{
strSku = new StringMember("SKU", null, 10, "", 'T', true);
}
StringMember strName =
new StringMember("Name", (String) hm.get("Name"), 10, "", 'T', false);
// StringMember strCatagory = new StringMember("Category", (String)hm.get("categoryname"), 10, "", 'T', false);new Float(((Double) hm.get( "cost" )).floatValue())
StringMember strType =
new StringMember("Type", (String) hm.get("type"), 10, "", 'T', false);
FloatMember price = null;
if (hm.get("Price") != null)
{
price =
new FloatMember("Price",
new Float(Float.parseFloat((hm.get("Price")).toString())), 10,
"", 'T', false, 10);
}
else
{
price =
new FloatMember("Price", new Float(0), 10, "", 'T', false, 10);
}
DoubleMember intQty = null;
if (hm.get("OnHand") != null)
{
intQty =
new DoubleMember("OnHand",
new Double(Double.parseDouble((hm.get("OnHand")).toString())),
10, "", 'T', false, 10);
}
else
{
intQty =
new DoubleMember("OnHand", new Double(0), 10, "", 'T', false, 10);
}
StringMember strtaxClass =
new StringMember("TaxClass", (String) hm.get("taxclass"), 10, "",
'T', false);
int taxClassId = ((Number) hm.get("taxclassid")).intValue();
IntMember intTaxClassID = new IntMember("TaxClassID", taxClassId, 10, "", 'T', false, 10);
FloatMember cost =
new FloatMember("Cost",
new Float(Float.parseFloat((hm.get("cost")).toString())), 10, "",
'T', false, 10);
//Added by Shilpa for getting Manufacture and Vendor for item
int manid = 0;
int venid = 0;
if (hm.get("manid") != null)
{
manid = ((Long) hm.get("manid")).intValue();
}
IntMember manufacturerID =
new IntMember("ManufacturerID", manid, 10, "", 'T', false, 10);
if (hm.get("vendorid") != null)
{
venid = ((Long) hm.get("vendorid")).intValue();
}
IntMember vendorID =
new IntMember("VendorID", venid, 10, "", 'T', false, 10);
StringMember strVendor = null;
StringMember strManufacturer = null;
if (hm.get("vendor") != null)
{
strVendor =
new StringMember("Vendor", (String) hm.get("vendor"), 10, "",
'T', false);
}
if (hm.get("manufacturer") != null)
{
strManufacturer =
new StringMember("Manufacturer", (String) hm.get("manufacturer"),
10, "", 'T', false);
}
//Added by shilpa ends here
ItemListElement listElement = new ItemListElement(id);
listElement.put("ItemID", intListID);
listElement.put("SKU", strSku);
listElement.put("Name", strName);
// listElement .put("Category", strCatagory);
listElement.put("Type", strType);
listElement.put("Price", price);
listElement.put("OnHand", intQty);
listElement.put("TaxClass", strtaxClass);
listElement.put("TaxClassID", intTaxClassID);
listElement.put("Cost", cost);
//Added By Shilpa
listElement.put("VendorID", vendorID);
listElement.put("Vendor", strVendor);
listElement.put("Manufacturer", strManufacturer);
listElement.put("ManufacturerID", manufacturerID);
//Added By Shilpa ends here
StringBuffer stringbuffer = new StringBuffer("00000000000");
stringbuffer.setLength(11);
String s3 = (new Integer(i)).toString();
stringbuffer.replace(stringbuffer.length() - s3.length(),
stringbuffer.length(), s3);
String s4 = stringbuffer.toString();
list.put(s4, listElement);
}
catch (Exception e)
{
System.out.println(" Exception in AccountListEJB.getItemList " + e);
//e.printStackTrace();
}
}
}
list.setTotalNoOfRecords(list.size());
list.setListType("Item");
list.setBeginIndex(beginIndex);
list.setEndIndex(list.size());
return list;
}