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 * ID for serialization.
040 */
041 private static final long serialVersionUID = -4008272266049438745L;
042
043 /**
044 * Create a new CatalogItemDataBasketEntry.
045 *
046 * @param cSource the source Catalog.
047 * @param cDest the destination Catalog.
048 * @param ci the CatalogItem that was operated on.
049 */
050 public CatalogItemDataBasketEntry(CatalogImpl cSource, CatalogImpl cDest, CatalogItemImpl ci) {
051 super(CATALOG_ITEM_MAIN_KEY, ci.getName(), (SelfManagingDBESource)cSource,
052 (SelfManagingDBEDestination)cDest, ci);
053 }
054
055 /**
056 * Set the source of the DataBasketEntry.
057 *
058 * <p>This method is public as an implementation detail and must not be called directly!</p>
059 *
060 * @override Never
061 */
062 public void setSource(CatalogImpl cSource) {
063 m_dbesSource = (SelfManagingDBESource)cSource;
064 }
065
066 /**
067 * Set the destination of the DataBasketEntry.
068 *
069 * <p>This method is public as an implementation detail and must not be called directly!</p>
070 *
071 * @override Never
072 */
073 public void setDestination(CatalogImpl cDest) {
074 m_dbedDest = (SelfManagingDBEDestination)cDest;
075 }
076
077 /**
078 * A LogEntry that describes {@link CatalogItemDataBasketEntry CatalogItemDataBasketEntries}.
079 *
080 * @author Steffen Zschaler
081 * @version 2.0 19/08/1999
082 * @since v2.0
083 */
084 public static class CIDBELogEntry extends LogEntry {
085
086 /**
087 * ID for serialization.
088 */
089 private static final long serialVersionUID = -3035986340586194087L;
090
091 /**
092 * The name of the source Catalog,if any.
093 *
094 * @serial
095 */
096 private String m_sSourceName;
097
098 /**
099 * The name of the destination Catalog, if any.
100 *
101 * @serial
102 */
103 private String m_sDestName;
104
105 /**
106 * The key of the CatalogItem.
107 *
108 * @serial
109 */
110 private String m_sKey;
111
112 /**
113 * The result of the CatalogItem's toString() method.
114 *
115 * @serial
116 */
117 private String m_sCIDescription;
118
119 /**
120 * Create a new CIDBELogEntry.
121 *
122 * @param cidbe the DataBasketEntry to be logged.
123 */
124 public CIDBELogEntry(CatalogItemDataBasketEntry cidbe) {
125 super();
126
127 m_sSourceName = ((cidbe.getSource() != null) ? (((Nameable)cidbe.getSource()).getName()) : (null));
128 m_sDestName = ((cidbe.getDestination() != null) ? (((Nameable)cidbe.getDestination()).getName()) : (null));
129 m_sKey = cidbe.getSecondaryKey();
130 m_sCIDescription = ((cidbe.getValue() != null) ? (cidbe.getValue().toString()) : (null));
131 }
132
133 /**
134 * Get the source Catalog's name.
135 *
136 * @override Never
137 */
138 public String getSource() {
139 return m_sSourceName;
140 }
141
142 /**
143 * Get the destination Catalog's name.
144 *
145 * @override Never
146 */
147 public String getDestination() {
148 return m_sDestName;
149 }
150
151 /**
152 * Get the CatalogItem's key.
153 *
154 * @override Never
155 */
156 public String getKey() {
157 return m_sKey;
158 }
159
160 /**
161 * Get the CatalogItem's description. I.e. the result of its toString() method.
162 *
163 * @override Never
164 */
165 public String getCIDescription() {
166 return m_sCIDescription;
167 }
168
169 /**
170 * Return a String representation of this LogEntry.
171 *
172 * @override Never
173 */
174 public String toString() {
175 return "CatalogItem transfer: \"" + getKey() + "\" (" + getCIDescription() + ") was transferred" +
176 ((getSource() != null) ? (" from Catalog \"" + getSource() + "\"") :
177 ("")) + ((getDestination() != null) ? (" to Catalog \"" + getDestination() + "\"") :
178 ("")) + " on " + getLogDate() + ".";
179 }
180 }
181
182 /**
183 * Return a LogEntry describing this DataBasketEntry.
184 *
185 * @override Never
186 */
187 public LogEntry getLogData() {
188 return new CIDBELogEntry(this);
189 }
190 }