Author: jpepin Date: 2010-05-07 18:27:07 +0200 (Fri, 07 May 2010) New Revision: 2887 Url: http://chorem.org/repositories/revision/lima/2887 Log: recherches des entr?\195?\169es d'un compte via une p?\195?\169riode d?\195?\169finie par deux dates Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-06 16:48:20 UTC (rev 2886) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-07 16:27:07 UTC (rev 2887) @@ -19,6 +19,7 @@ package org.chorem.lima.business; +import java.util.Date; import java.util.List; import org.chorem.lima.entity.Account; @@ -89,5 +90,8 @@ void removeEntry(Entry entry) throws LimaException; List<Entry> getAllEntriesForAccount(Account account) throws LimaException; + + List<Entry> getAllEntriesForAccount(Account account, Date beginDate, Date endDate) throws LimaException; + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-06 16:48:20 UTC (rev 2886) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-07 16:27:07 UTC (rev 2887) @@ -21,6 +21,7 @@ import static org.nuiton.i18n.I18n._; +import java.util.Date; import java.util.List; import javax.ejb.Stateless; @@ -367,16 +368,29 @@ @Override public List<Entry> getAllEntriesForAccount(Account account) throws LimaException { + + return getAllEntriesForAccount(account, null, null); + } + + @Override + public List<Entry> getAllEntriesForAccount(Account account, Date beginDate, Date endDate) throws LimaException { List<Entry> entries = null; - TopiaContext topiaContext = null; + TopiaContext topiaTransaction = null; try { - // basic check done, make check in database - // TODO move it into JTA - topiaContext = rootContext.beginTransaction(); + topiaTransaction = rootContext.beginTransaction(); + EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaTransaction); + + if (beginDate != null && endDate != null && account != null) { + String transactionDateProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); + TopiaQuery query = entryDAO.createQuery("E"); + query + .add(Entry.ACCOUNT, account) + .add(transactionDateProperty+" BETWEEN :beginDate AND :endDate") + .addParam("beginDate", beginDate) + .addParam("endDate", endDate); + entries=entryDAO.findAllByQuery(query); + } - EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); - entries = entryDAO.findAllByAccount(account); - //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION for (Entry entry : entries) { entry.getEntryBook(); @@ -384,13 +398,13 @@ } // commit - topiaContext.commitTransaction(); + topiaTransaction.commitTransaction(); } catch (TopiaException ex) { - doCatch(topiaContext, ex, log); + doCatch(topiaTransaction, ex, log); } finally { - doFinally(topiaContext, log); + doFinally(topiaTransaction, log); } return entries; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-06 16:48:20 UTC (rev 2886) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-07 16:27:07 UTC (rev 2887) @@ -63,6 +63,12 @@ /** Account. */ protected Account selectedAccount; + /** Begin Date. */ + protected Date selectedBeginDate; + + /** EndDate. */ + protected Date selectedEndDate; + /** data cache */ protected List<Entry> cacheDataList; @@ -121,36 +127,7 @@ } return res; } - - @Override - public Class<?> getColumnClass(int column) { - Class<?> result = null; - - switch (column) { - case 0: - result = Date.class; - break; - case 1: - result = EntryBook.class; - break; - case 2: - result = String.class; - break; - case 3: - result = String.class; - break; - case 4: - result = String.class; - break; - case 5: - result = String.class; - break; - } - - return result; - } - @Override public Object getValueAt(int row, int column) { Object result = null; @@ -199,6 +176,16 @@ return false; } + public void setBeginDate(Date date){ + selectedBeginDate = date; + log.debug(date); + } + + public void setEndDate(Date date){ + selectedEndDate = date; + log.debug(date); + } + /** * @param entryBook * @throws LimaException @@ -208,7 +195,7 @@ selectedAccount = account; try { log.debug(selectedAccount); - cacheDataList = financialTransactionService.getAllEntriesForAccount(selectedAccount); + cacheDataList = financialTransactionService.getAllEntriesForAccount(selectedAccount, selectedBeginDate, selectedEndDate); } catch (LimaException eee) { if (log.isErrorEnabled()) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-05-06 16:48:20 UTC (rev 2886) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-05-07 16:27:07 UTC (rev 2887) @@ -32,13 +32,15 @@ <JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/> </cell> <cell> - <JLabel text="TODO begincalendarPanel"/> + <org.jdesktop.swingx.JXDatePicker id="beginDatePicker" + onActionPerformed="getModelAccountsReportsTable().setBeginDate(beginDatePicker.getDate())" /> </cell> <cell> <JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/> </cell> <cell> - <JLabel text="TODO endcalendarPanel"/> + <org.jdesktop.swingx.JXDatePicker id="endDatePicker" + onActionPerformed="getModelAccountsReportsTable().setEndDate(endDatePicker.getDate())"/> </cell> <cell> <JLabel id="accountSelectorLabel" text="lima.account"/> Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-05-06 16:48:20 UTC (rev 2886) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-05-07 16:27:07 UTC (rev 2887) @@ -21,8 +21,8 @@ lima.account.type3=Produit lima.account.type4=Charge lima.accounts= -lima.accountsreports.begincalendar= -lima.accountsreports.endcalendar= +lima.accountsreports.begincalendar=Date d\u00E9but +lima.accountsreports.endcalendar=Date fin lima.actif=Actif lima.action.commandline.disable.main.ui=Ne pas lancer l'ui lima.action.commandline.help=Afficher l'aide en console