package data.ooimpl; import log.*; import data.*; /** * DataBasketEntry that represents an operation with StockItems. The details as * to how the individual fields are used depend on the subclasses. * * @author Steffen Zschaler * @version 2.0 19/08/1999 * @since v2.0 */ public abstract class StockItemDBEntry extends DataBasketEntryImpl { /** * Create a new StockItemDBEntry. * * @param sKey the key of the affected item(s). * @param stiSource the source Stock. * @param stiDest the destination Stock. * @param oValue the value of the DataBasketEntry. */ public StockItemDBEntry (String sKey, StockImpl stiSource, StockImpl stiDest, Object oValue) { super (STOCK_ITEM_MAIN_KEY, sKey, stiSource, stiDest, oValue); } /** * Count the items affected by this DataBasketEntry. * * @override Sometimes The default implementation returns 1. */ public int count() { return 1; } /** * A LogEntry that describes an operation on one or more StockItem(s). * * @author Steffen Zschaler * @version 2.0 19/08/1999 * @since v2.0 */ public static class StockItemDBELogEntry extends LogEntry { /** * The key of the affected item. * * @serial */ private String m_sKey; /** * The source Stock's name, if any. * * @serial */ private String m_sSourceName; /** * The destination Stock's name, if any. * * @serial */ private String m_sDestName; /** * Create a new StockItemDBELogEntry. * * @param sidbe the DataBasketEntry to be described. */ public StockItemDBELogEntry (StockItemDBEntry sidbe) { super(); m_sKey = sidbe.getSecondaryKey(); m_sSourceName = ((sidbe.getSource() != null)? (((Nameable) sidbe.getSource()).getName()): (null)); m_sDestName = ((sidbe.getDestination() != null)? (((Nameable) sidbe.getDestination()).getName()): (null)); } /** * Get the affected item's key. * * @override Never */ public String getKey() { return m_sKey; } /** * Get the source Stock's name. * * @override Never */ public String getSource() { return m_sSourceName; } /** * Get the destination Stock's name. * * @override Never */ public String getDestination() { return m_sDestName; } /** * Get a String representation of the LogEntry. * * @override Sometimes */ public String toString() { return "StockItem transfer: \"" + getKey() + "\" was transferred" + ((getSource() != null)?(" from Stock \"" + getSource() + "\""):("")) + ((getDestination() != null)?(" to Stock \"" + getDestination() + "\""):("")) + " on " + getLogDate() + "."; } } /** * Get a LogEntry describing this DataBasketEntry. * * @override Never */ public LogEntry getLogData() { return new StockItemDBELogEntry (this); } }