001: /*
002: * Created on 05/06/2006
003: *
004: * Swing Components - visit http://sf.net/projects/gfd
005: *
006: * Copyright (C) 2004 Igor Regis da Silva Simões
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or (at your option) any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: */
022: package br.com.gfp.dao;
023:
024: import java.sql.ResultSet;
025: import java.sql.SQLException;
026: import java.util.ArrayList;
027:
028: import javax.swing.event.EventListenerList;
029:
030: import br.com.gfp.data.PendingTransaction;
031: import br.com.gfp.data.ProjecaoFinanceira;
032: import br.com.gfp.data.Transaction;
033: import br.com.gfp.util.SimpleLog;
034:
035: /**
036: * Controler para as aplicações financeiras
037: * A idéia é que esta classe realize a formulação de relatórios.
038: * @author Igor Regis da Silva Simoes
039: */
040: public class PendingTransactionDAO extends
041: TransactionDAO<PendingTransaction> {
042: /**
043: * Lista de listeners de eventos do controller
044: */
045: private static final EventListenerList listeners = new EventListenerList();
046:
047: /**
048: * @see br.com.gfpshare.db.AbstractDAO#getListeners()
049: */
050: @Override
051: protected EventListenerList getListeners() {
052: return listeners;
053: }
054:
055: public void marcarTodosParaEfetivacao() throws SQLException {
056: executarSQL(new PendingTransaction(),
057: "update \"LancamentoPendente\" set \"Efetivar\"=TRUE",
058: false, false);
059: }
060:
061: public void efetivarMarcados() throws SQLException {
062: PendingTransaction lancamentoPendenteVisaVale = new PendingTransaction();
063: lancamentoPendenteVisaVale.setEfetivar(Boolean.TRUE);
064: final ArrayList<PendingTransaction> lancamentosPendente = getAllBy(lancamentoPendenteVisaVale);
065: new Thread("EfetivandoLancamentos") {
066: @Override
067: public void run() {
068: TransactionDAO<Transaction> lancamentoController = new TransactionDAO<Transaction>();
069: Transaction transaction = null;
070: for (PendingTransaction lancamentoPendente : lancamentosPendente) {
071: transaction = new Transaction();
072: transaction.setDados(lancamentoPendente.getAsMap());
073: try {
074: lancamentoController.adicionarNovo(transaction);
075: } catch (SQLException e) {
076: continue;
077: }
078:
079: try {
080: deletar(lancamentoPendente);
081: } catch (SQLException e) {
082: ((SimpleLog) GFPController.getGFPController()
083: .getContexto().get(GFPController.LOG))
084: .log("Erro ao deletar lançamento pendente");
085: ((SimpleLog) GFPController.getGFPController()
086: .getContexto().get(GFPController.LOG))
087: .log(e.getLocalizedMessage());
088: ((SimpleLog) GFPController.getGFPController()
089: .getContexto().get(GFPController.LOG))
090: .log(e);
091: }
092: }
093: }
094: }.start();
095: }
096:
097: /**
098: * @deprecated Nao implementado
099: */
100: @Override
101: @Deprecated
102: public synchronized Double calculaMedia(
103: PendingTransaction lancamentoOriginal, int meses)
104: throws NumberFormatException, SQLException {
105: return null;
106: }
107:
108: /**
109: * @deprecated Nao implementado
110: */
111: @Override
112: @Deprecated
113: public synchronized ProjecaoFinanceira calculaMediana(
114: PendingTransaction lancamentoOriginal, int meses)
115: throws NumberFormatException, SQLException {
116: return null;
117: }
118:
119: /**
120: * @deprecated Nao implementado
121: */
122: @Override
123: @Deprecated
124: public synchronized boolean existeLancamentoDesseTipoNoMes(
125: PendingTransaction lancamento) {
126: return false;
127: }
128:
129: /**
130: * @deprecated Nao implementado
131: */
132: @Override
133: @Deprecated
134: public synchronized int getDiaComumParaLancamento(
135: PendingTransaction argumento) throws SQLException {
136: return -1;
137: }
138:
139: /**
140: * @deprecated Nao implementado
141: */
142: @Override
143: @Deprecated
144: public synchronized double getTotalNoPeriodo(
145: PendingTransaction argumento) throws SQLException {
146: return -1;
147: }
148:
149: /**
150: * @deprecated Nao implementado
151: */
152: @Override
153: @Deprecated
154: public synchronized double getTotalNoPeriodo(
155: PendingTransaction argumento, int mesIni, int mesFim)
156: throws SQLException {
157: return -1;
158: }
159:
160: /**
161: * @deprecated Nao implementado
162: */
163: @Override
164: @Deprecated
165: public synchronized ResultSet getTotalPorTipo(
166: PendingTransaction argumento) throws SQLException {
167: return null;
168: }
169: }
|