FileDocCategorySizeDatePackage
RentalOperations.javaAPI DocExample2607Wed May 04 09:57:44 BST 2005com.samscdrental.controller

RentalOperations

public class RentalOperations extends Object

Title: Sams CD Rental Store

Description:

Copyright: Copyright (c) 2004

Company:

author
Ken Pugh
version
1.0

Fields Summary
private static final String
ERROR_CD_DISC_NOT_IN_COLLECTION
private static final String
ERROR_CUSTOMER_NOT_IN_COLLECTION
private StoreDataAccess
collections
private static RentalOperations
theInstance
Constructors Summary
private RentalOperations()


	 
	

	
Methods Summary
public voidcheckinCDDisc(PhysicalID aPhysicalID)
checkinCDDisc

param
aPhysicalID PhysicalID

		CDDisc aCDDisc = collections.theCDDiscDataAccess.
			findByPhysicalID( aPhysicalID );
		if ( aCDDisc != null )
		{
			aCDDisc.endRental();
		}
		else
		{
			throw new CheckInDeviation( ERROR_CD_DISC_NOT_IN_COLLECTION );
		}
	
public RentalContractDTOcheckoutCDDisc(PhysicalID aPhysicalID, CustomerID aCustomerID)
checkoutCDDisc

param
anObject PhysicalID

		CDDisc aCDDisc = collections.theCDDiscDataAccess.
			findByPhysicalID( aPhysicalID );
		Customer aCustomer = collections.theCustomerDataAccess.
			findByCustomerID( aCustomerID );
		if ( aCDDisc == null )
		{
			throw new CheckOutDeviation(
				ERROR_CD_DISC_NOT_IN_COLLECTION );
		}
		if ( aCustomer == null )
		{
			throw new CheckOutDeviation(
				ERROR_CUSTOMER_NOT_IN_COLLECTION );
		}
		return aCDDisc.startRental( aCustomer );
	
public voiddispose()
dispose

		collections.dispose();
	
public static com.samscdrental.controller.RentalOperationsgetInstance()

		if ( theInstance == null )
		{
			theInstance = new RentalOperations();
		}
		return theInstance;

	
public booleanisCDDiscRented(PhysicalID aPhysicalID)
isCDDiscRented

param
aPhysicalID PhysicalID
return
boolean

		CDDisc aCDDisc = collections.theCDDiscDataAccess.
			findByPhysicalID( aPhysicalID );
		if ( aCDDisc != null )
		{
			return ( aCDDisc.isRented() );
		}
		else
		{
			throw new StatusDeviation( ERROR_CD_DISC_NOT_IN_COLLECTION );

		}