Examples of DAOFactory


Examples of net.sourceforge.wampum.system.data.DAOFactory

  public static Payee findPayee(String name, boolean create) {
    if (name == null)
      throw new RuntimeException("Payee name is null!");
    Payee payee = null;
    if (payeeList == null) {
      DAOFactory daoFactory = new DAOFactory();
      PayeeDAO payeeDao = (PayeeDAO)daoFactory.getDAO("payee");
      payeeList = payeeDao.load(null, null, true);
    }
   
    boolean found = false;
    int count = 0;
    Payee currentPayee = null;
    while (!found && count<payeeList.size()) {
      currentPayee = (Payee)payeeList.get(count);
      if (name.equalsIgnoreCase(currentPayee.getName()) ||
          (currentPayee.getFilters() != null &&
          Pattern.matches(currentPayee.getFilters(), name))) {
        found = true;
        payee = currentPayee;
      }
      count++;
    }
   
    if (!found) {
      payee = new Payee();
      payee.setName(name);
     
      DAOFactory daoFactory = new DAOFactory();
      PayeeDAO payeeDao = (PayeeDAO)daoFactory.getDAO("payee");
      payeeDao.create(payee, false);
    }
   
    return payee;
  }
View Full Code Here

Examples of net.sourceforge.wampum.system.data.DAOFactory

    finally {
      if (ps != null) { try {ps.close(); } catch (Throwable th) {}}
      if (conn != null) { try {conn.close(); } catch (Throwable th) {}}
    }
   
    DAOFactory daoFactory = new DAOFactory();
    PayeeDAO payeeDao = (PayeeDAO)daoFactory.getDAO("payee");
    payeeDao.delete(mergePayee);
  }
View Full Code Here

