001 package data.ooimpl;
002
003 import data.*;
004
005 import log.*;
006
007 /**
008 * A {@link DataBasketEntry} representing operations on {@link CatalogImpl}s
009 * and {@link CatalogItemImpl}s. The fields of the <code>DataBasketEntry</code>
010 * are set as follows:
011 *
012 * <table border=1>
013 * <tr><td><strong>Field</strong></td><td><strong>Value</strong></td></tr>
014 * <tr><td>{@link DataBasketEntry#getMainKey main key}</td>
015 * <td>{@link DataBasketKeys#CATALOG_ITEM_MAIN_KEY CATALOG_ITEM_MAIN_KEY}
016 * </td>
017 * </tr>
018 * <tr><td>{@link DataBasketEntry#getSecondaryKey secondary key}</td>
019 * <td>{@link CatalogItem#getName name} of the CatalogItem in question</td>
020 * </tr>
021 * <tr><td>{@link DataBasketEntry#getSource source}</td>
022 * <td>{@link Catalog source catalog}<td>
023 * </tr>
024 * <tr><td>{@link DataBasketEntry#getDestination destination}</td>
025 * <td>{@link Catalog destination catalog}<td>
026 * </tr>
027 * <tr><td>{@link DataBasketEntry#getValue value}</td>
028 * <td>{@link CatalogItem} in question<td>
029 * </tr>
030 * </table>
031 *
032 * @author Steffen Zschaler
033 * @version 2.0 19/08/1999
034 * @since v2.0
035 */
036 public class CatalogItemDataBasketEntry extends DataBasketEntryImpl {
037
038 /**
039 * Create a new CatalogItemDataBasketEntry.
040 *
041 * @param cSource the source Catalog.
042 * @param cDest the destination Catalog.
043 * @param ci the CatalogItem that was operated on.
044 */
045 public CatalogItemDataBasketEntry(CatalogImpl cSource, CatalogImpl cDest, CatalogItemImpl ci) {
046 super(CATALOG_ITEM_MAIN_KEY, ci.getName(), (SelfManagingDBESource)cSource,
047 (SelfManagingDBEDestination)cDest, ci);
048 }
049
050 /**
051 * Set the source of the DataBasketEntry.
052 *
053 * <p>This method is public as an implementation detail and must not be called directly!</p>
054 *
055 * @override Never
056 */
057 public void setSource(CatalogImpl cSource) {
058 m_dbesSource = (SelfManagingDBESource)cSource;
059 }
060
061 /**
062 * Set the destination of the DataBasketEntry.
063 *
064 * <p>This method is public as an implementation detail and must not be called directly!</p>
065 *
066 * @override Never
067 */
068 public void setDestination(CatalogImpl cDest) {
069 m_dbedDest = (SelfManagingDBEDestination)cDest;
070 }
071
072 /**
073 * A LogEntry that describes {@link CatalogItemDataBasketEntry CatalogItemDataBasketEntries}.
074 *
075 * @author Steffen Zschaler
076 * @version 2.0 19/08/1999
077 * @since v2.0
078 */
079 public static class CIDBELogEntry extends LogEntry {
080
081 /**
082 * The name of the source Catalog,if any.
083 *
084 * @serial
085 */
086 private String m_sSourceName;
087
088 /**
089 * The name of the destination Catalog, if any.
090 *
091 * @serial
092 */
093 private String m_sDestName;
094
095 /**
096 * The key of the CatalogItem.
097 *
098 * @serial
099 */
100 private String m_sKey;
101
102 /**
103 * The result of the CatalogItem's toString() method.
104 *
105 * @serial
106 */
107 private String m_sCIDescription;
108
109 /**
110 * Create a new CIDBELogEntry.
111 *
112 * @param cidbe the DataBasketEntry to be logged.
113 */
114 public CIDBELogEntry(CatalogItemDataBasketEntry cidbe) {
115 super();
116
117 m_sSourceName = ((cidbe.getSource() != null) ? (((Nameable)cidbe.getSource()).getName()) : (null));
118 m_sDestName = ((cidbe.getDestination() != null) ? (((Nameable)cidbe.getDestination()).getName()) : (null));
119 m_sKey = cidbe.getSecondaryKey();
120 m_sCIDescription = ((cidbe.getValue() != null) ? (cidbe.getValue().toString()) : (null));
121 }
122
123 /**
124 * Get the source Catalog's name.
125 *
126 * @override Never
127 */
128 public String getSource() {
129 return m_sSourceName;
130 }
131
132 /**
133 * Get the destination Catalog's name.
134 *
135 * @override Never
136 */
137 public String getDestination() {
138 return m_sDestName;
139 }
140
141 /**
142 * Get the CatalogItem's key.
143 *
144 * @override Never
145 */
146 public String getKey() {
147 return m_sKey;
148 }
149
150 /**
151 * Get the CatalogItem's description. I.e. the result of its toString() method.
152 *
153 * @override Never
154 */
155 public String getCIDescription() {
156 return m_sCIDescription;
157 }
158
159 /**
160 * Return a String representation of this LogEntry.
161 *
162 * @override Never
163 */
164 public String toString() {
165 return "CatalogItem transfer: \"" + getKey() + "\" (" + getCIDescription() + ") was transferred" +
166 ((getSource() != null) ? (" from Catalog \"" + getSource() + "\"") :
167 ("")) + ((getDestination() != null) ? (" to Catalog \"" + getDestination() + "\"") :
168 ("")) + " on " + getLogDate() + ".";
169 }
170 }
171
172 /**
173 * Return a LogEntry describing this DataBasketEntry.
174 *
175 * @override Never
176 */
177 public LogEntry getLogData() {
178 return new CIDBELogEntry(this);
179 }
180 }