// Path: src/main/java/eu/cloudscale/showcase/db/dao/IShoppingCartDao.java
// public interface IShoppingCartDao extends IDao<IShoppingCart> 
// {
// //	public Integer createEmptyCart();
// 
// 	public IShoppingCart findById(Integer shoppingId);
// 
// 	public List<IShoppingCartLine> findAllBySC(IShoppingCart shoppingCart);
// }
// 
// Path: src/main/java/eu/cloudscale/showcase/db/model/IShoppingCart.java
// public interface IShoppingCart
// {
// 
// 	public void setScTime(Date scTime);
// 
// 	public Date getScTime();
// 
// 	public void setScId(Integer scId);
// 
// 	public Integer getScId();
// 
// 	public Set<IShoppingCartLine> getShoppingCartLines();
// 
// }
// 
// Path: src/main/java/eu/cloudscale/showcase/db/model/IShoppingCartLine.java
// public interface IShoppingCartLine
// {
// 
// 	public IShoppingCart getShoppingCart();
// 
// 	public void setShoppingCart(IShoppingCart shoppingCart);
// 
// 	public Integer getSclId();
// 
// 	public void setSclId(Integer sclScId);
// 
// 	public IItem getItem();
// 
// 	public void setItem(IItem item);
// 
// 	public Integer getSclQty();
// 
// 	public void setSclQty(Integer sclQty);
// 
// }
// 
// Path: src/main/java/eu/cloudscale/showcase/db/model/hibernate/ShoppingCart.java
// @Entity
// @Table( name = "shopping_cart", catalog = "tpcw" )
// @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
// 
// public class ShoppingCart implements IShoppingCart
// {
// 	private Integer scId;
// 
// 	private Date    scTime;
// 	
// 	private Set<IShoppingCartLine> shoppingCartLines = new HashSet<IShoppingCartLine>( 0 );
// 
// 	public ShoppingCart()
// 	{
// 	}
// 
// 	public ShoppingCart(Date scTime)
// 	{
// 		this.scTime = scTime;
// 	}
// 
// 	@OneToMany( targetEntity=ShoppingCartLine.class, fetch = FetchType.LAZY, mappedBy = "shoppingCart" )
//     public Set<IShoppingCartLine> getShoppingCartLines()
//     {
//     	return shoppingCartLines;
//     }
// 
//     public void setShoppingCartLines(Set<IShoppingCartLine> shoppingCartLines)
//     {
//     	this.shoppingCartLines = shoppingCartLines;
//     }
// 
// 	@Id
// 	@GeneratedValue( strategy = IDENTITY )
// 	@Column( name = "SC_ID", unique = true, nullable = false )
// 	@Override
// 	public Integer getScId()
// 	{
// 		return this.scId;
// 	}
// 
// 	@Override
// 	public void setScId(Integer scId)
// 	{
// 		this.scId = scId;
// 	}
// 
// 	@Temporal( TemporalType.TIMESTAMP )
// 	@Column( name = "SC_TIME", length = 19 )
// 	@Override
// 	public Date getScTime()
// 	{
// 		return this.scTime;
// 	}
// 
// 	@Override
// 	public void setScTime(Date scTime)
// 	{
// 		this.scTime = scTime;
// 	}
// 
// }


import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import eu.cloudscale.showcase.db.dao.IShoppingCartDao;
import eu.cloudscale.showcase.db.model.IShoppingCart;
import eu.cloudscale.showcase.db.model.IShoppingCartLine;
import eu.cloudscale.showcase.db.model.hibernate.ShoppingCart;
    		try
    		{
    			IShoppingCart cart = service.doCart(sc, itemId, ids, quantities);
    			model.addAttribute( "cart", cart);
    		}
    		catch(Exception e)
    		{
    			System.out.println("[EXCEPTION] ShoppingCartController.java");
    			System.out.println("ADD_FLAG = " + addFlag + ", itemId = " + itemId + ", customerId = " + customerId + ", shoppingId = " + shoppingId + ", sc = " + sc.getScId());
    			e.printStackTrace();
    			System.out.println("----------------------------------------------------------------------");
    		}
    		
