001 package data.ooimpl; 002 003 import log.*; 004 005 import data.*; 006 007 /** 008 * DataBasketEntry that represents an operation with StockItems. The details as 009 * to how the individual fields are used depend on the subclasses. 010 * 011 * @author Steffen Zschaler 012 * @version 2.0 19/08/1999 013 * @since v2.0 014 */ 015 public abstract class StockItemDBEntry extends DataBasketEntryImpl { 016 017 /** 018 * Create a new StockItemDBEntry. 019 * 020 * @param sKey the key of the affected item(s). 021 * @param stiSource the source Stock. 022 * @param stiDest the destination Stock. 023 * @param oValue the value of the DataBasketEntry. 024 */ 025 public StockItemDBEntry(String sKey, StockImpl stiSource, StockImpl stiDest, Object oValue) { 026 super(STOCK_ITEM_MAIN_KEY, sKey, stiSource, stiDest, oValue); 027 } 028 029 /** 030 * Count the items affected by this DataBasketEntry. 031 * 032 * @override Sometimes The default implementation returns 1. 033 */ 034 public int count() { 035 return 1; 036 } 037 038 /** 039 * A LogEntry that describes an operation on one or more StockItem(s). 040 * 041 * @author Steffen Zschaler 042 * @version 2.0 19/08/1999 043 * @since v2.0 044 */ 045 public static class StockItemDBELogEntry extends LogEntry { 046 047 /** 048 * The key of the affected item. 049 * 050 * @serial 051 */ 052 private String m_sKey; 053 054 /** 055 * The source Stock's name, if any. 056 * 057 * @serial 058 */ 059 private String m_sSourceName; 060 061 /** 062 * The destination Stock's name, if any. 063 * 064 * @serial 065 */ 066 private String m_sDestName; 067 068 /** 069 * Create a new StockItemDBELogEntry. 070 * 071 * @param sidbe the DataBasketEntry to be described. 072 */ 073 public StockItemDBELogEntry(StockItemDBEntry sidbe) { 074 super(); 075 076 m_sKey = sidbe.getSecondaryKey(); 077 m_sSourceName = ((sidbe.getSource() != null) ? (((Nameable)sidbe.getSource()).getName()) : (null)); 078 m_sDestName = ((sidbe.getDestination() != null) ? (((Nameable)sidbe.getDestination()).getName()) : (null)); 079 } 080 081 /** 082 * Get the affected item's key. 083 * 084 * @override Never 085 */ 086 public String getKey() { 087 return m_sKey; 088 } 089 090 /** 091 * Get the source Stock's name. 092 * 093 * @override Never 094 */ 095 public String getSource() { 096 return m_sSourceName; 097 } 098 099 /** 100 * Get the destination Stock's name. 101 * 102 * @override Never 103 */ 104 public String getDestination() { 105 return m_sDestName; 106 } 107 108 /** 109 * Get a String representation of the LogEntry. 110 * 111 * @override Sometimes 112 */ 113 public String toString() { 114 return "StockItem transfer: \"" + getKey() + "\" was transferred" + ((getSource() != null) ? 115 (" from Stock \"" + getSource() + "\"") : ("")) + ((getDestination() != null) ? 116 (" to Stock \"" + getDestination() + "\"") : ("")) + " on " + getLogDate() + "."; 117 } 118 } 119 120 /** 121 * Get a LogEntry describing this DataBasketEntry. 122 * 123 * @override Never 124 */ 125 public LogEntry getLogData() { 126 return new StockItemDBELogEntry(this); 127 } 128 }