/**
 * <p>Title: ShoppingCartHDAO Class>
 * <p>Description:	ShoppingCartBizLogic provides the shopping cart functionality.</p>
 * Copyright:    Copyright (c) year
 * Company: Washington University, School of Medicine, St. Louis.
 * @author Aniruddha Phadnis
 * @version 1.00
 * Created on Jul 21, 2005
 */

package edu.wustl.catissuecore.bizlogic;

import java.io.File;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;

import edu.wustl.catissuecore.domain.Specimen;
import edu.wustl.catissuecore.query.ShoppingCart;
import edu.wustl.catissuecore.util.global.Variables;
import edu.wustl.common.util.dbManager.DAOException;
import edu.wustl.common.util.logger.Logger;

/**
 * ShoppingCartBizLogic provides the shopping cart functionality.
 * @author aniruddha_phadnis
 */
public class ShoppingCartBizLogic extends DefaultBizLogic
{
	public void add(ShoppingCart cart,Object obj[]) throws DAOException
    {
		if(cart!=null && obj!=null)
		{
			for(int i=0;i<obj.length;i++)
			{
				List list = retrieve(Specimen.class.getName(),"systemIdentifier",obj[i].toString());
				
				if (list!=null && list.size()!= 0)
				{
					Specimen specimen = (Specimen)list.get(0);
					cart.add(specimen);
				}
			}
		}
    }
    
	public ShoppingCart delete(ShoppingCart cart,Object obj[])
    {
		if(cart!=null && obj!=null)
		{
			for(int i=0;i<obj.length;i++)
			{
	        	String str = obj[i].toString();
	        	int index = str.indexOf("_") + 1;
	        	
	        	cart.remove(str.substring(index));
			}
		}
		
		return cart;
    }
    
	public void deleteCartFile(String fileName)
    {
		try
		{
			fileName = fileName + ".txt";
			File f = new File(Variables.catissueHome,fileName);
			f.delete();
		}
		catch(Exception e)
		{
			 Logger.out.error(e.getMessage(), e);
		}
	}
	
	public List export(ShoppingCart cart,String fileName)
    {
		List shoppingCartList = null;
		
		if(cart != null)
		{
			Hashtable table = cart.getCart();
			
			if(table != null && table.size() != 0)
			{
				Enumeration enum = table.keys();
				
				shoppingCartList = new ArrayList();
				
				List rowList = new ArrayList();
				
				rowList.add("Identifier");
				rowList.add("Type");
				rowList.add("Subtype");
				rowList.add("Tissue Site");
				rowList.add("Tissue Side");
				rowList.add("Pathological Status");
				
				shoppingCartList.add(rowList);
				
				while(enum.hasMoreElements())
				{
					rowList = new ArrayList();
					
					String key = (String)enum.nextElement();
					Specimen specimen = (Specimen)table.get(key);
					
					rowList.add(String.valueOf(specimen.getSystemIdentifier()));
					rowList.add(specimen.getClassName());
					
					if(specimen.getType() != null)
						rowList.add(specimen.getType());
					else
						rowList.add("");
					
					rowList.add(specimen.getSpecimenCharacteristics().getTissueSite());
					rowList.add(specimen.getSpecimenCharacteristics().getTissueSide());
					rowList.add(specimen.getSpecimenCharacteristics().getPathologicalStatus());
					
					shoppingCartList.add(rowList);
				}
			}
		}
		
		return shoppingCartList;
	}
}
@@ -370,75 +370,22 @@
 ava.
-io.File;%0D%0Aimport java.util.ArrayList;%0D%0Aimport java.util.Enumeration
+util.ArrayList
 ;%0D%0Ai
@@ -541,62 +541,8 @@
 t;%0D%0A
-import edu.wustl.catissuecore.util.global.Variables;%0D%0A
 impo
@@ -594,53 +594,8 @@
 on;%0D
-%0Aimport edu.wustl.common.util.logger.Logger;%0D
 %0A%0D%0A/
@@ -1490,32 +1490,34 @@
 ;%0D%0A    %7D%0D%0A    %0D%0A
+//
 %09public void del
@@ -1550,27 +1550,35 @@
 e)%0D%0A
+//
     %7B%0D%0A
+//
 %09%09try%0D%0A
+//
 %09%09%7B%0D%0A
+//
 %09%09%09f
@@ -1607,16 +1607,18 @@
 .txt%22;%0D%0A
+//
 %09%09%09File 
@@ -1665,16 +1665,18 @@
 Name);%0D%0A
+//
 %09%09%09f.del
@@ -1683,21 +1683,25 @@
 ete();%0D%0A
+//
 %09%09%7D%0D%0A
+//
 %09%09catch(
@@ -1714,21 +1714,25 @@
 ion e)%0D%0A
+//
 %09%09%7B%0D%0A
+//
 %09%09%09 Logg
@@ -1765,21 +1765,25 @@
 ), e);%0D%0A
+//
 %09%09%7D%0D%0A
+//
 %09%7D%0D%0A%09%0D%0A%09
@@ -1819,16 +1819,29 @@
 rt cart,
+Object obj%5B%5D,
 String f
@@ -2015,52 +2015,8 @@
 %09%7B%0D%0A
-%09%09%09%09Enumeration enum = table.keys();%0D%0A%09%09%09%09%0D%0A
 %09%09%09%09
@@ -2351,36 +2351,36 @@
 %09%09%09%09
-while(enum.hasMoreElements()
+for(int i=0;i%3Cobj.length;i++
 )%0D%0A%09
@@ -2441,39 +2441,123 @@
 ing 
-key = (String)enum.nextElement(
+str = obj%5Bi%5D.toString();%0D%0A%09%09        %09int index = str.indexOf(%22_%22) + 1;%0D%0A%09%09        %09String key = str.substring(index
 );%0D%0A

Change in export functionality