Examples of net.sourceforge.wampum.system.data.DAOFactory

      ps.setString(2, accountID);
      resultSet = ps.executeQuery();
     
      if (resultSet.next()) {
        String transactionID = resultSet.getString("TRANSACTION_ID");
        DAOFactory daoFactory = new DAOFactory();
        TransactionDAO transDAO = (TransactionDAO)daoFactory.getDAO("transaction");
        retVal = (Transaction)transDAO.load("WHERE TRANSACTION_ID = '" + transactionID + "'", null, false).get(0);
      }
    }
    catch (Exception ex) {
      throw new RuntimeException(ex);
View Full Code Here

Examples of net.sourceforge.wampum.system.data.DAOFactory

import net.sourceforge.wampum.system.data.DAOFactory;

public class AccountTreeDAO {
 
  public static List loadAccountTree() {
    DAOFactory daoFactory = new DAOFactory();
    AccountDAO accountDao = (AccountDAO)daoFactory.getDAO("account");
    List accountList = accountDao.load(null, "ORDER BY TITLE", true);
   
    // get root list
    List rootList = new ArrayList();
    Account account = null;
View Full Code Here

Examples of net.sourceforge.wampum.system.data.DAOFactory

 
  public AccountEditor() {
    super();
    this.setRenderer(new AccountRenderer());
   
    DAOFactory factory = new DAOFactory();
    AccountDAO accountDAO = (AccountDAO)factory.getDAO("account");
    accountList = accountDAO.load(null, "ORDER BY TITLE", true);
    Account account = null;
    for (int i=0; i<accountList.size(); i++) {
      account = (Account)accountList.get(i);
      this.addItem(account);
View Full Code Here

Examples of net.sourceforge.wampum.system.data.DAOFactory

  protected List transIDList = null;
 
  public QIFParser() {
    transIDList = new ArrayList();
    dateFormat = new SimpleDateFormat("MM/dd/yyyy");
    factory = new DAOFactory();
  }
View Full Code Here

Examples of net.sourceforge.wampum.system.data.DAOFactory

      deletePayees();
     
      FileInputStream fis = new FileInputStream("./data/payees.csv");
      BufferedReader in = new BufferedReader(new InputStreamReader(fis));
     
      DAOFactory daoFactory = new DAOFactory();
      PayeeDAO payeeDao = (PayeeDAO)daoFactory.getDAO("payee");
     
      String textLine = null;
      String[] payeeStr = null;
      Payee payee = null;
      while ((textLine = in.readLine()) != null) {
        payeeStr = textLine.split(",");
        payee = new Payee();
        payee.setName(payeeStr[0]);
        payee.setFilters(payeeStr[1]);
        payeeDao.create(payee, false);
      }
      daoFactory.commit();
    }
    catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }
View Full Code Here

Examples of net.sourceforge.wampum.system.data.DAOFactory

  public GnuCashHandler(GNUCashEventListener eventListener) {
    this.eventListener = eventListener;
  }

  public void startDocument() throws SAXException {
    daoFactory = new DAOFactory();
  }
View Full Code Here

Examples of net.sourceforge.wampum.system.data.DAOFactory

 
  public void endTag(String tagName) {
    if (tagName.equalsIgnoreCase("STMTTRN")) {
      System.out.println(name + "  " + amount + "  " + dateFormat.format(datePosted.getTime()));
      Transaction trans = null;
      DAOFactory factory = new DAOFactory();
     
      try {
        factory.beginTransaction();
        // Look for fitID
        if (this.fitID != null) {
          RegisterDAO registerDAO = (RegisterDAO)factory.getDAO("register");
          trans = registerDAO.loadTransactionByFitID(this.fitID);
          System.out.println("Transaction found!");
        }
     
        if (trans == null) {
          trans = new Transaction();
          Payee payee = PayeeUtils.findPayee(this.name, true);
          trans.setPayee(payee);
          trans.setDatePosted(datePosted);
          trans.setFitID(fitID);
       
          Transaction payeeTrans = PayeeUtils.findLastTransactionForPayee(payee, this.accountID);
          if (payeeTrans != null) {
            List transSplitList = payeeTrans.getTransSplitList();
            TransSplit transSplit = null;
            TransSplit newSplit = null;
            double oldTotal = 0;
            for (int i=0; i<transSplitList.size(); i++) {
              transSplit = (TransSplit)transSplitList.get(i);
              if (transSplit.getAmount().doubleValue() >= 0)
                oldTotal += transSplit.getAmount().doubleValue();
            }
         
            for (int i=0; i<transSplitList.size(); i++) {
              transSplit = (TransSplit)transSplitList.get(i);
              newSplit = new TransSplit();
              newSplit.setParentTransaction(trans);
              newSplit.setAccount(transSplit.getAccount());
              double splitAmount = Math.abs((transSplit.getAmount().doubleValue()/oldTotal)*amount);
              if (newSplit.getAccountAccountID().equals(accountID)) {
                if (amount >= 0) {
                  newSplit.setAmount(new Double(splitAmount));
                }
                else {
                  newSplit.setAmount(new Double(-splitAmount));
                }
              }
              else {
                if (amount >= 0) {
                  newSplit.setAmount(new Double(-splitAmount));
                }
                else {
                  newSplit.setAmount(new Double(splitAmount));
                }
              }
              trans.appendTransSplit(newSplit);
            }
          }
          else {
            AccountDAO accountDAO = (AccountDAO)factory.getDAO("account");
            Account newAccount = (Account)accountDAO.load("WHERE TITLE = 'Imbalance-USD'", null, true).get(0);
            TransSplit transSplit = new TransSplit();
            transSplit.setParentTransaction(trans);
            Account account = new Account();
            account.setAccountID(accountID);
            transSplit.setAccount(account);
            transSplit.setAmount(new Double(amount));
            trans.appendTransSplit(transSplit);
         
            TransSplit newSplit = new TransSplit();
            newSplit.setParentTransaction(trans);
            newSplit.setAccount(newAccount);
            newSplit.setAmount(new Double(-amount));
            trans.appendTransSplit(newSplit);
          }
        }
        TransactionDAO transDAO = (TransactionDAO)factory.getDAO("transaction");
        transDAO.store(trans, true);
        factory.commit();
        factory.close();
      }
      catch (Exception ex) {
        System.out.println("Error with transaction: Payee" + trans.getPayee().getName() + "\n" +
            "Fit ID: " + trans.getFitID());
        throw new RuntimeException(ex);
View Full Code Here

Examples of net.sourceforge.wampum.system.data.DAOFactory

 
  private void buildPayeesTree() {
      DefaultMutableTreeNode root = new DefaultMutableTreeNode("Payees");
    DefaultTreeModel treeModel = new DefaultTreeModel(root);
   
    DAOFactory daoFactory = new DAOFactory();
    PayeeDAO payeeDao = (PayeeDAO)daoFactory.getDAO("payee");
    payeeList = payeeDao.load(null, "ORDER BY NAME", true);

    GUIPayee treePayee = null;
    DefaultMutableTreeNode treeNode = null;
    for (int i=0; i<payeeList.size(); i++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.