Großmarkt

market
Class SICustomer

java.lang.Object
  |
  +--data.AbstractNameable
        |
        +--data.ooimpl.StockItemImpl
              |
              +--market.SICustomer
All Implemented Interfaces:
Cloneable, Comparable, DataBasketKeys, Nameable, OfferEventListener, Serializable, StockItem

public class SICustomer
extends StockItemImpl
implements OfferEventListener

A StockItemImpl that is used as a representation of a UCustomer. It can be used to add it to an instance of SSListenable which represents a waiting-queue at the tills or at the warehouse. The implementation of OfferEventListener makes it possible to inform about the whole inventory of the market this is useful if shortages occurred, the only correction of the CSOffer wouldn't be suffice because already selled articles and those in the shopping-basket of customers aren`t in it anymore.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class data.AbstractNameable
m_ncContext, m_pcsPropertyListeners
 
Fields inherited from interface data.Nameable
NAME_PROPERTY
 
Fields inherited from interface data.DataBasketKeys
CATALOG_ITEM_MAIN_KEY, STOCK_ITEM_MAIN_KEY
 
Constructor Summary
SICustomer(String customer)
           
 
Method Summary
 void addOrderToQueue(CountingStock cs, boolean active)
          Adds a new CSOrder to the order-set.
static void addToOrderQueue(UCustomer customer)
          Adds the shoppingbasket of a UCustomer as a CSOrder to the warehouse-queue(a Stock).
static void addToTillQueue(UCustomer customer)
          Adds a UCustomer to the global till-queue(a Stock).
 Object clone()
           
 int compareTo(Object o)
          Compares this SICustomer to another one using l_tillTime.
 void countArticles(String articleKey, SProcessWorker spw)
          Reaction on event: a SProcessWorker needs the count of all existing articles.
 UCustomer getCustomer()
           
 String getMissingArticles()
           
 int getOrderCount(boolean active)
           
 Long getOrderQueueTime()
           
 void offerEmpty(String articleKey)
          Reaction on event: An article is unavaible.
 CSOrder removeOrderFromQueue()
           
 void rollbackOrder(CSOrder order)
          Puts a given CSOrder back to the order-set of this SICustomer.
 void wakeUpOrders()
          Reaction on event: a new delivery arrived the market.
 
Methods inherited from class data.ooimpl.StockItemImpl
equals, getAssociatedItem, getShallowClone, getStock, setStock, toString
 
Methods inherited from class data.AbstractNameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface data.Nameable
addNameListener, addPropertyChangeListener, attach, detachNC, getName, removeNameListener, removePropertyChangeListener, setName
 

Constructor Detail

SICustomer

public SICustomer(String customer)
Parameters:
customer - name of the UCustomer as the new ID, all keys of the UCustomers are stored in a CatalogImpl.
Method Detail

addOrderToQueue

public void addOrderToQueue(CountingStock cs,
                            boolean active)
Adds a new CSOrder to the order-set.

Parameters:
cs - the StockItems of this CountingStock will be added to the new CSOrder.
active - if true the new CSOrder will be active, otherwise not.

removeOrderFromQueue

public CSOrder removeOrderFromQueue()
Returns:
the oldest, active CSOrder of this SICustomer and removes it from the order-set.

rollbackOrder

public void rollbackOrder(CSOrder order)
Puts a given CSOrder back to the order-set of this SICustomer.

Parameters:
order - the CSOrder that will be put back.

clone

public Object clone()
Specified by:
clone in interface StockItem
Overrides:
clone in class StockItemImpl
Returns:
an identical SICustomer.

getOrderCount

public int getOrderCount(boolean active)
Parameters:
active - if true only active CSOrders will be counted.
Returns:
the number of CSOrders of this SICustomer.

getCustomer

public UCustomer getCustomer()
Returns:
the UCustomer this SICustomer represents.

getMissingArticles

public String getMissingArticles()

getOrderQueueTime

public Long getOrderQueueTime()
Returns:
the waiting-time of the oldest order of this SICustomer in milliseconds.

compareTo

public int compareTo(Object o)
Compares this SICustomer to another one using l_tillTime.

Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class StockItemImpl
Parameters:
o - a SICustomer that should be compared to this one
Returns:
0 if the argument SICustomer is equal to this one; a value less than 0 if this SICustomer is older than the given one; and else a value greater than 0.

offerEmpty

public void offerEmpty(String articleKey)
Reaction on event: An article is unavaible.

Specified by:
offerEmpty in interface OfferEventListener
Parameters:
articleKey - the key of the unavaible article.

wakeUpOrders

public void wakeUpOrders()
Reaction on event: a new delivery arrived the market.

Specified by:
wakeUpOrders in interface OfferEventListener

countArticles

public void countArticles(String articleKey,
                          SProcessWorker spw)
Reaction on event: a SProcessWorker needs the count of all existing articles.

Specified by:
countArticles in interface OfferEventListener
Parameters:
articleKey - the name of the article.
spw - the SProcessWorker that is affected.

addToTillQueue

public static void addToTillQueue(UCustomer customer)
Adds a UCustomer to the global till-queue(a Stock).

Parameters:
customer - the UCustomer that will be added.

addToOrderQueue

public static void addToOrderQueue(UCustomer customer)
Adds the shoppingbasket of a UCustomer as a CSOrder to the warehouse-queue(a Stock).

Parameters:
customer - the UCustomer who`s shoppingbasket will be added.

Großmarkt