Author: jpepin Date: 2010-04-15 17:30:01 +0200 (Thu, 15 Apr 2010) New Revision: 2863 Log: Modification du mod?\195?\168le, UI d'?\195?\169criture Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java trunk/lima-swing/src/main/resources/log4j.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-14 15:46:15 UTC (rev 2862) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-15 15:30:01 UTC (rev 2863) @@ -63,7 +63,7 @@ */ List<Transaction> getAllTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod period) throws LimaException; - void createTransaction(Transaction transaction) throws LimaException; + Transaction createTransaction() throws LimaException; void updateTransaction(Transaction transaction) throws LimaException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-14 15:46:15 UTC (rev 2862) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-15 15:30:01 UTC (rev 2863) @@ -19,15 +19,21 @@ package org.chorem.lima.business.ejb; +import static org.nuiton.i18n.I18n._; + import java.util.List; import javax.ejb.Stateless; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.TransactionService; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.AccountDAO; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.LimaCallaoDAOHelper; @@ -81,10 +87,34 @@ * @param timespan * @param journal * @return + * @throws LimaException */ @Override - public void createTransaction(Transaction transaction /*Date entryDate, String voucherRef, - String description, TimeSpan timeSpan, Journal journal*/) { + public void createTransaction(Transaction transaction/*Date entryDate, String voucherRef, + String description, TimeSpan timeSpan, Journal journal*/) throws LimaException { + + + TopiaContext topiaContext = null; + try { + // basic check done, make check in database + // TODO move it into JTA + topiaContext = rootContext.beginTransaction(); + + TransactionDAO transactionDAO = LimaCallaoDAOHelper + .getTransactionDAO(topiaContext); + + transactionDAO.create(transaction); + + // commit + topiaContext.commitTransaction(); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + /*String result = ServiceHelper.RESPOND_ERROR; try { // Acces BDD Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-14 15:46:15 UTC (rev 2862) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-15 15:30:01 UTC (rev 2863) @@ -22,6 +22,8 @@ <script> <![CDATA[ + import org.chorem.lima.entity.EntryBook; + ]]> </script> @@ -42,7 +44,8 @@ <JComboBox id="entryBookComboBox" model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}" renderer="{new org.chorem.lima.ui.transaction.model.EntryBookRenderer()}" - /> + onItemStateChanged="getTransactionTableModel().setEntryBook((EntryBook) event.getItem())" + editable="false"/> </cell> <cell> <JLabel id="periodLabel" text="lima.transaction.period" @@ -51,7 +54,9 @@ <cell> <JComboBox id="financialPeriodComboBox" model="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel()}" - renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodRenderer()}" /> + renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodRenderer()}" + editable="false" + /> </cell> </row> <row> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-14 15:46:15 UTC (rev 2862) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-15 15:30:01 UTC (rev 2863) @@ -35,10 +35,12 @@ import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.chorem.lima.entity.Transaction; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.transaction.TransactionHelper; import org.chorem.lima.util.ErrorHelper; +import org.nuiton.topia.TopiaContextFactory; /** * Basic transaction table model. @@ -97,9 +99,12 @@ * @return */ protected List<Object> getDataList() { - + + log.debug("getDatalist"); + List<Object> results = new ArrayList<Object>(); try { + List<Transaction> transactions = transactionService.getAllTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod); @@ -230,6 +235,7 @@ Object result = null; // just prevent too much result + System.out.println("OK2"); if (selectedEntryBook != null) { // TODO EC-20100407 remove this ugly code List<Object> datas = getDataList(); @@ -315,15 +321,28 @@ return result; } + + public void setEntryBook(EntryBook entryBook){ + + System.out.println("OK"); + selectedEntryBook = entryBook; + fireTableDataChanged(); + } + /** * @throws LimaException */ - public void addEmptyTransaction() throws LimaException{ + public void addTransaction() throws LimaException{ /* Calling transaction service */ //TODO transaction = currentdate, current periode, current journal - Transaction transaction=null; + Transaction transaction =null; + transaction.setFinancialPeriod(selectedFinancialPeriod); + transaction.setEntryBook(selectedEntryBook); + transaction.setDescription(description); transactionService.createTransaction(transaction); - int row = transactionService.getAllTransactions().indexOf(transaction); + int row = getDataList().indexOf(transaction); + //int row = transactionService.getAllTransactions().indexOf(transaction); + log.debug(row); fireTableRowsInserted(row, row); } Modified: trunk/lima-swing/src/main/resources/log4j.properties =================================================================== --- trunk/lima-swing/src/main/resources/log4j.properties 2010-04-14 15:46:15 UTC (rev 2862) +++ trunk/lima-swing/src/main/resources/log4j.properties 2010-04-15 15:30:01 UTC (rev 2863) @@ -13,4 +13,4 @@ log4j.appender.file.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n # package level -log4j.logger.org.chorem.lima=INFO \ No newline at end of file +log4j.logger.org.chorem.lima=DEBUG \ No newline at end of file