001    package data.ooimpl;
002    
003    import data.*; // This is to help javadoc...
004    
005    /**
006     * DataBasketEntry that describes operations with StoringStock's items. The
007     * fields of the <code>DataBasketEntry</code> are set as follows:
008     *
009     * <table border=1>
010     * <tr><td><strong>Field</strong></td><td><strong>Value</strong></td></tr>
011     * <tr><td>{@link DataBasketEntry#getMainKey main key}</td>
012     *     <td>{@link DataBasketKeys#STOCK_ITEM_MAIN_KEY STOCK_ITEM_MAIN_KEY}
013     *     </td>
014     * </tr>
015     * <tr><td>{@link DataBasketEntry#getSecondaryKey secondary key}</td>
016     *     <td>{@link StockItem#getName name} of the StockItem in question</td>
017     * </tr>
018     * <tr><td>{@link DataBasketEntry#getSource source}</td>
019     *     <td>{@link Stock source stock}<td>
020     * </tr>
021     * <tr><td>{@link DataBasketEntry#getDestination destination}</td>
022     *     <td>{@link Stock destination stock}<td>
023     * </tr>
024     * <tr><td>{@link DataBasketEntry#getValue value}</td>
025     *     <td>{@link StockItem} that was moved.<td>
026     * </tr>
027     * </table>
028     *
029     * @author Steffen Zschaler
030     * @version 2.0 19/09/1999
031     * @since v2.0
032     */
033    public class StoringStockItemDBEntry extends StockItemDBEntry {
034    
035        /**
036             * ID for serialization.
037             */
038            private static final long serialVersionUID = 8511828947009795094L;
039    
040            /**
041         * Create a new StoringStockItemDBEntry.
042         *
043         * @param sstiSource the source Stock.
044         * @param sstiDest the destination Stock.
045         * @param siiItem the item that was operated on.
046         */
047        public StoringStockItemDBEntry(StoringStockImpl sstiSource, StoringStockImpl sstiDest,
048                StockItemImpl siiItem) {
049            super(siiItem.getName(), sstiSource, sstiDest, siiItem);
050        }
051    
052        /**
053         * Rollback the destination part of the operation described by this {@link data.DataBasketEntry}.
054         *
055         * <p>The method will correctly update the underlying DataBasket.</p>
056         *
057         * <p><strong>Attention</strong>: The method is public as an implementation detail and should not be called
058         * directly.</p>
059         *
060         * @override Never
061         */
062        public void rollbackDestination() {
063            DataBasketEntryImpl dbe = new StoringStockItemDBEntry(null, (StoringStockImpl)getDestination(),
064                    (StockItemImpl)getValue());
065    
066            dbe.setOwner(m_dbiOwner);
067    
068            m_dbedDest = null;
069    
070            dbe.rollback();
071        }
072    
073        /**
074         * Commit the source part of the operation described by this {@link data.DataBasketEntry}.
075         *
076         * <p>The method will correctly update the underlying DataBasket.</p>
077         *
078         * <p><strong>Attention</strong>: The method is public as an implementation detail and should not be called
079         * directly.</p>
080         *
081         * @override Never
082         */
083        public void commitSource() {
084            DataBasketEntryImpl dbe = new StoringStockItemDBEntry((StoringStockImpl)getSource(), null,
085                    (StockItemImpl)getValue());
086            dbe.setOwner(m_dbiOwner);
087    
088            m_dbesSource = null;
089    
090            dbe.commit();
091        }
092    }