KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > ejosa > piggybank > business > session > CoinManagerImpl


1 /**
2  * Title: EJOSA - Enterprise Java Open Source Architecture
3  * My Piggy Bank Example
4  * Description: Business Object
5  * Copyright: Copyright (c) 2003 by B. Lofi Dewanto, T. Menzel
6  * Company: University of Muenster, HTWK Leipzig
7  * @author B. Lofi Dewanto, T. Menzel
8  * @version 1.2
9  */

10 package net.sourceforge.ejosa.piggybank.business.session;
11
12 import java.util.*;
13 import net.sourceforge.ejosa.piggybank.spec.*;
14 import net.sourceforge.ejosa.piggybank.spec.business.*;
15 import net.sourceforge.ejosa.piggybank.spec.system.*;
16
17 import net.sourceforge.ejosa.piggybank.business.*;
18 import net.sourceforge.ejosa.piggybank.business.entity.*;
19 import net.sourceforge.ejosa.piggybank.data.coin.*;
20 //import com.lutris.dods.builder.generator.query.*;
21

22
23 /**
24  * The workflow object business delegate ejb implementation.
25  *
26  * @author B. Lofi Dewanto, T. Menzel
27  * @version 1.2
28  */

29 public class CoinManagerImpl implements CoinManager {
30     
31     /**
32     * Create a coin
33     *
34     * @param Coin
35     * @exception CoinException
36     */

37     public void createCoin(Coin coin) throws CoinException {
38         try {
39           CoinImpl coinImpl = new CoinImpl();
40           coinImpl.setId(coin.getId());
41           coinImpl.setCurrency(coin.getCurrency());
42           coinImpl.setDate(coin.getDate());
43           coinImpl.setAmount(coin.getAmount());
44           coinImpl.save();
45         } catch (Exception JavaDoc ex) {
46             System.out.println("Exception: " + ex);
47             //throw new CoinBusinessException("Exception in createCoin(Coin)", ex);
48
}
49     }
50
51     /**
52     * Update a coin
53     *
54     * @param Coin
55     * @exception CoinException
56     */

57     public void updateCoin(Coin coin) throws CoinException {
58         try {
59            
60         } catch (Exception JavaDoc ex) {
61             System.out.println("Exception: " + ex);
62             //throw new CoinException("Exception in updateCoin(Coin)", ex);
63
}
64     }
65
66     /**
67     * Remove a coin
68     *
69     * @param Coin
70     * @exception CoinException
71     */

72     public void removeCoin(String JavaDoc id) throws CoinException {
73         try {
74           CoinImpl theCoin = null;
75           CoinQuery query = new CoinQuery();
76           // Order coins by date
77
query.setQueryID(id);
78           CoinDO[] DOcoinArray = query.getDOArray();
79           theCoin = new CoinImpl(DOcoinArray[0]);
80           theCoin.delete();
81         } catch (Exception JavaDoc ex) {
82             System.out.println("Exception: " + ex);
83             //throw new CoinException("Exception in removeCoin(String)", ex);
84
}
85     }
86
87     /*========================= Find Methods ============================*/
88
89     /**
90     * Find all coins
91     *
92     * @return vector of coins
93     * @exception RemoteException, CoinException
94     */

95     public Vector findAllCoins() throws CoinException {
96         Vector result = new Vector();
97         try {
98           Coin[] theCoinArray = null;
99           CoinQuery query = new CoinQuery();
100           // Order coins by date
101
query.addOrderByDATE();
102           CoinDO[] DOarray = query.getDOArray();
103           for ( int i = 0; i < DOarray.length; i++ )
104                  result.addElement(new CoinImpl(DOarray[i]));
105         } catch (Exception JavaDoc ex) {
106             System.out.println("Exception: " + ex);
107             //throw new CoinException("Exception in findAllCoins()", ex);
108
}
109         return result;
110     }
111 }
Popular Tags