001: /**
002: * Title: EJOSA - Enterprise Java Open Source Architecture
003: * My Piggy Bank Example
004: * Description: Business Object
005: * Copyright: Copyright (c) 2003 by B. Lofi Dewanto, T. Menzel
006: * Company: University of Muenster, HTWK Leipzig
007: * @author B. Lofi Dewanto, T. Menzel
008: * @version 1.2
009: */package net.sourceforge.ejosa.piggybank.business.session;
010:
011: import java.util.*;
012: import net.sourceforge.ejosa.piggybank.spec.*;
013: import net.sourceforge.ejosa.piggybank.spec.business.*;
014: import net.sourceforge.ejosa.piggybank.spec.system.*;
015:
016: import net.sourceforge.ejosa.piggybank.business.*;
017: import net.sourceforge.ejosa.piggybank.business.entity.*;
018: import net.sourceforge.ejosa.piggybank.data.coin.*;
019:
020: //import com.lutris.dods.builder.generator.query.*;
021:
022: /**
023: * The workflow object business delegate ejb implementation.
024: *
025: * @author B. Lofi Dewanto, T. Menzel
026: * @version 1.2
027: */
028: public class CoinManagerImpl implements CoinManager {
029:
030: /**
031: * Create a coin
032: *
033: * @param Coin
034: * @exception CoinException
035: */
036: public void createCoin(Coin coin) throws CoinException {
037: try {
038: CoinImpl coinImpl = new CoinImpl();
039: coinImpl.setId(coin.getId());
040: coinImpl.setCurrency(coin.getCurrency());
041: coinImpl.setDate(coin.getDate());
042: coinImpl.setAmount(coin.getAmount());
043: coinImpl.save();
044: } catch (Exception ex) {
045: System.out.println("Exception: " + ex);
046: //throw new CoinBusinessException("Exception in createCoin(Coin)", ex);
047: }
048: }
049:
050: /**
051: * Update a coin
052: *
053: * @param Coin
054: * @exception CoinException
055: */
056: public void updateCoin(Coin coin) throws CoinException {
057: try {
058:
059: } catch (Exception ex) {
060: System.out.println("Exception: " + ex);
061: //throw new CoinException("Exception in updateCoin(Coin)", ex);
062: }
063: }
064:
065: /**
066: * Remove a coin
067: *
068: * @param Coin
069: * @exception CoinException
070: */
071: public void removeCoin(String id) throws CoinException {
072: try {
073: CoinImpl theCoin = null;
074: CoinQuery query = new CoinQuery();
075: // Order coins by date
076: query.setQueryID(id);
077: CoinDO[] DOcoinArray = query.getDOArray();
078: theCoin = new CoinImpl(DOcoinArray[0]);
079: theCoin.delete();
080: } catch (Exception ex) {
081: System.out.println("Exception: " + ex);
082: //throw new CoinException("Exception in removeCoin(String)", ex);
083: }
084: }
085:
086: /*========================= Find Methods ============================*/
087:
088: /**
089: * Find all coins
090: *
091: * @return vector of coins
092: * @exception RemoteException, CoinException
093: */
094: public Vector findAllCoins() throws CoinException {
095: Vector result = new Vector();
096: try {
097: Coin[] theCoinArray = null;
098: CoinQuery query = new CoinQuery();
099: // Order coins by date
100: query.addOrderByDATE();
101: CoinDO[] DOarray = query.getDOArray();
102: for (int i = 0; i < DOarray.length; i++)
103: result.addElement(new CoinImpl(DOarray[i]));
104: } catch (Exception ex) {
105: System.out.println("Exception: " + ex);
106: //throw new CoinException("Exception in findAllCoins()", ex);
107: }
108: return result;
109: }
110: }
|