//    		model.addAttribute( "subTotal", getSubTotal(cart.getShoppingCartLines()));
		
    		String customerRegistration = getCustomerRegistrationURL(customerId, sc.getScId());
    		model.addAttribute( "checkoutUrl", customerRegistration);
		
    		if( customerId != null )
    			model.addAttribute("customerId", customerId);
		}
		
		model.addAttribute("errors", errors);
		setupFrontend(model, sc.getScId(), customerId);
		return "shopping-cart";
	}

	private double getSubTotal(Set<IShoppingCartLine> shoppingCartLines)
    {
		double subtotal = 0;
// Path: src/main/java/eu/cloudscale/showcase/db/dao/IShoppingCartDao.java
// public interface IShoppingCartDao extends IDao<IShoppingCart> 
// {
// //	public Integer createEmptyCart();
// 
// 	public IShoppingCart findById(Integer shoppingId);
// 
// 	public List<IShoppingCartLine> findAllBySC(IShoppingCart shoppingCart);
// }
// 
// Path: src/main/java/eu/cloudscale/showcase/db/model/IShoppingCart.java
// public interface IShoppingCart
// {
// 
// 	public void setScTime(Date scTime);
// 
// 	public Date getScTime();
// 
// 	public void setScId(Integer scId);
// 
// 	public Integer getScId();
// 
// 	public Set<IShoppingCartLine> getShoppingCartLines();
// 
// }
// 
// Path: src/main/java/eu/cloudscale/showcase/db/model/IShoppingCartLine.java
// public interface IShoppingCartLine
// {
// 
// 	public IShoppingCart getShoppingCart();
// 
// 	public void setShoppingCart(IShoppingCart shoppingCart);
// 
// 	public Integer getSclId();
// 
// 	public void setSclId(Integer sclScId);
// 
// 	public IItem getItem();
// 
// 	public void setItem(IItem item);
// 
// 	public Integer getSclQty();
// 
// 	public void setSclQty(Integer sclQty);
// 
// }
// 
// Path: src/main/java/eu/cloudscale/showcase/db/model/hibernate/ShoppingCart.java
// @Entity
// @Table( name = "shopping_cart", catalog = "tpcw" )
// @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
// 
// public class ShoppingCart implements IShoppingCart
// {
// 	private Integer scId;
// 
// 	private Date    scTime;
// 	
// 	private Set<IShoppingCartLine> shoppingCartLines = new HashSet<IShoppingCartLine>( 0 );
// 
// 	public ShoppingCart()
// 	{
// 	}
// 
// 	public ShoppingCart(Date scTime)
// 	{
// 		this.scTime = scTime;
// 	}
// 
// 	@OneToMany( targetEntity=ShoppingCartLine.class, fetch = FetchType.LAZY, mappedBy = "shoppingCart" )
//     public Set<IShoppingCartLine> getShoppingCartLines()
//     {
//     	return shoppingCartLines;
//     }
// 
//     public void setShoppingCartLines(Set<IShoppingCartLine> shoppingCartLines)
//     {
//     	this.shoppingCartLines = shoppingCartLines;
//     }
// 
// 	@Id
// 	@GeneratedValue( strategy = IDENTITY )
// 	@Column( name = "SC_ID", unique = true, nullable = false )
// 	@Override
// 	public Integer getScId()
// 	{
// 		return this.scId;
// 	}
// 
// 	@Override
// 	public void setScId(Integer scId)
// 	{
// 		this.scId = scId;
// 	}
// 
// 	@Temporal( TemporalType.TIMESTAMP )
// 	@Column( name = "SC_TIME", length = 19 )
// 	@Override
// 	public Date getScTime()
// 	{
// 		return this.scTime;
// 	}
// 
// 	@Override
// 	public void setScTime(Date scTime)
// 	{
// 		this.scTime = scTime;
// 	}
// 
// }


// Path: src/main/java/eu/cloudscale/showcase/servlets/ShoppingCartController.java
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import eu.cloudscale.showcase.db.dao.IShoppingCartDao;
import eu.cloudscale.showcase.db.model.IShoppingCart;
import eu.cloudscale.showcase.db.model.IShoppingCartLine;
import eu.cloudscale.showcase.db.model.hibernate.ShoppingCart;

    		try
    		{
    			IShoppingCart cart = service.doCart(sc, itemId, ids, quantities);
    			model.addAttribute( "cart", cart);
    		}
    		catch(Exception e)
    		{
    			System.out.println("[EXCEPTION] ShoppingCartController.java");
    			System.out.println("ADD_FLAG = " + addFlag + ", itemId = " + itemId + ", customerId = " + customerId + ", shoppingId = " + shoppingId + ", sc = " + sc.getScId());
    			e.printStackTrace();
    			System.out.println("----------------------------------------------------------------------");
    		}
    		
//    		model.addAttribute( "subTotal", getSubTotal(cart.getShoppingCartLines()));
		
    		String customerRegistration = getCustomerRegistrationURL(customerId, sc.getScId());
    		model.addAttribute( "checkoutUrl", customerRegistration);
		
    		if( customerId != null )
    			model.addAttribute("customerId", customerId);
		}
		
		model.addAttribute("errors", errors);
		setupFrontend(model, sc.getScId(), customerId);
		return "shopping-cart";
	}

	private double getSubTotal(Set<IShoppingCartLine> shoppingCartLines)
    {
		double subtotal = 0;
		for(IShoppingCartLine scl : shoppingCartLines)